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

Go to the SVN repository for this file.

1 /* $Id: test_objmgr.cpp 102081 2024-03-28 14:38:47Z grichenk $
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: Christiam Camacho
27 *
28 * File Description:
29 * Singleton class to facilitate the creation of SSeqLocs
30 *
31 * ===========================================================================
32 */
33 #include <ncbi_pch.hpp>
34 #include "test_objmgr.hpp"
36 #include <objmgr/scope.hpp>
38 #include <objmgr/util/sequence.hpp>
39 
43 
45 #include <corelib/test_boost.hpp>
46 
47 #ifndef SKIP_DOXYGEN_PROCESSING
48 
50 USING_SCOPE(blast);
51 
52 unique_ptr<CTestObjMgr> CTestObjMgr::m_Instance;
53 
55 {
56 
58  if (!m_ObjMgr) {
59  throw std::runtime_error("Could not initialize object manager");
60  }
62 }
63 
65 {
66 }
67 
70 {
71  if (m_Instance == NULL) {
72  m_Instance.reset(new CTestObjMgr());
73  }
74  return *m_Instance;
75 }
76 
79 {
80  return *m_ObjMgr;
81 }
82 
83 SSeqLoc*
85 {
86  CRef<CSeq_loc> seqloc(new CSeq_loc());
87  CRef<CScope> scope(new CScope(GetObjMgr()));
88  scope->AddDefaults();
89 
90  seqloc->SetInt().SetFrom(0);
91  seqloc->SetInt().SetTo(sequence::GetLength(id, scope)-1);
92  seqloc->SetInt().SetStrand(strand);
93  seqloc->SetInt().SetId().Assign(id);
94 
95  return new SSeqLoc(seqloc, scope);
96 }
97 
98 SSeqLoc*
100  pair<TSeqPos, TSeqPos> range,
101  ENa_strand strand)
102 {
103  CRef<CSeq_loc> seqloc(new CSeq_loc());
104  CRef<CScope> scope(new CScope(GetObjMgr()));
105  scope->AddDefaults();
106 
107  seqloc->SetInt().SetFrom(range.first);
108  seqloc->SetInt().SetTo(range.second);
109  seqloc->SetInt().SetStrand(strand);
110  seqloc->SetInt().SetId().Assign(id);
111 
112  return new SSeqLoc(seqloc, scope);
113 }
114 
115 SSeqLoc*
117  TSeqRange const & sr,
118  ENa_strand strand)
119 {
120  return CreateSSeqLoc(id, make_pair(sr.GetFrom(), sr.GetTo()), strand);
121 }
122 
123 SSeqLoc*
125 {
126  CRef<CSeq_loc> seqloc(new CSeq_loc());
127  CRef<CScope> scope(new CScope(GetObjMgr()));
128  scope->AddDefaults();
129 
130  seqloc->SetWhole(id);
131 
132  return new SSeqLoc(seqloc, scope);
133 }
134 
135 SSeqLoc*
137 {
138  CRef<CSeq_loc> seqloc(new CSeq_loc());
139  CRef<CScope> scope(new CScope(GetObjMgr()));
140  scope->AddDefaults();
141 
142  seqloc->SetEmpty(id);
143 
144  return new SSeqLoc(seqloc, scope);
145 }
146 
149 {
150  CRef<CSeq_loc> seqloc(new CSeq_loc());
151  CRef<CScope> scope(new CScope(GetObjMgr()));
152  scope->AddDefaults();
153 
154  seqloc->SetInt().SetFrom(0);
155  seqloc->SetInt().SetTo(sequence::GetLength(id, scope)-1);
156  seqloc->SetInt().SetStrand(strand);
157  seqloc->SetInt().SetId().Assign(id);
158 
160 
162  bsq(new CBlastSearchQuery(*seqloc, *scope, mqr));
163 
164  return bsq;
165 }
166 
167 #endif /* SKIP_DOXYGEN_PROCESSING */
Search Query.
Definition: sseqloc.hpp:147
static TRegisterLoaderInfo RegisterInObjectManager(CObjectManager &om, CReader *reader=0, CObjectManager::EIsDefault is_default=CObjectManager::eDefault, CObjectManager::TPriority priority=CObjectManager::kPriority_NotSet)
Definition: gbloader.cpp:366
CObjectManager –.
CScope –.
Definition: scope.hpp:92
This class wraps the C++ Object Manager to control its lifetime and to facilitate the creation of SSe...
Definition: test_objmgr.hpp:60
blast::SSeqLoc * CreateSSeqLoc(objects::CSeq_id &id, objects::ENa_strand s=objects::eNa_strand_unknown)
CRef< blast::CBlastSearchQuery > CreateBlastSearchQuery(objects::CSeq_id &id, objects::ENa_strand s=objects::eNa_strand_unknown)
objects::CObjectManager & GetObjMgr()
Definition: test_objmgr.cpp:78
blast::SSeqLoc * CreateEmptySSeqLoc(objects::CSeq_id &id)
static CTestObjMgr & Instance()
Definition: test_objmgr.cpp:69
static unique_ptr< CTestObjMgr > m_Instance
Definition: test_objmgr.hpp:92
blast::SSeqLoc * CreateWholeSSeqLoc(objects::CSeq_id &id)
CRef< objects::CObjectManager > m_ObjMgr
Definition: test_objmgr.hpp:91
Collection of masked regions for a single query sequence.
Definition: seqlocinfo.hpp:113
#define NULL
Definition: ncbistd.hpp:225
void SetWhole(TWhole &v)
Definition: Seq_loc.hpp:982
void SetEmpty(TEmpty &v)
Definition: Seq_loc.hpp:981
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
TSeqPos GetLength(const CSeq_id &id, CScope *scope)
Get sequence length if scope not null, else return max possible TSeqPos.
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
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
range(_Ty, _Ty) -> range< _Ty >
The Object manager core.
Definition of SSeqLoc structure.
Structure to represent a single sequence to be fed to BLAST.
Definition: sseqloc.hpp:47
Utility stuff for more convenient using of Boost.Test library.
USING_SCOPE(objects)
Modified on Sun Apr 14 05:28:49 2024 by modify_doxy.py rev. 669887