I have a small snippet of BAM that I want to convert to CRAM.
% samtools --version
samtools 1.9
Using htslib 1.9
Copyright (C) 2018 Genome Research Ltd.
% samtools view -T chr1.fa -C hg19_chr1.bam -o hg19_chr1.cram
[E::cram_get_ref] Failed to populate reference for id 1
[main_samview] failed to write the SAM header
%
I have looked at other errors like this on google but couldn't really see why this simple scenario would fail. I tried also using a different version of chr1 and it gives an error about length mismatching, so this seems to be a different error.
Hello cmdcolin ,
I guess in your reference sequence file the chromosome name is prefixed with
chr
, but in yourbam
file it isn't.$ samtools view -H hg19_chr1.bam|grep "SN"
will give you the sequence name used in your bam file.grep "^>" chr1.fa
will give you the sequence name in your reference.fin swimmer
I think they are the same actually, in BAM header
@SQ SN:chr1 LN:249250621
and in FASTA>chr1