Write free text comment with @CO in BAM file
1
0
Entering edit mode
3.1 years ago
mhasa006 ▴ 70

I'm trying to add a free text while writing the reads in a BAM file. As the Java hstjdk samtool doc mentions, I can add a free text with @CO SAMTag. For example,

I'm adding the NM tag and MD tag using this code

record.setAttribute(htsjdk.samtools.SAMTag.MD.name(), "Value");
record.setAttribute(htsjdk.samtools.SAMTag.NM.name(), "Value");

But when I try to do the same for @CO tag

record.setAttribute(htsjdk.samtools.SAMTag.CO.name(), "Value");

I get the following error

cannot find symbol
symbol:   variable CO
location: class htsjdk.samtools.SAMTag

Can someone help me figure out how to add free text while writing a BAM file? Thanks in advance.

BAM hstjdk java • 2.1k views
ADD COMMENT
0
Entering edit mode

what is your version of htsjdk ?

ADD REPLY
0
Entering edit mode

samtools 1.2 Using htslib 1.2.1

ADD REPLY
0
Entering edit mode

Samtools is up to v.1.12 so consider updating.

ADD REPLY
0
Entering edit mode

Can this be an issue because of the earlier version of samtools? I tried the

record.setAttribute("SO","value");

It runs through without error, but nothing was written in the BAM file

ADD REPLY
0
Entering edit mode

but nothing was written in the BAM file

we cannot help without seeing the code.

ADD REPLY
0
Entering edit mode

GenoMax htsjdk version is ~ not related to samtools or htslib.

ADD REPLY
0
Entering edit mode

no, what is the version of htsjdk ? not samtools, not htslib. https://github.com/samtools/htsjdk/releases

ADD REPLY
0
Entering edit mode

htsjdk version 1.133

Can the version cause this issue?

ADD REPLY
0
Entering edit mode

htsjdk version 1.133 Can the version cause this issue?

yes. 1.333 is 7 years old. And CO was not defined then.

https://github.com/samtools/htsjdk/blob/3ed9b1d7681099ab77921916f7e6d0dd29f7d245/src/java/htsjdk/samtools/SAMTag.java

It's just too old. You shouldn't use this library. "951 commits to master since this release "

ADD REPLY
0
Entering edit mode

Got it, Thanks for the help.

ADD REPLY
0
Entering edit mode
3.1 years ago

use setAttribute(String,String) https://github.com/samtools/htsjdk/blob/master/src/main/java/htsjdk/samtools/SAMRecord.java#L1529

record.setAttribute("SO","value");
ADD COMMENT

Login before adding your answer.

Traffic: 1742 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