comment_item.cpp

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

CPP
893
字号
                                                wgsaccn.substr(7);    CNcbiOstrstream text;    text << "The " << *taxname          << "whole genome shotgun (WGS) project has the project accession "          << wgsaccn << ".  This version of the project (" << version          << ") has the accession number " << ctx.GetWGSMasterName() << ",";    if ( (*first != *last) ) {        text << " and consists of sequences " << *first << "-" << *last;    } else {        text << " and consists of sequence " << *first;    }    return CNcbiOstrstreamToString(text);}string CCommentItem::GetStringForMolinfo(const CMolInfo& mi, CBioseqContext& ctx){    _ASSERT(mi.CanGetCompleteness());    bool is_prot = ctx.IsProt();    switch ( mi.GetCompleteness() ) {    case CMolInfo::eCompleteness_complete:        return "COMPLETENESS: full length";    case CMolInfo::eCompleteness_partial:        return "COMPLETENESS: not full length";    case CMolInfo::eCompleteness_no_left:        return (is_prot ? "COMPLETENESS: incomplete on the amino end" :                          "COMPLETENESS: incomplete on the 5' end");    case CMolInfo::eCompleteness_no_right:        return (is_prot ? "COMPLETENESS: incomplete on the carboxy end" :                          "COMPLETENESS: incomplete on the 3' end");    case CMolInfo::eCompleteness_no_ends:        return "COMPLETENESS: incomplete on both ends";    case CMolInfo::eCompleteness_has_left:        return (is_prot ? "COMPLETENESS: complete on the amino end" :                          "COMPLETENESS: complete on the 5' end");    case CMolInfo::eCompleteness_has_right:        return (is_prot ? "COMPLETENESS: complete on the carboxy end" :                          "COMPLETENESS: complete on the 3' end");    default:        return "COMPLETENESS: unknown";    }    return kEmptyStr;}string CCommentItem::GetStringForHTGS(CBioseqContext& ctx){    SDeltaSeqSummary summary;    if ( ctx.GetRepr() == CSeq_inst::eRepr_delta ) {        GetDeltaSeqSummary(ctx.GetHandle(), summary);    }    CMolInfo::TTech tech = ctx.GetTech();    CNcbiOstrstream text;    if ( tech == CMolInfo::eTech_htgs_0 ) {        if ( summary.num_segs > 0 ) {            text << "* NOTE: This record contains " << (summary.num_gaps + 1) << " individual~"                 << "* sequencing reads that have not been assembled into~"                 << "* contigs. Runs of N are used to separate the reads~"                 << "* and the order in which they appear is completely~"                 << "* arbitrary. Low-pass sequence sampling is useful for~"                 << "* identifying clones that may be gene-rich and allows~"                 << "* overlap relationships among clones to be deduced.~"                 << "* However, it should not be assumed that this clone~"                 << "* will be sequenced to completion. In the event that~"                 << "* the record is updated, the accession number will~"                 << "* be preserved.";        }        text << "~";        text << summary.text;    } else if ( tech == CMolInfo::eTech_htgs_1 ) {        text << "* NOTE: This is a \"working draft\" sequence.";        if ( summary.num_segs > 0 ) {            text << " It currently~"                 << "* consists of " << (summary.num_gaps + 1) << " contigs. The true order of the pieces~"                 << "* is not known and their order in this sequence record is~"                 << "* arbitrary. Gaps between the contigs are represented as~"                 << "* runs of N, but the exact sizes of the gaps are unknown.";        }        text << "~* This record will be updated with the finished sequence~"             << "* as soon as it is available and the accession number will~"             << "* be preserved."             << "~"             << summary.text;    } else if ( tech == CMolInfo::eTech_htgs_2 ) {        text << "* NOTE: This is a \"working draft\" sequence.";        if ( summary.num_segs > 0 ) {            text << " It currently~* consists of " << (summary.num_gaps + 1)                  << " contigs. Gaps between the contigs~"                 << "* are represented as runs of N. The order of the pieces~"                 << "* is believed to be correct as given, however the sizes~"                 << "* of the gaps between them are based on estimates that have~"                 << "* provided by the submittor.";        }        text << "~* This sequence will be replaced~"             << "* by the finished sequence as soon as it is available and~"             << "* the accession number will be preserved."             << "~"             << summary.text;    } else if ( !GetTechString(tech).empty() ) {        text << "Method: " << GetTechString(tech) << ".";    }    return CNcbiOstrstreamToString(text);}string CCommentItem::GetStringForModelEvidance(const SModelEvidance& me){    CNcbiOstrstream text;    text << "MODEL " << "REFSEQ" << ":  " << "This record is predicted by "         << "automated computational analysis. This record is derived from"         << "an annotated genomic sequence (" << me.name << ")";    if ( !me.method.empty() ) {        text << " using gene prediction method: " << me.method;    }    if ( me.mrnaEv  ||  me.estEv ) {        text << ", supported by ";        if ( me.mrnaEv  &&  me.estEv ) {            text << "mRNA and EST ";        } else if ( me.mrnaEv ) {            text << "mRNA ";        } else {            text << "EST ";        }        // !!! for html we need much more !!!        text << "evidence";    }    text << "." << ExpandTildes("~Also see:~    ", eTilde_newline)          << "Documentation"          << ExpandTildes(" of NCBI's Annotation Process~    ", eTilde_newline);    return CNcbiOstrstreamToString(text);}/***************************************************************************//*                                 PROTECTED                               *//***************************************************************************/void CCommentItem::x_GatherInfo(CBioseqContext& ctx){    const CSeqdesc* desc = dynamic_cast<const CSeqdesc*>(GetObject());    if ( desc != 0 ) {        x_GatherDescInfo(*desc);        return;    }    const CSeq_feat* feat = dynamic_cast<const CSeq_feat*>(GetObject());    if ( feat != 0 ) {        x_GatherFeatInfo(*feat, ctx);    }}void CCommentItem::x_GatherDescInfo(const CSeqdesc& desc){    string prefix, str, suffix;    switch ( desc.Which() ) {    case CSeqdesc::e_Comment:        {{            str = desc.GetComment();        }}        break;    case CSeqdesc::e_Maploc:        {{            const CDbtag& dbtag = desc.GetMaploc();            if ( dbtag.CanGetTag() ) {                const CObject_id& oid = dbtag.GetTag();                if ( oid.IsStr() ) {                    prefix = "Map location: ";                    str = oid.GetStr();                } else if ( oid.IsId()  &&  dbtag.CanGetDb() ) {                    prefix = "Map location: (Database ";                    str = dbtag.GetDb();                    suffix = "; id # " + NStr::IntToString(oid.GetId()) + ").";                }            }        }}        break;    case CSeqdesc::e_Region:        {{            prefix = "Region: ";            str = desc.GetRegion();        }}        break;    default:        break;    }    if ( str.empty() ) {        return;    }    x_SetCommentWithURLlinks(prefix, str, suffix);    }void CCommentItem::x_GatherFeatInfo(const CSeq_feat&, CBioseqContext&){    // !!!}void CCommentItem::x_SetSkip(void){    CFlatItem::x_SetSkip();    swap(m_First, sm_FirstComment);}void CCommentItem::x_SetCommentWithURLlinks(const string& prefix, const string& str, const string& suffix){    // !!! test for html - find links within the comment string    string comment = ExpandTildes(prefix + str + suffix, eTilde_newline);    size_t pos = comment.find_last_not_of(" \n\t\r");    if ( pos != NPOS ) {        comment.erase(pos + 1);    }    if ( NStr::EndsWith(str, "..")  &&  !NStr::EndsWith(str, "...") ) {        comment.erase(str.length() - 1);    }    if ( !NStr::EndsWith(str, ".") ) {        comment += ".";    }        m_Comment =  comment;}///////////////////////////////////////////////////////////////////////////////// Derived Classes// --- CGenomeAnnotCommentCGenomeAnnotComment::CGenomeAnnotComment(CBioseqContext& ctx, const string& build_num) :    CCommentItem(ctx), m_GenomeBuildNumber(build_num){    x_GatherInfo(ctx);}void CGenomeAnnotComment::x_GatherInfo(CBioseqContext&){    CNcbiOstrstream text;    text << "GENOME ANNOTATION " << "REFSEQ" << ":  ";    if ( !m_GenomeBuildNumber.empty() ) {         text << "Features on this sequence have been produced for build "              << m_GenomeBuildNumber << " of the NCBI's genome annotation"              << " [see " << "documentation" << "].";    } else {        text << "NCBI contigs are derived from assembled genomic sequence data."             << "~Also see:~    " << "Documentation"              << " of NCBI's Annotation Process~ ";    }        x_SetComment(ExpandTildes(CNcbiOstrstreamToString(text), eTilde_newline));}// --- CHistCommentCHistComment::CHistComment(EType type, const CSeq_hist& hist, CBioseqContext& ctx) :     CCommentItem(ctx), m_Type(type), m_Hist(&hist){    x_GatherInfo(ctx);    m_Hist.Reset();}string s_CreateHistCommentString(const string& prefix, const string& suffix, const CSeq_hist_rec& hist){    _ASSERT(hist.CanGetDate());    _ASSERT(hist.CanGetIds());    string date;    hist.GetDate().GetDate(&date, "%3N %2D, %4Y");    vector<int> gis;    ITERATE (CSeq_hist_rec::TIds, id, hist.GetIds()) {        if ( (*id)->IsGi() ) {            gis.push_back((*id)->GetGi());        }    }    CNcbiOstrstream text;    text << prefix << ((gis.size() > 1) ? " or before " : " ") << date          << ' ' << suffix;    if ( gis.empty() ) {        text << " gi:?";        return CNcbiOstrstreamToString(text);    }    for ( size_t count = 0; count < gis.size(); ++count ) {        if ( count != 0 ) {            text << ",";        }        text << " gi:" << NStr::IntToString(gis[count]);    }    text << '.';    return CNcbiOstrstreamToString(text);}void CHistComment::x_GatherInfo(CBioseqContext&){    _ASSERT(m_Hist);    switch ( m_Type ) {    case eReplaced_by:        x_SetComment(s_CreateHistCommentString(            "[WARNING] On",            "this sequence was replaced by a newer version",            m_Hist->GetReplaced_by()));        break;    case eReplaces:        x_SetComment(s_CreateHistCommentString(            "On",            "this sequence version replaced",            m_Hist->GetReplaces()));        break;    }}// --- CGsdbCommentCGsdbComment::CGsdbComment(const CDbtag& dbtag, CBioseqContext& ctx) :    CCommentItem(ctx), m_Dbtag(&dbtag){    x_GatherInfo(ctx);}void CGsdbComment::x_GatherInfo(CBioseqContext&){    x_SetComment("GSDB:S:" + m_Dbtag->GetTag().GetId());}// --- CLocalIdCommentCLocalIdComment::CLocalIdComment(const CObject_id& oid, CBioseqContext& ctx) :    CCommentItem(ctx), m_Oid(&oid){    x_GatherInfo(ctx);}void CLocalIdComment::x_GatherInfo(CBioseqContext&){    CNcbiOstrstream msg;    switch ( m_Oid->Which() ) {    case CObject_id::e_Id:        msg << "LocalID: " << m_Oid->GetId();            break;    case CObject_id::e_Str:        if ( m_Oid->GetStr().length() < 100 ) {            msg << "LocalID: " << m_Oid->GetStr();        } else {            msg << "LocalID string too large";        }        break;    default:        break;    }    x_SetComment(CNcbiOstrstreamToString(msg));}END_SCOPE(objects)END_NCBI_SCOPE/** ===========================================================================** $Log: comment_item.cpp,v $* Revision 1000.2  2004/06/01 19:43:50  gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8** Revision 1.8  2004/05/21 21:42:54  gorelenk* Added PCH ncbi_pch.hpp** Revision 1.7  2004/05/06 17:45:43  shomrat* + CLocalIdComment** Revision 1.6  2004/04/22 15:51:13  shomrat* Changes in context** Revision 1.5  2004/04/13 16:45:22  shomrat* Fixed comment cleanup** Revision 1.4  2004/03/26 17:22:51  shomrat* Minor fixes to comment string** Revision 1.3  2004/03/05 18:44:05  shomrat* fixed RefTRack comments** Revision 1.2  2003/12/18 17:43:31  shomrat* context.hpp moved** Revision 1.1  2003/12/17 20:18:17  shomrat* Initial Revision (adapted from flat lib)*** ===========================================================================*/

⌨️ 快捷键说明

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