Question: GATB - create or manipulate data of Sequence
0
gravatar for wfd
13 months ago by
wfd0
wfd0 wrote:

Hi there,

For my recent GATB project I'd like to either create a Sequence object [with comment(id and such), possibly quality and a given string] or manipulate the sequence string of an existing Sequence. However, while there are setters for quality and comment, I do not know how to set the data itself. Is there a way to do it?

I tried creating a sequence using a dummy bank with just one sequence like this;

 Sequence str2seq(string str){
      IBank *dummyBank = new BankStrings(str.c_str(), NULL);
      LOCAL (dummyBank);
      Iterator<Sequence> *it = dummyBank->iterator();
      LOCAL (it);
      it->first();
      Sequence seq = it->item();
      seq.setComment("DUMMYCOMMENT"); 
      return seq;
 }

But the returned Sequence is corrupted - pointers, I guess?

Thanks for your help

gatb • 457 views
ADD COMMENTlink modified 13 months ago by pierre.peterlongo830 • written 13 months ago by wfd0
3
gravatar for pierre.peterlongo
13 months ago by
France
pierre.peterlongo830 wrote:

Hi,

From the GATB documentation, you will find many snipets examples.

You code could be

  #include <gatb/gatb_core.hpp>

 Sequence str2seq(std::string str){


    BankFasta dummyBank (str);
    BankFasta::Iterator it (dummyBank);
    for (it.first(); !it.isDone(); it.next())
    {

        std::cout << "[" << it->getDataSize() << "] " << it->getComment()  << std::endl;
        it->setComment("DUMMYCOMMENT"); 

        std::cout << it->toString() << std::endl;
    }
 }

 int main (int argc, char* argv[]){
    if(argc != 2)
    {
        printf("%s filename\n",argv[0]);
        exit(1);
    }

    // We get the file name from the user arguments
    const char* filename = argv[1] ;

    str2seq(filename);

 }
ADD COMMENTlink modified 13 months ago • written 13 months ago by pierre.peterlongo830

seems to work, thanks!

ADD REPLYlink modified 13 months ago • written 13 months ago by wfd0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1068 users visited in the last hour