hartwigmedical / hmftools

Various algorithms for analysing genomics data
GNU General Public License v3.0
189 stars 58 forks source link

question on bam tools.. #498

Closed nan5895 closed 7 months ago

nan5895 commented 9 months ago

hello,

i have a question on bam-tools

i tried to slice bam files with below code that found in READ.me

java -cp /opt/hmftools/bamtools/bam-tools_v1.1.jar com.hartwig.hmftools.bamtools.slice.RegionSlicer \
   -bam_file ${path_to_bam} \
   -ref_genome ${path_to_ref}/Homo_sapiens.GRCh37.GATK.illumina.fasta \
   -ref_genome_version 37 \
   -output_dir ${output_dir} \
   -threads 10 

but it returns 04:29:36.289 [main] [ERROR] missing specific regions or slice BED file for slicing

So, for the test, I added some BED like the below for the test...

chr4    20886302        20897009
chr6    41483250        42552696
chr10   46947465        47150354
chr10   54760442        55261010
chr12   25228630        25664018
chr12   28416078        28646784
chr12   28882735        29873318
chr12   30345582        30671369
chr12   30774420        30785127
chr17   37605396        40188034
chr18   24436782        2479209

java -cp /opt/hmftools/bamtools/bam-tools_v1.1.jar com.hartwig.hmftools.bamtools.slice.RegionSlicer \
   -bam_file ${path_to_bam} \
   -ref_genome ${path_to_ref}/Homo_sapiens.GRCh37.GATK.illumina.fasta \
   -ref_genome_version 37 \
   - regions_bed_file ${bed} \
   -output_dir ${output_dir} \
   -threads 10 

But the above commands delete contents in my bam all and return.

Exception in thread "main" java.lang.RuntimeException: Cannot use index file with textual SAM file
    at htsjdk.samtools.SamReaderFactory$SamReaderFactoryImpl.open(SamReaderFactory.java:432)
    at htsjdk.samtools.SamReaderFactory$SamReaderFactoryImpl.open(SamReaderFactory.java:208)
    at com.hartwig.hmftools.bamtools.slice.RegionBamSlicer.<init>(RegionBamSlicer.java:44)
    at com.hartwig.hmftools.bamtools.slice.RegionSlicer.run(RegionSlicer.java:48)
    at com.hartwig.hmftools.bamtools.slice.RegionSlicer.main(RegionSlicer.java:105)
#### originally 
-r-xr-x---   168G file1.realn.mdup.bqsr.bam
-r-xr-x---   8.7M  file1.realn.mdup.bqsr.bam.bai
-r-xr-x---   32  file1.realn.mdup.bqsr.bam.md5

#### After run command above
-rwxr-x---     0  file1.realn.mdup.bqsr.bam 
-rwxr-x---  8.7M  file1.realn.mdup.bqsr.bam.bai
-rwxr-x---    32  file1.realn.mdup.bqsr.bam.md5

I have backup files, so it was okay ... but would you tell me what I have done wrong?? btw ... I changed permission because the command asked me to write permission...

charlesshale commented 8 months ago

Add this config: -sample SAMPLE_ID

which will then make an output BAM like: /output_dir/SAMPLE_ID.bam

and optionally add: -output_id slice_name

which will then make an output BAM like: /output_dir/SAMPLE_ID.slice_name.bam

(that can be anohter way to help with naming conflicts with the input BAM file)

In the next version I've replaced the 'sample' config with 'output_prefix', which merges these 2 configs into one for naming the output files.

charlesshale commented 7 months ago

The latest BAM tools is: https://github.com/hartwigmedical/hmftools/releases/tag/bam-tools-v1.2.1