validatorp.cpp

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

CPP
2,068
字号
/* * =========================================================================== * PRODUCTION $Log: validatorp.cpp,v $ * PRODUCTION Revision 1000.3  2004/06/01 19:47:39  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.52 * PRODUCTION * =========================================================================== *//*  $Id: validatorp.cpp,v 1000.3 2004/06/01 19:47:39 gouriano Exp $ * =========================================================================== * *                            PUBLIC DOMAIN NOTICE *               National Center for Biotechnology Information * *  This software/database is a "United States Government Work" under the *  terms of the United States Copyright Act.  It was written as part of *  the author's official duties as a United States Government employee and *  thus cannot be copyrighted.  This software/database is freely available *  to the public for use. The National Library of Medicine and the U.S. *  Government have not placed any restriction on its use or reproduction. * *  Although all reasonable efforts have been taken to ensure the accuracy *  and reliability of the software and data, the NLM and the U.S. *  Government do not and cannot warrant the performance or results that *  may be obtained by using this software or data. The NLM and the U.S. *  Government disclaim all warranties, express or implied, including *  warranties of performance, merchantability or fitness for any particular *  purpose. * *  Please cite the author in any work or product based on this material. * * =========================================================================== * * Author:  Jonathan Kans, Clifford Clausen, Aaron Ucko, Mati Shomrat, .... * * File Description: *   Implementation of private parts of the validator *   ....... * */#include <ncbi_pch.hpp>#include <corelib/ncbistd.hpp>#include <corelib/ncbistr.hpp>#include <objmgr/object_manager.hpp>#include "validatorp.hpp"#include "utilities.hpp"#include <serial/iterator.hpp>#include <serial/enumvalues.hpp>#include <objects/general/Dbtag.hpp>#include <objects/general/Person_id.hpp>#include <objects/general/Name_std.hpp>#include <objects/seqalign/Seq_align.hpp>#include <objects/seqset/Bioseq_set.hpp>#include <objects/seqset/Seq_entry.hpp>#include <objects/seq/Bioseq.hpp>#include <objects/seq/Seq_annot.hpp>#include <objects/seq/Seqdesc.hpp>#include <objects/seq/Seq_descr.hpp>#include <objects/seq/Pubdesc.hpp>#include <objects/seqfeat/BioSource.hpp>#include <objects/seqfeat/OrgMod.hpp>#include <objects/seqfeat/OrgName.hpp>#include <objects/seqfeat/Org_ref.hpp>#include <objects/seqfeat/Seq_feat.hpp>#include <objects/seqfeat/SubSource.hpp>#include <objects/seqloc/Seq_loc.hpp>#include <objects/seqloc/Seq_interval.hpp>#include <objects/seqloc/Seq_point.hpp>#include <objects/seqloc/Textseq_id.hpp>#include <objects/seqres/Seq_graph.hpp>#include <objects/submit/Seq_submit.hpp>#include <objects/submit/Submit_block.hpp>#include <objmgr/util/feature.hpp>#include <objmgr/util/sequence.hpp>#include <objmgr/feat_ci.hpp>#include <objmgr/seq_vector.hpp>#include <objmgr/scope.hpp>#include <objects/pub/Pub.hpp>#include <objects/pub/Pub_equiv.hpp>#include <objects/biblio/Author.hpp>#include <objects/biblio/Auth_list.hpp>#include <objects/biblio/Cit_art.hpp>#include <objects/biblio/Cit_book.hpp>#include <objects/biblio/Cit_gen.hpp>#include <objects/biblio/Cit_jour.hpp>#include <objects/biblio/Cit_let.hpp>#include <objects/biblio/Cit_proc.hpp>#include <objects/biblio/Cit_sub.hpp>#include <objects/biblio/PubMedId.hpp>#include <objects/biblio/PubStatus.hpp>#include <objects/biblio/Title.hpp>#include <objects/biblio/Imprint.hpp>#include <objects/biblio/Affil.hpp>#include <algorithm>BEGIN_NCBI_SCOPEBEGIN_SCOPE(objects)BEGIN_SCOPE(validator)using namespace sequence;auto_ptr<CTextFsa> CValidError_imp::m_SourceQualTags;// =============================================================================//                            CValidError_imp Public// =============================================================================// ConstructorCValidError_imp::CValidError_imp(CObjectManager& objmgr,  CValidError*       errs, Uint4              options) :      m_ObjMgr(&objmgr),      m_Scope(0),      m_TSE(0),      m_ErrRepository(errs),      m_NonASCII((options & CValidator::eVal_non_ascii) != 0),      m_SuppressContext((options & CValidator::eVal_no_context) != 0),      m_ValidateAlignments((options & CValidator::eVal_val_align) != 0),      m_ValidateExons((options & CValidator::eVal_val_exons) != 0),      m_SpliceErr((options & CValidator::eVal_splice_err) != 0),      m_OvlPepErr((options & CValidator::eVal_ovl_pep_err) != 0),      m_RequireTaxonID((options & CValidator::eVal_need_taxid) != 0),      m_RequireISOJTA((options & CValidator::eVal_need_isojta) != 0),      m_ValidateIdSet((options & CValidator::eVal_validate_id_set) != 0),      m_RemoteFetch((options & CValidator::eVal_remote_fetch) != 0),      m_PerfBottlenecks((options & CValidator::eVal_perf_bottlenecks) != 0),      m_IsStandaloneAnnot(false),      m_NoPubs(false),      m_NoBioSource(false),      m_IsGPS(false),      m_IsGED(false),      m_IsPDB(false),      m_IsTPA(false),      m_IsPatent(false),      m_IsRefSeq(false),      m_IsNC(false),      m_IsNG(false),      m_IsNM(false),      m_IsNP(false),      m_IsNR(false),      m_IsNS(false),      m_IsNT(false),      m_IsNW(false),      m_IsXR(false),      m_IsGI(false),      m_PrgCallback(0),      m_NumAlign(0),      m_NumAnnot(0),      m_NumBioseq(0),      m_NumBioseq_set(0),      m_NumDesc(0),      m_NumDescr(0),      m_NumFeat(0),      m_NumGraph(0){    if ( m_SourceQualTags.get() == 0 ) {        InitializeSourceQualTags();    }}// DestructorCValidError_imp::~CValidError_imp(){}// Error post methodsvoid CValidError_imp::PostErr(EDiagSev sv, EErrType et, const string&  msg, const CSerialObject& obj){    const CSeqdesc* desc = dynamic_cast < const CSeqdesc* > (&obj);    if (desc != 0) {        PostErr (sv, et, msg, *desc);        return;    }    const CSeq_feat* feat = dynamic_cast < const CSeq_feat* > (&obj);    if (feat != 0) {        PostErr (sv, et, msg, *feat);        return;    }    const CBioseq* seq = dynamic_cast < const CBioseq* > (&obj);    if (seq != 0) {        PostErr (sv, et, msg, *seq);        return;    }    const CBioseq_set* set = dynamic_cast < const CBioseq_set* > (&obj);    if (set != 0) {        PostErr (sv, et, msg, *set);        return;    }    const CSeq_annot* annot = dynamic_cast < const CSeq_annot* > (&obj);    if (annot != 0) {        PostErr (sv, et, msg, *annot);        return;    }    const CSeq_graph* graph = dynamic_cast < const CSeq_graph* > (&obj);    if (graph != 0) {        PostErr (sv, et, msg, *graph);        return;    }    const CSeq_align* align = dynamic_cast < const CSeq_align* > (&obj);    if (align != 0) {        PostErr (sv, et, msg, *align);        return;    }    const CSeq_entry* entry = dynamic_cast < const CSeq_entry* > (&obj);    if (entry != 0) {        PostErr (sv, et, msg, *entry);        return;    }}void CValidError_imp::PostErr(EDiagSev sv, EErrType et, const string&   message, TDesc    ds){    // Append Descriptor label    string msg(message + " DESCRIPTOR: ");    ds.GetLabel (&msg, CSeqdesc::eBoth);    m_ErrRepository->AddValidErrItem(new CValidErrItem(sv, et, msg, ds));}void CValidError_imp::PostErr(EDiagSev sv, EErrType et, const string&   message, TFeat    ft){    // Add feature part of label    string msg(message + " FEATURE: ");    feature::GetLabel(ft, &msg, feature::eBoth, m_Scope);    // Add feature location part of label    string loc_label;    if (m_SuppressContext) {        CSeq_loc loc;        loc.Assign(ft.GetLocation());        ChangeSeqLocId(&loc, false, m_Scope.GetPointer());        loc.GetLabel(&loc_label);    } else {        ft.GetLocation().GetLabel(&loc_label);    }    if (loc_label.size() > 800) {        loc_label = loc_label.substr(0, 797) + "...";    }    if (!loc_label.empty()) {        loc_label = string("[") + loc_label + "]";        msg += loc_label;    }    // Append label for bioseq of feature location    if (!m_SuppressContext) {        try {            CBioseq_Handle hnd = m_Scope->GetBioseqHandle(ft.GetLocation());            if( hnd ) {                CBioseq_Handle::TBioseqCore bc = hnd.GetBioseqCore();                msg += "[";                bc->GetLabel(&msg, CBioseq::eBoth);                msg += "]";            }        } catch (...){        };    }    // Append label for product of feature    loc_label.erase();    if (ft.IsSetProduct()) {        if (m_SuppressContext) {            CSeq_loc loc;            loc.Assign(ft.GetProduct());            ChangeSeqLocId(&loc, false, m_Scope.GetPointer());            loc.GetLabel(&loc_label);        } else {            ft.GetProduct().GetLabel(&loc_label);        }        if (loc_label.size() > 800) {            loc_label = loc_label.substr(0, 797) + "...";        }        if (!loc_label.empty()) {            loc_label = string("[") + loc_label + "]";            msg += loc_label;        }    }    m_ErrRepository->AddValidErrItem(new CValidErrItem(sv, et, msg, ft));}void CValidError_imp::PostErr(EDiagSev sv, EErrType et, const string&   message, TBioseq  sq){    // Append bioseq label    string msg(message + " BIOSEQ: ");    if (m_SuppressContext) {        sq.GetLabel(&msg, CBioseq::eContent, true);    } else {        sq.GetLabel(&msg, CBioseq::eBoth, false);    }    m_ErrRepository->AddValidErrItem(new CValidErrItem(sv, et, msg, sq));}void CValidError_imp::PostErr(EDiagSev sv, EErrType et, const string&   message, TBioseq  sq, TDesc    ds){    // Append Descriptor label    string msg(message + " DESCRIPTOR: ");    ds.GetLabel(&msg, CSeqdesc::eBoth);    PostErr(sv, et, msg, sq);}void CValidError_imp::PostErr(EDiagSev      sv, EErrType      et, const string& message, TSet          set){    // Append Bioseq_set label    string msg(message + " BIOSEQ-SET: ");    if (m_SuppressContext) {        set.GetLabel(&msg, CBioseq_set::eContent);    } else {        set.GetLabel(&msg, CBioseq_set::eBoth);    }    m_ErrRepository->AddValidErrItem(new CValidErrItem(sv, et, msg, set));}void CValidError_imp::PostErr(EDiagSev        sv, EErrType        et, const string&   message, TSet            set, TDesc           ds){    // Append Descriptor label    string msg(message + " DESCRIPTOR: ");    ds.GetLabel(&msg, CSeqdesc::eBoth);    PostErr(sv, et, msg, set);}void CValidError_imp::PostErr(EDiagSev sv, EErrType et, const string&   message, TAnnot    an){    // Append Annotation label    string msg(message + " ANNOTATION: ");    // !!! need to decide on the message    m_ErrRepository->AddValidErrItem(new CValidErrItem(sv, et, msg, an));}void CValidError_imp::PostErr(EDiagSev sv, EErrType et, const string& message, TGraph graph){    // Append Graph label    string msg(message + " GRAPH: ");    if ( graph.IsSetTitle() ) {        msg += graph.GetTitle();    } else {        msg += "Not Named";    }    msg += " ";    graph.GetLoc().GetLabel(&msg);    m_ErrRepository->AddValidErrItem(new CValidErrItem(sv, et, msg, graph));}void CValidError_imp::PostErr(EDiagSev sv, EErrType et,

⌨️ 快捷键说明

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