eldariont / svim

Structural Variant Identification Method using Long Reads
GNU General Public License v3.0
155 stars 19 forks source link

pysam error #27

Closed ndierckx closed 4 years ago

ndierckx commented 4 years ago

Hi,

I am trying to run svim on some sam or bam files generated by minimap, but I always get the following error, any idea how I can fix this?

2020-01-08 05:34:34,700 [INFO ] ** STEP 1: COLLECT ** 2020-01-08 05:34:34,700 [INFO ] MODE: alignment 2020-01-08 05:34:34,700 [INFO ] INPUT: /staging/leuven/stg_00019/Nicolas/Nanopore_tatjana/nanopore1_minimap.bam 2020-01-08 05:34:34,758 [ERROR ] 'pysam.calignmentfile.AlignedSegment' object has no attribute 'get_cigar_stats' Traceback (most recent call last): File "/data/leuven/332/vsc33273/miniconda3/envs/NGS/bin/svim", line 165, in sys.exit(main()) File "/data/leuven/332/vsc33273/miniconda3/envs/NGS/bin/svim", line 87, in main sv_signatures = analyze_alignment_file_coordsorted(aln_file, options) File "/data/leuven/332/vsc33273/miniconda3/envs/NGS/lib/python3.6/site-packages/svim/SVIM_COLLECT.py", line 138, in analyze_alignment_file_coordsorted supplementary_alignments = retrieve_other_alignments(current_alignment, bam) File "/data/leuven/332/vsc33273/miniconda3/envs/NGS/lib/python3.6/site-packages/svim/SVIM_COLLECT.py", line 47, in retrieve_other_alignments if main_alignment.get_cigar_stats()[0][5] > 0: AttributeError: 'pysam.calignmentfile.AlignedSegment' object has no attribute 'get_cigar_stats'

ndierckx commented 4 years ago

Never mind it solved by updating pysam, conda installation of svim uses an old version of pysam

eldariont commented 4 years ago

Alright, let me know if you experience any other problems.

Cheers David

ndierckx commented 4 years ago

Hi,

Yes I actually still have a problem with pysam:

2020-01-08 19:54:45,127 [INFO ] ** STEP 4: GENOTYPE ** 2020-01-08 19:54:45,127 [INFO ] Genotyping deletions.. 2020-01-08 19:54:45,127 [ERROR ] 'pysam.libcalignmentfile.AlignmentFile' object has no attribute 'get_reference_length'

eldariont commented 4 years ago

Hi Nicolas,

I think I need some more information in order to reproduce and fix your issue. You seem to have installed svim into the conda environment NGS. Could you please share the list of installed packages in this environment? Something like this should do the trick:

conda activate NGS
conda list

It would also be good to have the full log file that svim creates in the working directory.

Thanks for reporting this. Cheers David

ndierckx commented 4 years ago

Here is the llist:

_libgcc_mutex 0.1 main
bcftools 1.8 h4da6232_3 bioconda bedtools 2.29.2 hc088bd4_0 bioconda blas 1.0 mkl
bzip2 1.0.8 h7b6447c_0
ca-certificates 2019.11.27 0
certifi 2019.11.28 py36_0
curl 7.67.0 hbc83047_0
cycler 0.10.0 py36_0
dbus 1.13.12 h746ee38_0
decorator 4.4.1 py_0
expat 2.2.6 he6710b0_0
fontconfig 2.13.0 h9420a91_0
freetype 2.9.1 h8a8886c_1
glib 2.63.1 h5a9c865_0
gst-plugins-base 1.14.0 hbbd80ab_1
gstreamer 1.14.0 hb453b48_1
htslib 1.9 h4da6232_3 bioconda icu 58.2 h9c2bf20_1
intel-openmp 2019.4 243
jpeg 9b h024ee3a_2
kiwisolver 1.1.0 py36he6710b0_0
krb5 1.16.4 h173b8e3_0
libcurl 7.67.0 h20c2e04_0
libdeflate 1.2 h516909a_1 bioconda libedit 3.1.20181209 hc058e9b_0
libffi 3.2.1 hd88cf55_4
libgcc 7.2.0 h69d50b8_2
libgcc-ng 9.1.0 hdf63c60_0
libgfortran-ng 7.3.0 hdf63c60_0
libpng 1.6.37 hbc83047_0
libssh2 1.8.2 h1ba5d50_0
libstdcxx-ng 9.1.0 hdf63c60_0
libuuid 1.0.3 h1bed415_2
libxcb 1.13 h1bed415_1
libxml2 2.9.9 hea5a465_1
matplotlib 3.1.1 py36h5429711_0
minimap2 2.17 h8b12597_1 bioconda mkl 2019.4 243
mkl-service 2.3.0 py36he904b0f_0
mkl_fft 1.0.15 py36ha843d7b_0
mkl_random 1.1.0 py36hd6b4f25_0
nanosv 1.2.4 py_0 bioconda ncurses 6.1 he6710b0_1
networkx 2.4 py_0
ngmlr 0.2.7 he860b03_1 bioconda numpy 1.17.4 py36hc1035e2_0
numpy-base 1.17.4 py36hde5b4d6_0
openssl 1.1.1d h7b6447c_3
pcre 8.43 he6710b0_0
perl 5.26.2 h14c3975_0
pip 19.3.1 py36_0
pyparsing 2.4.5 py_0
pyqt 5.9.2 py36h05f1152_2
pysam 0.11.2.2 py36_1 bioconda python 3.6.9 h265db76_0
python-dateutil 2.8.1 py_0
pytz 2019.3 py_0
pyvcf 0.6.8 py36_0 bioconda qt 5.9.7 h5867ecd_1
readline 7.0 h7b6447c_5
samtools 1.9 h10a08f8_12 bioconda scipy 1.3.2 py36h7c811a0_0
setuptools 44.0.0 py36_0
sip 4.19.8 py36hf484d3e_0
six 1.13.0 py36_0
sniffles 1.0.11 hdbcaa40_1 bioconda sqlite 3.30.1 h7b6447c_0
svim 1.2.0 py_0 bioconda tclap 1.2.1 h470a237_1 bioconda tk 8.6.8 hbc83047_0
tornado 6.0.3 py36h7b6447c_0
wheel 0.33.6 py36_0
xz 5.2.4 h14c3975_4
zlib 1.2.11 h7b6447c_3

ndierckx commented 4 years ago

This is the log svim_minimap_np1.zip

eldariont commented 4 years ago

Hi, thanks for sending me the files. I could reproduce your problem now. It is still caused by your outdated version of pysam (0.11.2.2) which seems to be missing the get_reference_length method. You can either update pysam in your NGS environment with something like

conda activate NGS
conda install pysam=0.15.2

Alternatively, you can install svim in a separate environment which will automatically pull the current version of pysam with

conda create -n svim_env svim
conda activate svim_env
svim alignment ...

Installing in a separate environment is probably the best option because it keeps different tools separated and prevents the kind of problem you had. My guess is that pysam was installed already when you installed svim and because I did not enforce a specific version of pysam the old version remained.

I will push a commit that enforces a modern version of pysam when svim is installed to prevent this from happening again. So thanks for reporting this! :)

Please let me know whether updating pysam does the trick for you. Cheers David

ndierckx commented 4 years ago

Thanks, everything works great now!