Question: How to convert BAM to FASTQ using Picard Tools ?
2
gravatar for Deepak Tanwar
4.3 years ago by
Deepak Tanwar4.0k
ETH Zürich, Switzerland
Deepak Tanwar4.0k wrote:

Hi,

I am trying to convert a BAM file to a FASTQ file. This is my first time analysis of BAM file. I want to use Picard tools for the analysis. After reading some posts on Biostars and Picard website, I was able to understand something. But, I am getting following error:

COMMAND:

$  java -Xmx6g -jar ../picard-tools-1.126/picard.jar SamToFastq I=file.bam F=file.fastq

 

ERROR:


[Thu May 21 14:46:55 CDT 2015] picard.sam.SamToFastq INPUT=../../data/F14FTSUSAT1066_HUMsfcX/bam/1AA_rawlib.bam FASTQ=1AA_rawlib.fastq    OUTPUT_PER_RG=false RE_REVERSE=true INTERLEAVE=false INCLUDE_NON_PF_READS=false

READ1_TRIM=0 READ2_TRIM=0 INCLUDE_NON_PRIMARY_ALIGNMENTS=false VERBOSITY=INFO QUIET=false VALIDATION_STRINGENCY=STRICT COMPRESSION_LEVEL=5 MAX_RECORDS_IN_RAM=500000 CREATE_INDEX=false CREATE_MD5_FILE=false

[Thu May 21 14:46:55 CDT 2015] Executing as deepak@tenor on Linux 3.10.0-229.1.2.el7.x86_64 amd64; OpenJDK 64-Bit Server VM 1.7.0_75-mockbuild_2015_03_26_13_15-b00; Picard version: 1.126(4691ee611ac205d4afe2a1b7a2ea975a6f997426_1417447214) IntelDeflater
[Thu May 21 14:46:57 CDT 2015] picard.sam.SamToFastq done. Elapsed time: 0.02 minutes.

Runtime.totalMemory()=2058354688
To get help, see http://broadinstitute.github.io/picard/index.html#GettingHelp
Exception in thread "main" htsjdk.samtools.FileTruncatedException: Premature end of file
        at htsjdk.samtools.util.BlockCompressedInputStream.readBlock(BlockCompressedInputStream.java:382)
        at htsjdk.samtools.util.BlockCompressedInputStream.available(BlockCompressedInputStream.java:127)
        at htsjdk.samtools.util.BlockCompressedInputStream.read(BlockCompressedInputStream.java:252)
        at java.io.DataInputStream.read(DataInputStream.java:149)
        at htsjdk.samtools.util.BinaryCodec.readBytesOrFewer(BinaryCodec.java:404)
        at htsjdk.samtools.util.BinaryCodec.readBytes(BinaryCodec.java:380)
        at htsjdk.samtools.util.BinaryCodec.readByteBuffer(BinaryCodec.java:490)
        at htsjdk.samtools.util.BinaryCodec.readInt(BinaryCodec.java:501)
        at htsjdk.samtools.BAMRecordCodec.decode(BAMRecordCodec.java:178)
        at htsjdk.samtools.BAMFileReader$BAMFileIterator.getNextRecord(BAMFileReader.java:660)
        at htsjdk.samtools.BAMFileReader$BAMFileIterator.advance(BAMFileReader.java:634)
        at htsjdk.samtools.BAMFileReader$BAMFileIterator.next(BAMFileReader.java:628)
        at htsjdk.samtools.BAMFileReader$BAMFileIterator.next(BAMFileReader.java:598)
        at htsjdk.samtools.SamReader$AssertingIterator.next(SamReader.java:514)
        at htsjdk.samtools.SamReader$AssertingIterator.next(SamReader.java:488)
        at picard.sam.SamToFastq.doWork(SamToFastq.java:153)
        at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:187)
        at picard.cmdline.PicardCommandLine.instanceMain(PicardCommandLine.java:89)
        at picard.cmdline.PicardCommandLine.main(PicardCommandLine.java:99)

picard tools bam fastq • 7.0k views
ADD COMMENTlink modified 4.3 years ago by Pierre Lindenbaum122k • written 4.3 years ago by Deepak Tanwar4.0k
3
gravatar for Pierre Lindenbaum
4.3 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum122k wrote:

there's something wrong with the bam. Please try

 

samtools view -c file.bam

 

to test the bam.

ADD COMMENTlink written 4.3 years ago by Pierre Lindenbaum122k
1

Hi Pierre,

Yes.

/share/apps/samtools/samtools view -c file.bam
[bam_header_read] EOF marker is absent. The input is probably truncated.
[main_samview] truncated file.

ADD REPLYlink modified 4.3 years ago • written 4.3 years ago by Deepak Tanwar4.0k
1

so there was something wrong with the tool that generated file.bam, you'll have to generate it again.

ADD REPLYlink written 4.3 years ago by Pierre Lindenbaum122k
1

Yes, you are right. Same command for other 2 bam files is working perfectly.

Thank you so much Pierre.

ADD REPLYlink written 4.3 years ago by Deepak Tanwar4.0k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 808 users visited in the last hour