featid_table.cpp

来自「ncbi源码」· C++ 代码 · 共 241 行

CPP
241
字号
/* * =========================================================================== * PRODUCTION $Log: featid_table.cpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 21:00:37  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3 * PRODUCTION * =========================================================================== *//*  $Id: featid_table.cpp,v 1000.1 2004/06/01 21:00:37 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. * * =========================================================================== * * Authors:  Mike DiCuccio * * File Description: * */#include <ncbi_pch.hpp>#include "featid_table.hpp"#include <objects/general/Dbtag.hpp>#include <objects/general/Object_id.hpp>#include <objects/seqloc/Seq_interval.hpp>#include <objmgr/util/sequence.hpp>#include <set>#include <serial/iterator.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);CFeatIdTable::CFeatIdTable(int x, int y, int w, int h, const char* label)    : CTablePanel< CConstRef<CSeq_loc> >(x, y, w, h, label){    SetColumn(0, "Source",     eString, FL_ALIGN_LEFT, 0.5f);    SetColumn(1, "Database",   eString, FL_ALIGN_LEFT, 0.5f);    SetColumn(2, "Identifier", eString, FL_ALIGN_LEFT, 1.0f);}void CFeatIdTable::Update(const CSeq_feat& feat){    size_t row = 0;    // IDs from main location    {{        SetCell(row, 0) = "Sequence";        // use the whole spanned location, not the original location        const CSeq_id& id = sequence::GetId(feat.GetLocation());        CRef<CSeq_loc> loc(new CSeq_loc());        loc->SetInt().SetFrom(feat.GetLocation().GetTotalRange().GetFrom());        loc->SetInt().SetTo(feat.GetLocation().GetTotalRange().GetTo());        loc->SetInt().SetStrand(sequence::GetStrand(feat.GetLocation()));        loc->SetId(id);        SetData(row, loc);        SetCell(row, 1, x_GetSource(id));        SetCell(row, 2, id.AsFastaString());        ++row;    }}    // IDs from the product location, if it exists    if (feat.IsSetProduct()) {        SetCell(row, 0, "Product");        SetData(row, CConstRef<CSeq_loc>(&feat.GetProduct()));        const CSeq_id& id = sequence::GetId(feat.GetProduct());        SetCell(row, 1, x_GetSource(id));        SetCell(row, 2, id.AsFastaString());        ++row;    }    // IDs from DB xrefs    if (feat.IsSetDbxref()) {        SetCell(row, 0, "External DB");        ITERATE (CSeq_feat::TDbxref, iter, feat.GetDbxref()) {            const CDbtag& tag = **iter;            CRef<CSeq_loc> loc(new CSeq_loc());            loc->SetWhole(*x_GetSeqId(tag));            SetData(row, loc);            SetCell(row, 1, tag.GetDb());            if (tag.GetTag().IsStr()) {                SetCell(row, 2, tag.GetTag().GetStr());            } else {                SetCell(row, 2, NStr::UIntToString(tag.GetTag().GetId()));            }            ++row;        }    }}// get a string describing the source of a given seq-idstring CFeatIdTable::x_GetSource(const CSeq_id& id) const{    switch (id.Which()) {    case CSeq_id::e_Local:        return "Local";    case CSeq_id::e_Gibbsq:    case CSeq_id::e_Gibbmt:        return "Geninfo Backbone";    case CSeq_id::e_Giim:        return "Geninfo Import";    case CSeq_id::e_Genbank:        return "Genbank";    case CSeq_id::e_Embl:        return "EMBL";    case CSeq_id::e_Pir:        return "PIR";    case CSeq_id::e_Swissprot:        return "Swiss-PROT";    case CSeq_id::e_Patent:        return "Patent";    case CSeq_id::e_Other:        return "Other";    case CSeq_id::e_General:        return "General";    case CSeq_id::e_Gi:        return "Genbank ID";    case CSeq_id::e_Ddbj:        return "DDBJ";    case CSeq_id::e_Prf:        return "Prf Sequence";    case CSeq_id::e_Pdb:        return "PDB";    case CSeq_id::e_Tpg:        return "Third-Party";    case CSeq_id::e_Tpe:        return "Third-Party/EMBL";    case CSeq_id::e_Tpd:        return "Third-Party/DDBJ";    default:        return "Unknown";        break;    }}// get a seq-id for a given DbtagCSeq_id* CFeatIdTable::x_GetSeqId(const CDbtag& dbtag) const{    static map<string, string> s_IdDictionary;    if (s_IdDictionary.size() == 0) {        s_IdDictionary["ENSEMBL"] = "lcl|";        s_IdDictionary["GenBank"] = "gb|";        s_IdDictionary["RefSeq" ] = "ref|";        s_IdDictionary["EMBL"   ] = "gb|";        s_IdDictionary["DDBJ"   ] = "gb|";    }    string str(dbtag.GetDb() + "|");    map<string, string>::const_iterator iter =        s_IdDictionary.find(dbtag.GetDb());    if (iter != s_IdDictionary.end()) {        str = iter->second;    }    if (dbtag.GetTag().IsStr()) {        str += dbtag.GetTag().GetStr();    } else {        str += NStr::UIntToString(dbtag.GetTag().GetId());    }    CRef<CSeq_id> id(new CSeq_id(str));    if (id->Which() == CSeq_id::e_not_set) {        id.Reset(new CSeq_id("lcl|" + str));    }    return id.Release();}END_NCBI_SCOPE/* * =========================================================================== * $Log: featid_table.cpp,v $ * Revision 1000.1  2004/06/01 21:00:37  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3 * * Revision 1.3  2004/05/21 22:27:49  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.2  2004/01/20 18:17:53  dicuccio * Changed to match new API in CTablePanel * * Revision 1.1  2004/01/13 20:38:46  dicuccio * Added new view: feature IDs * * =========================================================================== */

⌨️ 快捷键说明

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