Hello,
I have a couple of CRAM files which I am aiming to convert to BAM files. I tried with these two commands:
samtools view -b -T ref.fa -o output_bam.bam input_cram.cram
and:
samtools view -b -o output_bam.bam input_cram.cram
The second command does not specify a reference file. I had the exact same BAM output from both commands: can someone please explain why this is the case? I read pretty much everywhere that the reference file is required for conversion (since CRAM does not contain bases that match with the reference). Is it really needed?
Of note, I am running samtools v 1.9.
Thanks for your help.
Hi Pierre, many thanks for the very quick reply! I also suspected the UR field in the CRAM header, however what I do not understand is that the UR path is not local to my machine: indeed, I got these CRAM files from a publication. The UR is something like this: UR:/lustre/.../fasta/hs37d5.fa. There is also an AS field that reads as: AS:NCBI37. Is there a way for samtools to get the reference even when it is not local to my working space at all? Thanks!
yes: if samtools finds the MD5 SUM and is able to find/fetch the reference from
REF_PATH
orREF_CACHE
. see : http://www.htslib.org/doc/samtools.html