DRL / blobtools

Modular command-line solution for visualisation, quality control and taxonomic partitioning of genome datasets
GNU General Public License v3.0
184 stars 44 forks source link

error reading bamfile #91

Closed jotech closed 4 years ago

jotech commented 4 years ago

Using the latest release of blobtool (1.1.1.),

blobtools create -i contigs.fasta -b BIGb0170_sorted.bam -t BIGb0170.megablast.out -o blobtools/BIGb0170

I'm getting an error related to pysam and the input bam file:

[+] Parsing bam0 - ./BIGb0170_sorted.bam
Traceback (most recent call last):
  File "blobtools-blobtools_v1.1.1/blobtools", line 7, in <module>
    main()
  File "blobtools-blobtools_v1.1.1/lib/interface.py", line 60, in main
    create.main()
  File "blobtools-blobtools_v1.1.1/lib/create.py", line 119, in main
    blobDb.parseCoverage(covLibObjs=cov_libs, estimate_cov=estimate_cov_flag, prefix=prefix)
  File "blobtools-blobtools_v1.1.1/lib/BtCore.py", line 369, in parseCoverage
    base_cov_dict, covLib.reads_total, covLib.reads_mapped, read_cov_dict = BtIO.parseBam(covLib.f, set(self.dict_of_blobs), estimate_cov)
  File "blobtools-blobtools_v1.1.1/lib/BtIO.py", line 221, in parseBam
    with pysam.AlignmentFile(infile) as aln:
  File "pysam/libcalignmentfile.pyx", line 741, in pysam.libcalignmentfile.AlignmentFile.__cinit__
  File "pysam/libcalignmentfile.pyx", line 990, in pysam.libcalignmentfile.AlignmentFile._open
ValueError: file has no sequences defined (mode='r') - is it SAM/BAM format? Consider opening with check_sq=False

This seems to be related to an issue in pysam and indeed when I change line 221 in lib/BtIO.py to

with pysam.AlignmentFile(infile, check_sq=False) as aln: 

the error disappears.

DRL commented 4 years ago

Well, also seems like you BAM file does not have a proper header ...

Will incorporate this in the next release with a warning re BAM file