Sounds like you're using the wrong reference file for that bam? Looking at the header of bam, it's clearly been aligned with a non-standard reference fasta.
> On 17 May 2015, at 10:12, Dan Greenfield <d...@storleap.com> wrote: > > Dear all, > > I encountered a problem converting a BAM file to CRAM and back again. This > problem is exhibited on both samtools 1.1 and the latest download for > samtools 1.2, each time reproduced from the first step. > > Steps to reproduce this: > 1. download original BAM from EBI: > ftp://ftp.sra.ebi.ac.uk/vol1/ERA172/ERA172924/bam/NA12878_S1.bam > 2. convert to CRAM: > samtools view -C -o NA12878_S1.cram -T hg38.fa NA12878_S1.bam > 3. attempt to convert back to BAM: > samtools view -b -o NA12878_S1.cram.bam -T hg38.fa NA12878_S1.cram > > Results from step 3: (no errors/warnings encountered in previous steps) > > Slice ends beyond reference end. > Slice ends beyond reference end. > ERROR: md5sum reference mismatch for ref 1 pos 248900092..248956422 > CRAM: 1ca5fd5ffe82936260309c85fc9b473b > Ref : b47b43c987dbf1af96ca6d59061401c8 > Failure to decode slice > [E::hts_close] Failed to decode sequence. > samtools: error closing "NA12878_S1.cram": -1 > > Here are the file sizes (note the cram file is actually bigger than the > original bam): > NA12878_S1.bam 121,691,186,161 > NA12878_S1.cram 125,386,599,695 > NA12878_S1.cram.bam 11,109,478,067 > > Regards, > Dan > > ------------------------------------------------------------------------------ > One dashboard for servers and applications across Physical-Virtual-Cloud > Widest out-of-the-box monitoring support with 50+ applications > Performance metrics, stats and reports that give you Actionable Insights > Deep dive visibility with transaction tracing using APM Insight. > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y_______________________________________________ > Samtools-help mailing list > Samtools-help@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/samtools-help -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE. ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ Samtools-help mailing list Samtools-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/samtools-help