KolmogorovLab / hapdiff

SV calling for diploid assemblies
MIT License
23 stars 3 forks source link

object has no attribute 'get_reference_length' #2

Open asylvz opened 1 year ago

asylvz commented 1 year ago

Hello, I'm getting the following error, do you have any idea?

./hapdiff.py --reference assembly_NA12878_h1.fasta --pat svtigs_h1.fa --mat svtigs_h2.fa --out-dir dnm -t 32
Running: /asoylev/hapdiff/submodules/minimap2/minimap2 -ax asm20 -B 2 -E 3,1 -O 6,100 --cs -t 32 assembly_NA12878_h1.fasta svtigs_h1.fa -K 5G | samtools sort -m 4G -@ 8 >dnm/hapdiff_pat.bam
[M::mm_idx_gen::60.625*1.53] collected minimizers
[M::mm_idx_gen::65.511*2.32] sorted minimizers
[M::main::65.511*2.32] loaded/built the index for 3154 target sequence(s)
[M::mm_mapopt_update::72.524*2.19] mid_occ = 176
[M::mm_idx_stat] kmer size: 19; skip: 10; is_hpc: 0; #seq: 3154
[M::mm_idx_stat::75.233*2.15] distinct minimizers: 387231193 (92.17% are singletons); average occurrences: 1.460; average spacing: 5.493; total length: 3104328850
[M::worker_pipeline::80.022*2.85] mapped 345 sequences
[M::main] Version: 2.24-r1150-dirty
[M::main] CMD: /asoylev/hapdiff/submodules/minimap2/minimap2 -ax asm20 -B 2 -E 3,1 -O 6,100 --cs -t 32 -K 5G assembly_NA12878_h1.fasta svtigs_h1.fa
[M::main] Real time: 80.978 sec; CPU: 229.410 sec; Peak RSS: 31.580 GB
[bam_sort_core] merging from 0 files and 8 in-memory blocks...
Running: /asoylev/hapdiff/submodules/minimap2/minimap2 -ax asm20 -B 2 -E 3,1 -O 6,100 --cs -t 32 assembly_NA12878_h1.fasta svtigs_h2.fa -K 5G | samtools sort -m 4G -@ 8 >dnm/hapdiff_mat.bam
[M::mm_idx_gen::59.465*1.55] collected minimizers
[M::mm_idx_gen::64.344*2.35] sorted minimizers
[M::main::64.344*2.35] loaded/built the index for 3154 target sequence(s)
[M::mm_mapopt_update::69.551*2.24] mid_occ = 176
[M::mm_idx_stat] kmer size: 19; skip: 10; is_hpc: 0; #seq: 3154
[M::mm_idx_stat::72.975*2.19] distinct minimizers: 387231193 (92.17% are singletons); average occurrences: 1.460; average spacing: 5.493; total length: 3104328850
[M::worker_pipeline::74.995*2.37] mapped 116 sequences
[M::main] Version: 2.24-r1150-dirty
[M::main] CMD: /asoylev/hapdiff/submodules/minimap2/minimap2 -ax asm20 -B 2 -E 3,1 -O 6,100 --cs -t 32 -K 5G assembly_NA12878_h1.fasta svtigs_h2.fa
[M::main] Real time: 75.594 sec; CPU: 178.150 sec; Peak RSS: 24.993 GB
2023-04-04 11:18:19,108 [INFO   ]  ****************** Start SVIM-asm, version 1.0.2 ******************
2023-04-04 11:18:19,108 [INFO   ]  CMD: python3 diploid dnm dnm/hapdiff_pat.bam dnm/hapdiff_mat.bam assembly_NA12878_h1.fasta --min_sv_size 30 --partition_max_distance 5000 --max_edit_distance 0.3 --filter_contained --query_names
2023-04-04 11:18:19,108 [INFO   ]  WORKING DIR: /asoylev/hapdiff/dnm
2023-04-04 11:18:19,108 [INFO   ]  PARAMETER: sub, VALUE: diploid
2023-04-04 11:18:19,108 [INFO   ]  PARAMETER: working_dir, VALUE: /asoylev/hapdiff/dnm
2023-04-04 11:18:19,108 [INFO   ]  PARAMETER: bam_file1, VALUE: dnm/hapdiff_pat.bam
2023-04-04 11:18:19,108 [INFO   ]  PARAMETER: bam_file2, VALUE: dnm/hapdiff_mat.bam
2023-04-04 11:18:19,108 [INFO   ]  PARAMETER: genome, VALUE: assembly_NA12878_h1.fasta
2023-04-04 11:18:19,108 [INFO   ]  PARAMETER: verbose, VALUE: False
2023-04-04 11:18:19,108 [INFO   ]  PARAMETER: phased_gt, VALUE: False
2023-04-04 11:18:19,108 [INFO   ]  PARAMETER: tandem, VALUE: None
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: filter_contained, VALUE: True
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: min_mapq, VALUE: 20
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: min_sv_size, VALUE: 30
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: max_sv_size, VALUE: 100000
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: query_gap_tolerance, VALUE: 50
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: query_overlap_tolerance, VALUE: 50
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: reference_gap_tolerance, VALUE: 50
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: reference_overlap_tolerance, VALUE: 50
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: partition_max_distance, VALUE: 5000
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: max_edit_distance, VALUE: 0.3
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: sample, VALUE: Sample
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: types, VALUE: DEL,INS,INV,DUP:TANDEM,DUP:INT,BND
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: symbolic_alleles, VALUE: False
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: tandem_duplications_as_insertions, VALUE: False
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: interspersed_duplications_as_insertions, VALUE: False
2023-04-04 11:18:19,109 [INFO   ]  PARAMETER: query_names, VALUE: True
2023-04-04 11:18:19,109 [INFO   ]  ****************** STEP 1: COLLECT ******************
2023-04-04 11:18:19,109 [INFO   ]  MODE: diploid
2023-04-04 11:18:19,109 [INFO   ]  INPUT1: /asoylev/hapdiff/dnm/hapdiff_pat.bam
2023-04-04 11:18:19,109 [INFO   ]  INPUT2: /asoylev/hapdiff/dnm/hapdiff_mat.bam
Traceback (most recent call last):
  File "./hapdiff.py", line 117, in <module>
    sys.exit(main())
  File "./hapdiff.py", line 110, in main
    run_svim("hapdiff_unphased.vcf", False)
  File "./hapdiff.py", line 98, in run_svim
    svim.main(svim_cmd)
  File "/asoylev/hapdiff/submodules/svim-asm/src/svim_asm/main.py", line 97, in main
    sv_candidates1 = analyze_alignment_file_coordsorted(aln_file1, options)    
  File "/asoylev/hapdiff/submodules/svim-asm/src/svim_asm/SVIM_COLLECT.py", line 126, in analyze_alignment_file_coordsorted
    options, tandem_annotations))
  File "/asoylev/hapdiff/submodules/svim-asm/src/svim_asm/SVIM_intra.py", line 98, in analyze_alignment_indel
    sv_candidates.append(CandidateInsertion(ref_chr, ref_start + pos_ref, ref_start + pos_ref + length, [query_name], insertion_seq, bam))
  File "/asoylev/hapdiff/submodules/svim-asm/src/svim_asm/SVCandidate.py", line 132, in __init__
    contig_length = bam.get_reference_length(dest_contig)
AttributeError: 'pysam.libcalignmentfile.AlignmentFile' object has no attribute 'get_reference_length'
mikolmogorov commented 1 year ago

Hi,

Are you using source or docker installation? This is likely caused by mismatch in the pysam package versions. If you prefer to use source isntallation, updating pysam to the latest available version will likely solve it.

Misha