NCBI C++ ToolKit
id_mapper_num_assembly.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: id_mapper_num_assembly.cpp 45427 2020-07-30 04:20:17Z rudnev $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Roman Katargin
27  *
28  * File Description: id remapping class
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
35 
37 
40 
41 CIdMapperNumAssembly::CIdMapperNumAssembly (const string &mappingAssembly, IGencollSvcErrors *svcErrors)
42 {
43  // usage of this class has not been found anywhere
44  // the call to GetGCAssembly() is coded as if it used only from GBench
45  // if it's ever to be used from SViewer, revisit this logic
46  CRef<CGC_Assembly> assm = CGencollSvc::GetInstance()->GetGCAssembly(mappingAssembly, true, "Gbench", svcErrors, true);
47  if (assm) {
49  scope->AddDefaults();
51  m_GCAssemblyMapper.reset(new CIdMapperGCAssembly(*scope, *assm, alias));
52  }
53 
54  m_NumMapper.reset(new CIdMapper());
55 
57 }
58 
59 
61 {
63  scope->AddDefaults();
65  m_GCAssemblyMapper.reset(new CIdMapperGCAssembly(*scope, *assm, alias));
66 
67  m_NumMapper.reset(new CIdMapper());
68 
70 }
71 
72 
74 {
75  CSeq_id_Handle h = m_NumMapper->Map(id);
76  if (!m_GCAssemblyMapper)
77  return h;
78  return m_GCAssemblyMapper->Map(h ? h : id);
79 }
80 
82 {
83  CRef<CSeq_loc> ret = m_NumMapper->Map(loc);
84  if (!m_GCAssemblyMapper)
85  return ret;
86  return m_GCAssemblyMapper->Map(ret ? *ret : loc);
87 }
88 
90 {
91  for (int i = 1; i <= 22; ++i) {
92  string strId = NStr::NumericToString(i);
94  CSeq_id target(CSeq_id::e_Local, "chr" + strId);
96  }
97 
98  {
100  CSeq_id target(CSeq_id::e_Local, "chrX");
102  }
103 
104  {
106  CSeq_id target(CSeq_id::e_Local, "chrY");
108  }
109 
110  {
112  CSeq_id target(CSeq_id::e_Local, "chrM");
114  }
115 
116  {
118  CSeq_id target(CSeq_id::e_Local, "chrM");
120  }
121 }
122 
bool IsRefSeq() const
Is this assembly a RefSeq assembly?
static CRef< CGencollSvc > GetInstance(void)
Definition: gencoll_svc.cpp:54
IdMapper implementation using a GC-Assembly.
Definition: idmapper.hpp:370
EAliasMapping
Mapping destination type.
Definition: idmapper.hpp:375
@ eGenBankAcc
GenBank accession.
Definition: idmapper.hpp:377
@ eRefSeqAcc
RefSeq accession.
Definition: idmapper.hpp:379
unique_ptr< objects::CIdMapperGCAssembly > m_GCAssemblyMapper
CIdMapperNumAssembly(const string &mappingAcc, IGencollSvcErrors *svcErrors=nullptr)
virtual objects::CSeq_id_Handle Map(const objects::CSeq_id_Handle &id)
unique_ptr< objects::CIdMapper > m_NumMapper
IdMapper base class implementation.
Definition: idmapper.hpp:56
CScope –.
Definition: scope.hpp:92
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
void AddDefaults(TPriority pri=kPriority_Default)
Add default data loaders from object manager.
Definition: scope.cpp:504
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
@ e_Local
local use
Definition: Seq_id_.hpp:95
USING_SCOPE(objects)
int i
const CharType(& source)[N]
Definition: pointer.h:1149
The Object manager core.
Modified on Fri Jul 19 17:10:54 2024 by modify_doxy.py rev. 669887