We've moved!
This site is now read-only. You can find our new documentation site and support forum for posting questions here.
Be sure to read our welcome blog!

GATK 3.5: CRAM file error with samtools-1.3


I recently created a cram file using PrintReads and tried to view the file with samtools-1.3. The header could be viewed just fine, but after the header ended the file was considered to be truncated. I received the following error:

Failed to populate reference for id 0
Unable to fetch reference #0 10001..893888
Failure to decode slice
[main_samview] truncated file.

The cram file size seems appropriate and could even be converted back to a BAM file with PrintReads successfully. I am not sure if this is a compatibility issue and if so is there a fix in the works.

Vito C.


Best Answer


  • vcaropre1vcaropre1 Member

    Yeah this version of samtools supports cram. They use a .crai index file and I created one with samtools and still the same error was reported. I will contact them about the error as well.

    I created a cram file through samtools-1.3 and could view it and GATK 3.5 could recognize the file and process it without an issue.

  • Geraldine_VdAuweraGeraldine_VdAuwera Cambridge, MAMember, Administrator, Broadie admin

    Ok, let us know what the samtools folks say. We're all just starting to support cram so I wouldn't be surprised if we had some incompatibilities. Sorry for the inconvenience.

  • vcaropre1vcaropre1 Member

    Just heard back from samtools. Simple fix. For samtools to open the cram file created by GATK it must have the reference sequence added with the -T flag. So it would look like:

    samtools view -h cram_file -T reference_file_used_to_make_cram_file

    This overrides the attempt to pull the reference via HTTP and uses the file instead.

  • Geraldine_VdAuweraGeraldine_VdAuwera Cambridge, MAMember, Administrator, Broadie admin

    Ah, that makes sense, good to know. Thanks for reporting back with the solution!

Sign In or Register to comment.