GATB buildNode giving errors
1
0
Entering edit mode
6.4 years ago
cwright • 0

I am playing around with the GATB library, and I have run into some problems, hopefully simple to overcome with guidance. I was reading through some other questions, specifically the question at: A: GATB de Bruijn graph

In the comments it says you can use Graph::buildNode to return a Node instance from a kmer as an ASCII string (broken link). I looked through the examples and see some examples of this, but when I am trying to use it in the following code, I get compile errors:

template <typename Graph_type, typename Node, typename Edge, size_t span>
void mytool::myfunction(Sequence& seq, Graph_type& graph, IBank *outputBank){
    int kSize = graph.getKmerSize();
    std::string sequence = seq.toString();
    Node left = graph.buildNode((char *)sequence.c_str(),0);
    Node right = graph.buildNode((char *)sequence.c_str(),sequence.length()-kSize);
...///even if all else is commented out, I get error for the assignment of Node left and Node right
}

When compiling, I get the errors similar to this (for both the left and right node assignments, and the LargeInt<x> iterates 1 to 4 in the errors):

error: conversion from ‘gatb::core::debruijn::impl::Node_t<gatb::core::tools::math::LargeInt<4> >’ to non-scalar type ‘gatb::core::debruijn::impl::NodeGU’ requested
    Node left = graph.buildNode((char *)sequence.c_str(),0);

Even when I change the code to have just a const char* with no offset as the constructor for buildNode I run into the same problem.

Do you have any advice for me to fix my problem? (Hopefully it is something I just don't understand) Thanks!

gatb • 1.5k views
ADD COMMENT
2
Entering edit mode
6.4 years ago
Rayan Chikhi ★ 1.5k

Hi, could you try changing "Node left" to "auto left" to see if it gets rid of the error? Best, Rayan

ADD COMMENT
0
Entering edit mode

That will get rid of the errors yes...But then it isn't the right type for subsequent calls. Essentially I want to take an existing contig and extend it using the graph, something like this:

    int kSize = graph.getKmerSize();
    std::string contig = seq.toString();
    string seqRight = "", seqLeft = "";
    int endDegreeLeft, endDegreeRight,lenSeqRight = 0, lenSeqLeft = 0;
    float rightTotalCoverage = 0, leftTotalCoverage = 0, curCoverage = 0;
    bool markDuringTraversal = false;//not sure if this should be true or false yet
    auto left = graph.buildNode((char *)contig.c_str(),0);
    auto right = graph.buildNode((char *)contig.c_str(),contig.length()-kSize);
    graph.simplePathLongest_avance (left, DIR_INCOMING, lenSeqLeft, 
                                    endDegreeLeft, markDuringTraversal, 
                                    leftTotalCoverage, &seqLeft);
    graph.simplePathLongest_avance (right, DIR_OUTCOMING, lenSeqRight, 
                                    endDegreeRight, markDuringTraversal, 
                                    rightTotalCoverage, &seqRight);
ADD REPLY
0
Entering edit mode

I can get what I want if I do some really inefficient things, but I really want to avoid this:

    int kSize = graph.getKmerSize();
    std::string contig = seq.toString();
    ///get the kmer from end of contig 
    std::string lstr = contig.substr(0,kSize);
    std::string rstr = contig.substr(contig.length() - kSize);

    string seqRight = "", seqLeft = "";
    int endDegreeLeft, endDegreeRight,lenSeqRight = 0, lenSeqLeft = 0;
    float rightTotalCoverage = 0, leftTotalCoverage = 0, curCoverage = 0;
    bool markDuringTraversal = false;//not sure if this should be true or false yet
    GraphIterator<Node> it = graph.iterator ();
    bool left = true, right = true;
    for (it.first(); !it.isDone(); it.next()){
        Node current = it.item();
        if(left && graph.toString(current) == lstr){
          graph.simplePathLongest_avance (current, DIR_INCOMING, lenSeqLeft, 
                                    endDegreeLeft, markDuringTraversal, 
                                    leftTotalCoverage, &seqLeft);
          left = false;
          continue;
        }
        if(right && graph.toString(current) == lstr){
          graph.simplePathLongest_avance (current, DIR_OUTCOMING, lenSeqRight, 
                                    endDegreeRight, markDuringTraversal, 
                                    rightTotalCoverage, &seqRight);
          right = false;
          continue;
        }
        if(!left && !right)
          break;
    }
ADD REPLY
1
Entering edit mode

Hi, sorry I didn't get notified by the responses in this thread. In the future, please reach me at rayan.chikhi@univ-lille.fr if this happens!

1) Are you using the Graph or GraphUnitigs class? (seems that it is GraphUnitigs)

2) If you're using GraphUnitigs, the function you're looking for is debugBuildNode() actually, not buildNode, as it produces a NodeGU (special node type for GraphUnitigs)

ADD REPLY
0
Entering edit mode

Yes I am using the GraphUnitigs, thank you for the help. I will re-implement and open another question/email if I have more problems. Thank you!

ADD REPLY

Login before adding your answer.

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