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

Go to the SVN repository for this file.

1 /* $Id: autodef_available_modifier.cpp 93822 2021-05-25 16:59:44Z foleyjp $
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: Colleen Bollin
27 *
28 * File Description:
29 * Generate unique definition lines for a set of sequences using organism
30 * descriptions and feature clauses.
31 */
32 
33 #include <ncbi_pch.hpp>
34 #include <objmgr/util/autodef.hpp>
35 #include <corelib/ncbimisc.hpp>
36 #include <objmgr/seqdesc_ci.hpp>
37 #include <objmgr/bioseq_ci.hpp>
38 #include <objmgr/feat_ci.hpp>
39 #include <objmgr/util/feature.hpp>
40 
42 #include <objects/seq/Seqdesc.hpp>
43 #include <objects/seq/Bioseq.hpp>
44 
45 #include <serial/iterator.hpp>
46 
49 
51  : m_IsOrgMod(true),
52  m_SubSrcType(CSubSource::eSubtype_other),
53  m_OrgModType(COrgMod::eSubtype_other),
54  m_AllUnique (true),
55  m_AllPresent (true),
56  m_IsUnique(true)
57 {
58  m_ValueList.clear();
59 }
60 
61 
63  : m_IsOrgMod(is_orgmod),
64  m_SubSrcType(CSubSource::eSubtype_other),
65  m_OrgModType(COrgMod::eSubtype_other),
66  m_AllUnique (true),
67  m_AllPresent (true),
68  m_IsUnique(true),
69  m_IsRequested (false)
70 {
71  m_ValueList.clear();
72  if (is_orgmod) {
74  } else {
76  }
77 }
78 
80 {
81  m_IsOrgMod = copy.IsOrgMod();
82  if (m_IsOrgMod) {
83  m_OrgModType = copy.GetOrgModType();
84  } else {
85  m_SubSrcType = copy.GetSubSourceType();
86  }
87  m_AllUnique = copy.AllUnique();
88  m_AllPresent = copy.AllPresent();
89  m_IsUnique = copy.IsUnique();
90  m_IsRequested = copy.IsRequested();
91  m_ValueList.clear();
92  if (copy.m_ValueList.size() > 0) {
93  ValueFound(copy.m_ValueList[0]);
94  }
95 }
96 
97 
99 {
100 }
101 
102 
103 /**
104  CAutoDefAvailableModifier comparator
105  to sort the set properly.
106  subsources first, then orgmods
107 */
109 {
110  unsigned int this_rank = GetRank();
111  unsigned int rhs_rank = rhs.GetRank();
112 
113  if (this_rank != rhs_rank) {
114  return this_rank < rhs_rank;
115  } else if (rhs.IsOrgMod()) {
116  if (m_IsOrgMod) {
117  return m_OrgModType < rhs.GetOrgModType();
118  } else {
119  return true;
120  }
121  } else {
122  if (m_IsOrgMod) {
123  return false;
124  } else {
125  return m_SubSrcType < rhs.GetSubSourceType();
126  }
127  }
128 }
129 
130 
132 {
133  if (m_IsOrgMod) {
134  if (rhs.IsOrgMod()) {
135  return m_OrgModType == rhs.GetOrgModType();
136  } else {
137  return false;
138  }
139  } else if (rhs.IsOrgMod()) {
140  return false;
141  } else {
142  return m_SubSrcType == rhs.GetSubSourceType();
143  }
144 }
145 
146 
148 {
149  m_IsOrgMod = true;
150  m_OrgModType = orgmod_type;
151 }
152 
153 
155 {
156  m_IsOrgMod = false;
157  m_SubSrcType = subsrc_type;
158 }
159 
160 
162 {
163  bool found = false;
164  if (NStr::Equal("", val_found)) {
165  m_AllPresent = false;
166  } else {
167  for (unsigned int k = 0; k < m_ValueList.size(); k++) {
168  if (NStr::Equal(val_found, m_ValueList[k])) {
169  m_AllUnique = false;
170  found = true;
171  break;
172  }
173  }
174  if (!found && m_ValueList.size() > 0) {
175  m_IsUnique = false;
176  }
177  if (!found) {
178  m_ValueList.push_back(val_found);
179  }
180  }
181 }
182 
183 
185 {
186  if (m_ValueList.size() > 0) {
187  first_val = m_ValueList[0];
188  } else {
189  first_val = "";
190  }
191 }
192 
193 
195 {
196  if (m_ValueList.size() > 0) {
197  return true;
198  } else {
199  return false;
200  }
201 }
202 
203 
205 {
206  if (m_IsOrgMod) {
208  return 3;
209  } else if (m_OrgModType == COrgMod::eSubtype_isolate) {
210  return 5;
212  return 7;
214  return 8;
215  } else if (m_OrgModType == COrgMod::eSubtype_ecotype) {
216  return 9;
217  } else if (m_OrgModType == COrgMod::eSubtype_type) {
218  return 10;
220  return 11;
222  return 12;
223  } else if (m_OrgModType == COrgMod::eSubtype_breed) {
224  return 13;
225  }
226  } else {
228  return 0;
230  return 1;
232  return 2;
234  return 4;
236  return 6;
237  }
238  }
239  return 50;
240 }
241 
242 
244 {
245  string label;
246  switch (st) {
248  label = "endogenous virus";
249  break;
251  label = "transgenic";
252  break;
254  label = "plasmid";
255  break;
257  label = "country";
258  break;
260  label = "chromosome";
261  break;
263  label = "clone";
264  break;
266  label = "subclone";
267  break;
269  label = "haplotype";
270  break;
272  label = "haplogroup";
273  break;
275  label = "genotype";
276  break;
278  label = "sex";
279  break;
281  label = "cell line";
282  break;
284  label = "cell type";
285  break;
287  label = "tissue type";
288  break;
290  label = "clone lib";
291  break;
293  label = "dev stage";
294  break;
296  label = "frequency";
297  break;
299  label = "germline";
300  break;
302  label = "lab host";
303  break;
305  label = "pop variant";
306  break;
308  label = "tissue lib";
309  break;
311  label = "transposon";
312  break;
314  label = "insertion sequence";
315  break;
317  label = "plastid";
318  break;
320  label = "segment";
321  break;
323  label = "isolation source";
324  break;
326  label = "lat lon";
327  break;
329  label = "altitude";
330  break;
332  label = "collection date";
333  break;
335  label = "collected by";
336  break;
338  label = "identified by";
339  break;
341  label = "linkage group";
342  break;
343  default:
344  label = "";
345  break;
346  }
347  return label;
348 }
349 
350 
352 {
353  string label;
354  switch (st) {
356  label = "specific host";
357  break;
359  label = "culture";
360  break;
362  label = "common name";
363  break;
365  label = "subspecies";
366  break;
368  label = "voucher";
369  break;
371  label = "forma specialis";
372  break;
374  label = "acronym";
375  break;
377  label = "anamorph";
378  break;
380  label = "synonym";
381  break;
382  default:
384  break;
385  }
386  return label;
387 }
388 
389 
391 {
392  if (m_IsOrgMod) {
394  return "OrgMod Note";
395  } else {
397  }
398  } else {
400  return "SubSource Note";
401  } else {
403  }
404  }
405 }
406 
407 
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
void SetSubSourceType(CSubSource::ESubtype subsrc_type)
bool operator<(const CAutoDefAvailableModifier &rhs) const
CAutoDefAvailableModifier comparator to sort the set properly.
static string GetOrgModLabel(COrgMod::ESubtype st)
COrgMod::ESubtype GetOrgModType() const
static string GetSubSourceLabel(CSubSource::ESubtype st)
void SetOrgModType(COrgMod::ESubtype orgmod_type)
bool operator==(const CAutoDefAvailableModifier &rhs) const
CSubSource::ESubtype GetSubSourceType() const
@OrgMod.hpp User-defined methods of the data storage class.
Definition: OrgMod.hpp:54
static string GetSubtypeName(TSubtype stype, EVocabulary vocabulary=eVocabulary_raw)
Definition: OrgMod.cpp:108
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
Definition: ncbistr.hpp:5384
static const char label[]
@ eSubtype_collection_date
DD-MMM-YYYY format.
Definition: SubSource_.hpp:114
@ eSubtype_lat_lon
+/- decimal degrees
Definition: SubSource_.hpp:113
@ eSubtype_collected_by
name of person who collected the sample
Definition: SubSource_.hpp:115
@ eSubtype_endogenous_virus_name
Definition: SubSource_.hpp:109
@ eSubtype_identified_by
name of person who identified the sample
Definition: SubSource_.hpp:116
@ eSubtype_gb_acronym
used by taxonomy database
Definition: OrgMod_.hpp:115
@ eSubtype_gb_synonym
used by taxonomy database
Definition: OrgMod_.hpp:117
@ eSubtype_other
ASN5: old-name (254) will be added to next spec.
Definition: OrgMod_.hpp:125
@ eSubtype_authority
Definition: OrgMod_.hpp:107
@ eSubtype_sub_species
Definition: OrgMod_.hpp:105
@ eSubtype_nat_host
natural host of this specimen
Definition: OrgMod_.hpp:104
@ eSubtype_cultivar
Definition: OrgMod_.hpp:93
@ eSubtype_strain
Definition: OrgMod_.hpp:85
@ eSubtype_specimen_voucher
Definition: OrgMod_.hpp:106
@ eSubtype_serotype
Definition: OrgMod_.hpp:90
@ eSubtype_gb_anamorph
used by taxonomy database
Definition: OrgMod_.hpp:116
@ eSubtype_culture_collection
Definition: OrgMod_.hpp:118
@ eSubtype_ecotype
Definition: OrgMod_.hpp:110
@ eSubtype_forma_specialis
Definition: OrgMod_.hpp:109
@ eSubtype_isolate
Definition: OrgMod_.hpp:100
Miscellaneous common-use basic types and functionality.
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Definition: njn_matrix.hpp:613
Definition: type.c:6
Modified on Mon Mar 04 05:14:38 2024 by modify_doxy.py rev. 669887