malonge / RagTag

Tools for fast and flexible genome assembly scaffolding and improvement
MIT License
476 stars 49 forks source link

a bytes-like object is required, not 'dict' #141

Open mabh5 opened 2 years ago

mabh5 commented 2 years ago

hello,

I am running ragtag scaffold in order to fill in gaps between contigs using a reference genome. everything seems to run fine up until the very end when I get the error:

raise RuntimeError('Failed : %s > %s 2> %s. Check stderr file for details.' % (" ".join(cmd), out, err))

when I look into ragtag.scaffold.err this is what I get:

Traceback (most recent call last):
  File "/home/mh/anaconda3/envs/ragtag/bin/ragtag_agp2fa.py", line 79, in <module>
    main()
  File "/home/mh/anaconda3/envs/ragtag/bin/ragtag_agp2fa.py", line 69, in main
    sys.stdout.write(reverse_complement(fai.fetch(agp_line.comp, agp_line.comp_beg-1, agp_line.comp_end)))
  File "/home/mh/anaconda3/envs/ragtag/lib/python3.6/site-packages/ragtag_utilities/utilities.py", line 48, in reverse_complement
    return seq.translate(complements)[::-1]
TypeError: a bytes-like object is required, not 'dict'

the code I am running is as follows:

ragtag.py scaffold --mm2-params '-x asm10' genomic.fa combined.fasta -u

any idea on how to fix this error?

2218301020 commented 1 year ago

Have you fixed the error? I encountered the same issue.

mabh5 commented 1 year ago

I did, but not using RagTag. at this point in the RagTag assembly you should have a .agp file. I used the .agp file with agptools (https://github.com/WarrenLab/agptools) to finish the assembly step that kept failing in this step in RagTag. This is what that looks like:

agptools assemble combined.fasta ragtag.scaffold.agp > corrected_scaffolds.fasta

combined.fasta = the original contig assembly fasta file that you put into RagTag ragtag.scaffold.agp = the new file that ragtag assembled (this file has all the data on how the contigs fit together) corrected_scaffolds = the name that you want to name your scaffold assembly.

this worked decently quickly for me and seemed to have given me a good final scaffold assembly!

Yogesh1-11 commented 1 year ago

same error

hrpelg commented 1 year ago

I got same error:

Traceback (most recent call last): File "/workspace/appscratch/miniconda/ragtag/bin/ragtag_agp2fa.py", line 79, in main() File "/workspace/appscratch/miniconda/ragtag/bin/ragtag_agp2fa.py", line 69, in main sys.stdout.write(reverse_complement(fai.fetch(agp_line.comp, agp_line.comp_beg-1, agp_line.comp_end))) File "/workspace/appscratch/miniconda/ragtag/lib/python3.6/site-packages/ragtag_utilities/utilities.py", line 48, in reverse_complement return seq.translate(complements)[::-1] TypeError: a bytes-like object is required, not 'dict'

mabh5 commented 1 year ago

Not sure if RagTag ever found a fix to this issue, but my fix is in this reply: https://github.com/malonge/RagTag/issues/141#issuecomment-1500436880

hrpelg commented 1 year ago

Thanks, I am going that way but having a hard time installing screed package needed for the agptools :-)

I will sort it using bioconda instead of pip I guess

jaehakson commented 5 months ago

I installed/upgraded/downgraded additional packages in the 'ragtag' environment, and then that issue is gone in my ragtag conda environment when running 'ragtag.py scaffold'.

conda install libgcc-ng=13.2.0 libgomp=13.2.0 libstdcxx-ng=13.2.0 python_abi=3.7 libffi=3.4.2 libgfortran5=13.2.0 libgfortran-ng=13.2.0 tk=8.6.13 libopenblas=0.3.24 minimap2=2.26 sqlite=3.43.2 python=3.7.12 setuptools=68.2.2 wheel=0.41.2 numpy=1.21.6 pip=23.3 pysam=0.15.3 bzip2=1.0.8 c-ares=1.20.1 keyutils=1.6.1 libdeflate=1.0 libev=4.33 libnsl=2.0.1 libzlib=1.2.13 ncurses=6.4 openssl=3.2.1 libedit=3.1.20191231 libnghttp2=1.52.0 libsqlite=3.43.2 libssh2=1.11.0 zstd=1.5.5 k8=0.2.5 krb5=1.21.2 libcurl=8.4.0 curl=8.4.0

dannagifford commented 4 months ago

Thanks to @jaehakson for the hint. This can be solved by downgrading python. python version 3.5 works OK See https://github.com/malonge/RagTag/issues/155#issuecomment-2238574039

A workaround for this is to downgrade your python version to 3.5. If you've installed within a conda environment, e.g. your_ragtag_env, you can do this with

conda activate your_ragtag_env
conda install python=3.5