⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 seq_id.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/* * =========================================================================== * PRODUCTION $Log: Seq_id.cpp,v $ * PRODUCTION Revision 1000.4  2004/06/01 19:34:28  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R6.81 * PRODUCTION * =========================================================================== *//* $Id: Seq_id.cpp,v 1000.4 2004/06/01 19:34:28 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:  ....... * * File Description: *   ....... * * Remark: *   This code was originally generated by application DATATOOL *   using specifications from the ASN data definition file *   'seqloc.asn'. */// standard includes// generated includes#include <ncbi_pch.hpp>#include <corelib/ncbiutil.hpp>#include <objects/seq/Bioseq.hpp>#include <objects/seq/Seq_inst.hpp>#include <objects/seqloc/Seq_id.hpp>#include <objects/seqloc/Textseq_id.hpp>#include <objects/seqloc/Giimport_id.hpp>#include <objects/seqloc/Patent_seq_id.hpp>#include <objects/seqloc/PDB_seq_id.hpp>#include <objects/biblio/Id_pat.hpp>#include <objects/general/Object_id.hpp>#include <objects/general/Dbtag.hpp>#include <objects/general/Date.hpp>#include <objects/general/Date_std.hpp>#include <objects/general/Date.hpp>// generated classesBEGIN_NCBI_SCOPEBEGIN_objects_SCOPE // namespace ncbi::objects::// constructorCSeq_id::CSeq_id(void){    return;}// destructorCSeq_id::~CSeq_id(void){    return;}const CTextseq_id* CSeq_id::GetTextseq_Id(void) const{    switch ( Which() ) {    case e_Genbank:        return &GetGenbank();    case e_Embl:        return &GetEmbl();    case e_Ddbj:        return &GetDdbj();    case e_Pir:        return &GetPir();    case e_Swissprot:        return &GetSwissprot();    case e_Other:        return &GetOther();    case e_Prf:        return &GetPrf();    case e_Tpg:        return &GetTpg();    case e_Tpe:        return &GetTpe();    case e_Tpd:        return &GetTpd();    default:        return 0;    }}inlinevoid x_Assign(CObject_id& dst, const CObject_id& src){    switch ( src.Which() ) {    case CObject_id::e_not_set:        dst.Reset();        return;    case CObject_id::e_Id:        dst.SetId(src.GetId());        return;    case CObject_id::e_Str:        dst.SetStr(src.GetStr());        return;    default:        THROW1_TRACE(runtime_error, "invalid Object-id variant");    }}inlinevoid x_Assign(CGiimport_id& dst, const CGiimport_id& src){    dst.SetId(src.GetId());    if ( src.IsSetDb() ) {        dst.SetDb(src.GetDb());    }    else {        dst.ResetDb();    }    if ( src.IsSetRelease() ) {        dst.SetRelease(src.GetRelease());    }    else {        dst.ResetRelease();    }}inlinevoid x_Assign(CTextseq_id& dst, const CTextseq_id& src){    if ( src.IsSetName() ) {        dst.SetName(src.GetName());    }    else {        dst.ResetName();    }    if ( src.IsSetAccession() ) {        dst.SetAccession(src.GetAccession());    }    else {        dst.ResetAccession();    }    if ( src.IsSetRelease() ) {        dst.SetRelease(src.GetRelease());    }    else {        dst.ResetRelease();    }    if ( src.IsSetVersion() ) {        dst.SetVersion(src.GetVersion());    }    else {        dst.ResetVersion();    }}inlinevoid x_Assign(CDbtag& dst, const CDbtag& src){    dst.SetDb(src.GetDb());    x_Assign(dst.SetTag(), src.GetTag());}inlinevoid x_Assign(CPatent_seq_id& dst, const CPatent_seq_id& src){    dst.SetSeqid(src.GetSeqid());    dst.SetCit().Assign(src.GetCit());}inlinevoid x_Assign(CDate& dst, const CDate& src){    dst.Assign(src);}inlinevoid x_Assign(CPDB_seq_id& dst, const CPDB_seq_id& src){    dst.SetMol().Set(src.GetMol());    if ( src.IsSetChain() ) {        dst.SetChain(src.GetChain());    }    else {        dst.ResetChain();    }    if ( src.IsSetRel() ) {        dst.SetRel().Assign(src.GetRel());    }    else {        dst.ResetRel();    }}void CSeq_id::Assign(const CSerialObject& obj, ESerialRecursionMode how){    if ( GetTypeInfo() == obj.GetThisTypeInfo() ) {        const CSeq_id& id = static_cast<const CSeq_id&>(obj);        switch ( id.Which() ) {        case e_not_set:            Reset();            return;        case e_Local:            x_Assign(SetLocal(), id.GetLocal());            return;        case e_Gibbsq:            SetGibbsq(id.GetGibbsq());            return;        case e_Gibbmt:            SetGibbmt(id.GetGibbmt());            return;        case e_Giim:            x_Assign(SetGiim(), id.GetGiim());            return;        case e_Pir:            x_Assign(SetPir(), id.GetPir());            return;        case e_Swissprot:            x_Assign(SetSwissprot(), id.GetSwissprot());            return;        case e_Patent:            x_Assign(SetPatent(), id.GetPatent());            return;        case e_Other:            x_Assign(SetOther(), id.GetOther());            return;        case e_General:            x_Assign(SetGeneral(), id.GetGeneral());            return;        case e_Gi:            SetGi(id.GetGi());            return;        case e_Prf:            x_Assign(SetPrf(), id.GetPrf());            return;        case e_Pdb:            x_Assign(SetPdb(), id.GetPdb());            return;        case e_Genbank:            x_Assign(SetGenbank(), id.GetGenbank());            return;        case e_Embl:            x_Assign(SetEmbl(), id.GetEmbl());            return;        case e_Ddbj:            x_Assign(SetDdbj(), id.GetDdbj());            return;        case e_Tpg:            x_Assign(SetTpg(), id.GetTpg());            return;        case e_Tpe:            x_Assign(SetTpe(), id.GetTpe());            return;        case e_Tpd:            x_Assign(SetTpd(), id.GetTpd());            return;        }    }    CSerialObject::Assign(obj, how);}// Compare() - are SeqIds equivalent?CSeq_id::E_SIC CSeq_id::Compare(const CSeq_id& sid2) const{    if ( Which() != sid2.Which() ) { // Only one case where this will work        const CTextseq_id *tsip1 = GetTextseq_Id();        if ( !tsip1 )            return e_DIFF;        const CTextseq_id *tsip2 = sid2.GetTextseq_Id();        if ( !tsip2 )            return e_DIFF;        if ( tsip1->Match(*tsip2) ) // id Textseq_id match            return e_YES;        else            return e_NO;    }    switch ( Which() ) { // Now we only need to know one    case e_Local:        return GetLocal().Match(sid2.GetLocal()) ? e_YES : e_NO;    case e_Gibbsq:        return GetGibbsq() == sid2.GetGibbsq() ? e_YES : e_NO;    case e_Gibbmt:        return GetGibbmt() == sid2.GetGibbmt() ? e_YES : e_NO;    case e_Giim:        return GetGiim().GetId() == sid2.GetGiim().GetId() ? e_YES : e_NO;    case e_Pir:        return GetPir().Match(sid2.GetPir()) ? e_YES : e_NO;    case e_Swissprot:        return GetSwissprot().Match(sid2.GetSwissprot()) ? e_YES : e_NO;    case e_Patent:        return GetPatent().Match(sid2.GetPatent()) ? e_YES : e_NO;    case e_Other:        return GetOther().Match(sid2.GetOther()) ? e_YES : e_NO;    case e_General:        return GetGeneral().Match(sid2.GetGeneral()) ? e_YES : e_NO;    case e_Gi:        return GetGi() == sid2.GetGi() ? e_YES : e_NO;    case e_Prf:        return GetPrf().Match(sid2.GetPrf()) ? e_YES : e_NO;    case e_Pdb:        return GetPdb().Match(sid2.GetPdb()) ? e_YES : e_NO;    case e_Genbank:        return GetGenbank().Match(sid2.GetGenbank()) ? e_YES : e_NO;    case e_Embl:        return GetEmbl().Match(sid2.GetEmbl()) ? e_YES : e_NO;    case e_Ddbj:        return GetDdbj().Match(sid2.GetDdbj()) ? e_YES : e_NO;    case e_Tpg:        return GetTpg().Match(sid2.GetTpg()) ? e_YES : e_NO;    case e_Tpe:        return GetTpe().Match(sid2.GetTpe()) ? e_YES : e_NO;    case e_Tpd:        return GetTpd().Match(sid2.GetTpd()) ? e_YES : e_NO;    default:        return e_error;    }}int CSeq_id::CompareOrdered(const CSeq_id& sid2) const{    int ret = Which() - sid2.Which();    if ( ret != 0 ) {        return ret;    }    const CTextseq_id *tsip1 = GetTextseq_Id();    const CTextseq_id *tsip2 = sid2.GetTextseq_Id();    if ( tsip1 && tsip2 ) {        return tsip1->Compare(*tsip2);    }    switch ( Which() ) { // Now we only need to know one    case e_Local:        return GetLocal().Compare(sid2.GetLocal());    case e_Gibbsq:        return GetGibbsq() - sid2.GetGibbsq();    case e_Gibbmt:        return GetGibbmt() - sid2.GetGibbmt();    case e_Giim:        return GetGiim().GetId() - sid2.GetGiim().GetId();    case e_Patent:        return GetPatent().Compare(sid2.GetPatent());    case e_General:        return GetGeneral().Compare(sid2.GetGeneral());    case e_Gi:        return GetGi() - sid2.GetGi();    case e_Pdb:        return 0;    default:        return this == &sid2? 0: this < &sid2? -1: 1;    }}static const char* const s_TextId[20] = {   // FASTA_LONG formats    "???" , // not-set = ???    "lcl",  // local = lcl|integer or string    "bbs",  // gibbsq = bbs|integer    "bbm",  // gibbmt = bbm|integer    "gim",  // giim = gim|integer    "gb", // genbank = gb|accession|locus    "emb",  // embl = emb|accession|locus    "pir",  // pir = pir|accession|name    "sp", // swissprot = sp|accession|name    "pat",  // patent = pat|country|patent number (string)|seq number (integer)    "ref",  // other = ref|accession|name|release - changed from oth to ref    "gnl",  // general = gnl|database(string)|id (string or number)    "gi", // gi = gi|integer    "dbj",  // ddbj = dbj|accession|locus    "prf",  // prf = prf|accession|name    "pdb",  // pdb = pdb|entry name (string)|chain id (char)    "tpg",  // tpg = tpg|accession|name    "tpe",  // tpe = tpe|accession|name    "tpd",  // tpd = tpd|accession|name    ""  // Placeholder for end of list};CSeq_id::E_Choice CSeq_id::WhichInverseSeqId(const char* SeqIdCode){    int retval = 0;    int dex;    // Last item in list has null byte for first character, so    // *s_TextId[dex] will be zero at end.    for (dex = 0;  *s_TextId[dex];  dex++) {        if ( !NStr::CompareNocase(s_TextId[dex], SeqIdCode) ) {            break;        }    }    if ( !*s_TextId[dex] ) {        retval = 0;    } else {        retval = dex;    }    return static_cast<CSeq_id_Base::E_Choice> (retval);}static CSeq_id::EAccessionInfo s_IdentifyNAcc(const string& acc){    _ASSERT(acc[0] == 'N');    int n = NStr::StringToInt(acc.substr(1), 10, NStr::eCheck_Skip);    if (n >= 20000) {        return CSeq_id::eAcc_gb_est;    } else { // big mess; fortunately, these are all secondary        switch (n) {        case 1: case 2: case 11: case 57:            return CSeq_id::eAcc_gb_embl;        case 3: case 4: case 6: case 7: case 10: case 14: case 15:        case 16: case 17: case 21: case 23: case 24: case 26: case 29:

⌨️ 快捷键说明

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