|
NCBI C++ ToolKit
|
00001 /* $Id: seqgraphic_utils.cpp 25159 2012-01-27 17:17:16Z wuliangs $ 00002 * =========================================================================== 00003 * 00004 * PUBLIC DOMAIN NOTICE 00005 * National Center for Biotechnology Information 00006 * 00007 * This software/database is a "United States Government Work" under the 00008 * terms of the United States Copyright Act. It was written as part of 00009 * the author's official duties as a United States Government employee and 00010 * thus cannot be copyrighted. This software/database is freely available 00011 * to the public for use. The National Library of Medicine and the U.S. 00012 * Government have not placed any restriction on its use or reproduction. 00013 * 00014 * Although all reasonable efforts have been taken to ensure the accuracy 00015 * and reliability of the software and data, the NLM and the U.S. 00016 * Government do not and cannot warrant the performance or results that 00017 * may be obtained by using this software or data. The NLM and the U.S. 00018 * Government disclaim all warranties, express or implied, including 00019 * warranties of performance, merchantability or fitness for any particular 00020 * purpose. 00021 * 00022 * Please cite the author in any work or product based on this material. 00023 * 00024 * =========================================================================== 00025 * 00026 * Authors: Liangshou Wu 00027 * 00028 * File Description: 00029 * 00030 */ 00031 00032 00033 #include <ncbi_pch.hpp> 00034 00035 #include <gui/widgets/seq_graphic/seqgraphic_utils.hpp> 00036 00037 #include <objmgr/seq_annot_handle.hpp> 00038 #include <objmgr/util/sequence.hpp> 00039 #include <objmgr/seqdesc_ci.hpp> 00040 #include <objects/seqfeat/BioSource.hpp> 00041 #include <objects/seq/seq_id_handle.hpp> 00042 #include <objects/seq/MolInfo.hpp> 00043 00044 00045 BEGIN_NCBI_SCOPE 00046 USING_SCOPE(objects); 00047 00048 bool CSGUtils::IsChromosome(const CBioseq_Handle& handle, CScope& scope) 00049 { 00050 CConstRef<CSeq_id> seq_id = handle.GetSeqId(); 00051 00052 CSeq_id_Handle idh = sequence::GetId(handle.GetSeq_id_Handle(), 00053 scope, sequence::eGetId_Best); 00054 if (idh) { 00055 seq_id = idh.GetSeqId(); 00056 } 00057 00058 CSeq_id::EAccessionInfo info = seq_id->IdentifyAccession(); 00059 if ((info & CSeq_id::eAcc_division_mask) == CSeq_id::eAcc_chromosome) { 00060 return true; 00061 } 00062 00063 CSeqdesc_CI desc_it(handle, CSeqdesc::e_Source); 00064 while (desc_it) { 00065 if (desc_it->GetSource().GetGenome() == CBioSource::eGenome_chromosome) { 00066 return true; 00067 } 00068 ++desc_it; 00069 } 00070 00071 return false; 00072 } 00073 00074 00075 bool CSGUtils::IsSegSet(const CBioseq_Handle& handle, CScope& scope) 00076 { 00077 // try to resolve the given seq-id 00078 {{ 00079 CSeq_id_Handle idh = handle.GetSeq_id_Handle(); 00080 idh = sequence::GetId(*idh.GetSeqId(), scope, sequence::eGetId_Best); 00081 }} 00082 00083 if (handle.IsSetInst_Repr() && 00084 handle.GetInst_Repr() == CSeq_inst::eRepr_seg) { 00085 return true; 00086 } 00087 00088 return false; 00089 } 00090 00091 00092 bool CSGUtils::IsmRNA(const CBioseq_Handle& handle, CScope& scope) 00093 { 00094 const CMolInfo* info = sequence::GetMolInfo(handle); 00095 if (info) { 00096 if (info->GetBiomol() == CMolInfo::eBiomol_mRNA || 00097 info->GetBiomol() == CMolInfo::eBiomol_pre_RNA || 00098 info->GetBiomol() == CMolInfo::eBiomol_tRNA || 00099 info->GetBiomol() == CMolInfo::eBiomol_snRNA || 00100 info->GetBiomol() == CMolInfo::eBiomol_scRNA || 00101 info->GetBiomol() == CMolInfo::eBiomol_cRNA || 00102 info->GetBiomol() == CMolInfo::eBiomol_snoRNA || 00103 info->GetBiomol() == CMolInfo::eBiomol_ncRNA || 00104 info->GetBiomol() == CMolInfo::eBiomol_tmRNA) { 00105 return true; 00106 } 00107 } 00108 00109 CConstRef<CSeq_id> seq_id = handle.GetSeqId(); 00110 CSeq_id_Handle idh = sequence::GetId(handle.GetSeq_id_Handle(), scope, 00111 sequence::eGetId_Best); 00112 if (idh) { 00113 seq_id = idh.GetSeqId(); 00114 } 00115 00116 CSeq_id::EAccessionInfo id_info = seq_id->IdentifyAccession(); 00117 00118 if ((id_info & CSeq_id::eAcc_division_mask) == CSeq_id::eAcc_est || 00119 id_info == CSeq_id::eAcc_refseq_mrna || 00120 id_info == CSeq_id::eAcc_refseq_mrna_predicted || 00121 id_info == CSeq_id::eAcc_gpipe_mrna) { 00122 return true; 00123 } 00124 00125 return false; 00126 } 00127 00128 00129 bool CSGUtils::IsRefSeq(const objects::CBioseq_Handle& handle) 00130 { 00131 CConstRef<CSeq_id> seq_id = handle.GetSeqId(); 00132 CSeq_id::EAccessionInfo info = seq_id->IdentifyAccession(); 00133 if (info == CSeq_id::eAcc_refseq_chromosome //NC 00134 || info == CSeq_id::eAcc_refseq_contig //NT 00135 || info == CSeq_id::eAcc_refseq_genome //NS 00136 || info == CSeq_id::eAcc_refseq_genomic //NG 00137 || info == CSeq_id::eAcc_refseq_mrna //NM 00138 || info == CSeq_id::eAcc_refseq_mrna_predicted //XM 00139 || info == CSeq_id::eAcc_refseq_ncrna //NR 00140 || info == CSeq_id::eAcc_refseq_ncrna_predicted //XR 00141 || info == CSeq_id::eAcc_refseq_prot //NP 00142 || info == CSeq_id::eAcc_refseq_prot_predicted //XP 00143 || info == CSeq_id::eAcc_refseq_unreserved //AA 00144 || info == CSeq_id::eAcc_refseq_wgs_intermed 00145 || info == CSeq_id::eAcc_refseq_wgs_nuc //NZ 00146 || info == CSeq_id::eAcc_refseq_wgs_prot // ZP 00147 ) { 00148 return true; 00149 } 00150 return false; 00151 } 00152 00153 00154 bool CSGUtils::IsMainFeature(int type, int subtype) 00155 { 00156 return (subtype == CSeqFeatData::eSubtype_exon || 00157 subtype == CSeqFeatData::eSubtype_misc_RNA || 00158 type == CSeqFeatData::e_Gene || 00159 type == CSeqFeatData::e_Cdregion || 00160 type == CSeqFeatData::e_Rna); 00161 } 00162 00163 00164 /////////////////////////////////////////////////////////////////////////////// 00165 /// CTimedReporter implementation 00166 /////////////////////////////////////////////////////////////////////////////// 00167 int CTimedReporter::m_Indent = -CTimedReporter::m_Step; 00168 00169 CTimedReporter::CTimedReporter(const string& str) 00170 : m_Tag(str) 00171 { 00172 m_Indent += m_Step; 00173 m_sw.Start(); 00174 LOG_POST(Info << string(m_Indent, ' ') << m_Tag << ": started"); 00175 //cout << string(m_Indent, ' ') << m_Tag << ": started" << endl; 00176 00177 } 00178 00179 CTimedReporter::~CTimedReporter() 00180 { 00181 LOG_POST(Info << string(m_Indent, ' ') << m_Tag << ": finished: " 00182 << (m_sw.Elapsed() > 0.2 ? "---------------" : "") 00183 << size_t(m_sw.Elapsed() * 1000) << "msec"); 00184 /* 00185 cout << string(m_Indent, ' ') << m_Tag << ": finished: " 00186 << (m_sw.Elapsed() > 0.2 ? "---------------" : "") 00187 << size_t(m_sw.Elapsed() * 1000) << "msec" << endl; 00188 */ 00189 m_Indent -= m_Step; 00190 }; 00191 00192 00193 00194 END_NCBI_SCOPE
1.7.5.1
Modified on Wed May 23 13:07:21 2012 by modify_doxy.py rev. 337098