annot_object.cpp
来自「ncbi源码」· C++ 代码 · 共 606 行 · 第 1/2 页
CPP
606 行
/* * =========================================================================== * PRODUCTION $Log: annot_object.cpp,v $ * PRODUCTION Revision 1000.3 2004/06/01 19:22:36 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.39 * PRODUCTION * =========================================================================== *//* $Id: annot_object.cpp,v 1000.3 2004/06/01 19:22:36 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: Aleksey Grichenko, Eugene Vasilchenko** File Description:**/#include <ncbi_pch.hpp>#include <objmgr/impl/annot_object.hpp>#include <objmgr/impl/handle_range_map.hpp>#include <objmgr/impl/seq_entry_info.hpp>#include <objmgr/impl/bioseq_base_info.hpp>#include <objmgr/impl/seq_annot_info.hpp>#include <objmgr/impl/tse_chunk_info.hpp>#include <objects/seqset/Seq_entry.hpp>#include <objects/seq/Seq_annot.hpp>#include <objects/seqloc/Seq_interval.hpp>#include <objects/seqloc/Seq_loc.hpp>#include <objects/seqalign/Dense_diag.hpp>#include <objects/seqalign/Dense_seg.hpp>#include <objects/seqalign/Std_seg.hpp>#include <objects/seqalign/Packed_seg.hpp>#include <objects/seqalign/Seq_align_set.hpp>#include <objects/seqalign/Seq_align.hpp>#include <objects/seqfeat/Seq_feat.hpp>#include <objects/seqres/Seq_graph.hpp>BEGIN_NCBI_SCOPEBEGIN_SCOPE(objects)//////////////////////////////////////////////////////////////////////// CAnnotObject_Info:://CAnnotObject_Info::CAnnotObject_Info(void) : m_Annot_Info(0), m_Object(0), m_FeatSubtype(CSeqFeatData::eSubtype_any), m_FeatType(CSeqFeatData::e_not_set), m_AnnotType(CSeq_annot::C_Data::e_not_set), m_MultiId(0){}CAnnotObject_Info::CAnnotObject_Info(const CSeq_feat& feat, CSeq_annot_Info& annot) : m_Annot_Info(&annot), m_Object(&feat), m_FeatSubtype(feat.GetData().GetSubtype()), m_FeatType(feat.GetData().Which()), m_AnnotType(CSeq_annot::C_Data::e_Ftable), m_MultiId(0){ _ASSERT(!IsChunkStub());}CAnnotObject_Info::CAnnotObject_Info(const CSeq_align& align, CSeq_annot_Info& annot) : m_Annot_Info(&annot), m_Object(&align), m_FeatSubtype(CSeqFeatData::eSubtype_any), m_FeatType(CSeqFeatData::e_not_set), m_AnnotType(CSeq_annot::C_Data::e_Align), m_MultiId(0){ _ASSERT(!IsChunkStub());}CAnnotObject_Info::CAnnotObject_Info(const CSeq_graph& graph, CSeq_annot_Info& annot) : m_Annot_Info(&annot), m_Object(&graph), m_FeatSubtype(CSeqFeatData::eSubtype_any), m_FeatType(CSeqFeatData::e_not_set), m_AnnotType(CSeq_annot::C_Data::e_Graph), m_MultiId(0){ _ASSERT(!IsChunkStub());}CAnnotObject_Info::CAnnotObject_Info(CTSE_Chunk_Info& chunk_info, const SAnnotTypeSelector& sel) : m_Annot_Info(0), m_Object(&chunk_info), m_FeatSubtype(sel.GetFeatSubtype()), m_FeatType(sel.GetFeatType()), m_AnnotType(sel.GetAnnotType()), m_MultiId(0){ _ASSERT(IsChunkStub());}CAnnotObject_Info::~CAnnotObject_Info(void){}const CTSE_Chunk_Info& CAnnotObject_Info::GetChunk_Info(void) const{ _ASSERT(IsChunkStub()); return *static_cast<const CTSE_Chunk_Info*>(m_Object.GetPointer());}void CAnnotObject_Info::GetMaps(vector<CHandleRangeMap>& hrmaps) const{ switch ( Which() ) { case CSeq_annot::C_Data::e_Ftable: { const CSeq_feat& feat = *GetFeatFast(); hrmaps.resize(feat.IsSetProduct()? 2: 1); hrmaps[0].clear(); hrmaps[0].AddLocation(feat.GetLocation()); if (hrmaps[0].GetMap().size() > 1) { m_MultiId |= fMultiId_Location; } if ( feat.IsSetProduct() ) { hrmaps[1].clear(); hrmaps[1].AddLocation(feat.GetProduct()); if (hrmaps[1].GetMap().size() > 1) { m_MultiId |= fMultiId_Product; } } break; } case CSeq_annot::C_Data::e_Graph: { const CSeq_graph& graph = *GetGraphFast(); hrmaps.resize(1); hrmaps[0].clear(); hrmaps[0].AddLocation(graph.GetLoc()); if (hrmaps[0].GetMap().size() > 1) { m_MultiId |= fMultiId_Location; } break; } case CSeq_annot::C_Data::e_Align: { const CSeq_align& align = GetAlign(); // TODO: separate alignment locations hrmaps.clear(); x_ProcessAlign(hrmaps, align, 0); break; } default: break; }}const CSeq_entry_Info& CAnnotObject_Info::GetSeq_entry_Info(void) const{ return GetSeq_annot_Info().GetParentSeq_entry_Info();}const CTSE_Info& CAnnotObject_Info::GetTSE_Info(void) const{ return GetSeq_annot_Info().GetTSE_Info();}CTSE_Info& CAnnotObject_Info::GetTSE_Info(void){ return GetSeq_annot_Info().GetTSE_Info();}CDataSource& CAnnotObject_Info::GetDataSource(void) const{ return GetSeq_annot_Info().GetDataSource();}const CSeq_feat& CAnnotObject_Info::GetFeat(void) const{ _ASSERT(!IsChunkStub() && IsFeat()); const CObject& obj = *m_Object; return dynamic_cast<const CSeq_feat&>(obj);}const CSeq_align& CAnnotObject_Info::GetAlign(void) const{ _ASSERT(!IsChunkStub() && IsAlign()); const CObject& obj = *m_Object; return dynamic_cast<const CSeq_align&>(obj);}const CSeq_graph& CAnnotObject_Info::GetGraph(void) const{ _ASSERT(!IsChunkStub() && IsGraph()); const CObject& obj = *m_Object; return dynamic_cast<const CSeq_graph&>(obj);}void CAnnotObject_Info::x_ProcessAlign(vector<CHandleRangeMap>& hrmaps, const CSeq_align& align, int loc_index_shift) const{ //### Check the implementation. switch ( align.GetSegs().Which() ) { case CSeq_align::C_Segs::e_not_set: { break; } case CSeq_align::C_Segs::e_Dendiag: { const CSeq_align::C_Segs::TDendiag& dendiag = align.GetSegs().GetDendiag(); ITERATE ( CSeq_align::C_Segs::TDendiag, it, dendiag ) { const CDense_diag& diag = **it; int dim = diag.GetDim(); if (dim != (int)diag.GetIds().size()) { ERR_POST(Warning << "Invalid 'ids' size in dendiag"); dim = min(dim, (int)diag.GetIds().size()); } if (dim != (int)diag.GetStarts().size()) { ERR_POST(Warning << "Invalid 'starts' size in dendiag"); dim = min(dim, (int)diag.GetStarts().size()); } if (diag.IsSetStrands() && dim != (int)diag.GetStrands().size()) { ERR_POST(Warning << "Invalid 'strands' size in dendiag"); dim = min(dim, (int)diag.GetStrands().size()); } if (hrmaps.size() < loc_index_shift + dim) { hrmaps.resize(loc_index_shift + dim); } TSeqPos len = (*it)->GetLen(); for (int row = 0; row < dim; ++row) { CSeq_loc loc; loc.SetInt().SetId().Assign(*(*it)->GetIds()[row]); loc.SetInt().SetFrom((*it)->GetStarts()[row]); loc.SetInt().SetTo((*it)->GetStarts()[row] + len - 1); if ( (*it)->IsSetStrands() ) { loc.SetInt().SetStrand((*it)->GetStrands()[row]); } hrmaps[loc_index_shift + row].AddLocation(loc); } } break; } case CSeq_align::C_Segs::e_Denseg: { const CSeq_align::C_Segs::TDenseg& denseg = align.GetSegs().GetDenseg(); int dim = denseg.GetDim(); int numseg = denseg.GetNumseg(); // claimed dimension may not be accurate :-/ if (numseg != (int)denseg.GetLens().size()) { ERR_POST(Warning << "Invalid 'lens' size in denseg"); numseg = min(numseg, (int)denseg.GetLens().size()); } if (denseg.IsSetScores() && numseg != (int)denseg.GetScores().size()) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?