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

Go to the SVN repository for this file.

1 /* $Id: editing_action_seqid.cpp 45101 2020-05-29 20:53:24Z asztalos $
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  * Authors: Igor Filippov
27  */
28 
29 #include <ncbi_pch.hpp>
31 #include <objmgr/bioseq_ci.hpp>
35 #include <objects/seq/Seq_data.hpp>
41 
42 
45 
46 
48  : IEditingAction(seh, name)
49 {
50 }
51 
53 {
54  if (!m_TopSeqEntry)
55  return;
56  size_t count = 0;
57  for (CBioseq_CI b_iter(m_TopSeqEntry, objects::CSeq_inst::eMol_na); b_iter; ++b_iter)
58  {
59  CBioseq_Handle bsh = *b_iter;
61  if (m_constraint->Match(bsh))
62  {
64  {
65  m_id = *id_iter;
66  Modify(action);
67  }
68  }
69  ++count;
70  if (count >= m_max_records)
71  break;
72  }
73 }
74 
76 {
77  Find(action);
78 }
79 
81 {
82  Action(action);
83  if (m_modified)
84  m_ChangedIds = true;
85 }
86 
88 {
89  CEditingActionSeqid *other = dynamic_cast<CEditingActionSeqid*>(m_Other);
90  if (other)
91  return true;
92  return false;
93 }
94 
96 {
97  CEditingActionSeqid *id_source = dynamic_cast<CEditingActionSeqid*>(source);
98  if (id_source)
99  {
100  swap(m_id, id_source->m_id);
101  }
103 }
104 
106 {
107  return m_id;
108 }
109 
111 {
112 }
113 
115 {
116  string value;
118  return value;
119 }
120 
122 {
123 }
124 
126  : CEditingActionSeqid(seh, "CEditingActionFileId")
127 {
128 }
129 
131 {
132  CEditingActionFileId *other = dynamic_cast<CEditingActionFileId*>(m_Other);
133  if (other)
134  return true;
135  return false;
136 }
137 
139 {
140  return m_id && m_id->IsGeneral() && m_id->GetGeneral().IsSetDb()
141  && NStr::EqualCase(m_id->GetGeneral().GetDb(), "NCBIFILE");
142 }
143 
145 {
146  string value;
148  NStr::TrimPrefixInPlace(value, "NCBIFILE:");
149  return value;
150 }
151 
153  : CEditingActionSeqid(seh, "CEditingActionEntireGeneralId")
154 {
155 }
156 
158 {
160  if (other)
161  return true;
162  return false;
163 }
164 
166 {
167  return m_id && m_id->IsGeneral();
168 }
169 
171 {
172  string value;
174  return value;
175 }
176 
178  : CEditingActionSeqid(seh, "CEditingActionGeneralIdDb")
179 {
180 }
181 
183 {
185  if (other)
186  return true;
187  return false;
188 }
189 
191 {
192  return m_id && m_id->IsGeneral() && m_id->GetGeneral().IsSetDb();
193 }
194 
196 {
197  return m_id->GetGeneral().GetDb();
198 }
199 
201  : CEditingActionSeqid(seh, "CEditingActionGeneralIdTag"), m_db(db)
202 {
203 }
204 
206 {
208  if (other)
209  return true;
210  return false;
211 }
212 
214 {
215  return m_id && m_id->IsGeneral() && m_id->GetGeneral().IsSetTag()
217 }
218 
220 {
221  CNcbiOstrstream ostr;
222  m_id->GetGeneral().GetTag().AsString(ostr);
223  return CNcbiOstrstreamToString(ostr);
224 }
225 
227 {
228  if (field == "SeqId")
229  return new CEditingActionSeqid(seh);
230  if (field == "File ID")
231  return new CEditingActionFileId(seh);
232  if (field == "Entire General ID")
233  return new CEditingActionEntireGeneralId(seh);
234  if (field == "General ID DB")
235  return new CEditingActionGeneralIdDb(seh);
236  if (NStr::StartsWith(field, "General ID Tag"))
237  {
238  string db = field;
239  NStr::TrimPrefixInPlace(db, "General ID Tag");
240  NStr::TrimPrefixInPlace(db," ");
241  return new CEditingActionGeneralIdTag(seh, db);
242  }
243 
244  return NULL;
245 }
246 
247 
248 
250 
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
void GetLabel(string *label) const
Definition: Dbtag.cpp:187
virtual bool Match(const string &value)
CEditingActionEntireGeneralId(CSeq_entry_Handle seh)
CEditingActionFileId(CSeq_entry_Handle seh)
virtual bool IsSetValue(void)
virtual string GetValue(void)
CEditingActionGeneralIdDb(CSeq_entry_Handle seh)
CEditingActionGeneralIdTag(CSeq_entry_Handle seh, const string &db)
virtual void SwapContext(IEditingAction *source)
virtual void SetValue(const string &value)
virtual void FindRelated(EActionType action)
virtual void Find(EActionType action)
CEditingActionSeqid(CSeq_entry_Handle seh, const string &name="CEditingActionSeqid")
virtual string GetValue(void)
virtual bool IsSetValue(void)
virtual void Modify(EActionType action)
virtual void ResetValue(void)
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
ostream & AsString(ostream &s) const
Definition: Object_id.cpp:202
CSeq_entry_Handle –.
CSeq_entry_Handle m_TopSeqEntry
IEditingAction * m_Other
CSeq_entry_Handle m_CurrentSeqEntry
void Action(EActionType action)
virtual void SwapContext(IEditingAction *source)
CRef< CEditingActionConstraint > m_constraint
char value[7]
Definition: config.c:431
USING_SCOPE(objects)
CEditingActionSeqid * CreateActionSeqid(CSeq_entry_Handle seh, const string &field)
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
Definition: ncbimisc.hpp:1508
#define NULL
Definition: ncbistd.hpp:225
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
Definition: Seq_id.cpp:2039
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:573
TBioseqCore GetBioseqCore(void) const
Get bioseq core structure.
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
#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 bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
static bool EqualCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive equality of a substring with another string.
Definition: ncbistr.hpp:5325
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5412
static void TrimPrefixInPlace(string &str, const CTempString prefix, ECase use_case=eCase)
Trim prefix from a string (in-place)
Definition: ncbistr.cpp:3238
bool IsSetDb(void) const
name of database or system Check if a value has been assigned to Db data member.
Definition: Dbtag_.hpp:208
const TTag & GetTag(void) const
Get the Tag member data.
Definition: Dbtag_.hpp:267
bool IsSetTag(void) const
appropriate tag Check if a value has been assigned to Tag data member.
Definition: Dbtag_.hpp:255
const TDb & GetDb(void) const
Get the Db member data.
Definition: Dbtag_.hpp:220
bool IsGeneral(void) const
Check if variant General is selected.
Definition: Seq_id_.hpp:877
const TGeneral & GetGeneral(void) const
Get the variant data.
Definition: Seq_id_.cpp:369
const CharType(& source)[N]
Definition: pointer.h:1149
The Object manager core.
Utility macros and typedefs for exploring NCBI objects from seq.asn.
#define FOR_EACH_SEQID_ON_BIOSEQ(Itr, Var)
FOR_EACH_SEQID_ON_BIOSEQ EDIT_EACH_SEQID_ON_BIOSEQ.
Definition: seq_macros.hpp:308
Modified on Wed Mar 27 11:17:24 2024 by modify_doxy.py rev. 669887