etal / cnvkit

Copy number variant detection from targeted DNA sequencing
http://cnvkit.readthedocs.org
Other
501 stars 163 forks source link

Error while indexing BAM files #817

Open brettChapman opened 1 year ago

brettChapman commented 1 year ago

Hi

I get an error while indexing. It appears that I require CSI indexing due to the length of my chromosomes.

Is there a work around for this? Will you be adding CSI indexing as a feature?

Extracting sequences from chromosome chr4H
Extracting sequences from chromosome chr5H
Extracting sequences from chromosome chr6H
Extracting sequences from chromosome chr7H
Wrote morex_reference.cnn with 2821 regions
Running 895 samples in serial
Running the CNVkit pipeline on ERS2903440.sorted.bam ...
[E::idx_find_and_load] Could not retrieve index file for 'ERS2903440.sorted.bam'
Indexing BAM file ERS2903440.sorted.bam
[E::hts_idx_check_range] Region 536877674..536877825 cannot be stored in a bai index. Try using a csi index
[E::sam_index] Read 'ERR2902347.39283' with ref_name='chr2H', ref_length=665585731, flags=99, pos=536877675 cannot be indexed
Traceback (most recent call last):
  File "/usr/local/bin/cnvkit.py", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/cnvlib/cnvkit.py", line 10, in main
    args.func(args)
  File "/usr/local/lib/python3.10/dist-packages/cnvlib/commands.py", line 194, in _cmd_batch
    pool.submit(
  File "/usr/local/lib/python3.10/dist-packages/cnvlib/parallel.py", line 18, in submit
    return SerialFuture(func(*args))
  File "/usr/local/lib/python3.10/dist-packages/cnvlib/batch.py", line 244, in batch_run_sample
    raw_tgt = coverage.do_coverage(target_bed, bam_fname, by_count, 0, processes, fasta)
  File "/usr/local/lib/python3.10/dist-packages/cnvlib/coverage.py", line 26, in do_coverage
    samutil.ensure_bam_index(bam_fname)
  File "/usr/local/lib/python3.10/dist-packages/cnvlib/samutil.py", line 71, in ensure_bam_index
    pysam.index(bam_fname)
  File "/usr/local/lib/python3.10/dist-packages/pysam/utils.py", line 69, in __call__
    raise SamtoolsError(
pysam.utils.SamtoolsError: 'samtools returned with error 1: stdout=, stderr=samtools index: failed to create index for "ERS2903440.sorted.bam": Numerical result out of range\n'
srun: error: node-1: task 0: Exited with exit code 1

Thanks

weiliwei1 commented 1 month ago

Hello, Have you already solved this problem? I had a similar problem, but in fact my bam file was in a folder that contained its corresponding bai file.