将标签添加到bioperl DB::SAM/BAM

发布于 2024-11-13 11:39:45 字数 424 浏览 7 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甩你一脸翔 2024-11-20 11:39:45

简短的回答,不。

可以对原始 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文