snp_annot_info.cpp
来自「ncbi源码」· C++ 代码 · 共 711 行 · 第 1/2 页
CPP
711 行
} { // allele CSeq_feat::TQual& qual = feat.SetQual(); size_t i; const string& qual_str = m_Flags & fQualReplace? kId_replace: kId_allele; for ( i = 0; i < kMax_AllelesCount; ++i ) { TAlleleIndex allele_index = m_AllelesIndices[i]; if ( allele_index == kNo_AlleleIndex ) { break; } CGb_qual* gb_qual; if ( i < qual.size() ) { gb_qual = qual[i].GetPointer(); } else { qual.push_back(CRef<CGb_qual>(gb_qual = new CGb_qual)); CPackString::Assign(gb_qual->SetQual(), qual_str); } CPackString::Assign(gb_qual->SetVal(), annot_info.x_GetAllele(allele_index)); } qual.resize(i); } { // weight CSeq_feat::TExt::TData& data = feat.SetExt().SetData(); _ASSERT(data.size() == 1); CUser_field& user_field = *data[0]; user_field.SetData().SetInt(m_Weight); } { // snpid CSeq_feat::TDbxref& dbxref = feat.SetDbxref(); _ASSERT(dbxref.size() == 1); CDbtag& dbtag = *dbxref[0]; dbtag.SetTag().SetId(m_SNP_Id); }}void SSNP_Info::x_UpdateSeq_feat(CSeq_feat& feat, CRef<CSeq_point>& seq_point, CRef<CSeq_interval>& seq_interval, const CSeq_annot_SNP_Info& annot_info) const{ x_UpdateSeq_featData(feat, annot_info); { // location TSeqPos to_position = m_ToPosition; TPositionDelta position_delta = m_PositionDelta; int gi = annot_info.GetGi(); ENa_strand strand = MinusStrand()? eNa_strand_minus: eNa_strand_plus; if ( position_delta == 0 ) { // point feat.SetLocation().Reset(); if ( !seq_point || !seq_point->ReferencedOnlyOnce() ) { seq_point.Reset(new CSeq_point); } CSeq_point& point = *seq_point; feat.SetLocation().SetPnt(point); point.SetPoint(to_position); point.SetStrand(strand); point.SetId().SetGi(gi); } else { // interval feat.SetLocation().Reset(); if ( !seq_interval || !seq_interval->ReferencedOnlyOnce() ) { seq_interval.Reset(new CSeq_interval); } CSeq_interval& interval = *seq_interval; feat.SetLocation().SetInt(interval); interval.SetFrom(to_position-position_delta); interval.SetTo(to_position); interval.SetStrand(strand); interval.SetId().SetGi(gi); } }}void SSNP_Info::x_UpdateSeq_feat(CSeq_feat& feat, const CSeq_annot_SNP_Info& annot_info) const{ x_UpdateSeq_featData(feat, annot_info); { // location TSeqPos to_position = m_ToPosition; TPositionDelta position_delta = m_PositionDelta; int gi = annot_info.GetGi(); ENa_strand strand = MinusStrand()? eNa_strand_minus: eNa_strand_plus; if ( position_delta == 0 ) { // point CSeq_point& point = feat.SetLocation().SetPnt(); point.SetPoint(to_position); point.SetStrand(strand); point.SetId().SetGi(gi); } else { // interval CSeq_interval& interval = feat.SetLocation().SetInt(); interval.SetFrom(to_position-position_delta); interval.SetTo(to_position); interval.SetStrand(strand); interval.SetId().SetGi(gi); } }}CRef<CSeq_feat>SSNP_Info::CreateSeq_feat(const CSeq_annot_SNP_Info& annot_info) const{ CRef<CSeq_feat> feat_ref = x_CreateSeq_feat(); x_UpdateSeq_feat(*feat_ref, annot_info); return feat_ref;}void SSNP_Info::UpdateSeq_feat(CRef<CSeq_feat>& feat_ref, const CSeq_annot_SNP_Info& annot_info) const{ if ( !feat_ref || !feat_ref->ReferencedOnlyOnce() ) { feat_ref = x_CreateSeq_feat(); } x_UpdateSeq_feat(*feat_ref, annot_info);}void SSNP_Info::UpdateSeq_feat(CRef<CSeq_feat>& feat_ref, CRef<CSeq_point>& seq_point, CRef<CSeq_interval>& seq_interval, const CSeq_annot_SNP_Info& annot_info) const{ if ( !feat_ref || !feat_ref->ReferencedOnlyOnce() ) { feat_ref = x_CreateSeq_feat(); } x_UpdateSeq_feat(*feat_ref, seq_point, seq_interval, annot_info);}/////////////////////////////////////////////////////////////////////////////// CSeq_annot_SNP_Info/////////////////////////////////////////////////////////////////////////////CSeq_annot_SNP_Info::CSeq_annot_SNP_Info(void) : m_Gi(-1){}CSeq_annot_SNP_Info::CSeq_annot_SNP_Info(const CSeq_annot_SNP_Info& info) : m_Gi(info.m_Gi), m_SNP_Set(info.m_SNP_Set), m_Comments(info.m_Comments), m_Alleles(info.m_Alleles), m_Seq_annot(info.m_Seq_annot){}CSeq_annot_SNP_Info::~CSeq_annot_SNP_Info(void){}const CSeq_annot_Info& CSeq_annot_SNP_Info::GetParentSeq_annot_Info(void) const{ return static_cast<const CSeq_annot_Info&>(GetBaseParent_Info());}CSeq_annot_Info& CSeq_annot_SNP_Info::GetParentSeq_annot_Info(void){ return static_cast<CSeq_annot_Info&>(GetBaseParent_Info());}const CSeq_entry_Info& CSeq_annot_SNP_Info::GetParentSeq_entry_Info(void) const{ return GetParentSeq_annot_Info().GetParentSeq_entry_Info();}CSeq_entry_Info& CSeq_annot_SNP_Info::GetParentSeq_entry_Info(void){ return GetParentSeq_annot_Info().GetParentSeq_entry_Info();}void CSeq_annot_SNP_Info::x_ParentAttach(CSeq_annot_Info& parent){ x_BaseParentAttach(parent);}void CSeq_annot_SNP_Info::x_ParentDetach(CSeq_annot_Info& parent){ x_BaseParentDetach(parent);}void CSeq_annot_SNP_Info::x_UpdateAnnotIndexContents(CTSE_Info& tse){ CSeq_id_Handle idh = CSeq_id_Handle::GetGiHandle(GetGi()); tse.x_MapSNP_Table(GetParentSeq_annot_Info().GetName(), idh, *this); TParent::x_UpdateAnnotIndexContents(tse);}void CSeq_annot_SNP_Info::x_UnmapAnnotObjects(CTSE_Info& tse){ CSeq_id_Handle idh = CSeq_id_Handle::GetGiHandle(GetGi()); tse.x_UnmapSNP_Table(GetParentSeq_annot_Info().GetName(), idh, *this);}void CSeq_annot_SNP_Info::x_DropAnnotObjects(CTSE_Info& /*tse*/){}void CSeq_annot_SNP_Info::x_DoUpdateObject(void){}size_t CIndexedStrings::GetIndex(const string& s, size_t max_index){ TIndices::iterator it = m_Indices.lower_bound(s); if ( it != m_Indices.end() && it->first == s ) { return it->second; } size_t index = m_Strings.size(); if ( index <= max_index ) { //NcbiCout << "string["<<index<<"] = \"" << s << "\"\n"; m_Strings.push_back(s); m_Indices.insert(it, TIndices::value_type(s, index)); } else { _ASSERT(index == max_index + 1); } return index;}SSNP_Info::TAlleleIndexCSeq_annot_SNP_Info::x_GetAlleleIndex(const string& allele){ if ( allele.size() > SSNP_Info::kMax_AlleleLength ) return SSNP_Info::kNo_AlleleIndex; if ( m_Alleles.IsEmpty() ) { // prefill by small alleles for ( const char* c = "-NACGT"; *c; ++c ) { m_Alleles.GetIndex(string(1, *c), SSNP_Info::kMax_AlleleIndex); } for ( const char* c1 = "ACGT"; *c1; ++c1 ) { string s(1, *c1); for ( const char* c2 = "ACGT"; *c2; ++c2 ) { m_Alleles.GetIndex(s+*c2, SSNP_Info::kMax_AlleleIndex); } } } return m_Alleles.GetIndex(allele, SSNP_Info::kMax_AlleleIndex);}void CSeq_annot_SNP_Info::x_SetGi(int gi){ _ASSERT(m_Gi == -1); m_Gi = gi; _ASSERT(!m_Seq_id); m_Seq_id.Reset(new CSeq_id); m_Seq_id->SetGi(gi);}void CSeq_annot_SNP_Info::Reset(void){ m_Gi = -1; m_Seq_id.Reset(); m_Comments.Clear(); m_Alleles.Clear(); m_SNP_Set.clear(); m_Seq_annot.Reset();}END_SCOPE(objects)END_NCBI_SCOPE/* * $Log: snp_annot_info.cpp,v $ * Revision 1000.3 2004/06/01 19:24:32 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.13 * * Revision 1.13 2004/05/21 21:42:13 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.12 2004/03/24 18:30:30 vasilche * Fixed edit API. * Every *_Info object has its own shallow copy of original object. * * Revision 1.11 2004/03/16 15:47:28 vasilche * Added CBioseq_set_Handle and set of EditHandles * * Revision 1.10 2004/02/06 16:13:20 vasilche * Added parsing "replace" as a synonym of "allele" in SNP qualifiers. * More compact format of SNP table in cache. SNP table version increased. * Fixed null pointer exception when SNP features are loaded from cache. * * Revision 1.9 2004/01/28 20:54:36 vasilche * Fixed mapping of annotations. * * Revision 1.8 2004/01/13 16:55:34 vasilche * CReader, CSeqref and some more classes moved from xobjmgr to separate lib. * Headers moved from include/objmgr to include/objtools/data_loaders/genbank. * * Revision 1.7 2003/11/26 17:56:00 vasilche * Implemented ID2 split in ID1 cache. * Fixed loading of splitted annotations. * * Revision 1.6 2003/10/21 14:27:35 vasilche * Added caching of gi -> sat,satkey,version resolution. * SNP blobs are stored in cache in preprocessed format (platform dependent). * Limit number of connections to GenBank servers. * Added collection of ID1 loader statistics. * * Revision 1.5 2003/09/30 16:22:04 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.4 2003/08/27 14:29:53 vasilche * Reduce object allocations in feature iterator. * * Revision 1.3 2003/08/19 18:35:21 vasilche * CPackString classes were moved to SERIAL library. * * Revision 1.2 2003/08/15 19:19:16 vasilche * Fixed memory leak in string packing hooks. * Fixed processing of 'partial' flag of features. * Allow table packing of non-point SNP. * Allow table packing of SNP with long alleles. * * Revision 1.1 2003/08/14 20:05:19 vasilche * Simple SNP features are stored as table internally. * They are recreated when needed using CFeat_CI. * */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?