FU Logo
  • Startseite
  • Kontakt
  • Impressum
  • Home
  • Listenauswahl
  • Anleitungen

[Seqan-dev] appendTagValue() for BamTagsDict

<-- thread -->
<-- date -->
  • From: "Schulze, Jakob" <SchulzeJa@rki.de>
  • To: "seqan-dev@lists.fu-berlin.de" <seqan-dev@lists.fu-berlin.de>
  • Date: Mon, 8 Feb 2016 14:30:11 +0000
  • Reply-to: SeqAn Development <seqan-dev@lists.fu-berlin.de>
  • Subject: [Seqan-dev] appendTagValue() for BamTagsDict

Hi everyone,
I am currently trying to write out Bam files using seqan's BamFileOut. I stumbled across some strange behavior of appendTagValue()
When using the function three times in a row, length(tags) returns 2, which seems one to less to me. I enclosed a code example using the example from
http://docs.seqan.de/seqan/2.0.0/demos/bam_io/bam_tags_dict.cpp

I marked my changes. Did I miss something?

Furthermore, I wondered whether there is a function, which converts a BamTagsDict into a String, which I can directly use as an Entry in a Sam file.


Best Regards,
Jakob


PS: Output of the code snippet on my machine is:
3
AA -> "value1"
AB -> "value2"
AC -> 30
2
#include <iostream>
#include <seqan/stream.h>
#include <seqan/bam_io.h>

using namespace seqan;

int main()
{
    CharString bamStr, samStr = "AA:Z:value1\tAB:Z:value2\tAC:i:30";
    assignTagsSamToBam(bamStr, samStr);
    BamTagsDict tags(bamStr);
    BamTagsDict newTags; // NEW: added by Jakob Schulze
    std::cout << length(tags) << std::endl;  // #=> "3"
    for (unsigned id = 0; id < length(tags); ++id)
    {
        std::cout << getTagKey(tags, id) << " -> ";

        if (getTagType(tags, id) == 'i')  // is 32 bit integer
        {
            __int32 x = 0;
            bool res = extractTagValue(x, tags, id);
            SEQAN_ASSERT_MSG(res, "Not a valid integer at pos %u!", id);
            std::cout << x;
			appendTagValue(newTags, getTagKey(tags, id), x); // NEW: added by Jakob Schulze
        }
        if (getTagType(tags, id) == 'Z')  // is string
        {
            CharString str;
            bool res = extractTagValue(str, tags, id);
            SEQAN_ASSERT_MSG(res, "Not a valid string at pos %u!", id);
            std::cout << '"' << str << '"';
			appendTagValue(newTags, getTagKey(tags, id), str); // NEW: added by Jakob Schulze
        }

        std::cout << std::endl;
    }

	std::cout << length(newTags) << std::endl; // NEW: added by Jakob Schulze
    return 0;
}
<-- thread -->
<-- date -->
  • Follow-Ups:
    • Re: [Seqan-dev] appendTagValue() for BamTagsDict
      • From: Hannes Hauswedell <hannes.hauswedell@fu-berlin.de>
  • seqan-dev - February 2016 - Archives indexes sorted by:
    [ thread ] [ subject ] [ author ] [ date ]
  • Complete archive of the seqan-dev mailing list
  • More info on this list...

Hilfe

  • FAQ
  • Dienstbeschreibung
  • ZEDAT Beratung
  • postmaster@lists.fu-berlin.de

Service-Navigation

  • Startseite
  • Listenauswahl

Einrichtung Mailingliste

  • ZEDAT-Portal
  • Mailinglisten Portal