Пример #1
0
void Grid::simplify()
{
    extendLeft();
    extendRight();
    extendUp();
    extendDown();
    merge();
}
Пример #2
0
void BWTTraverse::extractSG(const BWT* pBWT, const BWT* pRevBWT, const unsigned int len)
{
    WARN_ONCE("Skipping bwt[0]");
    // Keep a bool vector marking which entries in pBWT have been visited
    size_t n_elems = pBWT->getBWLen();
    bool_vec visited(n_elems, false);

    size_t count = 0;
    size_t currIdx = 1;
    while(currIdx < n_elems)
    {
        // Invariant: currIdx is the index into pBWT that is the lowest index that has not been visited
        // Left-extend the entry at currIdx into a string of length len
        
        std::string str;
        str.reserve(len);

        // Get the first character of the suffix starting at this position
        char first = pBWT->getF(currIdx);
        str += first;
        BWTInterval range(currIdx, currIdx);

        while(str.length() < len)
        {
            char b = pBWT->getChar(range.lower);
            if(b == '$')
                break;
            str += b;
            BWTAlgorithms::updateInterval(range, b, pBWT);
        }

        // The string was built backwards, reverse it
        str = reverse(str);
        if(str.length() < len)
        {
            visited[currIdx] = true;
        }
        else if(!visited[range.lower])
        {
            markVisited(str, visited, pBWT);
            //std::cout << currIdx << " interval: " << range << " string: " << str << "\n";
            extendLeft(len, str, visited, pBWT, pRevBWT);
            extendRight(len, str, visited, pBWT, pRevBWT, false);
            printf(">%zu %zu 0\n%s\n", count++, str.length(), str.c_str());
        }

        currIdx++;
    }
}