bioseq_info.cpp
来自「ncbi源码」· C++ 代码 · 共 880 行 · 第 1/2 页
CPP
880 行
/* * =========================================================================== * PRODUCTION $Log: bioseq_info.cpp,v $ * PRODUCTION Revision 1000.4 2004/06/01 19:22:57 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.22 * PRODUCTION * =========================================================================== *//* $Id: bioseq_info.cpp,v 1000.4 2004/06/01 19:22:57 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:* Bioseq info for data source**/#include <ncbi_pch.hpp>#include <objmgr/impl/bioseq_info.hpp>#include <objmgr/impl/seq_entry_info.hpp>#include <objmgr/impl/tse_info.hpp>#include <objmgr/impl/data_source.hpp>#include <objmgr/seq_id_handle.hpp>#include <objmgr/seq_id_mapper.hpp>#include <objmgr/seq_map.hpp>#include <objects/seq/Bioseq.hpp>#include <objects/seq/Seq_inst.hpp>#include <objects/seq/Seq_data.hpp>#include <objects/seq/Seq_hist.hpp>#include <objects/seq/Seq_ext.hpp>#include <objects/seq/Seg_ext.hpp>#include <objects/seq/Delta_ext.hpp>#include <objects/seq/Delta_seq.hpp>#include <objects/seq/Seq_literal.hpp>#include <objects/seq/Ref_ext.hpp>#include <objects/seqloc/Seq_id.hpp>#include <objects/seqloc/Packed_seqint.hpp>#include <objects/seqloc/Seq_loc.hpp>#include <objects/seqloc/Seq_interval.hpp>#include <objects/seqloc/Seq_loc_mix.hpp>#include <objects/seqloc/Seq_loc_equiv.hpp>#include <objects/general/Int_fuzz.hpp>#include <algorithm>BEGIN_NCBI_SCOPEBEGIN_SCOPE(objects)//////////////////////////////////////////////////////////////////////// CBioseq_Info:://// Structure to keep bioseq's parent seq-entry along with the list// of seq-id synonyms for the bioseq.//CBioseq_Info::CBioseq_Info(CBioseq& seq){ x_SetObject(seq);}CBioseq_Info::CBioseq_Info(const CBioseq_Info& info){ x_SetObject(info);}CBioseq_Info::~CBioseq_Info(void){}CConstRef<CBioseq> CBioseq_Info::GetCompleteBioseq(void) const{ return m_Object;}CConstRef<CBioseq> CBioseq_Info::GetBioseqCore(void) const{ x_UpdateObject(); return m_Object;}void CBioseq_Info::x_DSAttachContents(CDataSource& ds){ TParent::x_DSAttachContents(ds); x_DSMapObject(m_Object, ds);}void CBioseq_Info::x_DSDetachContents(CDataSource& ds){ x_DSUnmapObject(m_Object, ds); TParent::x_DSDetachContents(ds);}void CBioseq_Info::x_DSMapObject(CConstRef<TObject> obj, CDataSource& ds){ ds.x_Map(obj, this);}void CBioseq_Info::x_DSUnmapObject(CConstRef<TObject> obj, CDataSource& ds){ ds.x_Unmap(obj, this);}void CBioseq_Info::x_TSEAttachContents(CTSE_Info& tse){ TParent::x_TSEAttachContents(tse); ITERATE ( TId, it, m_Id ) { tse.x_SetBioseqId(*it, this); }}void CBioseq_Info::x_TSEDetachContents(CTSE_Info& tse){ ITERATE ( TId, it, m_Id ) { tse.x_ResetBioseqId(*it, this); } TParent::x_TSEDetachContents(tse);}void CBioseq_Info::x_ParentAttach(CSeq_entry_Info& parent){ TParent::x_ParentAttach(parent); CSeq_entry& entry = parent.x_GetObject(); entry.ParentizeOneLevel();#ifdef _DEBUG _ASSERT(&entry.GetSeq() == m_Object); _ASSERT(m_Object->GetParentEntry() == &entry);#endif}void CBioseq_Info::x_ParentDetach(CSeq_entry_Info& parent){ //m_Object->ResetParentEntry(); TParent::x_ParentDetach(parent);}void CBioseq_Info::x_SetObject(TObject& obj){ _ASSERT(!m_Object); m_Object.Reset(&obj); if ( obj.IsSetId() ) { ITERATE ( TObject::TId, it, obj.GetId() ) { m_Id.push_back(CSeq_id_Handle::GetHandle(**it)); } } if ( obj.IsSetAnnot() ) { x_SetAnnot(); }}void CBioseq_Info::x_SetObject(const CBioseq_Info& info){ _ASSERT(!m_Object); m_Object = sx_ShallowCopy(*info.m_Object); m_Id = info.m_Id; m_SeqMap = info.m_SeqMap; if ( info.IsSetAnnot() ) { x_SetAnnot(info); }}CRef<CBioseq> CBioseq_Info::sx_ShallowCopy(const TObject& src){ CRef<TObject> obj(new TObject); if ( src.IsSetId() ) { obj->SetId() = src.GetId(); } if ( src.IsSetDescr() ) { obj->SetDescr(const_cast<TDescr&>(src.GetDescr())); } if ( src.IsSetInst() ) { CRef<TInst> inst = sx_ShallowCopy(src.GetInst()); obj->SetInst(*inst); } if ( src.IsSetAnnot() ) { obj->SetAnnot() = src.GetAnnot(); } return obj;}CRef<CSeq_inst> CBioseq_Info::sx_ShallowCopy(const TInst& src){ CRef<TInst> obj(new TInst); if ( src.IsSetRepr() ) { obj->SetRepr(src.GetRepr()); } if ( src.IsSetMol() ) { obj->SetMol(src.GetMol()); } if ( src.IsSetLength() ) { obj->SetLength(src.GetLength()); } if ( src.IsSetFuzz() ) { obj->SetFuzz(const_cast<TInst_Fuzz&>(src.GetFuzz())); } if ( src.IsSetTopology() ) { obj->SetTopology(src.GetTopology()); } if ( src.IsSetStrand() ) { obj->SetStrand(src.GetStrand()); } if ( src.IsSetSeq_data() ) { obj->SetSeq_data(const_cast<TInst_Seq_data&>(src.GetSeq_data())); } if ( src.IsSetExt() ) { obj->SetExt(const_cast<TInst_Ext&>(src.GetExt())); } if ( src.IsSetHist() ) { obj->SetHist(const_cast<TInst_Hist&>(src.GetHist())); } return obj;}bool CBioseq_Info::IsSetId(void) const{ return m_Object->IsSetId();}bool CBioseq_Info::CanGetId(void) const{ return bool(m_Object) && m_Object->CanGetId();}const CBioseq_Info::TId& CBioseq_Info::GetId(void) const{ return m_Id;}bool CBioseq_Info::HasId(const CSeq_id_Handle& id) const{ return find(m_Id.begin(), m_Id.end(), id) != m_Id.end();}void CBioseq_Info::AddId(const CSeq_id_Handle& id){ m_Id.push_back(id);}void CBioseq_Info::RemoveId(const CSeq_id_Handle& id){ TId::iterator found = find(m_Id.begin(), m_Id.end(), id); if(found != m_Id.end()) { m_Id.erase(found); }}bool CBioseq_Info::IsSetDescr(void) const{ return m_Object->IsSetDescr();}bool CBioseq_Info::CanGetDescr(void) const{ return bool(m_Object) && m_Object->CanGetDescr();}const CSeq_descr& CBioseq_Info::GetDescr(void) const{ return m_Object->GetDescr();}void CBioseq_Info::SetDescr(TDescr& v){ m_Object->SetDescr(v);}CSeq_descr& CBioseq_Info::x_SetDescr(void){ return m_Object->SetDescr();}void CBioseq_Info::ResetDescr(void){ m_Object->ResetDescr();}CBioseq::TAnnot& CBioseq_Info::x_SetObjAnnot(void){ return m_Object->SetAnnot();}void CBioseq_Info::x_ResetObjAnnot(void){ m_Object->ResetAnnot();}bool CBioseq_Info::IsSetInst(void) const{ return m_Object->IsSetInst();}bool CBioseq_Info::CanGetInst(void) const{ return bool(m_Object) && m_Object->CanGetInst();}const CBioseq_Info::TInst& CBioseq_Info::GetInst(void) const{ return m_Object->GetInst();}bool CBioseq_Info::IsSetInst_Repr(void) const{ return IsSetInst() && GetInst().IsSetRepr();}bool CBioseq_Info::CanGetInst_Repr(void) const{ return CanGetInst() && GetInst().CanGetRepr();}CBioseq_Info::TInst_Repr CBioseq_Info::GetInst_Repr(void) const{ return GetInst().GetRepr();}bool CBioseq_Info::IsSetInst_Mol(void) const{ return IsSetInst() && GetInst().IsSetMol();}bool CBioseq_Info::CanGetInst_Mol(void) const{ return CanGetInst() && GetInst().CanGetMol();}CBioseq_Info::TInst_Mol CBioseq_Info::GetInst_Mol(void) const{ return GetInst().GetMol();}bool CBioseq_Info::IsSetInst_Length(void) const{ return IsSetInst() && GetInst().IsSetLength();}bool CBioseq_Info::CanGetInst_Length(void) const{ return CanGetInst() && GetInst().CanGetLength();}CBioseq_Info::TInst_Length CBioseq_Info::GetInst_Length(void) const{ return GetInst().GetLength();}CBioseq_Info::TInst_Length CBioseq_Info::GetBioseqLength(void) const{ if ( IsSetInst_Length() ) { return GetInst_Length(); } else { return x_CalcBioseqLength(); }}bool CBioseq_Info::IsSetInst_Fuzz(void) const{ return IsSetInst() && GetInst().IsSetFuzz();}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?