nccl-jmli / VarBen

MIT License
35 stars 15 forks source link

Failed to open file ./sv_out/tempDir/edit.remap.bam #23

Closed jingjing578 closed 1 year ago

jingjing578 commented 1 year ago

hi, When I was running sveditor.py script to add CNV to BAM files, it had an error"Failed to open file ./sv_out/tempDir/edit.remap.bam".I checkd every script in VarBen , i didn't find which step can generate this edit.remap.bam. so can you help me?

yulijia commented 1 year ago

Hi, There is a step to merge the edited bam file. https://github.com/nccl-jmli/VarBen/blob/0f66e35dc85b80938df2beafa5919330c9356953/varben/deal_sv/mergeEditBam.py#L168

However, with the limited information, I cannot interpret what happened with your data.

jingjing578 commented 1 year ago

thank you ,but i still have a question ,why i didn't generate the edit.remap.bam and there was no error before that. And I'm confused why my generated edit.bam is so small. I think this error maybe caused by the edit.bam. this is my command:

/home/software/miniconda3/bin/python /home/fengjingj/VarBen/bin/sveditor.py -m /home/fengjingj/cnv.tsv -b /home/fengjingj/my.sorted.bam -r /home/database/Human/reference_genome_hg19/genome.fa --aligner /home/software/miniconda3/bin/bwa --alignerIndex /home/database/Human/reference_genome_hg19/genome.fa --seqer illumina --mindepth 100 --minmutreads 10 -p 12 -l 100 -o ./sv_out/

The content of cnv.tsv is as follow:

chrom start end type AF cnv_type

chr20 52186265 52200826 cnv 1 loss

this is the error log: step4: merge edited reads and remap to new bam, consider about the tag, R remap start ....................................... remap end .......................................... ./sv_out/tempDir/edit.remap.sort samtools sort start................................ samtools sort -o ./sv_out/tempDir/edit.remap.sort.bam ./sv_out/tempDir/ed [E::hts_open_format] Failed to open file ./sv_out/tempDir/edit.remap.bam samtools sort: can't open "./sv_out/tempDir/edit.remap.bam": No such file Traceback (most recent call last): File "/home/fengjingj/VarBen/bin/sveditor.py", line 134, in run() File "/home/fengjingj/VarBen/bin/sveditor.py", line 130, in run main(run_args) File "/home/fengjingj/VarBen/bin/sveditor.py", line 79, in main run_args.libkey, run_args.barcode, run_args.tag) File "/home/fengjingj/VarBen/bin/../varben/deal_sv/mergeEditBam.py", li bamSort(edit_remap_bam_file, edit_remap_bam_sorted_prefix) File "/home/fengjingj/VarBen/bin/../varben/common/bamconvert.py", line _call(bamSort_cmd) File "/home/fengjingj/VarBen/bin/../varben/common/bamconvert.py", line raise Exception("Cmd Error: %s" % cmd) Exception: Cmd Error: samtools sort -o ./sv_out/tempDir/edit.remap.sort.bm

Here is my current generated file: name size used_tmp.bambai 25 used_tmp.bam 2 356 used_chr20,bam,del 6 used_chr20.bam 1 used.sort.bam.bai 1 used.sort.bam 1 total_modify_reads,txt 0 total_modify_pair.list 0 total_delete reads,txt 24866 total_delete pair.list 2458 total_add reads,txt 0 total_add pair.list 0 readname_convert,txt 0 exdude_tmp.bam 3235826 exdude_chr20.bam 2373 exdude,bam 3238358 edit,bam 1 consider_region.bed 1 bam,header 1

yulijia commented 1 year ago

The problem may happen before step 4, I guess the Varben didn't edit any reads in your BAM file. Usually it is because your BAM file including reads that don't meet the editing criteria, so Varben will skip these reads when editing.

jingjing578 commented 1 year ago

The problem may happen before step 4, I guess the Varben didn't edit any reads in your BAM file. Usually it is because your BAM file including reads that don't meet the editing criteria, so Varben will skip these reads when editing.

I found that I made a mistake in parameter options, the "--aligner" should be "bwa",not bwa's path. But after I corrected this mistake, the new error appeared in "bwa", this is my command:

/home/software/miniconda3/bin/python /home/fengjingj/VarBen/bin/sveditor.py -m /home/fengjingj/cnv.tsv -b /home/fengjingj/VarBen/examples/input/EGFR_sort.bam -r /home/database/Human/reference_genome_hg19/genome.fa --aligner bwa --alignerIndex /home/database/Human/reference_genome_hg19/genome.fa --seqer illumina --mindepth 50 --minmutreads 5 -p 6 -l 50 -o ./sv_out/

the erro msg is: [mem_sam_pe] paired reads have different names: "/1", "/2" Traceback (most recent call last): File "/home/fengjingj/VarBen/bin/sveditor.py", line 134, in run() File "/home/fengjingj/VarBen/bin/sveditor.py", line 130, in run main(run_args) File "/home/fengjingj/VarBen/bin/sveditor.py", line 79, in main run_args.libkey, run_args.barcode, run_args.tag) File "/home/fengjingj/VarBen/bin/../varben/deal_sv/mergeEditBam.py", line 169, in merge_edit_bam remap(aligner_index, edit_bam_file, edit_remap_bam_file, aligner, is_single, head) File "/home/fengjingj/VarBen/bin/../varben/common/bamconvert.py", line 106, in remap map_bwa(ref_index, outSamFile, fq1, fq2, header=header, threadNum=threadNum) File "/home/fengjingj/VarBen/bin/../varben/common/bamconvert.py", line 50, in map_bwa _call(mapping_cmd) File "/home/fengjingj/VarBen/bin/../varben/common/bamconvert.py", line 14, in _call raise Exception("Cmd Error: %s" % cmd) Exception: Cmd Error: bwa mem -t 1 /home/database/Human/reference_genome_hg19/genome.fa ./sv_out/tempDir/edit.remap.to_1.fq ./sv_out/tempDir/edit.remap.to_2.fq >./sv_out/tempDir/edit.remap.sam

can you help me check if there is any other error in my command and how can i deal with this erro in "bwa",thank you

yulijia commented 1 year ago

Thank you for your feedback! I will check with the demo in a few weeks. Recently, If you still need to get the edited data with CNV , can you try using bamsurgeon?https://github.com/adamewing/bamsurgeon

jingjing578 commented 1 year ago

Thank you for your feedback! I will check with the demo in a few weeks. Recently, If you still need to get the edited data with CNV , can you try using bamsurgeon?https://github.com/adamewing/bamsurgeon

thank for your suggestions, I will try it .if your script is ok, please tell me

yulijia commented 1 year ago

I have tried to edit a CNV in the example data EGFR_sort.bam, and I didn't encounter any error. My bwa version is 0.7.17-r1198-dirty. This problem may doesn't related with VarBen package. I will close this issue.

chr7    55248067        55249038        cnv     2.5     gain