Picard MergeSam error : Cannot use index file with textual SAM file
1
0
Entering edit mode
7.6 years ago
AB ▴ 360

I tried to run a simple mergesam using picard on two bam files using the following command

java -jar /opt/picard/picard.jar MergeSamFiles I=file1.bam I=file2.bam O=merged_output.bam USE_THREADING=TRUE

This is giving me the following error

Exception in thread "main" java.lang.RuntimeException: **Cannot use index file with textual SAM file**
    at htsjdk.samtools.SamReaderFactory$SamReaderFactoryImpl.open(SamReaderFactory.java:317)
    at htsjdk.samtools.SamReaderFactory$SamReaderFactoryImpl.open(SamReaderFactory.java:145)
    at picard.sam.MergeSamFiles.doWork(MergeSamFiles.java:142)
    at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:208)
    at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:95)

What does it mean and how do I fix it ?

Thanks

picard mergesam • 5.3k views
ADD COMMENT
0
Entering edit mode

Figured it out. I only had a partial bam file. Once i downloaded it again, MergeSam ran perfectly. Easy solution to a very silly problem.

Thanks for your time Pierre.

ADD REPLY
0
Entering edit mode

if it answered your question, click on the green mark near my answer to close the post.

ADD REPLY
2
Entering edit mode
7.6 years ago

can your please run the following command:

file file1.bam file2.bam

it should return:

gzip compressed data, extra field

if not (eg: ASCII text) your files are SAM but not BAM.

if not, I suggest your update your version of picard because there is no such method SamReaderFactoryImpl.openat line 317. https://github.com/samtools/htsjdk/blob/master/src/main/java/htsjdk/samtools/SamReaderFactory.java#L317

ADD COMMENT
0
Entering edit mode

Thank you. I tried the command and I got this

file1.bam: gzip compressed data, extra field

file2.bam: data

Does this mean my file2 is a SAM file ?

ADD REPLY
0
Entering edit mode

mean my file2 is a SAM file

try head file2.bamor hexdump -c file2.bam | head to see if you can guess the format...

ADD REPLY

Login before adding your answer.

Traffic: 1971 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6