Csparc2star.py issue

I tried to use the pyem package command of csparc2star.py to convert the .cs file of cryosparc into a relion star file and didn’t have much luck either:

[hansenbry@D01868462 J86]$ csparc2star.py cryosparc_P4_J86_005_particles.cs cryosparc_P4_J86_005_particles.star
Traceback (most recent call last):
File “/home/hansenbry/EMsoftware/pyem/csparc2star.py”, line 28, in
from pyem import metadata
File “/home/hansenbry/EMsoftware/pyem/pyem/init.py”, line 3, in
from . import metadata
File “/home/hansenbry/EMsoftware/pyem/pyem/metadata.py”, line 24, in
from . import star
File “/home/hansenbry/EMsoftware/pyem/pyem/star.py”, line 31, in
from pyem.util import rot2euler
File “/home/hansenbry/EMsoftware/pyem/pyem/util/init.py”, line 3, in
from .util import *
File “/home/hansenbry/EMsoftware/pyem/pyem/util/util.py”, line 25, in
from … import geom
File “/home/hansenbry/EMsoftware/pyem/pyem/geom/init.py”, line 4, in
from .geom import *
File “/home/hansenbry/EMsoftware/pyem/pyem/geom/geom.py”, line 20, in
from .quat import distq
File “/home/hansenbry/EMsoftware/pyem/pyem/geom/quat.py”, line 27, in
qconj = np.vectorize(_qconj, signature="(m),(m)->(m)")
TypeError: init() got an unexpected keyword argument ‘signature’

I’ve posted this error on the github page for pyem too so hopefully someone gets back to me, but thought I would put it in here too in case someone might have seen this before

You are using a (very) old verson of numpy. If you install following the instructions on the project wiki, it will work.

Good luck.

Hi, I am having a similar problem, with a slightly different error. This was the original error:

Traceback (most recent call last):
File “…/pyem-master/csparc2star.py”, line 103, in
sys.exit(main(parser.parse_args()))
File “…/pyem-master/csparc2star.py”, line 42, in main
df = metadata.parse_cryosparc_2_cs(cs, passthrough=args.passthrough, minphic=args.minphic)
File “/home/exacloud/lustre1/gouaux/Zad/pyem-master/pyem/metadata.py”, line 313, in parse_cryosparc_2_cs
star.simplify_star_ucsf(df)
File “/home/exacloud/lustre1/gouaux/Zad/pyem-master/pyem/star.py”, line 357, in simplify_star_ucsf
lambda x: “%.6d” % (x + 1)).str.cat(df[UCSF.IMAGE_PATH], sep="@")
File “/home/users/jalaliya/.local/lib/python3.6/site-packages/pandas/core/strings.py”, line 2320, in cat
res = str_cat(data, others=others, sep=sep, na_rep=na_rep)
File “/home/users/jalaliya/.local/lib/python3.6/site-packages/pandas/core/strings.py”, line 110, in str_cat
cats = [sep.join(tup) for tup in tuples]
File “/home/users/jalaliya/.local/lib/python3.6/site-packages/pandas/core/strings.py”, line 110, in
cats = [sep.join(tup) for tup in tuples]
TypeError: sequence item 1: expected str instance, bytes found

I upgraded the numpy to 1.15, and I still get the following:
Traceback (most recent call last):
File “…/pyem-master/csparc2star.py”, line 103, in
sys.exit(main(parser.parse_args()))
File “…/pyem-master/csparc2star.py”, line 42, in main
df = metadata.parse_cryosparc_2_cs(cs, passthrough=args.passthrough, minphic=args.minphic)
File “/home/exacloud/lustre1/gouaux/Zad/pyem-master/pyem/metadata.py”, line 313, in parse_cryosparc_2_cs
star.simplify_star_ucsf(df)
File “/home/exacloud/lustre1/gouaux/Zad/pyem-master/pyem/star.py”, line 357, in simplify_star_ucsf
lambda x: “%.6d” % (x + 1)).str.cat(df[UCSF.IMAGE_PATH], sep="@")
File “/home/users/jalaliya/.local/lib/python3.6/site-packages/pandas/core/strings.py”, line 2320, in cat
res = str_cat(data, others=others, sep=sep, na_rep=na_rep)
File “/home/users/jalaliya/.local/lib/python3.6/site-packages/pandas/core/strings.py”, line 110, in str_cat
cats = [sep.join(tup) for tup in tuples]
File “/home/users/jalaliya/.local/lib/python3.6/site-packages/pandas/core/strings.py”, line 110, in
cats = [sep.join(tup) for tup in tuples]
TypeError: sequence item 1: expected str instance, bytes found

Hi @ThyZAD, I am not entirely sure what causes this error. I have a fix, but I need to understand what the real cause is in order to make sure my fix will be correct for every case.

Please let me know what Python and pandas version you are using.

python --version
python -c 'import pandas; print pandas.__version__'

Thanks.

This problem is caused by using Python 3 instead of Python 2.7.

While pyem is only guaranteed to be compatible with Python 2.7, and I thus highly recommend only using Python 2.7, pyem intends to be forwards-compatible with Python 3 wherever possible. In this case, Python 3 compatibility was easy, so csparc2star.py currently works fine with Python 3.

All of my programs have a #! “shebang” line at the top which directly specifies Python 2.7. I suspect you ran the program using a particular python binary like python csparc2star.py <arguments>. You do not need to specify python yourself, and doing so may cause errors. Just run csparc2star.py <arguments> directly.

Best regards!

Thanks! you are right! problem solved. I was using python3 since it already had all of the required packages installed. but doing so on python 2.7 works like a charm! thanks!