Using samtools and Picard tools with cram files
1
0
Entering edit mode
8.0 years ago
Chris Gene ▴ 80

I have a series of cram files that I want to merge without converting to bam. When I try samtools merge out.cram in1.cram in2.cram in3.cram

I get the following error: [bam_header_read] EOF marker is absent. The input is probably truncated. [bam_header_read] invalid BAM binary header (this is not a BAM file). [bam_header_read] EOF marker is absent. The input is probably truncated. [bam_header_read] invalid BAM binary header (this is not a BAM file). /tmp/1460051111.1957878: line 8: 18355 Segmentation fault

Is there any specification I can add to the merge command to make it work? None of the options seem to do the trick.

Also, can I then pass the cram file to Picard tools BamToFastq?

Thanks

samtools cram bam • 4.4k views
ADD COMMENT
0
Entering edit mode

What version of samtools do you have?

ADD REPLY
0
Entering edit mode

BTW, there's an --input-fmt-option that you can use.

ADD REPLY
0
Entering edit mode

It's 0.1.18; doesn't work with that option. I'll update and try again. Thanks!

ADD REPLY
1
Entering edit mode

0.1.18 was written before CRAM was invented...

ADD REPLY
0
Entering edit mode

You should upgrade to the latest. That is a fairly old version of samtools.

ADD REPLY
0
Entering edit mode
8.0 years ago
Chris Gene ▴ 80

Worked fine with the update, thanks. And picard's BamToFastq? I'm using v. 1.99, that already supports cram files, but still get parsing error:

Exception in thread "main" net.sf.samtools.SAMFormatException: Error parsing text SAM file. Not enough fields; Line 1 Line: CRAM^C^@ (...) at net.sf.samtools.SAMLineParser.reportFatalErrorParsingLine(SAMLineParser.java:420) at net.sf.samtools.SAMLineParser.parseLine(SAMLineParser.java:210) at net.sf.samtools.SAMTextReader$RecordIterator.parseLine(SAMTextReader.java:237) at net.sf.samtools.SAMTextReader$RecordIterator.next(SAMTextReader.java:225) at net.sf.samtools.SAMTextReader$RecordIterator.next(SAMTextReader.java:201) at net.sf.samtools.SAMFileReader$AssertableIterator.next(SAMFileReader.java:687) at net.sf.samtools.SAMFileReader$AssertableIterator.next(SAMFileReader.java:665) at net.sf.picard.sam.SamToFastq.doWork(SamToFastq.java:132) at net.sf.picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:177) at net.sf.picard.sam.SamToFastq.main(SamToFastq.java:121)

ADD COMMENT
1
Entering edit mode

Picard v1.99 is from September 2013, which also pretty much predates the CRAM format and certainly is well before any Picard support for CRAM (which according to ENA was introduced in 1.133, but I too would recommend staying very up-to-date if you want to do anything with CRAM in HTSJDK or Picard).

You might consider samtools fastq for this job.

ADD REPLY
0
Entering edit mode

I'd suggest using the latest version (2.2.1, I think) of picard as well. Picard's ability to handle CRAM files still seems to be a bit of a work in progress.

ADD REPLY

Login before adding your answer.

Traffic: 2047 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