Beispiel #1
0
bool CDVDStateSerializer::DVDToXMLState( std::string &xmlstate, const dvd_state_t *state )
{
    char buffer[256];
    TiXmlDocument xmlDoc("navstate");

    TiXmlElement eRoot("navstate");
    eRoot.SetAttribute("version", 1);


    {   TiXmlElement eRegisters("registers");

        for( int i = 0; i < 24; i++ )
        {

            if( state->registers.SPRM[i] )
            {   TiXmlElement eReg("sprm");
                eReg.SetAttribute("index", i);

                {   TiXmlElement eValue("value");
                    sprintf(buffer, "0x%hx", state->registers.SPRM[i]);
                    eValue.InsertEndChild( TiXmlText(buffer) );
                    eReg.InsertEndChild(eValue);
                }

                eRegisters.InsertEndChild(eReg);
            }
        }

        for( int i = 0; i < 16; i++ )
        {
            if( state->registers.GPRM[i] || state->registers.GPRM_mode[i] || state->registers.GPRM_time[i].tv_sec || state->registers.GPRM_time[i].tv_usec )
            {   TiXmlElement eReg("gprm");
                eReg.SetAttribute("index", i);

                {   TiXmlElement eValue("value");
                    sprintf(buffer, "0x%hx", state->registers.GPRM[i]);
                    eValue.InsertEndChild( TiXmlText(buffer) );
                    eReg.InsertEndChild(eValue);
                }

                {   TiXmlElement eMode("mode");
                    sprintf(buffer, "0x%c", state->registers.GPRM_mode[i]);
                    eMode.InsertEndChild( TiXmlText(buffer) );
                    eReg.InsertEndChild(eMode);
                }

                {   TiXmlElement eTime("time");
                    {   TiXmlElement eValue("tv_sec");
                        sprintf(buffer, "%ld", state->registers.GPRM_time[i].tv_sec);
                        eValue.InsertEndChild( TiXmlText( buffer ) );
                        eTime.InsertEndChild( eValue ) ;
                    }

                    {   TiXmlElement eValue("tv_usec");
                        sprintf(buffer, "%ld", (long int)state->registers.GPRM_time[i].tv_usec);
                        eValue.InsertEndChild( TiXmlText( buffer ) );
                        eTime.InsertEndChild( eValue ) ;
                    }
                    eReg.InsertEndChild(eTime);
                }
                eRegisters.InsertEndChild(eReg);
            }
        }
        eRoot.InsertEndChild(eRegisters);
    }

    {   TiXmlElement element("domain");
        sprintf(buffer, "%d", state->domain);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("vtsn");
        sprintf(buffer, "%d", state->vtsN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("pgcn");
        sprintf(buffer, "%d", state->pgcN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("pgn");
        sprintf(buffer, "%d", state->pgN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("celln");
        sprintf(buffer, "%d", state->cellN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("cell_restart");
        sprintf(buffer, "%d", state->cell_restart);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement element("blockn");
        sprintf(buffer, "%d", state->blockN);
        element.InsertEndChild( TiXmlText( buffer ) );
        eRoot.InsertEndChild(element);
    }

    {   TiXmlElement rsm("rsm");

        {   TiXmlElement element("vtsn");
            sprintf(buffer, "%d", state->rsm_vtsN);
            element.InsertEndChild( TiXmlText( buffer ) );
            rsm.InsertEndChild(element);
        }

        {   TiXmlElement element("blockn");
            sprintf(buffer, "%d", state->rsm_blockN);
            element.InsertEndChild( TiXmlText( buffer ) );
            rsm.InsertEndChild(element);
        }

        {   TiXmlElement element("pgcn");
            sprintf(buffer, "%d", state->rsm_pgcN);
            element.InsertEndChild( TiXmlText( buffer ) );
            rsm.InsertEndChild(element);
        }

        {   TiXmlElement element("celln");
            sprintf(buffer, "%d", state->rsm_cellN);
            element.InsertEndChild( TiXmlText( buffer ) );
            rsm.InsertEndChild(element);
        }

        {   TiXmlElement regs("registers");

            for( int i = 0; i < 5; i++ )
            {
                TiXmlElement reg("sprm");
                reg.SetAttribute("index", i);

                {   TiXmlElement element("value");
                    sprintf(buffer, "0x%hx", state->rsm_regs[i]);
                    element.InsertEndChild( TiXmlText(buffer) );
                    reg.InsertEndChild(element);
                }

                regs.InsertEndChild(reg);
            }
            rsm.InsertEndChild(regs);
        }
        eRoot.InsertEndChild(rsm);
    }


    xmlDoc.InsertEndChild(eRoot);

    std::stringstream stream;
    stream << xmlDoc;
    xmlstate = stream.str();
    return true;
}
Beispiel #2
0
//This function uses the contents of m_blastOutput (the raw output from the
//BLAST search) to construct the BlastHit objects.
//It looks at the filters to possibly exclude hits which fail to meet user-
//defined thresholds.
void BlastSearch::buildHitsFromBlastOutput()
{
    QStringList blastHitList = m_blastOutput.split("\n", QString::SkipEmptyParts);

    for (int i = 0; i < blastHitList.size(); ++i)
    {
        QString hitString = blastHitList[i];
        QStringList alignmentParts = hitString.split('\t');

        if (alignmentParts.size() < 12)
            continue;

        QString queryName = alignmentParts[0];
        QString nodeLabel = alignmentParts[1];
        double percentIdentity = alignmentParts[2].toDouble();
        int alignmentLength = alignmentParts[3].toInt();
        int numberMismatches = alignmentParts[4].toInt();
        int numberGapOpens = alignmentParts[5].toInt();
        int queryStart = alignmentParts[6].toInt();
        int queryEnd = alignmentParts[7].toInt();
        int nodeStart = alignmentParts[8].toInt();
        int nodeEnd = alignmentParts[9].toInt();
        SciNot eValue(alignmentParts[10]);
        double bitScore = alignmentParts[11].toDouble();

        //Only save BLAST hits that are on forward strands.
        if (nodeStart > nodeEnd)
            continue;

        QString nodeName = getNodeNameFromString(nodeLabel);
        DeBruijnNode * node;
        if (g_assemblyGraph->m_deBruijnGraphNodes.contains(nodeName))
            node = g_assemblyGraph->m_deBruijnGraphNodes[nodeName];
        else
            continue;

        BlastQuery * query = g_blastSearch->m_blastQueries.getQueryFromName(queryName);
        if (query == 0)
            continue;

        QSharedPointer<BlastHit> hit(new BlastHit(query, node, percentIdentity, alignmentLength,
                                                  numberMismatches, numberGapOpens, queryStart, queryEnd,
                                                  nodeStart, nodeEnd, eValue, bitScore));

        //Check the user-defined filters.
        if (g_settings->blastAlignmentLengthFilterOn &&
                alignmentLength < g_settings->blastAlignmentLengthFilterValue)
            continue;
        if (g_settings->blastQueryCoverageFilterOn)
        {
            if (100.0 * hit->getQueryCoverageFraction() <= g_settings->blastQueryCoverageFilterValue)
                continue;
        }
        if (g_settings->blastIdentityFilterOn &&
                percentIdentity < g_settings->blastIdentityFilterValue)
            continue;
        if (g_settings->blastEValueFilterOn &&
                eValue > g_settings->blastEValueFilterValue)
                continue;
        if (g_settings->blastBitScoreFilterOn &&
                bitScore < g_settings->blastBitScoreFilterValue)
            continue;

        m_allHits.push_back(hit);
        query->addHit(hit);
    }
}