I have a package (breakseq) that fails on newer versions of bam files. It uses older version of pysam which is unable to read the new bam file header. And throws errors.
Is there an easy way to convert .bam files from version 1.6 to 1.4 ?
I have a package (breakseq) that fails on newer versions of bam files. It uses older version of pysam which is unable to read the new bam file header. And throws errors.
Is there an easy way to convert .bam files from version 1.6 to 1.4 ?
The real question for me personally would be whether this one single package (breakseq) is that much of a game changer that it merits messing with the already processed data. There are really tons of tools that call structural variants, wouldn't you save yourself the headache and use them? There might be others issues with deprecated software downstream I would just skip it if at all possible.
I think that you should be able to convert your BAM file to SAM with the current version of samtools
, then you could use an older version of the samtools
software to convert it to BAM again.
I believe (but I could be wrong here) that most changes between 1.4 and 1.6 are related to the binary versions (BAM and CRAM) and that the SAM format stayed the same.
In all fairness that is not a change from 1.4 to 1.6, though.
That being said I missed that they finally added the more "sane" operators. Finally, CIGAR strings operate the way they should have always worked.
The SAM Spec still lists M as: alignment match (can be a sequence match or mismatch)
But it shows =
and X
as new operators for match and mismatch.
Now I wonder, if all one had was 100M
, how would they know which notation applies ...
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
I have the same issue, but I have to convert BAM file from v.1.3 to v.1.6 and I cannot do that using the samtools v.1.15. Maybe you have some other suggestions? I get an error of mismatched versions of BAM files when I am calling somatic variants with Mutect2 in paired mode.
Convert to fastq, realign, convert SAM to BAM with a modern version of samtools. If you used a robust pipeline in the first place you should know the version of the aligner that was used back in the day, so you should be able to reproduce the alignment exactly, and only the samtools version would change.
It helped, thank you ATpoint !
If you are not able/willing to realign then you can convert a SAM from v.1.3 to newer using
reformat.sh
which willconvert 'M' to '=' and 'X' (sam=1.4 requires MD tags to be present, or ref to be specified).
You will need to havesamtools
orsambamba
available in $PATH.You can try