Convert .bam file from version 1.6 to 1.4
2
0
Entering edit mode
20 months ago
Abhi • 0

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 ?

bam samtools • 1.4k views
ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
1
Entering edit 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.

ADD REPLY
0
Entering edit mode

It helped, thank you ATpoint !

ADD REPLY
1
Entering edit mode

If you are not able/willing to realign then you can convert a SAM from v.1.3 to newer using reformat.sh which will convert 'M' to '=' and 'X' (sam=1.4 requires MD tags to be present, or ref to be specified). You will need to have samtools or sambamba available in $PATH.

You can try

reformat.sh -Xmx4g in=orig.bam out=new.bam sam=1.4
ADD REPLY
1
Entering edit mode
20 months ago
ATpoint 85k

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.

ADD COMMENT
0
Entering edit mode
20 months ago

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.

ADD COMMENT
0
Entering edit mode

As I recall a major change was between 1.3 and later versions when M and = notation changed.

ADD REPLY
0
Entering edit mode

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 ...

ADD REPLY

Login before adding your answer.

Traffic: 1318 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6