Esempio n. 1
0
int CSeq_id_Handle::CompareOrdered(const CSeq_id_Handle& id) const
{
    // small optimization to avoid creation of temporary CSeq_id objects
    if ( int diff = Which() - id.Which() ) {
        return diff;
    }
    if ( IsGi() && id.IsGi() ) {
        return GetGi() - id.GetGi();
    }
    return GetSeqId()->CompareOrdered(*id.GetSeqId());
}
Esempio n. 2
0
Int8 CLDS2_Database::x_GetLdsSeqId(const CSeq_id_Handle& id)
{
    CSQLITE_Statement* st = NULL;
    if ( id.IsGi() ) {
        // Try to use integer index
        st = &x_GetStatement(eSt_GetLdsSeqIdForIntId);
        st->Bind(1, id.GetGi());
    }
    else {
        // Use text index
        st = &x_GetStatement(eSt_GetLdsSeqIdForTxtId);
        st->Bind(1, id.AsString());
    }
    if ( st->Step() ) {
        Int8 ret = st->GetInt8(0);
        st->Reset();
        return ret;
    }

    // Id not in the database yet -- add new entry.
    st = &x_GetStatement(eSt_AddLdsSeqId);
    st->Bind(1, id.AsString());
    if ( id.IsGi() ) {
        st->Bind(2, id.GetGi());
    }
    else {
        // HACK: reset GI to null if not available.
        st->Bind(2, (void*)NULL, 0);
    }
    CNcbiOstrstream out;
    out << MSerial_AsnBinary << *id.GetSeqId();
    string buf = CNcbiOstrstreamToString(out);
    st->Bind(3, buf.size());
    st->Bind(4, buf.data(), buf.size());

    st->Execute();
    Int8 ret = st->GetLastInsertedRowid();
    st->Reset();
    return ret;
}
Esempio n. 3
0
int 
CLocalBlastDbAdapter::GetTaxId(const CSeq_id_Handle& idh)
{
    int retval = static_cast<int>(kInvalidSeqPos);
    CConstRef<CSeq_id> id = idh.GetSeqId();
    if (id.NotEmpty()) {
        int oid = 0;
        if (SeqidToOid(*id, oid)) {
            map<int, int> gi_to_taxid;
            m_SeqDB->GetTaxIDs(oid, gi_to_taxid);
            if (idh.IsGi()) {
                retval = gi_to_taxid[GI_TO(int, idh.GetGi())];
            } else {