GATB - create or manipulate data of Sequence
1
0
Entering edit mode
7.1 years ago
wfd • 0

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 • 1.6k views
ADD COMMENT
3
Entering edit mode
7.1 years ago

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 COMMENT
0
Entering edit mode

seems to work, thanks!

ADD REPLY

Login before adding your answer.

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