seq_annot_ci.cpp
来自「ncbi源码」· C++ 代码 · 共 276 行
CPP
276 行
/* * =========================================================================== * PRODUCTION $Log: seq_annot_ci.cpp,v $ * PRODUCTION Revision 1000.2 2004/06/01 19:23:46 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8 * PRODUCTION * =========================================================================== *//* $Id: seq_annot_ci.cpp,v 1000.2 2004/06/01 19:23:46 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:* Seq-annot iterator**/#include <ncbi_pch.hpp>#include <objmgr/seq_annot_ci.hpp>#include <objmgr/objmgr_exception.hpp>#include <objmgr/scope.hpp>#include <objmgr/seq_entry_handle.hpp>#include <objmgr/impl/seq_entry_info.hpp>#include <objmgr/impl/bioseq_set_info.hpp>BEGIN_NCBI_SCOPEBEGIN_SCOPE(objects)CSeq_annot_CI::SEntryLevel_CI::SEntryLevel_CI(const CBioseq_set_Info& seqset, const TEntry_CI& iter) : m_Set(&seqset), m_Iter(iter){}CSeq_annot_CI::SEntryLevel_CI::SEntryLevel_CI(const SEntryLevel_CI& l) : m_Set(l.m_Set), m_Iter(l.m_Iter){}CSeq_annot_CI::SEntryLevel_CI&CSeq_annot_CI::SEntryLevel_CI::operator=(const SEntryLevel_CI& l){ m_Set = l.m_Set; m_Iter = l.m_Iter; return *this;}CSeq_annot_CI::SEntryLevel_CI::~SEntryLevel_CI(void){}CSeq_annot_CI::CSeq_annot_CI(void) : m_UpTree(false){}CSeq_annot_CI::~CSeq_annot_CI(void){}CSeq_annot_CI::CSeq_annot_CI(const CSeq_annot_CI& iter) : m_UpTree(false){ *this = iter;}CSeq_annot_CI& CSeq_annot_CI::operator=(const CSeq_annot_CI& iter){ if (this != &iter) { m_CurrentEntry = iter.m_CurrentEntry; m_AnnotIter = iter.m_AnnotIter; m_CurrentAnnot = iter.m_CurrentAnnot; m_EntryStack = iter.m_EntryStack; m_UpTree = iter.m_UpTree; } return *this;}CSeq_annot_CI::CSeq_annot_CI(CScope& scope, const CSeq_entry& entry, EFlags flags) : m_Scope(scope), m_UpTree(false){ x_Initialize(scope.GetSeq_entryHandle(entry), flags);}CSeq_annot_CI::CSeq_annot_CI(const CSeq_entry_Handle& entry, EFlags flags) : m_Scope(entry.GetScope()), m_UpTree(false){ x_Initialize(entry, flags);}CSeq_annot_CI::CSeq_annot_CI(const CBioseq_Handle& bioseq) : m_Scope(bioseq.GetScope()), m_UpTree(true){ x_Initialize(bioseq.GetParentEntry(), eSearch_entry);}CSeq_annot_CI::CSeq_annot_CI(const CBioseq_set_Handle& bioseq_set, EFlags flags) : m_Scope(bioseq_set.GetScope()), m_UpTree(false){ x_Initialize(bioseq_set.GetParentEntry(), flags);}inlinevoid CSeq_annot_CI::x_Push(void){ if ( m_CurrentEntry->IsSet() ) { const CBioseq_set_Info& set = m_CurrentEntry->GetSet(); m_EntryStack.push(SEntryLevel_CI(set, set.GetSeq_set().begin())); }}inlinevoid CSeq_annot_CI::x_SetEntry(const CSeq_entry_Info& entry){ m_CurrentEntry.Reset(&entry); m_AnnotIter = entry.m_Contents->GetAnnot().begin(); if ( !m_EntryStack.empty() ) { x_Push(); }}void CSeq_annot_CI::x_Initialize(const CSeq_entry_Handle& entry, EFlags flags){ if ( !entry ) { NCBI_THROW(CAnnotException, eFindFailed, "Can not find seq-entry in the scope"); } if ( entry.Which() == CSeq_entry::e_not_set ) { NCBI_THROW(CAnnotException, eFindFailed, "seq-entry is empty"); } x_SetEntry(entry.x_GetInfo()); if ( flags == eSearch_recursive ) { x_Push(); } x_Settle();}CSeq_annot_CI& CSeq_annot_CI::operator++(void){ _ASSERT(*this); ++m_AnnotIter; x_Settle(); return *this;}void CSeq_annot_CI::x_Settle(void){ for ( ;; ) { if ( m_AnnotIter != m_CurrentEntry->m_Contents->GetAnnot().end() ) { m_CurrentAnnot = CSeq_annot_Handle(GetScope(), **m_AnnotIter); return; } if ( m_UpTree ) { // Iterating from a bioseq up to its TSE if ( m_CurrentEntry->HasParent_Info() ) { x_SetEntry(m_CurrentEntry->GetParentSeq_entry_Info()); continue; } m_CurrentAnnot = CSeq_annot_Handle(); return; } if ( m_EntryStack.empty() ) { m_CurrentAnnot = CSeq_annot_Handle(); return; } if ( m_EntryStack.top().m_Iter != m_EntryStack.top().m_Set->GetSeq_set().end() ) { x_SetEntry(**m_EntryStack.top().m_Iter++); } else { m_EntryStack.pop(); } }}END_SCOPE(objects)END_NCBI_SCOPE/** ---------------------------------------------------------------------------* $Log: seq_annot_ci.cpp,v $* Revision 1000.2 2004/06/01 19:23:46 gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.8** Revision 1.8 2004/05/21 21:42:13 gorelenk* Added PCH ncbi_pch.hpp** Revision 1.7 2004/04/26 14:13:46 grichenk* Added constructors from bioseq-set handle and bioseq handle.** Revision 1.6 2004/03/16 15:47:28 vasilche* Added CBioseq_set_Handle and set of EditHandles** Revision 1.5 2003/10/08 14:14:27 vasilche* Use CHeapScope instead of CRef<CScope> internally.** Revision 1.4 2003/09/30 16:22:03 vasilche* Updated internal object manager classes to be able to load ID2 data.* SNP blobs are loaded as ID2 split blobs - readers convert them automatically.* Scope caches results of requests for data to data loaders.* Optimized CSeq_id_Handle for gis.* Optimized bioseq lookup in scope.* Reduced object allocations in annotation iterators.* CScope is allowed to be destroyed before other objects using this scope are* deleted (feature iterators, bioseq handles etc).* Optimized lookup for matching Seq-ids in CSeq_id_Mapper.* Added 'adaptive' option to objmgr_demo application.** Revision 1.3 2003/09/05 17:29:40 grichenk* Structurized Object Manager exceptions** Revision 1.2 2003/07/25 21:41:30 grichenk* Implemented non-recursive mode for CSeq_annot_CI,* fixed friend declaration in CSeq_entry_Info.** Revision 1.1 2003/07/25 15:23:42 grichenk* Initial revision*** ===========================================================================*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?