flat_head.cpp

来自「ncbi源码」· C++ 代码 · 共 759 行 · 第 1/2 页

CPP
759
字号
            }        }        ITERATE (set<CBioseq_Handle>, it, sources) {            m_DBSource.push_back(x_FormatDBSourceID                                 (*FindBestChoice(it->GetBioseqCore()->GetId(),                                                  s_ScoreForDBSource)));        }        if (sources.empty()) {            m_DBSource.push_back(x_FormatDBSourceID(*id));        }        break;    }    default:        m_DBSource.push_back("UNKNOWN");    }}string CFlatHead::x_FormatDBSourceID(const CSeq_id& id) {    switch (id.Which()) {    case CSeq_id::e_Local:    {        const CObject_id& oi = id.GetLocal();        return (oi.IsStr() ? oi.GetStr() : NStr::IntToString(oi.GetId()));    }    case CSeq_id::e_Gi:        return "gi: " + NStr::IntToString(id.GetGi());    case CSeq_id::e_Pdb:    {        const CPDB_seq_id& pdb = id.GetPdb();        string s("pdb: "), sep;        if ( !pdb.GetMol().Get().empty() ) {            s += "molecule " + pdb.GetMol().Get();            sep = ",";        }        if (pdb.GetChain() > 0) {            s += sep + "chain " + NStr::IntToString(pdb.GetChain());            sep = ",";        }        if (pdb.IsSetRel()) {            s += sep + "release ";            m_Context->GetFormatter().FormatDate(pdb.GetRel(), s);            sep = ",";        }        return s;    }    default:    {        const CTextseq_id* tsid = id.GetTextseq_Id();        if ( !tsid ) {            return kEmptyStr;        }        string s, sep, comma;        switch (id.Which()) {        case CSeq_id::e_Embl:       s = "embl ";        comma = ",";  break;        case CSeq_id::e_Other:      s = "REFSEQ: ";                   break;        case CSeq_id::e_Swissprot:  s = "swissprot: ";  comma = ",";  break;        case CSeq_id::e_Pir:        s = "pir: ";                      break;        case CSeq_id::e_Prf:        s = "prf: ";                      break;        default:                    break;        }        if (tsid->IsSetName()) {            s += "locus " + tsid->GetName();            sep = " ";        } else {            comma.erase();        }        if (tsid->IsSetAccession()) {            string acc = tsid->GetAccession();            if (tsid->IsSetVersion()) {                acc += '.' + NStr::IntToString(tsid->GetVersion());            }            s += comma + sep + "accession "                + m_Context->GetFormatter().GetAccnLink(acc);            sep = " ";        }        if (tsid->IsSetRelease()) {            s += sep + "release " + tsid->GetRelease();        }        if (id.IsSwissprot()) {            s += ';';        }        return s;    }    }}void CFlatHead::x_AddPIRBlock(void){    for (CSeqdesc_CI dsc(m_Context->GetHandle(), CSeqdesc::e_Pir);         dsc;  ++dsc) {        m_ProteinBlock = &*dsc;        break;    }    if ( !m_ProteinBlock ) {        return;    }    const CPIR_block& pir = m_ProteinBlock->GetPir();    if (pir.IsSetHost()) {        m_DBSource.push_back("host: " + pir.GetHost());    }    if (pir.IsSetSource()) {        m_DBSource.push_back("source: " + pir.GetSource());    }    if (pir.IsSetSummary()) {        m_DBSource.push_back("summary: " + pir.GetSummary());    }    if (pir.IsSetGenetic()) {        m_DBSource.push_back("genetic: " + pir.GetGenetic());    }    if (pir.IsSetIncludes()) {        m_DBSource.push_back("includes: " + pir.GetIncludes());    }    if (pir.IsSetPlacement()) {        m_DBSource.push_back("placement: " + pir.GetPlacement());    }    if (pir.IsSetSuperfamily()) {        m_DBSource.push_back("superfamily: " + pir.GetSuperfamily());    }    if (pir.IsSetCross_reference()) {        m_DBSource.push_back("xref: " + pir.GetCross_reference());    }    if (pir.IsSetDate()) {        m_DBSource.push_back("PIR dates: " + pir.GetDate());    }    if (pir.GetHad_punct()) {        m_DBSource.push_back("punctuation in sequence");    }    if (pir.IsSetSeqref()) {        list<string> xrefs;        ITERATE (CPIR_block::TSeqref, it, pir.GetSeqref()) {            const char* type = 0;            switch ((*it)->Which()) {            case CSeq_id::e_Genbank:    type = "genbank ";    break;            case CSeq_id::e_Embl:       type = "embl ";       break;            case CSeq_id::e_Pir:        type = "pir ";        break;            case CSeq_id::e_Swissprot:  type = "swissprot ";  break;            case CSeq_id::e_Gi:         type = "gi: ";        break;            case CSeq_id::e_Ddbj:       type = "ddbj ";       break;            case CSeq_id::e_Prf:        type = "prf ";        break;            default:                    break;            }            if (type) {                xrefs.push_back(type + (*it)->GetSeqIdString(true));            }        }        if ( !xrefs.empty() ) {            m_DBSource.push_back("xrefs: " + NStr::Join(xrefs, ", "));        }    }    NON_CONST_ITERATE (list<string>, it, m_DBSource) {        // The C version puts newlines before these for some reason        *it += (&*it == &m_DBSource.back() ? '.' : ';');    }}void CFlatHead::x_AddSPBlock(void){    for (CSeqdesc_CI dsc(m_Context->GetHandle(), CSeqdesc::e_Sp);         dsc;  ++dsc) {        m_ProteinBlock = &*dsc;        break;    }    if ( !m_ProteinBlock ) {        return;    }    const CSP_block& sp = m_ProteinBlock->GetSp();    switch (sp.GetClass()) {    case CSP_block::eClass_standard:        m_DBSource.push_back("class: standard.");        break;    case CSP_block::eClass_prelim:        m_DBSource.push_back("class: preliminary.");        break;    default:        break;    }    // laid out slightly differently from the C version, but I think that's    // a bug in the latter (which runs some things together)    if (sp.IsSetExtra_acc()  &&  !sp.GetExtra_acc().empty() ) {        m_DBSource.push_back("extra_accessions:"                             + NStr::Join(sp.GetExtra_acc(), ","));    }    if (sp.GetImeth()) {        m_DBSource.push_back("seq starts with Met");    }    if (sp.IsSetPlasnm()  &&  !sp.GetPlasnm().empty() ) {        m_DBSource.push_back("plasmid:" + NStr::Join(sp.GetPlasnm(), ","));    }    if (sp.IsSetCreated()) {        string s("created: ");        sp.GetCreated().GetDate(&s, "%3N %D %Y");        m_DBSource.push_back(s + '.');    }    if (sp.IsSetSequpd()) {        string s("sequence updated: ");        sp.GetSequpd().GetDate(&s, "%3N %D %Y");        m_DBSource.push_back(s + '.');    }    if (sp.IsSetAnnotupd()) {        string s("annotation updated: ");        sp.GetAnnotupd().GetDate(&s, "%3N %D %Y");        m_DBSource.push_back(s + '.');    }    if (sp.IsSetSeqref()  &&  !sp.GetSeqref().empty() ) {        list<string> xrefs;        ITERATE (CSP_block::TSeqref, it, sp.GetSeqref()) {            const char* s = 0;            switch ((*it)->Which()) {            case CSeq_id::e_Genbank:  s = "genbank accession ";          break;            case CSeq_id::e_Embl:     s = "embl accession ";             break;            case CSeq_id::e_Pir:      s = "pir locus ";                  break;            case CSeq_id::e_Swissprot: s = "swissprot accession ";       break;            case CSeq_id::e_Gi:       s = "gi: ";                        break;            case CSeq_id::e_Ddbj:     s = "ddbj accession ";             break;            case CSeq_id::e_Prf:      s = "prf accession ";              break;            case CSeq_id::e_Pdb:      s = "pdb accession ";              break;            case CSeq_id::e_Tpg:   s = "genbank third party accession "; break;            case CSeq_id::e_Tpe:      s = "embl third party accession "; break;            case CSeq_id::e_Tpd:      s = "ddbj third party accession "; break;            default:                  break;            }            if (s) {                string acc = (*it)->GetSeqIdString(true);                xrefs.push_back(s +m_Context->GetFormatter().GetAccnLink(acc));            }        }        if ( !xrefs.empty() ) {            m_DBSource.push_back("xrefs: " + NStr::Join(xrefs, ", "));        }    }    if (sp.IsSetDbref()  &&  !sp.GetDbref().empty() ) {        list<string> xrefs;        ITERATE (CSP_block::TDbref, it, sp.GetDbref()) {            const CObject_id& tag = (*it)->GetTag();            string            id  = (tag.IsStr() ? tag.GetStr()                                     : NStr::IntToString(tag.GetId()));            if ((*it)->GetDb() == "MIM") {                xrefs.push_back                    ("MIM <a href=\""                     "http://www.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id=" + id                     + "\">" + id + "</a>");            } else {                xrefs.push_back((*it)->GetDb() + id); // no space(!)            }        }        m_DBSource.push_back            ("xrefs (non-sequence databases): " + NStr::Join(xrefs, ", "));    }}void CFlatHead::x_AddPRFBlock(void){    for (CSeqdesc_CI dsc(m_Context->GetHandle(), CSeqdesc::e_Prf);         dsc;  ++dsc) {        m_ProteinBlock = &*dsc;        break;    }    if ( !m_ProteinBlock ) {        return;    }    const CPRF_block& prf = m_ProteinBlock->GetPrf();    if (prf.IsSetExtra_src()) {        const CPRF_ExtraSrc& es = prf.GetExtra_src();        if (es.IsSetHost()) {            m_DBSource.push_back("host: " + es.GetHost());        }        if (es.IsSetPart()) {            m_DBSource.push_back("part: " + es.GetPart());        }        if (es.IsSetState()) {            m_DBSource.push_back("state: " + es.GetState());        }        if (es.IsSetStrain()) {            m_DBSource.push_back("strain: " + es.GetStrain());        }        if (es.IsSetTaxon()) {            m_DBSource.push_back("taxonomy: " + es.GetTaxon());        }    }    NON_CONST_ITERATE (list<string>, it, m_DBSource) {        *it += (&*it == &m_DBSource.back() ? '.' : ';');    }}void CFlatHead::x_AddPDBBlock(void){    for (CSeqdesc_CI dsc(m_Context->GetHandle(), CSeqdesc::e_Pdb);         dsc;  ++dsc) {        m_ProteinBlock = &*dsc;        break;    }    if ( !m_ProteinBlock ) {        return;    }    const CPDB_block& pdb = m_ProteinBlock->GetPdb();    {{        string s("deposition: ");        m_Context->GetFormatter().FormatDate(pdb.GetDeposition(), s);        m_DBSource.push_back(s);    }}    m_DBSource.push_back("class: " + pdb.GetClass());    if (!pdb.GetSource().empty() ) {        m_DBSource.push_back("source: " + NStr::Join(pdb.GetSource(), ", "));    }    if (pdb.IsSetExp_method()) {        m_DBSource.push_back("Exp. method: " + pdb.GetExp_method());    }    if (pdb.IsSetReplace()) {        const CPDB_replace& rep = pdb.GetReplace();        if ( !rep.GetIds().empty() ) {            m_DBSource.push_back                ("ids replaced: " + NStr::Join(pdb.GetSource(), ", "));        }        string s("replacement date: ");        m_Context->GetFormatter().FormatDate(rep.GetDate(), s);        m_DBSource.push_back(s);    }    NON_CONST_ITERATE (list<string>, it, m_DBSource) {        *it += (&*it == &m_DBSource.back() ? '.' : ';');    }}END_SCOPE(objects)END_NCBI_SCOPE/** ===========================================================================** $Log: flat_head.cpp,v $* Revision 1000.2  2004/06/01 19:43:17  gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8** Revision 1.8  2004/05/21 21:42:53  gorelenk* Added PCH ncbi_pch.hpp** Revision 1.7  2004/04/05 15:56:15  grichenk* Redesigned CAnnotTypes_CI: moved all data and data collecting* functions to CAnnotDataCollector. CAnnotTypes_CI is no more* inherited from SAnnotSelector.** Revision 1.6  2003/07/22 18:04:13  dicuccio* Fixed access of unset optional variables** Revision 1.5  2003/06/02 16:06:42  dicuccio* Rearranged src/objects/ subtree.  This includes the following shifts:*     - src/objects/asn2asn --> arc/app/asn2asn*     - src/objects/testmedline --> src/objects/ncbimime/test*     - src/objects/objmgr --> src/objmgr*     - src/objects/util --> src/objmgr/util*     - src/objects/alnmgr --> src/objtools/alnmgr*     - src/objects/flat --> src/objtools/flat*     - src/objects/validator --> src/objtools/validator*     - src/objects/cddalignview --> src/objtools/cddalignview* In addition, libseq now includes six of the objects/seq... libs, and libmmdb* replaces the three libmmdb? libs.** Revision 1.4  2003/03/21 18:49:17  ucko* Turn most structs into (accessor-requiring) classes; replace some* formerly copied fields with pointers to the original data.** Revision 1.3  2003/03/18 21:56:06  grichenk* Removed obsolete class CAnnot_CI** Revision 1.2  2003/03/11 15:37:51  kuznets* iterate -> ITERATE** Revision 1.1  2003/03/10 16:39:09  ucko* Initial check-in of new flat-file generator*** ===========================================================================*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?