feat_config_list.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:18k
- /*
- * ===========================================================================
- * PRODUCTION $Log: feat_config_list.cpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 20:43:13 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: feat_config_list.cpp,v 1000.1 2004/06/01 20:43:13 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: Robert Smith
- *
- */
- /// @file feat_config_list.cpp
- ///
- /// List of feature types to configure preferences for viewing SeqFeats.
- #include <ncbi_pch.hpp>
- #include <gui/config/feat_config_list.hpp>
- BEGIN_NCBI_SCOPE
- const CFeatConfigList* GetFeatConfigList()
- {
- static CFeatConfigList* theFeatConfigList = 0;
-
- if (theFeatConfigList == 0) {
- theFeatConfigList = new CFeatConfigList();
-
- }
- return theFeatConfigList;
- }
- #define kMasterDescString "All"
- static string s_MasterDesc(kMasterDescString);
- string ChangeMasterFeatDescription(const string& oldDesc, const string& newMasterDesc)
- {
- string newDesc = oldDesc;
- SIZE_TYPE mast_pos = newDesc.find(s_MasterDesc);
- while (mast_pos != NPOS) {
- newDesc.replace(mast_pos, s_MasterDesc.size(), newMasterDesc);
- mast_pos = newDesc.find(s_MasterDesc, mast_pos + newMasterDesc.size());
- }
- return newDesc;
- }
- USING_SCOPE(objects);
- namespace {
- CFeatConfigItem config_item_init[] = {
- CFeatConfigItem( CSeqFeatData::e_not_set, CSeqFeatData::eSubtype_any, kMasterDescString, "Master" ),
- CFeatConfigItem( CSeqFeatData::e_Gene, CSeqFeatData::eSubtype_gene, "Gene", "Gene" ),
- CFeatConfigItem( CSeqFeatData::e_Org, CSeqFeatData::eSubtype_org, "Org", "Org" ),
- CFeatConfigItem( CSeqFeatData::e_Cdregion, CSeqFeatData::eSubtype_cdregion, "CDS", "CDS" ),
- CFeatConfigItem( CSeqFeatData::e_Prot, CSeqFeatData::eSubtype_any, "Protein, " kMasterDescString, "Prot Master" ),
- CFeatConfigItem( CSeqFeatData::e_Prot, CSeqFeatData::eSubtype_prot, "Protein", "Prot" ),
- CFeatConfigItem( CSeqFeatData::e_Prot, CSeqFeatData::eSubtype_preprotein, "PreProtein", "PreProtein" ),
- CFeatConfigItem( CSeqFeatData::e_Prot, CSeqFeatData::eSubtype_mat_peptide_aa, "Mature Peptide AA", "Mat-Peptide AA" ),
- CFeatConfigItem( CSeqFeatData::e_Prot, CSeqFeatData::eSubtype_sig_peptide_aa, "Signal Peptide AA", "Sig-Peptide AA" ),
- CFeatConfigItem( CSeqFeatData::e_Prot, CSeqFeatData::eSubtype_transit_peptide_aa, "Transit Peptide AA", "Transit-Peptide AA" ),
- CFeatConfigItem( CSeqFeatData::e_Rna, CSeqFeatData::eSubtype_any, "RNA, " kMasterDescString, "RNA Master" ),
- CFeatConfigItem( CSeqFeatData::e_Rna, CSeqFeatData::eSubtype_preRNA, "precursor_RNA", "precursor_RNA" ),
- CFeatConfigItem( CSeqFeatData::e_Rna, CSeqFeatData::eSubtype_mRNA, "mRNA", "mRNA" ),
- CFeatConfigItem( CSeqFeatData::e_Rna, CSeqFeatData::eSubtype_tRNA, "tRNA", "tRNA" ),
- CFeatConfigItem( CSeqFeatData::e_Rna, CSeqFeatData::eSubtype_rRNA, "rRNA", "rRNA" ),
- CFeatConfigItem( CSeqFeatData::e_Rna, CSeqFeatData::eSubtype_snRNA, "snRNA", "snRNA" ),
- CFeatConfigItem( CSeqFeatData::e_Rna, CSeqFeatData::eSubtype_scRNA, "scRNA", "scRNA" ),
- CFeatConfigItem( CSeqFeatData::e_Rna, CSeqFeatData::eSubtype_snoRNA, "sno_RNA", "sno_RNA" ),
- CFeatConfigItem( CSeqFeatData::e_Rna, CSeqFeatData::eSubtype_otherRNA, "misc_RNA", "misc_RNA" ),
- CFeatConfigItem( CSeqFeatData::e_Pub, CSeqFeatData::eSubtype_pub, "Pub", "Pub" ),
- CFeatConfigItem( CSeqFeatData::e_Seq, CSeqFeatData::eSubtype_seq, "Seq", "Seq" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_any, "Import, " kMasterDescString, "Import Master" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_imp, "import", "import" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_allele, "allele", "allele" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_attenuator, "attenuator", "attenuator"),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_C_region, "C_region", "C_region" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_CAAT_signal,"CAAT_signal", "CAAT_signal" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_Imp_CDS, "Imp_CDS", "Imp_CDS"),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_conflict, "conflict", "conflict"),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_D_loop, "D_loop", "D_loop"),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_D_segment, "D_segment", "D_segment"),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_enhancer, "enhancer", "enhancer" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_exon, "exon", "exon" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_GC_signal, "GC_signal", "GC_signal" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_iDNA, "iDNA", "iDNA" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_intron, "intron", "intron" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_J_segment, "J_segment", "J_segment" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_LTR, "LTR", "LTR" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_mat_peptide,"mat_peptide", "mat_peptide" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_misc_binding, "misc_binding", "misc_binding" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_misc_difference, "misc_difference", "misc_difference" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_misc_feature, "misc_feature", "misc_feature" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_misc_recomb, "misc_recomb", "misc_recomb" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_misc_RNA, "misc_RNA", "misc_RNA" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_misc_signal, "misc_signal", "misc_signal" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_misc_structure, "misc_structure", "misc_structure" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_modified_base, "modified_base", "modified_base" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_mutation, "mutation", "mutation" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_N_region, "N_region", "N_region" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_old_sequence, "old_sequence", "old_sequence" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_polyA_signal, "polyA_signal", "polyA_signal" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_polyA_site, "polyA_site", "polyA_site" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_precursor_RNA, "precursor_RNA", "precursor_RNA" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_prim_transcript,"prim_transcript", "prim_transcript" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_primer_bind, "primer_bind", "primer_bind" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_promoter, "promoter", "promoter" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_protein_bind, "protein_bind", "protein_bind" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_RBS, "RBS", "RBS" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_repeat_region, "repeat_region", "repeat_region" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_repeat_unit, "repeat_unit", "repeat_unit" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_rep_origin, "rep_origin", "rep_origin" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_S_region, "S_region", "S_region" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_satellite, "satellite", "satellite" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_sig_peptide, "sig_peptide", "sig_peptide" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_source, "source", "source" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_stem_loop, "stem_loop", "stem_loop" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_STS, "STS", "STS" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_TATA_signal, "TATA_signal", "TATA_signal" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_terminator, "terminator", "terminator" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_transit_peptide, "transit_peptide", "transit_peptide" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_unsure, "unsure", "unsure" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_V_region, "V_region", "V_region" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_V_segment, "V_segment", "V_segment" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_variation, "variation", "variation" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_virion, "virion", "virion" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_3clip, "3'clip", "3'clip" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_3UTR, "3'UTR", "3'UTR" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_5clip, "5'clip", "5'clip" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_5UTR, "5'UTR", "5'UTR" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_10_signal, "-10_signal", "-10_signal" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_35_signal, "-35_signal", "-35_signal" ),
- CFeatConfigItem( CSeqFeatData::e_Imp, CSeqFeatData::eSubtype_site_ref, "site_ref", "site_ref" ),
- CFeatConfigItem( CSeqFeatData::e_Region, CSeqFeatData::eSubtype_region, "region", "region" ),
- CFeatConfigItem( CSeqFeatData::e_Comment, CSeqFeatData::eSubtype_comment, "comment", "comment" ),
- CFeatConfigItem( CSeqFeatData::e_Bond, CSeqFeatData::eSubtype_bond, "bond", "bond" ),
- CFeatConfigItem( CSeqFeatData::e_Site, CSeqFeatData::eSubtype_site, "site", "site" ),
- CFeatConfigItem( CSeqFeatData::e_Rsite, CSeqFeatData::eSubtype_rsite, "rsite", "rsite" ),
- CFeatConfigItem( CSeqFeatData::e_User, CSeqFeatData::eSubtype_user, "user", "user" ),
- CFeatConfigItem( CSeqFeatData::e_Txinit, CSeqFeatData::eSubtype_txinit, "txinit", "txinit" ),
- CFeatConfigItem( CSeqFeatData::e_Num, CSeqFeatData::eSubtype_num, "num", "num" ),
- CFeatConfigItem( CSeqFeatData::e_Psec_str, CSeqFeatData::eSubtype_psec_str, "psec_str", "psec_str" ),
- CFeatConfigItem( CSeqFeatData::e_Non_std_residue, CSeqFeatData::eSubtype_non_std_residue, "non_std_residue", "non_std_residue" ),
- CFeatConfigItem( CSeqFeatData::e_Het, CSeqFeatData::eSubtype_het, "het", "het" ),
- CFeatConfigItem( CSeqFeatData::e_Biosrc, CSeqFeatData::eSubtype_biosrc, "biosrc", "biosrc" ),
- };
- } // unnamed namespace
- /**
- CFeatConfigItem comparator
- to sort the set properly.
- */
- bool CFeatConfigItem::operator<(const CFeatConfigItem& rhs) const {
- if (m_Type == rhs.m_Type) {
- // the 'Any' subtype should sort lower than anything else in that type.
- if (m_Subtype == CSeqFeatData::eSubtype_any) {
- return rhs.m_Subtype != CSeqFeatData::eSubtype_any;
- }
- if ( rhs.m_Subtype == CSeqFeatData::eSubtype_any) {
- return false;
- }
- return m_Subtype < rhs.m_Subtype;
- }
- return m_Type < rhs.m_Type;
- }
- /*****
- CFeatConfigList definitions.
- *****/
- CFeatConfigList::CFeatConfigList()
- {
- x_Init();
- }
- bool CFeatConfigList::TypeValid(int type, int subtype) const
- {
- const_iterator ci_it = m_FeatTypes.find(CFeatConfigItem(type, subtype, "", ""));
- if (ci_it == m_FeatTypes.end()) {
- return false;
- }
- return true;
- }
- bool CFeatConfigList::GetItem(int type, int subtype, CFeatConfigItem& config_item) const
- {
- const_iterator ci_it = m_FeatTypes.find(CFeatConfigItem(type, subtype, "", ""));
- if (ci_it == m_FeatTypes.end()) {
- return false;
- }
- config_item = *ci_it;
- return true;
- }
- bool CFeatConfigList::GetItemByDescription(const string& desc, CFeatConfigItem& config_item) const
- {
- const_iterator ci_it = begin();
- for (; ci_it != end(); ++ci_it) {
- if (ci_it->GetDescription() == desc) {
- config_item = *ci_it;
- return true;
- }
- }
- return false;
- }
- bool CFeatConfigList::GetTypeSubType(const string& desc, int& type, int& subtype) const
- {
- CFeatConfigItem config_item;
- if ( GetItemByDescription(desc, config_item) ) {
- type = config_item.GetType();
- subtype = config_item.GetSubtype();
- return true;
- }
- return false;
- }
- bool CFeatConfigList::GetItemByKey(const string& key, CFeatConfigItem& config_item) const
- {
- const_iterator ci_it = begin();
- for (; ci_it != end(); ++ci_it) {
- if (ci_it->GetStoragekey() == key) {
- config_item = *ci_it;
- return true;
- }
- }
- return false;
- }
- string CFeatConfigList::GetDescription(int type, int subtype) const
- {
- CFeatConfigItem config_item;
- if (!GetItem(type, subtype, config_item)) {
- return kEmptyStr;
- }
- return config_item.GetDescription();
- }
- string CFeatConfigList::GetStoragekey(int type, int subtype) const
- {
- CFeatConfigItem config_item;
- if (!GetItem(type, subtype, config_item)) {
- return kEmptyStr;
- }
- return config_item.GetStoragekey();
- }
- size_t CFeatConfigList::size() const
- {
- return m_FeatTypes.size();
- }
- CFeatConfigList::const_iterator CFeatConfigList::begin() const
- {
- return m_FeatTypes.begin();
- }
- CFeatConfigList::const_iterator CFeatConfigList::end() const
- {
- return m_FeatTypes.end();
- }
- void CFeatConfigList::x_Init()
- {
- size_t config_item_size = sizeof(config_item_init)/sizeof(CFeatConfigItem);
- for (size_t i = 0; i < config_item_size; ++i ) {
- bool config_items_init_no_dups =
- m_FeatTypes.insert(config_item_init[i]).second;
- _ASSERT(config_items_init_no_dups);
- }
- }
- /// return a list of all the feature descriptions for a menu or other control.
- void CFeatConfigList::GetDescriptions(vector<string> &descs, bool hierarchical) const
- {
- descs.clear();
-
- ITERATE (TFeatTypeContainer, iter, m_FeatTypes) {
- string this_desc = iter->GetDescription();
-
- if (hierarchical) {
- string parent_desc;
- if (iter->GetSubtype() != CSeqFeatData::eSubtype_any) {
- parent_desc = GetDescription(iter->GetType(), CSeqFeatData::eSubtype_any);
- } else if (iter->GetType() != CSeqFeatData::e_not_set) {
- parent_desc = this_desc;
- }
- if ( ! parent_desc.empty()) {
- this_desc = parent_desc + "/" + this_desc;
- }
- }
-
- descs.push_back(this_desc);
- }
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: feat_config_list.cpp,v $
- * Revision 1000.1 2004/06/01 20:43:13 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6
- *
- * Revision 1.6 2004/05/21 22:27:39 gorelenk
- * Added PCH ncbi_pch.hpp
- *
- * Revision 1.5 2004/05/20 12:27:41 dicuccio
- * Removed unnecessary doxygen module directives - they're in the headers
- *
- * Revision 1.4 2004/01/15 14:48:09 rsmith
- * add GetTypeSubType method from CFeatConfig (deprecated).
- *
- * Revision 1.3 2004/01/14 20:30:43 rsmith
- * Add method GetDescriptions to easily get all feature descriptions.
- * Change the uility function ChangeMasterFeatDescription to search and replace
- * all "master" strings.
- *
- * Revision 1.2 2003/12/30 15:45:10 dicuccio
- * Fixed compilation errors on Linux
- *
- * Revision 1.1 2003/12/29 14:34:38 rsmith
- * split out from feat_config.cpp
- *
- *
- * ===========================================================================
- */