This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Converting CRAM to FastQ

I am trying to convert a cram file into fastq without reference. The command I am using is:

SamToFastq - I <path_to_cram_file> -F "<path_to_first_fastq>" -F2 "<path_to_second_fastq>"

This is the error that shows up:

java.lang.IllegalArgumentException: Failure getting reference bases for sequence chr1
    at htsjdk.samtools.cram.build.CRAMReferenceRegion.fetchReferenceBasesByRegion(CRAMReferenceRegion.java:172)
    at htsjdk.samtools.cram.build.CRAMReferenceRegion.fetchReferenceBasesByRegion(CRAMReferenceRegion.java:192)
    at htsjdk.samtools.cram.structure.Slice.normalizeCRAMRecords(Slice.java:450)
    at htsjdk.samtools.cram.structure.Container.getSAMRecords(Container.java:322)
    at htsjdk.samtools.CRAMIterator.nextContainer(CRAMIterator.java:112)
    at htsjdk.samtools.CRAMIterator.hasNext(CRAMIterator.java:204)
    at htsjdk.samtools.SamReader$AssertingIterator.hasNext(SamReader.java:608)
    at picard.sam.SamToFastq.doWork(SamToFastq.java:204)
    at picard.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:280)
    at org.broadinstitute.hellbender.cmdline.PicardCommandLineProgramExecutor.instanceMain(PicardCommandLineProgramExecutor.java:37)
    at org.broadinstitute.hellbender.Main.runCommandLineProgram(Main.java:166)
    at org.broadinstitute.hellbender.Main.mainEntry(Main.java:209)
    at org.broadinstitute.hellbender.Main.main(Main.java:306)

This is the output I received when I tried to view the cram file

This is the snapshot of the cram file when I tried to view it using ViewSam

Is there not a way to convert them without the reference file?

gatk samtools cram samtofastq fastq

1 answer

Use samtools view for this conversion. See discussion in Questions about a bug when transferring cram file to bam file

Specifically @jkbonfield's comment here --> Questions about a bug when transferring cram file to bam file

Thank you so much! Will look it up right away.

enter image description hereI was able to get my fastq files. I can see that my reference files are cached in a hts-ref directory but in multiple files as seen in the screenshot below. I want to run these fastq files now into my GATK pipeline that follows the GATK best practices workflow of broad.It requires a fasta file for running the bwa mem. is there a way to compile this cached ref files into a single fasta file? What would be the ideal way to handle this?

Thank you again!

Log in to answer this question.