将标签添加到bioperl DB::SAM/BAM
我有一个 bam 文件并使用 bioperl (Bio::DB::Sam) 来处理它。 现在我想问是否有可能在这个文件中添加标签到对齐中?
我用来
my $iterator = $bam->features(-iterator => 1,
-flags => {M_UNMAPPED=>0});
while (my $align = $iterator->next_seq) {
...
}
循环遍历对齐的读数。现在我正在寻找像
$align->addTag(key=>value)
再见这样的东西
I have a bam file and use bioperl (Bio::DB::Sam) to work with it.
Now i wanted to ask if there is any possibility to add tags to alignments in this File?
i use
my $iterator = $bam->features(-iterator => 1,
-flags => {M_UNMAPPED=>0});
while (my $align = $iterator->next_seq) {
...
}
to loop through the aligned reads. Now i am searching vor anthing like
$align->addTag(key=>value)
bye
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
BedTools 有一种注释 BAM 文件的方法,称为 TagBam
http://biostar.stackexchange .com/questions/9552/basic-bam-file-annotation
https://github.com/arq5x/bedtools
BedTools has a means of annotating BAM files called TagBam
http://biostar.stackexchange.com/questions/9552/basic-bam-file-annotation
https://github.com/arq5x/bedtools
简短的回答,不。
可以对原始 SAM 执行此操作,然后将其转换回 BAM。我最近一直在为 BAM 编写 C++ api,我自己也遇到了这个问题。问题是表示此信息的底层 C 结构都是紧密字节封装的,并占用特定数量的内存。有时他们拥有的可能比他们需要的多一点,但其他时候他们的数量刚好合适。在大多数情况下,添加到这些结构中会超出它们的可用内存。
所以,如果我是你,我会写一个新的 SAM 文件,其中包含你的附加标签,并使用 samtools 将其转换为 BAM
Short answer, no.
It might be possible to do it to the raw SAM and then convert it back to BAM. I've recently been writing a C++ api for BAM and came across this issue myself. The problem is the underlying c structures representing this information are all tightly byte packed and take up a specific amount of memory. Sometimes they might have a little more than they need, but other times they have just the right amount. Adding to these structures would, in most cases, exceed the available memory to them.
So, if I were you I would write out a new SAM file with your additional tags in it and convert it to BAM using samtools