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

Go to the SVN repository for this file.

1 /* $Id: srcedit_util.cpp 47485 2023-05-02 14:46:59Z ucko $
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: Colleen Bollin, J. Chen
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
32 #include <util/static_map.hpp>
38 #include <objects/biblio/Affil.hpp>
51 #include <objects/seq/Bioseq.hpp>
54 #include <objmgr/seqdesc_ci.hpp>
55 #include <objmgr/bioseq_ci.hpp>
56 #include <objmgr/feat_ci.hpp>
57 
67 
72 
76 
80 
82 {
83  m_Name = "";
84  m_Required = false;
85  m_ReportMissing = false;
86  m_Example = "";
87 }
88 
89 
90 CSrcQual::CSrcQual(string name, bool required, bool report_missing, string example)
91 : m_Name (name), m_Required (required), m_ReportMissing (report_missing), m_Example (example)
92 {
93 }
94 
96 {
97 }
98 
99 
100 string CSrcQual::GetValue(const CBioSource& src)
101 {
102  return "";
103 }
104 
106 {
107  if (src.IsSetOrg() && src.GetOrg().IsSetTaxname()) {
108  return src.GetOrg().GetTaxname();
109  } else {
110  return "";
111  }
112 }
113 
114 
116 {
117  vector<string> unwise_names;
118  unwise_names.push_back("unknown");
119  unwise_names.push_back("uncultured organism");
120  unwise_names.push_back("uncultured sample");
121  unwise_names.push_back("uncultured");
122  unwise_names.push_back("unidentified");
123 
124  vector<string>::iterator s = unwise_names.begin();
125  while (s != unwise_names.end()) {
126  if (NStr::EqualNocase(value, *s)) {
127  return "Ambiguous organism name";
128  }
129  ++s;
130  }
131  if (NStr::StartsWith (value, "uncultured ")) {
132  return "";
133  } else {
134  return "For uncultured samples, organism name should start with 'uncultured'";
135  }
136 }
137 
138 
140 {
141  string val = "";
142 
143  if (src.IsSetGenome()) {
144  int genome = src.GetGenome();
146  }
147 
148  return val;
149 }
150 
151 
152 COrgModQual::COrgModQual(string name, bool required, bool report_missing, string example)
153  : CSrcQual(name, required, report_missing, example)
154 {
156 }
157 
158 
160 {
161  if (src.IsSetOrg() && src.GetOrg().IsSetOrgname() && src.GetOrg().GetOrgname().IsSetMod()) {
162  ITERATE(COrgName::TMod, mit, src.GetOrg().GetOrgname().GetMod()) {
163  if ((*mit)->GetSubtype() == m_Subtype && (*mit)->IsSetSubname()) {
164  return (*mit)->GetSubname();
165  }
166  }
167  }
168  return "";
169 }
170 
171 
172 static bool s_IsAllNumbers (string val)
173 {
174  bool all_numbers = true;
175  if (NStr::IsBlank (val)) {
176  return false;
177  }
178  string::iterator it = val.begin();
179  while (it != val.end() && all_numbers) {
180  if (!isdigit (*it)) {
181  all_numbers = false;
182  }
183  ++it;
184  }
185  return all_numbers;
186 }
187 
188 
190 {
191  string rval = "";
192 
193  switch (m_Subtype) {
195  if (s_IsAllNumbers(value)) {
196  rval = "Invalid host";
197  }
198  break;
199  default:
200  break;
201  }
202  return rval;
203 }
204 
205 
206 CSubSrcQual::CSubSrcQual(string name, bool required, bool report_missing, string example)
207  : CSrcQual(name, required, report_missing, example)
208 {
210 
211  m_BadIsolationSourceValues.push_back("uncultured bacterium");
212  m_BadIsolationSourceValues.push_back("uncultured bacteria");
213  m_BadIsolationSourceValues.push_back("uncultured fungus");
214  m_BadIsolationSourceValues.push_back("uncultured fungi");
215  m_BadIsolationSourceValues.push_back("uncultured bacterium clone");
216  m_BadIsolationSourceValues.push_back("uncultured bacteria clone");
217  m_BadIsolationSourceValues.push_back("uncultured fungus clone");
218  m_BadIsolationSourceValues.push_back("uncultured fungi clone");
219  m_BadIsolationSourceValues.push_back("isolation source");
220 
221 }
222 
223 
225 {
226  if (src.IsSetSubtype()) {
228  if ((*mit)->GetSubtype() == m_Subtype && (*mit)->IsSetName()) {
229  return (*mit)->GetName();
230  }
231  }
232  }
233  return "";
234 }
235 
236 
238 {
239  string rval = "";
240 
241  switch (m_Subtype) {
243  if (value.length() < 3) {
244  rval = "Suspiciously short isolation source";
245  } else {
246  ITERATE (vector<string>, it, m_BadIsolationSourceValues) {
247  if (NStr::EqualNocase(value, *it)) {
248  rval = "Invalid isolation source";
249  break;
250  }
251  }
252  }
253  break;
255  if (s_IsAllNumbers(value)) {
256  rval = "Invalid country";
257  }
258  break;
259  default:
260  break;
261  }
262  return rval;
263 }
264 
265 
267 {
268  m_Requirements.clear();
269 }
270 
271 
273 {
274  for (size_t col = 0; col < m_Requirements.size(); col++) {
275  delete(m_Requirements[col]);
276  }
277  m_Requirements.clear();
278 }
279 
280 
281 void CSourceRequirements::AddRequirement(string name, bool required, string example)
282 {
283  // first, check to see if we already have requirement, increase requirement if necessary
285  if (MatchColumnName((*rit)->GetName(), name)) {
286  if (required) {
287  (*rit)->SetRequired(true);
288  }
289  if (!NStr::IsBlank(example)) {
290  (*rit)->SetExample(example);
291  }
292  return;
293  }
294  }
295 
296  if (NStr::EqualNocase(name, "uncultured taxname")) {
297  m_Requirements.push_back(new CUnculturedTaxnameQual("taxname", required, false, example));
298  } else if (IsOrgColumnName(name)) {
299  m_Requirements.push_back(new CTaxnameQual(name, required, false, example));
300  } else {
301  try {
302  m_Requirements.push_back(new CSubSrcQual(name, required, false, example));
303  } catch (CException& ) {
304  m_Requirements.push_back(new COrgModQual(name, required, false, example));
305  }
306  }
307 }
308 
309 
310 void CSourceRequirements::AddUniquenessList(vector<string> list)
311 {
312  ITERATE(vector<string>, it, list) {
313  AddRequirement(*it, false);
314  }
315  m_UniquenessLists.push_back(list);
316 }
317 
318 
320 {
321  va_list arguments;
322  vector<string> list;
323 
324  va_start ( arguments, num );
325  for ( int x = 0; x < num; x++ ) {
326  string item = va_arg ( arguments, char * );
327  AddRequirement(item, false);
328  list.push_back(item );
329  }
330  va_end ( arguments );
331 
332  m_UniquenessLists.push_back(list);
333 }
334 
335 
336 void CSourceRequirements::AddOneOfList(vector<string> list)
337 {
338  ITERATE(vector<string>, it, list) {
339  AddRequirement(*it, false);
340  }
341  m_OneOfLists.push_back(list);
342 }
343 
344 
346 {
347  va_list arguments;
348  vector<string> list;
349 
350  va_start ( arguments, num );
351  for ( int x = 0; x < num; x++ ) {
352  string item = va_arg ( arguments, char * );
353  AddRequirement(item, false);
354  list.push_back(item );
355  }
356  va_end ( arguments );
357 
358  m_OneOfLists.push_back(list);
359 }
360 
361 
362 static string s_MakeUniquenessVal (vector<CRef<CSeqTable_column> > cols, size_t row)
363 {
364  size_t i;
365  string this_val = "";
366 
367  for (i = 0; i < cols.size(); i++) {
368  // later, remove non-uniqueing characters
369  if (row < cols[i]->GetData().GetSize()) {
370  this_val += cols[i]->GetData().GetString()[row] + ";";
371  }
372  }
373  NStr::ToUpper(this_val);
374  return this_val;
375 }
376 
377 
378 int CSourceRequirements::x_AddUniquenessProblems(CRef<CSeq_table> values_table, vector<string> uniqueness_list, vector<string>& row_problems)
379 {
380  int num_duplicates = 0;
381 
382  if (values_table->GetNum_rows() < 2 || uniqueness_list.size() < 1) {
383  return 0;
384  }
385 
386  size_t j;
387  string description = uniqueness_list[0];
388  for (j = 1; j < uniqueness_list.size(); j++) {
389  description += "/" + uniqueness_list[j];
390  }
391 
392  vector<CRef<CSeqTable_column> > cols;
393  for (j = 0; j < uniqueness_list.size(); j++) {
394  CRef<CSeqTable_column> col = FindSeqTableColumnByName(values_table, uniqueness_list[j]);
395  if (col) {
396  cols.push_back(col);
397  }
398  }
399 
401 
402  vector<string> u_list;
403  int row;
404  for (row = 0; row < values_table->GetNum_rows(); row++) {
405  u_list.push_back(s_MakeUniquenessVal (cols, row));
406  }
407  sort(u_list.begin(), u_list.end());
408  vector<string>::iterator sit = u_list.begin();
409  vector<string>::iterator sit2 = sit;
410  sit2++;
411  bool is_dup = false;
412  while (sit2 != u_list.end()) {
413  if (NStr::Equal(*sit, *sit2)) {
414  // if the next value matches this one, delete it
415  sit2 = u_list.erase(sit2);
416  is_dup = true;
417  } else {
418  if (!is_dup) {
419  // if the next value does not match this one,
420  // and there were no matches, delete from the list
421  sit = u_list.erase(sit);
422  } else {
423  sit++;
424  }
425  sit2 = sit;
426  if (sit2 != u_list.end()) {
427  sit2++;
428  }
429  is_dup = false;
430  }
431  }
432  if (!is_dup && sit != u_list.end()) {
433  sit = u_list.erase(sit);
434  }
435  sit = u_list.begin();
436  while (sit != u_list.end()) {
437  bool is_first = true;
438  int first_row = 0;
439  for (row = 0; row < values_table->GetNum_rows(); row++) {
440  if (NStr::Equal(*sit, s_MakeUniquenessVal (cols, row))) {
441  if (is_first) {
442  first_row = row;
443  row_problems[row] += description + " is duplicated";
444  is_first = false;
445  } else {
446  string id_label;
447  if (id_col) {
448  id_col->GetData().GetId()[first_row]->GetLabel(&id_label);
449  } else {
450  id_label = NStr::NumericToString(first_row + 1);
451  }
452  row_problems[row] += description + " duplicates row " + id_label;
453  }
454  num_duplicates++;
455  }
456  }
457  sit++;
458  }
459  return num_duplicates;
460 }
461 
462 
463 void CSourceRequirements::x_AddOneOfProblems(CRef<CSeq_table> values_table, vector<string> one_of_list, CRef<CSeqTable_column> problems)
464 {
465  if (one_of_list.size() < 1) {
466  return;
467  }
468  size_t j;
469  string description = "Missing " + one_of_list[0];
470  for (j = 1; j < one_of_list.size(); j++) {
471  description += " or " + one_of_list[j];
472  }
473 
474  vector<CRef<CSeqTable_column> > cols;
475  for (j = 0; j < one_of_list.size(); j++) {
476  CRef<CSeqTable_column> col = FindSeqTableColumnByName(values_table, one_of_list[j]);
477  if (col) {
478  cols.push_back(col);
479  }
480  }
481 
482  int row;
483  for (row = 0; row < values_table->GetNum_rows(); row++) {
484  bool any = false;
485  for (j = 0; j < cols.size() && !any; j++) {
486  if (!NStr::IsBlank(cols[j]->GetData().GetString()[row])) {
487  any = true;
488  }
489  }
490  if (!any) {
491  if (!NStr::IsBlank(problems->SetData().SetString()[row])) {
492  problems->SetData().SetString()[row] += ", ";
493  }
494  problems->SetData().SetString()[row] += description;
495  }
496  }
497 }
498 
499 
501 {
502  string qual_report = "";
503  int row;
504  CRef<CSeqTable_column> problems (new CSeqTable_column());
505  problems->SetHeader().SetTitle(kProblems);
506  for (row = 0; row < values_table->GetNum_rows(); row++) {
507  problems->SetData().SetString().push_back("");
508  }
509 
510  // check for missing or invalid values
512  CRef<CSeqTable_column> col = FindSeqTableColumnByName (values_table, (*rit)->GetName());
513  if (col) {
514  // found value column, now validate
515  for (row = 0; row < values_table->GetNum_rows(); row++) {
516  string val = "";
517  if (col->GetData().GetSize() > (size_t) row) {
518  val = col->GetData().GetString()[row];
519  }
520  if ((*rit)->IsRequired() && NStr::IsBlank(val)) {
521  if (!NStr::IsBlank(problems->SetData().SetString()[row])) {
522  problems->SetData().SetString()[row] += ", ";
523  }
524  problems->SetData().SetString()[row] += (*rit)->GetName() + " is missing";
525  } else {
526  string tmp = (*rit)->GetFormatErrors(val);
527  if (!NStr::IsBlank(tmp)) {
528  if (!NStr::IsBlank(problems->SetData().SetString()[row])) {
529  problems->SetData().SetString()[row] += ", ";
530  }
531  problems->SetData().SetString()[row] += tmp;
532  }
533  }
534  }
535  } else {
536  for (row = 0; row < values_table->GetNum_rows(); row++) {
537  if (!NStr::IsBlank(problems->SetData().SetString()[row])) {
538  problems->SetData().SetString()[row] += ", ";
539  }
540  problems->SetData().SetString()[row] += (*rit)->GetName() + " is missing";
541  }
542  }
543  }
544 
545  size_t i;
546 
547  // check lists where at least one qualifier in the list is required
548  for (i = 0; i < m_OneOfLists.size(); i++) {
549  x_AddOneOfProblems(values_table, m_OneOfLists[i], problems);
550  }
551 
552  // if any uniqueness lists exist, at least one must be satisfied
553  if (values_table->GetNum_rows() > 1) {
554  bool found_good_combo = false;
555  int best_num = 0;
556  vector<string > uniqueness_problems;
557  vector<vector<int> > num_problems;
558  for (i = 0; i < m_UniquenessLists.size() && !found_good_combo; i++) {
559  vector<string> this_list;
560  for (row = 0; row < values_table->GetNum_rows(); row++) {
561  this_list.push_back("");
562  }
563  int num_problems = x_AddUniquenessProblems(values_table, m_UniquenessLists[i], this_list);
564  if (num_problems > 0) {
565  if (best_num == 0 || best_num > num_problems) {
566  uniqueness_problems = this_list;
567  best_num = num_problems;
568  }
569  } else {
570  found_good_combo = true;
571  }
572  }
573  if (!found_good_combo) {
574  for (i = 0; i < uniqueness_problems.size(); i++) {
575  if (!NStr::IsBlank(uniqueness_problems[i])) {
576  if (!NStr::IsBlank(problems->GetData().GetString()[i])) {
577  problems->SetData().SetString()[i] += ", ";
578  }
579  problems->SetData().SetString()[i] += uniqueness_problems[i];
580  }
581  }
582  }
583  }
584 
585  return problems;
586 }
587 
588 
589 void CSourceRequirements::PreferentiallyAddRequirement(CRef<CSeq_table> values_table, string choice1, string choice2, bool required)
590 {
591  CRef<CSeqTable_column> col1 = FindSeqTableColumnByName (values_table, choice1);
592  CRef<CSeqTable_column> col2 = FindSeqTableColumnByName (values_table, choice2);
593 
594  if (!col2) {
595  AddRequirement (choice1, required);
596  } else if (!col1) {
597  AddRequirement (choice2, required);
598  } else {
599  bool any1 = false, any2 = false;
600  for (int row = 0; row < values_table->GetNum_rows() && !any1; row++) {
601  if (!NStr::IsBlank(col1->GetData().GetString()[row])) {
602  any1 = true;
603  } else if (!NStr::IsBlank(col2->GetData().GetString()[row])) {
604  any2 = true;
605  }
606  }
607  if (any1 || !any2) {
608  AddRequirement(choice1, required);
609  } else {
610  AddRequirement(choice2, required);
611  }
612  }
613 }
614 
615 
617 {
618  if (!values_table) {
619  return;
620  }
621 
623  string val_name = (*rit)->GetName();
624  string example = (*rit)->GetExample();
625  if (NStr::IsBlank(example)) {
626  val_name += "\n";
627  } else {
628  val_name += "\n[" + example + "]";
629  }
630  CRef<CSeqTable_column> col = FindSeqTableColumnByName (values_table, val_name);
631  if (col) {
632  col->SetHeader().SetTitle(val_name);
633  } else {
635  new_col->SetHeader().SetTitle(val_name);
636  while (new_col->SetData().SetString().size() < (size_t) values_table->GetNum_rows()) {
637  new_col->SetData().SetString().push_back ("");
638  }
639  values_table->SetColumns().push_back(new_col);
640  }
641  }
642 }
643 
644 
645 typedef struct exampletable {
646  string field_name;
648  int src_type;
649  string example;
651 
652 
657  { "organism name", CSourceRequirements::eWizardType_viruses, CSourceRequirements::eWizardSrcType_virus_foot_and_mouth, "Foot-and-mouth disease virus - type O" } ,
658  { "organism name", CSourceRequirements::eWizardType_viruses, -1, "Tula virus" } ,
660  { "organism name", -1, CSourceRequirements::eWizardSrcType_cultured_fungus, "Morchella esculenta" } ,
661  { "organism name", -1, CSourceRequirements::eWizardSrcType_vouchered_fungus, "Morchella esculenta" } ,
662  { "organism name", CSourceRequirements::eWizardType_rrna_its_igs, -1, "Taxodium distichum" } ,
663  { "organism name", CSourceRequirements::eWizardType_igs, -1, "Taxodium distichum" } ,
664  { "organism name", CSourceRequirements::eWizardType_tsa, -1, "Homo sapiens" } ,
665  { "organism name", CSourceRequirements::eWizardType_d_loop, -1, "Coffea arabica" } ,
666  { "organism name", CSourceRequirements::eWizardType_microsatellite, -1, "Coffea arabica" } ,
667  { "Collection-date", -1, -1, "05-Feb-2005" } ,
668  { "Collection-date", CSourceRequirements::eWizardType_viruses, -1, "01-Jan-2011" } ,
669  { kHost, CSourceRequirements::eWizardType_viruses, -1, "Microtus arvalis" } ,
694  { "serotype", CSourceRequirements::eWizardType_viruses, -1, "Ex1" } ,
695  { "genotype", CSourceRequirements::eWizardType_viruses, -1, "D9" } ,
696  { "segment", CSourceRequirements::eWizardType_viruses, -1, "10" } ,
706  { "dev-stage", CSourceRequirements::eWizardType_tsa, -1, "seed" } ,
707  { "cell-line", CSourceRequirements::eWizardType_tsa, -1, "HK234" } ,
708  { "cell-type", CSourceRequirements::eWizardType_tsa, -1, "leukocyte" } ,
709  { "cultivar", CSourceRequirements::eWizardType_tsa, -1, "Microtom" } ,
710  { "tissue-type", CSourceRequirements::eWizardType_tsa, -1, "liver" } ,
711  { "haplotype", CSourceRequirements::eWizardType_d_loop, -1, "A1" } ,
712  { "specimen-voucher", CSourceRequirements::eWizardType_d_loop, -1, "A1" } ,
713  { kHost, -1, -1, "Homo sapiens" } ,
714  { "lat-lon", -1, -1, "39.00 N 77.10 W" } ,
715  { "strain", -1, -1, "ABC123" } ,
716  { "country", -1, -1, "USA: Ann Arbor, MI" } ,
717  { "country", CSourceRequirements::eWizardType_viruses, -1, "Finland" } ,
719  { "country", CSourceRequirements::eWizardType_viruses, -1, "Finland" } ,
720  { "Isolate", -1, -1, "SDZ123" } ,
726  { "Isolate", CSourceRequirements::eWizardType_rrna_its_igs, -1, "EX-A" } ,
728  { "Isolate", CSourceRequirements::eWizardType_igs, -1, "EX-A" } ,
729  { "Isolate", CSourceRequirements::eWizardType_d_loop, -1, "xyz1a" } ,
730  { "Specimen-voucher", -1, -1, "USNM:12345" } ,
731  { "sex", -1, -1, "female" } ,
732  { "breed", -1, -1, "Holstein" } ,
733  { "cultivar", -1, -1, "Granny Smith" } ,
734  { "isolation-source", CSourceRequirements::eWizardType_uncultured_samples, -1, "diseased leaf" } ,
738  { "isolation-source", CSourceRequirements::eWizardType_rrna_its_igs, -1, "lake shoreline" } ,
740  { "isolation-source", CSourceRequirements::eWizardType_igs, CSourceRequirements::eWizardSrcType_cultured_fungus, "soil under elm tree" } ,
741  { "isolation-source", CSourceRequirements::eWizardType_igs, -1, "lake shoreline" } ,
744  { "isolation-source", CSourceRequirements::eWizardType_viruses, -1, "feces" } ,
745  { "isolation-source", -1, -1, "soil" } ,
746  { "clone", CSourceRequirements::eWizardType_uncultured_samples, -1, "abc-1" } ,
747  { "clone", CSourceRequirements::eWizardType_microsatellite, -1, "Ca-789" } ,
748 };
749 
750 
751 static const int k_NumExampleTableRows = sizeof (s_ExampleTable) / sizeof (ExampleTableData);
752 
753 
755 {
756  if (e1 == NULL) {
757  return false;
758  }
759  if (!NStr::EqualNocase(field_name, e1->field_name)) {
760  return false;
761  }
762  if (e1->wizard_type != -1 && e1->wizard_type != wizard_type) {
763  return false;
764  }
765  if (e1->src_type != -1 && e1->src_type != src_type) {
766  return false;
767  }
768  return true;
769 }
770 
771 
772 static int CompareExampleTableRows (const ExampleTableData * e1, const ExampleTableData * e2)
773 {
774  if (e1->wizard_type == -1 && e2->wizard_type != -1) {
775  return -1;
776  } else if (e1->wizard_type != -1 && e2->wizard_type == -1) {
777  return 1;
778  } else if (e1->src_type == -1 && e2->wizard_type != -1) {
779  return -1;
780  } else if (e1->src_type != -1 && e2->wizard_type == -1) {
781  return 1;
782  } else {
783  return 0;
784  }
785 }
786 
787 
789 {
791  if (NStr::IsBlank((*rit)->GetExample())) {
792  int best_k = -1;
793  for (int k = 0; k < k_NumExampleTableRows; k++) {
794  if (IsExampleTableRowAcceptable(s_ExampleTable + k, (*rit)->GetName(), wizard_type, src_type)
795  && (best_k == -1 || CompareExampleTableRows(s_ExampleTable + best_k, s_ExampleTable + k) < 0)) {
796  best_k = k;
797  }
798  }
799  if (best_k > -1) {
800  (*rit)->SetExample(s_ExampleTable[best_k].example);
801  }
802  }
803  }
804 
805 }
806 
807 
810  CRef<CSeq_table> values_table)
811 {
812  CSourceRequirements *requirements = new CSourceRequirements();
814  requirements->AddRequirement("uncultured taxname", true, "uncultured bacterium");
815  } else {
816  requirements->AddRequirement("organism name", true);
817  }
818 
819 #if 0
820  string host = kHost;
821 
822  switch (wizard_type) {
824  {
825  bool has_gelband_isolate = false;
826  CRef<CSeqTable_column> isolate_col = FindSeqTableColumnByName (values_table, "isolate");
827  if (isolate_col) {
828  for (size_t row = 0; row < isolate_col->GetData().GetSize() && !has_gelband_isolate; row++) {
829  string isolate_val = isolate_col->GetData().GetString()[row];
830  if (NStr::StartsWith(isolate_val, "DGGE") || NStr::StartsWith(isolate_val, "TGGE")) {
831  has_gelband_isolate = true;
832  }
833  }
834  }
835  if (has_gelband_isolate) {
836  requirements->AddRequirement("isolate", true);
837  } else {
838  requirements->AddRequirement("clone", true);
839  }
840  requirements->AddRequirement("isolation-source", true);
841  break;
842  }
845  requirements->PreferentiallyAddRequirement (values_table, "strain", "isolate", true);
846  } else {
847  requirements->PreferentiallyAddRequirement (values_table, "isolate", "strain", true);
848  }
849  switch (source_type) {
851  requirements->AddRequirement("collection-date", true);
852  requirements->AddRequirement("country", true);
853  requirements->AddRequirement("genotype", true);
854  requirements->AddOneOfList(2, host, "isolation-source");
855  break;
857  requirements->AddRequirement("serotype", true);
858  requirements->AddRequirement("collection-date", true);
859  requirements->AddRequirement(host, true);
860  requirements->AddRequirement("country", true);
861  break;
863  requirements->AddRequirement("serotype", true);
864  requirements->AddRequirement("collection-date", true);
865  requirements->AddRequirement("country", true);
866  requirements->AddRequirement("segment", true);
867  requirements->AddOneOfList(2, host, "isolation-source");
868  break;
870  requirements->AddRequirement("collection-date", true);
871  requirements->AddRequirement("country", true);
872  requirements->AddRequirement("genotype", true);
873  requirements->AddOneOfList(2, host, "isolation-source");
874  break;
875  default:
876  requirements->AddRequirement("country", true);
877  requirements->AddRequirement("collection-date", true);
878  requirements->AddRequirement(host, true);
879  break;
880  }
881  requirements->AddUniquenessList(1, "segment");
882  requirements->AddUniquenessList(2, "segment", "isolate");
883  requirements->AddUniquenessList(2, "segment", "strain");
884  break;
886  switch (source_type) {
888  requirements->PreferentiallyAddRequirement (values_table, "strain", "isolate", true);
889  requirements->AddRequirement("isolation-source", true);
890  break;
892  requirements->PreferentiallyAddRequirement (values_table, "strain", "isolate", true);
893  requirements->AddRequirement("isolation-source", true);
894  break;
896  requirements->AddRequirement("specimen-voucher", true);
897  break;
898  default:
899  requirements->AddRequirement("isolate", true);
900  requirements->AddRequirement("isolation-source", true);
901  break;
902  }
903  break;
905  switch (source_type) {
907  requirements->PreferentiallyAddRequirement (values_table, "strain", "isolate", true);
908  requirements->AddRequirement("isolation-source", true);
909  break;
911  requirements->AddRequirement("specimen-voucher", true);
912  requirements->AddUniquenessList(5, "organism", "specimen-voucher", "isolate", "bio-material", "culture-collection");
913  break;
916  default:
917  requirements->AddRequirement("isolate", true);
918  requirements->AddRequirement("isolation-source", true);
919  requirements->AddRequirement("specimen-voucher", false);
920  requirements->AddRequirement("cultivar", false);
921  requirements->AddRequirement("bio-material", false);
922  requirements->AddRequirement("culture-collection", false);
923  requirements->AddUniquenessList(1, "organism");
924  requirements->AddUniquenessList(2, "organism", "isolate");
925  requirements->AddUniquenessList(2, "organism", "specimen-voucher");
926  requirements->AddUniquenessList(2, "organism", "cultivar");
927  requirements->AddUniquenessList(2, "organism", "bio-material");
928  requirements->AddUniquenessList(2, "organism", "culture-collection");
929  break;
930  }
931  break;
933  requirements->AddUniquenessList(1, "organism");
934  requirements->AddUniquenessList(2, "organism", "isolate");
935  requirements->AddUniquenessList(2, "organism", "specimen-voucher");
936  requirements->AddUniquenessList(2, "organism", "haplotype");
937  break;
938  default:
939  break;
940  }
941 #endif
942  requirements->SetExamples(wizard_type, source_type);
943  return requirements;
944 }
945 
946 
947 string GetPrimerSetNameValues(const CPCRPrimerSet& primer_set)
948 {
949  vector<string> names;
950  ITERATE (CPCRPrimerSet::Tdata, sit, primer_set.Get())
951  {
952  if ((*sit)->IsSetName())
953  {
954  string new_name = (*sit)->GetName();
955  if (!new_name.empty())
956  names.push_back(new_name);
957  }
958  }
959  return NStr::Join(names, ",");
960 }
961 
962 
963 string GetPrimerSetSeqValues(const CPCRPrimerSet& primer_set)
964 {
965  string this_seq = "";
966 
967  ITERATE (CPCRPrimerSet::Tdata, sit, primer_set.Get()) {
968  string new_seq = "";
969  if ((*sit)->IsSetSeq()) {
970  new_seq = (*sit)->GetSeq();
971  }
972  if (!NStr::IsBlank(this_seq)) {
973  this_seq += ",";
974  }
975  this_seq += new_seq;
976  }
977  return this_seq;
978 }
979 
980 
982 {
983  size_t len = str.length();
984  if (len > 0) {
985  str = str.substr(0, len - 1);
986  }
987 }
988 
989 string JoinValues(const string &name, const vector<string>& values)
990 {
991  if (name == "culture_collection" || name == "culture-collection" || name == "culture collection" ||
992  name == "bio_material" || name == "bio-material" || name == "biomaterial" ||
993  name == "specimen_voucher" || name == "specimen-voucher" || name == "specimen voucher")
994  return NStr::Join(values, "|");
995  return NStr::Join(values, ";");
996 }
997 
998 void SplitValues(const string& name, const string& newValue, vector<string> &values)
999 {
1000  if (name == "culture_collection" || name == "culture-collection" || name == "culture collection" ||
1001  name == "bio_material" || name == "bio-material" || name == "biomaterial" ||
1002  name == "specimen_voucher" || name == "specimen-voucher" || name == "specimen voucher")
1003  NStr::Split(newValue, "|", values);
1004  else
1005  values.push_back(newValue);
1006 }
1007 
1009 {
1013  id_col->SetHeader().SetTitle(kSequenceIdColLabel);
1014  table->SetColumns().push_back(id_col);
1015 
1016  CRef<CSeqTable_column> expand_col(new CSeqTable_column());
1017  expand_col->SetHeader().SetTitle("");
1018  expand_col->SetHeader().SetField_name("expand");
1019  expand_col->SetData().SetString();
1020  table->SetColumns().push_back(expand_col);
1021 
1022  CRef<CSeqTable_column> taxname_col(new CSeqTable_column());
1023  taxname_col->SetHeader().SetTitle("Organism Name");
1024  taxname_col->SetHeader().SetField_name("org.taxname");
1025  taxname_col->SetData().SetString();
1026  table->SetColumns().push_back(taxname_col);
1027 
1028  size_t row = 0;
1029  CBioseq_CI b_iter(seh, CSeq_inst::eMol_na);
1030  for ( ; b_iter ; ++b_iter ) {
1031  CSeqdesc_CI it (*b_iter, CSeqdesc::e_Source);
1032  CRef<CSeq_id> id(new CSeq_id());
1033  id->Assign (*(b_iter->GetSeqId()));
1034  id_col->SetData().SetId().push_back(id);
1035  expand_col->SetData().SetString().push_back("");
1036  if (it) {
1037  // populate taxname
1038  if (it->GetSource().IsSetTaxname()) {
1039  while (taxname_col->GetData().GetString().size() < row + 1) {
1040  taxname_col->SetData().SetString().push_back("");
1041  }
1042  taxname_col->SetData().SetString()[row] = it->GetSource().GetTaxname();
1043  }
1044  // populate genome
1045  if (it->GetSource().IsSetGenome()
1047  AddValueToTable (table, "genome",
1049  }
1050 
1051  if (it->GetSource().IsSetSubtype()) {
1052  map<string, vector<string> > name_to_values;
1054  string subtype_name = CSubSource::GetSubtypeName((*sit)->GetSubtype());
1055  if (NStr::EqualNocase(subtype_name, "note")) {
1056  subtype_name = kSubSourceNote;
1057  }
1058  string val = "";
1059  if ((*sit)->IsSetName()) {
1060  val = (*sit)->GetName();
1061  }
1062  if (NStr::IsBlank(val) && CSubSource::NeedsNoText((*sit)->GetSubtype())) {
1063  val = "true";
1064  }
1065  if (!val.empty())
1066  name_to_values[subtype_name].push_back(val);
1067  }
1068  for (const auto& name_val : name_to_values)
1069  {
1070  AddValueToTable(table, name_val.first, JoinValues(name_val.first, name_val.second), row);
1071  }
1072  }
1073  if (it->GetSource().IsSetOrgMod()) {
1074  map<string, vector<string> > name_to_values;
1075  ITERATE (COrgName::TMod, sit, it->GetSource().GetOrgname().GetMod()) {
1076  string subtype_name = COrgMod::GetSubtypeName((*sit)->GetSubtype());
1077  if (NStr::EqualNocase(subtype_name, "note")) {
1078  subtype_name = kOrgModNote;
1079  }
1080  if (NStr::EqualNocase(subtype_name, "nat-host")) {
1081  subtype_name = "host";
1082  }
1083  string val = (*sit)->GetSubname();
1084  if (!val.empty())
1085  name_to_values[subtype_name].push_back(val);
1086  }
1087  for (const auto& name_val : name_to_values)
1088  {
1089  AddValueToTable(table, name_val.first, JoinValues(name_val.first, name_val.second), row);
1090  }
1091  }
1092  if (it->GetSource().IsSetOrg() && it->GetSource().GetOrg().IsSetDb())
1093  {
1094  set<string> values;
1096  {
1097  string db = (*sit)->GetDb();
1098  string tag;
1099  if ((*sit)->GetTag().IsStr())
1100  tag = (*sit)->GetTag().GetStr();
1101  if ((*sit)->GetTag().IsId())
1102  tag = NStr::IntToString((*sit)->GetTag().GetId());
1103  values.insert(db + ":" + tag);
1104  }
1105  AddValueToTable(table, kDbXref, NStr::Join(values, ";"), row);
1106  }
1107  if (it->GetSource().IsSetPcr_primers()) {
1108  // list them all
1109  string fwd_name = "";
1110  string rev_name = "";
1111  string fwd_seq = "";
1112  string rev_seq = "";
1114  string this_fwd_name = "";
1115  string this_fwd_seq = "";
1116  string this_rev_name = "";
1117  string this_rev_seq = "";
1118  if ((*pit)->IsSetForward()) {
1119  this_fwd_name = GetPrimerSetNameValues((*pit)->GetForward());
1120  this_fwd_seq = GetPrimerSetSeqValues((*pit)->GetForward());
1121  }
1122  if ((*pit)->IsSetReverse()) {
1123  this_rev_name = GetPrimerSetNameValues((*pit)->GetReverse());
1124  this_rev_seq = GetPrimerSetSeqValues((*pit)->GetReverse());
1125  }
1126  fwd_name += this_fwd_name + ";";
1127  fwd_seq += this_fwd_seq + ";";
1128  rev_name += this_rev_name + ";";
1129  rev_seq += this_rev_seq + ";";
1130  }
1131  RemoveLastCharacter(fwd_name);
1132  RemoveLastCharacter(fwd_seq);
1133  RemoveLastCharacter(rev_name);
1134  RemoveLastCharacter(rev_seq);
1135  if (!NStr::IsBlank(fwd_name) || !NStr::IsBlank(fwd_seq) || !NStr::IsBlank(rev_name) || !NStr::IsBlank(rev_seq)) {
1136  AddValueToTable(table, "fwd-primer-name", fwd_name, row);
1137  AddValueToTable(table, "fwd-primer-seq", fwd_seq, row);
1138  AddValueToTable(table, "rev-primer-name", rev_name, row);
1139  AddValueToTable(table, "rev-primer-seq", rev_seq, row);
1140  }
1141  }
1142 
1143  }
1144  row++;
1145 
1146  }
1147 
1148  table->SetNum_rows(static_cast<CSeq_table::TNum_rows>(row));
1149  return table;
1150 }
1151 
1152 
1154 {
1158  id_col->SetHeader().SetTitle(kSequenceIdColLabel);
1159  table->SetColumns().push_back(id_col);
1160 
1161  vector< CRef<CSrcTableColumnBase> > handlers;
1162 
1163  ITERATE(vector<string>, q, qual_names) {
1165  col->SetHeader().SetTitle(*q);
1166  handlers.push_back(CSrcTableColumnBaseFactory::Create(*col));
1167  table->SetColumns().push_back(col);
1168  }
1169 
1170  size_t row = 0;
1171  CBioseq_CI b_iter(seh, CSeq_inst::eMol_na);
1172  for ( ; b_iter ; ++b_iter ) {
1173  CSeqdesc_CI it (*b_iter, CSeqdesc::e_Source);
1174  CRef<CSeq_id> id(new CSeq_id());
1175  id->Assign (*(b_iter->GetSeqId()));
1176  id_col->SetData().SetId().push_back(id);
1177  for (size_t i = 0; i < handlers.size(); i++) {
1178  if (it) {
1179  table->SetColumns()[i + 1]->SetData().SetString().push_back(handlers[i]->GetFromBioSource(it->GetSource()));
1180  } else {
1181  table->SetColumns()[i + 1]->SetData().SetString().push_back("");
1182  }
1183  }
1184  row++;
1185  }
1186 
1187  table->SetNum_rows(static_cast<CSeq_table::TNum_rows>(row));
1188  return table;
1189 }
1190 
1191 
1192 // class CSrcTableColumnBase
1193 vector<CConstRef<CObject> > CSrcTableColumnBase::GetObjects(CBioseq_Handle bsh)
1194 {
1195  vector<CConstRef<CObject> > objects;
1197  CSeqdesc_CI desc_ci(bsh, CSeqdesc::e_Source);
1198  while (desc_ci) {
1199  CConstRef<CObject> object;
1200  object.Reset(&(*desc_ci));
1201  objects.push_back(object);
1202  ++desc_ci;
1203  }
1204  }
1205 
1207  CFeat_CI feat_ci(bsh, CSeqFeatData::e_Biosrc);
1208  while (feat_ci) {
1209  CConstRef<CObject> object;
1210  object.Reset(&(feat_ci->GetOriginalFeature()));
1211  objects.push_back(object);
1212  ++feat_ci;
1213  }
1214  }
1215  return objects;
1216 }
1217 
1219 {
1220  vector<CRef<CApplyObject> > objects;
1222  CSeqdesc_CI desc_ci(bsh, CSeqdesc::e_Source);
1223  while (desc_ci) {
1224  CRef<CApplyObject> object(new CApplyObject(bsh, *desc_ci));
1225  objects.push_back(object);
1226  ++desc_ci;
1227  }
1228  if (objects.empty()) {
1230  objects.push_back(object);
1231  }
1232  }
1233 
1235  CFeat_CI feat_ci(bsh, CSeqFeatData::e_Biosrc);
1236  while (feat_ci) {
1237  CRef<CApplyObject> obj(new CApplyObject(bsh, feat_ci->GetOriginalFeature()));
1238  objects.push_back(obj);
1239  ++feat_ci;
1240  }
1241  }
1242  return objects;
1243 }
1244 
1246 {
1247  string val(kEmptyStr);
1248  const CSeqdesc* desc = dynamic_cast<const CSeqdesc * >(&object);
1249  const CSeq_feat* feat = dynamic_cast<const CSeq_feat * >(&object);
1250  if (desc && desc->IsSource()) {
1251  val = GetFromBioSource(desc->GetSource());
1252  } else if (feat && feat->IsSetData() && feat->GetData().IsBiosrc()) {
1253  val = GetFromBioSource(feat->GetData().GetBiosrc());
1254  }
1255  return val;
1256 }
1257 
1258 vector<string> CSrcTableColumnBase::GetVals(const CObject& object)
1259 {
1260  vector<string> vals;
1261  const CSeqdesc* desc = dynamic_cast<const CSeqdesc * >(&object);
1262  const CSeq_feat* feat = dynamic_cast<const CSeq_feat * >(&object);
1263 
1264  if (desc && desc->IsSource()) {
1265  vector<string> add = GetValsFromBioSource(desc->GetSource());
1266  vals.insert(vals.begin(), add.begin(), add.end());
1267  } else if (feat && feat->IsSetData() && feat->GetData().IsBiosrc()) {
1268  vector<string> add = GetValsFromBioSource(feat->GetData().GetBiosrc());
1269  vals.insert(vals.begin(), add.begin(), add.end());
1270  }
1271  return vals;
1272 }
1273 
1275 {
1276  vector<string> vals;
1277  string val = GetFromBioSource(src);
1278  if (!NStr::IsBlank(val)) {
1279  vals.push_back(val);
1280  }
1281  return vals;
1282 }
1283 
1285 {
1286  CSeqdesc* desc = dynamic_cast<CSeqdesc * >(&object);
1287  CSeq_feat* feat = dynamic_cast<CSeq_feat * >(&object);
1288  if (desc && desc->IsSource()) {
1289  ClearInBioSource(desc->SetSource());
1290  } else if (feat && feat->IsSetData() && feat->GetData().IsBiosrc()) {
1291  ClearInBioSource(feat->SetData().SetBiosrc());
1292  }
1293 }
1294 
1295 
1296 // class CSrcTableOrganismNameColumn
1297 bool CSrcTableOrganismNameColumn::AddToBioSource(CBioSource & src, const string & newValue, EExistingText existing_text )
1298 {
1299  bool rval = false;
1300  string orig_val = GetFromBioSource (src);
1301  if (AddValueToString(orig_val, newValue, existing_text)) {
1302  src.SetOrg().SetTaxname(orig_val);
1303  rval = true;
1304  }
1305  return rval;
1306 }
1307 
1309 {
1310  in_out_bioSource.SetOrg().ResetTaxname();
1311 }
1312 
1313 string CSrcTableOrganismNameColumn::GetFromBioSource(const CBioSource & in_out_bioSource ) const
1314 {
1315  string val = kEmptyStr;
1316  if (in_out_bioSource.IsSetTaxname()) {
1317  val = in_out_bioSource.GetTaxname();
1318  }
1319  return val;
1320 }
1321 
1322 
1323 // class CSrcTaxnameAfterBinomialColumn
1324 bool CSrcTaxnameAfterBinomialColumn::AddToBioSource(CBioSource & src, const string & newValue, EExistingText existing_text )
1325 {
1326  bool rval = false;
1327  string orig_val = GetFromBioSource(src);
1328  if (NStr::IsBlank(orig_val) && AddValueToString(orig_val, newValue, existing_text)) {
1329  src.SetOrg().SetTaxname(src.GetTaxname() + orig_val);
1330  return true;
1331  }
1332 
1333  SIZE_TYPE pos = NStr::Find(src.GetTaxname(), orig_val);
1334  if (pos != NPOS && AddValueToString(orig_val, newValue, existing_text)) {
1335  string new_taxname = src.GetTaxname().substr(0, pos) + orig_val;
1336  src.SetOrg().SetTaxname(new_taxname);
1337  rval = true;
1338  }
1339  return rval;
1340 }
1341 
1343 {
1344  if (in_out_bioSource.IsSetTaxname()) {
1345  string taxname = in_out_bioSource.GetTaxname();
1346  string taxname_after_binomial = x_GetTextAfterNomial(taxname);
1347  SIZE_TYPE pos = NStr::Find(taxname, taxname_after_binomial);
1348  if (pos != NPOS) {
1349  string new_taxname = taxname.substr(0, pos);
1350  NStr::TruncateSpacesInPlace(new_taxname);
1351  in_out_bioSource.SetOrg().SetTaxname(new_taxname);
1352  }
1353  }
1354 }
1355 
1356 string CSrcTaxnameAfterBinomialColumn::GetFromBioSource(const CBioSource & in_out_bioSource) const
1357 {
1358  string taxname = CSrcTableOrganismNameColumn::GetFromBioSource(in_out_bioSource);
1359  return x_GetTextAfterNomial(taxname);
1360 }
1361 
1362 static const string nomial_keywords[] = {
1363 "f. sp. ",
1364 "var",
1365 "pv.",
1366 "bv.",
1367 "serovar",
1368 "subsp."
1369 };
1370 
1371 string CSrcTaxnameAfterBinomialColumn::x_GetTextAfterNomial(const string& taxname) const
1372 {
1373  if (NStr::IsBlank(taxname)) {
1374  return kEmptyStr;
1375  }
1376 
1377  SIZE_TYPE pos = NStr::FindNoCase(taxname, " ");
1378  vector<string> names;
1379  if (pos != NPOS) {
1380  NStr::Split(taxname, " ", names, NStr::fSplit_Tokenize);
1381  }
1382 
1383  if (names.empty()) {
1384  return kEmptyStr;
1385  }
1386 
1387  pos = 0;
1388  if (NStr::EqualNocase(names[0], "uncultured")) {
1389  pos = 2; // skipping the first three words
1390  } else {
1391  pos = 1; // skipping the first two words
1392  }
1393 
1394  if (names.size() <= pos + 1) {
1395  return kEmptyStr;
1396  }
1397  pos++;
1398  bool found_keyword = true;
1399  while (pos < names.size() && found_keyword) {
1400  /* if the next word is a nomial keyword, skip that plus the first word that follows it */
1401  found_keyword = false;
1402  if (NStr::EqualCase(names[pos], "f.") && (pos+1 < names.size() && NStr::EqualCase(names[pos+1],"sp."))) {
1403  pos = pos + 3;
1404  found_keyword = true;
1405  } else {
1406  for (size_t n = 1; n < sizeof(nomial_keywords)/sizeof(string) && !found_keyword; ++n) {
1407  if (NStr::EqualCase(nomial_keywords[n], names[pos])) {
1408  pos = pos + 2;
1409  found_keyword = true;
1410  }
1411  }
1412  }
1413  }
1414  string taxname_after_binomial = kEmptyStr;
1415  while (pos < names.size()) {
1416  taxname_after_binomial += names[pos] + " ";
1417  pos++;
1418  }
1419  NStr::TruncateSpacesInPlace(taxname_after_binomial, NStr::eTrunc_End);
1420  return taxname_after_binomial;
1421 }
1422 
1423 
1424 // class CSrcTableGenomeColumn
1426 {
1427  m_organelle = -1;
1428  if (!organelle.empty())
1429  m_organelle = objects::CBioSource::ENUM_METHOD_NAME(EGenome)()->FindValue(organelle);
1430 }
1431 
1432 bool CSrcTableGenomeColumn::AddToBioSource(CBioSource & src, const string & newValue, EExistingText existing_text)
1433 {
1434  if (m_organelle == -1 || (src.IsSetGenome() && src.GetGenome() == m_organelle) )
1435  {
1437  return true;
1438  }
1439  return false;
1440 }
1441 
1442 void CSrcTableGenomeColumn::ClearInBioSource(CBioSource & in_out_bioSource)
1443 {
1444  if (m_organelle == -1 || (in_out_bioSource.IsSetGenome() && in_out_bioSource.GetGenome() == m_organelle) )
1445  {
1446  in_out_bioSource.ResetGenome();
1447  }
1448 }
1449 
1450 string CSrcTableGenomeColumn::GetFromBioSource(const CBioSource & in_out_bioSource) const
1451 {
1452  string val = "";
1453  if (in_out_bioSource.IsSetGenome() && (m_organelle == -1 || in_out_bioSource.GetGenome() == m_organelle)) {
1454  val = in_out_bioSource.GetOrganelleByGenome( in_out_bioSource.GetGenome());
1455  }
1456  return val;
1457 }
1458 
1459 vector<string> CSrcTableGenomeColumn::IsValid(const vector<string>& values)
1460 {
1461  vector<string> problems;
1462  bool any = false;
1463 
1464  ITERATE(vector<string>, it, values) {
1465  if (!NStr::IsBlank(*it)
1467  problems.push_back("'" + *it + "'" + " is not a valid value for Genome");
1468  any = true;
1469  } else {
1470  problems.push_back("");
1471  }
1472  }
1473  if (!any) {
1474  problems.clear();
1475  }
1476  return problems;
1477 }
1478 
1479 
1480 // class CSrcTableOriginColumn
1481 bool CSrcTableOriginColumn::AddToBioSource(CBioSource & src, const string & newValue, EExistingText existing_text)
1482 {
1483  bool rval = false;
1484  string curr = "";
1485  if (src.IsSetOrigin()) {
1487  }
1488  if (AddValueToString(curr, newValue, existing_text)) {
1490  src.SetOrigin(origin);
1491  rval = true;
1492  }
1493  return rval;
1494 }
1495 
1497 {
1498  in_out_bioSource.ResetOrigin();
1499 }
1500 
1501 string CSrcTableOriginColumn::GetFromBioSource(const CBioSource & in_out_bioSource) const
1502 {
1503  string val = "";
1504  if (in_out_bioSource.IsSetOrigin()) {
1505  val = CBioSource::GetStringFromOrigin(in_out_bioSource.GetOrigin());
1506  }
1507  return val;
1508 }
1509 
1510 vector<string> CSrcTableOriginColumn::IsValid(const vector<string>& values)
1511 {
1512  vector<string> problems;
1513  bool any = false;
1514 
1515 #if 0
1516  ITERATE(vector<string>, it, values) {
1517  if (!NStr::IsBlank(*it)
1519  problems.push_back("'" + *it + "'" + " is not a valid value for Origin");
1520  any = true;
1521  } else {
1522  problems.push_back("");
1523  }
1524  }
1525 #endif
1526  if (!any) {
1527  problems.clear();
1528  }
1529  return problems;
1530 }
1531 
1532 
1533 // class CSrcTableSubSourceColumn
1534 bool CSrcTableSubSourceColumn::AddToBioSource(CBioSource & src, const string & newValue, EExistingText existing_text)
1535 {
1536  bool rval = false;
1537  if (NStr::IsBlank(newValue)) {
1538  return false;
1539  }
1540 
1541  size_t i = 0;
1542  vector<string> values;
1543  SplitValues(CSubSource::ENUM_METHOD_NAME(ESubtype)()->FindName(m_Subtype, true), newValue, values);
1544  if (existing_text != eExistingText_add_qual && src.IsSetSubtype()) {
1545  CBioSource::TSubtype::iterator it = src.SetSubtype().begin();
1546  while (it != src.GetSubtype().end()) {
1547  if ((*it)->GetSubtype() == m_Subtype) {
1549  // do nothing, already here
1550  } else {
1551  string orig_val = "";
1552  if ((*it)->IsSetName()) {
1553  orig_val = (*it)->GetName();
1554  }
1555  string val;
1556  if (i < values.size())
1557  val = values[i];
1558  if (AddValueToString(orig_val, val, existing_text)) {
1559  (*it)->SetName(orig_val);
1560  rval = true;
1561  }
1562  }
1563  i++;
1564  }
1565  ++it;
1566  }
1567  }
1568  if (i < values.size() || existing_text == eExistingText_add_qual) {
1569  for (; i < values.size(); i++)
1570  {
1572  CRef<CSubSource> s(new CSubSource(m_Subtype, " "));
1573  src.SetSubtype().push_back(s);
1574  } else {
1575  CRef<CSubSource> s(new CSubSource(m_Subtype, values[i]));
1576  src.SetSubtype().push_back(s);
1577  }
1578  rval = true;
1579  }
1580  }
1581  return rval;
1582 }
1583 
1584 
1586 {
1587  if (in_out_bioSource.IsSetSubtype()) {
1588  CBioSource::TSubtype::iterator it = in_out_bioSource.SetSubtype().begin();
1589  while (it != in_out_bioSource.SetSubtype().end()) {
1590  if ((*it)->GetSubtype() == m_Subtype) {
1591  it = in_out_bioSource.SetSubtype().erase(it);
1592  } else {
1593  ++it;
1594  }
1595  }
1596  if (in_out_bioSource.SetSubtype().empty()) {
1597  in_out_bioSource.ResetSubtype();
1598  }
1599  }
1600 }
1601 
1602 
1603 string CSrcTableSubSourceColumn::GetFromBioSource(const CBioSource & in_out_bioSource) const
1604 {
1605  string val = "";
1606  if (in_out_bioSource.IsSetSubtype()) {
1607  CBioSource::TSubtype::const_iterator it = in_out_bioSource.GetSubtype().begin();
1608  while (it != in_out_bioSource.GetSubtype().end()) {
1609  if ((*it)->GetSubtype() == m_Subtype && (*it)->IsSetName()) {
1610  val = (*it)->GetName();
1611  break;
1612  }
1613  ++it;
1614  }
1615  }
1616  // independently of the current biosource, these qualifiers should always be set to TRUE
1618  val = "true";
1619  }
1620  return val;
1621 }
1622 
1623 
1624 vector <string> CSrcTableSubSourceColumn::GetValsFromBioSource(const CBioSource & biosrc) const
1625 {
1626  vector<string> vals;
1627 
1628  if (biosrc.IsSetSubtype()) {
1629  CBioSource::TSubtype::const_iterator it = biosrc.GetSubtype().begin();
1630  while (it != biosrc.GetSubtype().end()) {
1631  if ((*it)->GetSubtype() == m_Subtype && (*it)->IsSetName()) {
1632  string val = (*it)->GetName();
1633  // independently of the current biosource, these qualifiers should always be set to TRUE
1635  val = "true";
1636  }
1637  vals.push_back(val);
1638  }
1639  ++it;
1640  }
1641  }
1642  return vals;
1643 }
1644 
1645 
1646 // class CSrcTableOrgModColumn
1647 bool CSrcTableOrgModColumn::AddToBioSource(CBioSource & src, const string & newValue, EExistingText existing_text)
1648 {
1649  bool rval = false;
1650  if (NStr::IsBlank(newValue)) {
1651  return rval;
1652  }
1653  size_t i = 0;
1654  vector<string> values;
1655  SplitValues( COrgMod::ENUM_METHOD_NAME(ESubtype)()->FindName(m_Subtype, true), newValue, values);
1656  if (existing_text != eExistingText_add_qual
1657  && src.IsSetOrg() && src.GetOrg().IsSetOrgname()
1658  && src.GetOrg().GetOrgname().IsSetMod()) {
1659  COrgName::TMod::iterator it = src.SetOrg().SetOrgname().SetMod().begin();
1660  while (it != src.SetOrg().SetOrgname().SetMod().end()) {
1661  if ((*it)->GetSubtype() == m_Subtype) {
1662  string orig_val = "";
1663  if ((*it)->IsSetSubname()) {
1664  orig_val = (*it)->GetSubname();
1665  }
1666  string val;
1667  if (i < values.size())
1668  val = values[i];
1669  i++;
1670  if (AddValueToString(orig_val, val, existing_text)) {
1671  (*it)->SetSubname(orig_val);
1672  rval = true;
1673  }
1674  }
1675  ++it;
1676  }
1677  }
1678 
1679  if (i < values.size() || existing_text == eExistingText_add_qual) {
1680  for (; i < values.size(); i++)
1681  {
1682  CRef<COrgMod> s(new COrgMod(m_Subtype, values[i]));
1683  src.SetOrg().SetOrgname().SetMod().push_back(s);
1684  rval = true;
1685  }
1686  }
1687  return rval;
1688 }
1689 
1690 void CSrcTableOrgModColumn::ClearInBioSource(CBioSource & in_out_bioSource)
1691 {
1692  if (in_out_bioSource.IsSetOrg() && in_out_bioSource.GetOrg().IsSetOrgname() && in_out_bioSource.GetOrg().GetOrgname().IsSetMod()) {
1693  COrgName::TMod::iterator it = in_out_bioSource.SetOrg().SetOrgname().SetMod().begin();
1694  while (it != in_out_bioSource.SetOrg().SetOrgname().SetMod().end()) {
1695  if ((*it)->GetSubtype() == m_Subtype) {
1696  it = in_out_bioSource.SetOrg().SetOrgname().SetMod().erase(it);
1697  } else {
1698  ++it;
1699  }
1700  }
1701  if (in_out_bioSource.GetOrg().GetOrgname().GetMod().empty()) {
1702  in_out_bioSource.SetOrg().SetOrgname().ResetMod();
1703  }
1704  }
1705 }
1706 
1707 string CSrcTableOrgModColumn::GetFromBioSource(const CBioSource & in_out_bioSource) const
1708 {
1709  string val = "";
1710  if (in_out_bioSource.IsSetOrg() && in_out_bioSource.GetOrg().IsSetOrgname() && in_out_bioSource.GetOrg().GetOrgname().IsSetMod()) {
1711  COrgName::TMod::const_iterator it = in_out_bioSource.GetOrg().GetOrgname().GetMod().begin();
1712  while (it != in_out_bioSource.GetOrg().GetOrgname().GetMod().end()) {
1713  if ((*it)->GetSubtype() == m_Subtype && (*it)->IsSetSubname()) {
1714  val = (*it)->GetSubname();
1715  break;
1716  }
1717  ++it;
1718  }
1719  }
1720  return val;
1721 }
1722 
1723 vector <string> CSrcTableOrgModColumn::GetValsFromBioSource(const CBioSource & biosrc) const
1724 {
1725  vector<string> vals;
1726  if (biosrc.IsSetOrg() && biosrc.GetOrg().IsSetOrgname() && biosrc.GetOrg().GetOrgname().IsSetMod()) {
1727  COrgName::TMod::const_iterator it = biosrc.GetOrg().GetOrgname().GetMod().begin();
1728  while (it != biosrc.GetOrg().GetOrgname().GetMod().end()) {
1729  if ((*it)->GetSubtype() == m_Subtype && (*it)->IsSetSubname()) {
1730  string val = (*it)->GetSubname();
1731  vals.push_back(val);
1732  }
1733  ++it;
1734  }
1735  }
1736  return vals;
1737 }
1738 
1739 
1740 // class CSrcStructuredVoucherPartColumn
1741 
1748 };
1749 
1752 
1754 {
1755  TStrcVouchMap::const_iterator iter = sm_VouchMap.begin();
1756  for (; iter != sm_VouchMap.end(); ++iter){
1757  if (iter->second == stype_part){
1758  return iter->first;
1759  }
1760  }
1761  return kEmptyStr;
1762 }
1763 
1766 {
1767  TStrcVouchMap::const_iterator iter = sm_VouchMap.find(name);
1768  if (iter != sm_VouchMap.end()){
1769  return iter->second;
1770  }
1772 }
1773 
1774 
1775 void CSrcStructuredVoucherPartColumn::x_ParsePartsFromStructuredVoucher(const string& qualifier, string& inst, string& coll, string& id) const
1776 {
1777  if (!COrgMod::ParseStructuredVoucher(qualifier, inst, coll, id) &&
1778  NStr::IsBlank(inst) &&
1779  NStr::IsBlank(coll) &&
1780  NStr::IsBlank(id)) {
1781  id = qualifier;
1782  }
1783 }
1784 
1785 string CSrcStructuredVoucherPartColumn::GetFromBioSource( const CBioSource & in_out_bioSource ) const
1786 {
1787  string inst, coll, id;
1788  string qualifier = CSrcTableOrgModColumn::GetFromBioSource(in_out_bioSource);
1789  x_ParsePartsFromStructuredVoucher(qualifier, inst, coll, id);
1790  switch (m_SubtypePart) {
1791  case eInst:
1792  return inst;
1793  case eColl:
1794  return coll;
1795  case eSpecid:
1796  return id;
1797  default:
1798  break;
1799  }
1800  return kEmptyStr;
1801 }
1802 
1804 {
1805  vector<string> vals;
1806  string val = GetFromBioSource(src);
1807  if (!NStr::IsBlank(val)) {
1808  vals.push_back(val);
1809  }
1810  return vals;
1811 }
1812 
1814 {
1815  if (in_out_bioSource.IsSetOrg() && in_out_bioSource.GetOrg().IsSetOrgname() && in_out_bioSource.GetOrg().GetOrgname().IsSetMod()) {
1816  COrgName::TMod::iterator it = in_out_bioSource.SetOrg().SetOrgname().SetMod().begin();
1817  while (it != in_out_bioSource.SetOrg().SetOrgname().SetMod().end()) {
1818  if ((*it)->GetSubtype() == m_Subtype && (*it)->IsSetSubname()) {
1819  // delete the inst|coll|id part of the structured voucher
1820  string inst, coll, id;
1821  x_ParsePartsFromStructuredVoucher((*it)->GetSubname(), inst, coll, id);
1822  switch (m_SubtypePart) {
1823  case eInst:
1824  inst = kEmptyStr;
1825  break;
1826  case eColl:
1827  coll = kEmptyStr;
1828  break;
1829  case eSpecid:
1830  id = kEmptyStr;
1831  break;
1832  default:
1833  return;
1834  }
1835  string new_subname = COrgMod::MakeStructuredVoucher(inst, coll, id);
1836  if (NStr::IsBlank(new_subname)) {
1837  it = in_out_bioSource.SetOrg().SetOrgname().SetMod().erase(it);
1838  } else {
1839  (*it)->SetSubname(new_subname);
1840  ++it;
1841  }
1842  } else {
1843  ++it;
1844  }
1845  }
1846  if (in_out_bioSource.GetOrg().GetOrgname().GetMod().empty()) {
1847  in_out_bioSource.SetOrg().SetOrgname().ResetMod();
1848  }
1849  }
1850 }
1851 
1852 bool CSrcStructuredVoucherPartColumn::AddToBioSource(CBioSource & src, const string & newValue, EExistingText existing_text)
1853 {
1854  bool rval = false;
1855  if (NStr::IsBlank(newValue)) {
1856  return rval;
1857  }
1858 
1859  bool found = false;
1860  if (existing_text != eExistingText_add_qual
1861  && src.IsSetOrg() && src.GetOrg().IsSetOrgname()
1862  && src.GetOrg().GetOrgname().IsSetMod()) {
1863  COrgName::TMod::iterator it = src.SetOrg().SetOrgname().SetMod().begin();
1864  while (it != src.SetOrg().SetOrgname().SetMod().end()) {
1865  if ((*it)->GetSubtype() == m_Subtype) {
1866  found = true;
1867  string inst, coll, id;
1868  if ((*it)->IsSetSubname()) {
1869  x_ParsePartsFromStructuredVoucher((*it)->GetSubname(), inst, coll, id);
1870  }
1871 
1872  switch (m_SubtypePart) {
1873  case eInst:
1874  if (AddValueToString(inst, newValue, existing_text)) {
1875  rval = true;
1876  }
1877  break;
1878  case eColl:
1879  if (AddValueToString(coll, newValue, existing_text)) {
1880  rval = true;
1881  }
1882  break;
1883  case eSpecid:
1884  if (AddValueToString(id, newValue, existing_text)) {
1885  rval = true;
1886  }
1887  break;
1888  default:
1889  break;
1890  }
1891 
1892  if (rval) {
1893  string new_subname = COrgMod::MakeStructuredVoucher(inst, coll, id);
1894  (*it)->SetSubname(new_subname);
1895  }
1896  }
1897  ++it;
1898  }
1899  }
1900 
1901  if (!found || existing_text == eExistingText_add_qual) {
1902  CRef<COrgMod> s(new COrgMod());
1903  s->SetSubtype(m_Subtype);
1904  string inst, coll, id;
1905  inst = coll = id = kEmptyStr;
1906  switch (m_SubtypePart) {
1907  case eInst:
1908  inst = newValue;
1909  rval = true;
1910  break;
1911  case eColl:
1912  coll = newValue;
1913  rval = true;
1914  break;
1915  case eSpecid:
1916  id = newValue;
1917  rval = true;
1918  break;
1919  default:
1920  rval = false;
1921  break;
1922  }
1923  if (rval) {
1924  string new_subname = COrgMod::MakeStructuredVoucher(inst, coll, id);
1925  s->SetSubname(new_subname);
1926  src.SetOrg().SetOrgname().SetMod().push_back(s);
1927  }
1928  }
1929  return rval;
1930 }
1931 
1932 
1933 // class CSrcTablePrimerColumn
1935 {
1936  if (IsFwdPrimerName(field_name)) {
1937  return eFwdName;
1938  } else if (IsFwdPrimerSeq(field_name)) {
1939  return eFwdSeq;
1940  } else if (IsRevPrimerName(field_name)) {
1941  return eRevName;
1942  } else if (IsRevPrimerSeq(field_name)) {
1943  return eRevSeq;
1944  } else {
1945  return eNotPrimerCol;
1946  }
1947 }
1948 
1949 void CSrcTablePrimerColumn::SetConstraint(const string& field_name, CConstRef<CStringConstraint> string_constraint)
1950 {
1951  if (!string_constraint) {
1954  } else {
1955  m_ConstraintCol = GetPrimerColumnType(field_name);
1956  if (m_ConstraintCol == eNotPrimerCol) {
1958  } else {
1960  m_StringConstraint->Assign(*string_constraint);
1961  }
1962  }
1963 }
1964 
1966 {
1967  bool rval = false;
1968  switch (m_ColType) {
1969  case eFwdSeq:
1970  case eFwdName:
1971  if (reaction.IsSetForward()) {
1972  rval = x_DoesPrimerSetHaveSpace(reaction.GetForward());
1973  } else {
1974  rval = true;
1975  }
1976  break;
1977  case eRevSeq:
1978  case eRevName:
1979  if (reaction.IsSetReverse()) {
1980  rval = x_DoesPrimerSetHaveSpace(reaction.GetForward());
1981  } else {
1982  rval = true;
1983  }
1984  break;
1985  default:
1986  break;
1987  }
1988  return rval;
1989 }
1990 
1991 
1993 {
1994  bool rval = false;
1995  if (!set.IsSet() || set.Get().size() == 0) {
1996  return true;
1997  }
1998  switch (m_ColType) {
1999  case eFwdSeq:
2000  case eRevSeq:
2001  if (!set.Get().front()->IsSetSeq()) {
2002  rval = true;
2003  }
2004  break;
2005  case eFwdName:
2006  case eRevName:
2007  if (!set.Get().front()->IsSetName()) {
2008  rval = true;
2009  }
2010  break;
2011  default:
2012  break;
2013  }
2014  return rval;
2015 }
2016 
2017 
2019 {
2021  return true;
2022  }
2023 
2024  vector<string> vals = x_GetValues(m_ConstraintCol, reaction);
2025  // intermediate solution for now:
2026  return const_cast< CRef<CStringConstraint>& >(m_StringConstraint)->DoesListMatch(vals);
2027 }
2028 
2029 
2030 vector<string> CSrcTablePrimerColumn::x_GetValues(EPrimerColType col, const CBioSource& src) const
2031 {
2032  vector<string> vals;
2033  if (src.IsSetPcr_primers()) {
2035  vector<string> add = x_GetValues(col, **it);
2036  if (add.size() > 0) {
2037  vals.insert(vals.end(), add.begin(), add.end());
2038  }
2039  }
2040  }
2041  return vals;
2042 }
2043 
2044 
2045 vector<string> CSrcTablePrimerColumn::x_GetValues(EPrimerColType col, const CPCRReaction& reaction) const
2046 {
2047  vector<string> vals;
2048  switch (col) {
2049  case eFwdSeq:
2050  case eFwdName:
2051  if (reaction.IsSetForward()) {
2052  vector<string> add = x_GetValues(col, reaction.GetForward());
2053  if (add.size() > 0) {
2054  vals.insert(vals.end(), add.begin(), add.end());
2055  }
2056  }
2057  break;
2058  case eRevSeq:
2059  case eRevName:
2060  if (reaction.IsSetReverse()) {
2061  vector<string> add = x_GetValues(col, reaction.GetReverse());
2062  if (add.size() > 0) {
2063  vals.insert(vals.end(), add.begin(), add.end());
2064  }
2065  }
2066  break;
2067  default:
2068  break;
2069  }
2070  return vals;
2071 }
2072 
2073 
2075 {
2076  vector<string> vals;
2077 
2078  switch (col) {
2079  case eFwdSeq:
2080  case eRevSeq:
2081  ITERATE(CPCRPrimerSet::Tdata, it, set.Get()) {
2082  if ((*it)->IsSetSeq()) {
2083  vals.push_back((*it)->GetSeq());
2084  }
2085  }
2086  break;
2087  case eFwdName:
2088  case eRevName:
2089  ITERATE(CPCRPrimerSet::Tdata, it, set.Get()) {
2090  if ((*it)->IsSetName()) {
2091  vals.push_back((*it)->GetName());
2092  }
2093  }
2094  break;
2095  default:
2096  break;
2097  }
2098  return vals;
2099 }
2100 
2101 
2102 
2103 bool CSrcTablePrimerColumn::x_ApplyStringToReaction(const string& val, CPCRReaction& reaction, EExistingText existing_text)
2104 {
2105  bool try_this = false;
2106  bool rval = false;
2107  if (existing_text == eExistingText_add_qual) {
2108  if (x_DoesReactionHaveSpace(reaction)) {
2109  try_this = true;
2110  }
2111  } else if (x_DoesReactionMatchConstraint(reaction)) {
2112  try_this = true;
2113  }
2114  if (try_this) {
2115  switch (m_ColType) {
2116  case eFwdSeq:
2117  case eFwdName:
2118  rval = x_ApplyStringToPrimerSet(val, reaction.SetForward(), existing_text);
2119  break;
2120  case eRevSeq:
2121  case eRevName:
2122  rval = x_ApplyStringToPrimerSet(val, reaction.SetReverse(), existing_text);
2123  break;
2124  default:
2125  break;
2126  }
2127  }
2128 
2129  return rval;
2130 }
2131 
2132 
2134 {
2135  bool rval = false;
2136  switch (m_ColType) {
2137  case eFwdSeq:
2138  case eRevSeq:
2139  {{
2140  CPCRPrimerSeq seq(val);
2141  /*if (set.IsSet() && set.Get().size() > 0) {
2142  if (!set.Get().back()->IsSetSeq()) {
2143  set.Set().back()->SetSeq(seq);
2144  rval = true;
2145  }
2146  } else */{
2147  CRef<CPCRPrimer> primer (new CPCRPrimer());
2148  primer->SetSeq(seq);
2149  set.Set().push_back(primer);
2150  rval = true;
2151  }
2152  }}
2153  break;
2154  case eFwdName:
2155  case eRevName:
2156  {{
2157  CPCRPrimerName name(val);
2158  /* if (set.IsSet() && set.Get().size() > 0) {
2159  if (!set.Get().back()->IsSetName()) {
2160  set.Set().back()->SetName(name);
2161  rval = true;
2162  }
2163  } else*/ {
2164  CRef<CPCRPrimer> primer (new CPCRPrimer());
2165  primer->SetName(name);
2166  set.Set().push_back(primer);
2167  rval = true;
2168  }
2169  }}
2170  break;
2171  default:
2172  break;
2173  }
2174  return rval;
2175 }
2176 
2177 
2179 {
2180  size_t i = 0;
2181  vector<string> values;
2182  NStr::Split(orig_val, ",", values);
2183  bool rval = false;
2184  switch (m_ColType) {
2185  case eFwdSeq:
2186  case eRevSeq:
2188  string val = orig_val;
2189  if (i < values.size() && !m_StringConstraint)
2190  val = values[i];
2191  i++;
2192  string str = "";
2193  if ((*it)->IsSetSeq()) {
2194  str = (*it)->GetSeq();
2195  }
2196  if (m_ColType != m_ConstraintCol || !m_StringConstraint || m_StringConstraint->DoesTextMatch(str)) {
2197  if (NStr::IsBlank(val) && existing_text == eExistingText_replace_old) {
2198  (*it)->ResetSeq();
2199  rval = true;
2200  } else if (AddValueToString(str, val, existing_text)) {
2201  CPCRPrimerSeq seq(str);
2202  (*it)->SetSeq(seq);
2203  rval = true;
2204  }
2205  }
2206  }
2207  break;
2208  case eFwdName:
2209  case eRevName:
2211  string val = orig_val;
2212  if (i < values.size() && !m_StringConstraint)
2213  val = values[i];
2214  i++;
2215  string str = "";
2216  if ((*it)->IsSetName()) {
2217  str = (*it)->GetName();
2218  }
2219  if (m_ColType != m_ConstraintCol || !m_StringConstraint || m_StringConstraint->DoesTextMatch(str)) {
2220  if (NStr::IsBlank(val) && existing_text == eExistingText_replace_old) {
2221  (*it)->ResetName();
2222  rval = true;
2223  } else if(AddValueToString(str, val, existing_text)) {
2224  CPCRPrimerName name(str);
2225  (*it)->SetName(name);
2226  rval = true;
2227  }
2228  }
2229  }
2230  break;
2231  default:
2232  break;
2233  }
2234 
2235  if (i < values.size() && (m_ConstraintCol == eNotPrimerCol || !m_StringConstraint)) {
2236  // no constraint, not found, add if there is an empty space
2237  for (; i < values.size(); i++)
2238  rval |= x_AddFieldToPrimerSet(values[i], set);
2239  }
2240 
2241  return rval;
2242 }
2243 
2244 
2246 {
2247  if (src.IsSetPcr_primers()) {
2248  if (src.GetPcr_primers().IsSet()) {
2249  CPCRReactionSet::Tdata::iterator it = src.SetPcr_primers().Set().begin();
2250  while (it != src.SetPcr_primers().Set().end()) {
2251  x_RemoveEmptyValues(**it);
2252  if (!(*it)->IsSetForward() && !(*it)->IsSetReverse()) {
2253  it = src.SetPcr_primers().Set().erase(it);
2254  } else {
2255  ++it;
2256  }
2257  }
2258  if (src.GetPcr_primers().Get().empty()) {
2259  src.SetPcr_primers().Reset();
2260  }
2261  }
2262  if (!src.GetPcr_primers().IsSet()) {
2263  src.ResetPcr_primers();
2264  }
2265  }
2266 }
2267 
2268 
2270 {
2271  if (reaction.IsSetForward()) {
2272  x_RemoveEmptyValues(reaction.SetForward());
2273  if (!reaction.GetForward().IsSet()) {
2274  reaction.ResetForward();
2275  }
2276  }
2277 
2278  if (reaction.IsSetReverse()) {
2279  x_RemoveEmptyValues(reaction.SetReverse());
2280  if (!reaction.GetReverse().IsSet()) {
2281  reaction.ResetReverse();
2282  }
2283  }
2284 }
2285 
2286 
2288 {
2289  if (set.IsSet()) {
2290  CPCRPrimerSet::Tdata::iterator it = set.Set().begin();
2291  while (it != set.Set().end()) {
2292  bool is_empty = true;
2293  if ((*it)->IsSetName()) {
2294  string str = (*it)->GetName();
2295  if (NStr::IsBlank(str)) {
2296  (*it)->ResetName();
2297  } else {
2298  is_empty = false;
2299  }
2300  }
2301  if((*it)->IsSetSeq()) {
2302  string str = (*it)->GetSeq();
2303  if (NStr::IsBlank(str)) {
2304  (*it)->ResetSeq();
2305  } else {
2306  is_empty = false;
2307  }
2308  }
2309  if (is_empty) {
2310  it = set.Set().erase(it);
2311  } else {
2312  ++it;
2313  }
2314  }
2315  if (set.Set().empty()) {
2316  set.Reset();
2317  }
2318  }
2319 }
2320 
2321 
2322 bool CSrcTablePrimerColumn::AddToBioSource(CBioSource & src, const string & newValue, EExistingText existing_text)
2323 {
2324  bool rval = false;
2325  vector<string> values;
2326  NStr::Split(newValue, ";", values);
2327  size_t i = 0;
2329  string value = newValue;
2330  if (i < values.size() && !m_StringConstraint)
2331  value = values[i];
2332  i++;
2333  rval |= x_ApplyStringToReaction(value, **it, existing_text);
2334  }
2335  if (i < values.size() && (m_ConstraintCol == eNotPrimerCol || !m_StringConstraint)) {
2336  for (; i < values.size(); i++)
2337  {
2338  CRef<CPCRReaction> reaction(new CPCRReaction());
2339  if (x_ApplyStringToReaction(values[i], *reaction, existing_text)) {
2340  src.SetPcr_primers().Set().push_back(reaction);
2341  rval = true;
2342  }
2343  }
2344  }
2345  return rval;
2346 }
2347 
2348 
2350 {
2351  vector<string> vals = x_GetValues(m_ColType, src);
2352  if (vals.size() > 0) {
2353  return vals[0];
2354  } else {
2355  return "";
2356  }
2357 }
2358 
2359 
2361 {
2362  vector<string> vals;
2363  if (src.IsSetPcr_primers()) {
2365  if (x_DoesReactionMatchConstraint(**it)) {
2366  vector<string> add = x_GetValues(m_ColType, **it);
2367  if (add.size() > 0) {
2368  vals.insert(vals.end(), add.begin(), add.end());
2369  }
2370  }
2371  }
2372  }
2373  return vals;
2374 }
2375 
2376 
2378 {
2380  x_RemoveEmptyValues(src);
2381 }
2382 
2383 
2384 bool IsFwdPrimerName (string name)
2385 {
2386  return (NStr::EqualNocase(name, "fwd-primer-name") || NStr::EqualNocase(name, "fwd primer name")
2387  || NStr::EqualNocase(name, "fwd-name") || NStr::EqualNocase(name, "fwd name"));
2388 }
2389 
2390 
2391 bool IsRevPrimerName (string name)
2392 {
2393  return (NStr::EqualNocase(name, "rev-primer-name") || NStr::EqualNocase(name, "rev primer name")
2394  || NStr::EqualNocase(name, "rev-name") || NStr::EqualNocase(name, "rev name"));
2395 }
2396 
2397 
2398 bool IsFwdPrimerSeq (string name)
2399 {
2400  return (NStr::EqualNocase(name, "fwd-primer-seq") || NStr::EqualNocase(name, "fwd primer seq")
2401  || NStr::EqualNocase(name, "fwd-seq") || NStr::EqualNocase(name, "fwd seq"));
2402 }
2403 
2404 
2405 bool IsRevPrimerSeq (string name)
2406 {
2407  return (NStr::EqualNocase(name, "rev-primer-seq") || NStr::EqualNocase(name, "rev primer seq")
2408  || NStr::EqualNocase(name, "rev-seq") || NStr::EqualNocase(name, "rev seq"));
2409 }
2410 
2411 
2412 // class CSrcTableAllPrimersColumn
2414 {
2419 
2420  string primer_value = fwdseq->GetFromBioSource(src);
2421  if (NStr::IsBlank(primer_value)) {
2422  primer_value = revseq->GetFromBioSource(src);
2423  if (NStr::IsBlank(primer_value)) {
2424  primer_value = fwdname->GetFromBioSource(src);
2425  if (NStr::IsBlank(primer_value)) {
2426  primer_value = revname->GetFromBioSource(src);
2427  }
2428  }
2429  }
2430  return primer_value;
2431 }
2432 
2434 {
2435  vector <string> vals;
2436 
2438  string note = fwdseq->GetFromBioSource(src);
2439  if (!note.empty()) {
2440  vals.push_back(note);
2441  }
2443  note = kEmptyStr;
2444  note = revseq->GetFromBioSource(src);
2445  if (!note.empty()) {
2446  vals.push_back(note);
2447  }
2449  note = kEmptyStr;
2450  note = fwdname->GetFromBioSource(src);
2451  if (!note.empty()) {
2452  vals.push_back(note);
2453  }
2455  note = kEmptyStr;
2456  note = revname->GetFromBioSource(src);
2457  if (!note.empty()) {
2458  vals.push_back(note);
2459  }
2460 
2461  return vals;
2462 }
2463 
2465 {
2466  if (in_out_bioSource.IsSetPcr_primers()) {
2467  in_out_bioSource.ResetPcr_primers();
2468  }
2469 }
2470 
2471 
2472 // J. Chen
2474 {
2475  return (biosrc.IsSetCommon() ? biosrc.GetCommon() : kEmptyStr);
2476 }
2477 
2479 {
2480  return (biosrc.IsSetLineage() ? biosrc.GetLineage() : kEmptyStr);
2481 }
2482 
2484 {
2485  return (biosrc.IsSetDivision() ? biosrc.GetDivision() : kEmptyStr);
2486 }
2487 
2488 
2489 // class CSrcTableDbxrefColumn
2491 {
2492  if (!biosrc.GetOrg().IsSetDb()) {
2493  return kEmptyStr;
2494  }
2495 
2496  if (NStr::IsBlank(m_DbName)) {
2497  string label;
2498  biosrc.GetOrg().GetDb().front()->GetLabel(&label);
2499  return label;
2500  } else {
2501  FOR_EACH_DBXREF_ON_ORGREF(db, biosrc.GetOrg()) {
2502  if ((*db)->IsSetDb() && NStr::EqualCase((*db)->GetDb(), m_DbName) && (*db)->IsSetTag()) {
2503  CNcbiOstrstream oss;
2504  (*db)->GetTag().AsString(oss);
2505  return CNcbiOstrstreamToString(oss);
2506  }
2507  }
2508  }
2509  return kEmptyStr;
2510 };
2511 
2512 vector<string> CSrcTableDbxrefColumn::GetValsFromBioSource(const CBioSource& biosrc) const
2513 {
2514  vector<string> vals;
2515  if (!biosrc.GetOrg().IsSetDb()) {
2516  return vals;
2517  }
2518 
2519  if (NStr::IsBlank(m_DbName)) {
2520  FOR_EACH_DBXREF_ON_ORGREF(db, biosrc.GetOrg()) {
2521  string label;
2522  (*db)->GetLabel(&label);
2523  vals.push_back(label);
2524  }
2525  }
2526  else {
2527  vals.push_back(GetFromBioSource(biosrc));
2528  }
2529  return vals;
2530 }
2531 
2533 {
2534  return (NStr::IsBlank(m_DbName)) ? true : false;
2535 }
2536 
2537 bool CSrcTableDbxrefColumn::AddToBioSource(CBioSource & in_out_bioSource, const string & newValue, EExistingText existing_text)
2538 {
2539  vector<string> values;
2540  NStr::Split(newValue, ";", values);
2541  for (auto value : values)
2542  {
2543  {
2544  string db, tag;
2545  NStr::SplitInTwo(value, ":", db, tag);
2546  if (!db.empty() && !tag.empty())
2547  {
2548  m_DbName = db;
2549  value = tag;
2550  }
2551  }
2552  if (NStr::IsBlank(m_DbName)) {
2553  continue;
2554  }
2555 
2556  if (existing_text == edit::eExistingText_leave_old) {
2557  continue;
2558  }
2559 
2560  // if there is one already present, overwrite it
2561  EDIT_EACH_DBXREF_ON_ORGREF(db, in_out_bioSource.SetOrg()) {
2562  if ((*db)->IsSetDb() && NStr::EqualCase((*db)->GetDb(), m_DbName) && (*db)->IsSetTag()) {
2563  CObject_id& tag = (*db)->SetTag();
2564  CNcbiOstrstream oss;
2565  (*db)->GetTag().AsString(oss);
2566  string orig_val = CNcbiOstrstreamToString(oss);
2567  if (AddValueToString(orig_val, value, existing_text)) {
2568  tag.SetStr(orig_val);
2569  continue;
2570  }
2571  }
2572  }
2573 
2574  // otherwise make a new one
2575  CRef<CDbtag> db_tag(new CDbtag());
2576  db_tag->SetDb(m_DbName);
2577  try {
2578  int val = NStr::StringToInt(value);
2579  db_tag->SetTag().SetId(val);
2580  }
2581  catch (exception &) {
2582  db_tag->SetTag().SetStr(value);
2583  }
2584 
2585  in_out_bioSource.SetOrg().SetDb().push_back(db_tag);
2586  }
2587  return true;
2588 }
2589 
2590 void CSrcTableDbxrefColumn::ClearInBioSource(objects::CBioSource & in_out_bioSource )
2591 {
2592  if (in_out_bioSource.IsSetOrg() && in_out_bioSource.GetOrg().IsSetDb()) {
2593  in_out_bioSource.SetOrg().ResetDb();
2594  }
2595 }
2596 
2597 
2598 // class CSrcTableAllNotesColumn
2599 vector <string> CSrcTableAllNotesColumn::GetValsFromBioSource(const CBioSource& biosrc) const
2600 {
2601  vector <string> vals;
2602 
2605  string note = subsrc_note->GetFromBioSource(biosrc);
2606  if (!note.empty()) {
2607  vals.push_back(note);
2608  }
2610  orgmod_note( new CSrcTableOrgModColumn (COrgMod::eSubtype_other));
2611  note = kEmptyStr;
2612  note = orgmod_note->GetFromBioSource(biosrc);
2613  if (!note.empty()) {
2614  vals.push_back(note);
2615  }
2616 
2617  return vals;
2618 };
2619 // J. Chen
2620 
2621 string CSrcTableAllNotesColumn::GetFromBioSource(const CBioSource & in_out_bioSource) const
2622 {
2623  // return only the first found note on the biosource
2624  vector<string> note_values = GetValsFromBioSource(in_out_bioSource);
2625  if ( !note_values.empty() ){
2626  return note_values.front();
2627  }
2628  return kEmptyStr;
2629 }
2630 
2632 {
2635 
2636  orgmod_note->ClearInBioSource(in_out_bioSource);
2637  subsrc_note->ClearInBioSource(in_out_bioSource);
2638 }
2639 
2640 
2641 // class CSrcTableTaxonIdColumn
2642 bool CSrcTableTaxonIdColumn::AddToBioSource(CBioSource & in_out_bioSource, const string & newValue, EExistingText existing_text)
2643 {
2644  try {
2645  int val = NStr::StringToInt(newValue);
2646  in_out_bioSource.SetOrg().SetTaxId(val);
2647  return true;
2648  } catch (exception &) {
2649  }
2650  return false;
2651 }
2652 
2654 {
2655  if (in_out_bioSource.IsSetOrg() && in_out_bioSource.GetOrg().IsSetDb()) {
2656  COrg_ref::TDb::iterator it = in_out_bioSource.SetOrg().SetDb().begin();
2657  while (it != in_out_bioSource.SetOrg().SetDb().end()) {
2658  if ((*it)->IsSetDb() && NStr::EqualNocase((*it)->GetDb(), "taxon")) {
2659  it = in_out_bioSource.SetOrg().SetDb().erase(it);
2660  } else {
2661  ++it;
2662  }
2663  }
2664  }
2665 }
2666 
2667 string CSrcTableTaxonIdColumn::GetFromBioSource(const CBioSource & in_out_bioSource) const
2668 {
2669  string val = "";
2670  if (in_out_bioSource.IsSetOrg()) {
2671  try {
2672  int taxid = in_out_bioSource.GetOrg().GetTaxId();
2673  val = NStr::NumericToString(taxid);
2674  } catch (exception &) {
2675  }
2676  }
2677  return val;
2678 }
2679 
2680 
2681 // class CSrcTableColumnBaseFactory
2683 CSrcTableColumnBaseFactory::Create(const string &column_name)
2684 {
2685  // the default is a CSrcTableEditCommandFactory that does nothing
2686 
2687  string sTitle = column_name;
2688  SIZE_TYPE nl_pos = NStr::Find(sTitle, "\n");
2689  if ( nl_pos != NPOS ) {
2690  sTitle = sTitle.substr(0, nl_pos);
2691  }
2692 
2693  SIZE_TYPE desc_pos = NStr::FindNoCase(sTitle, " descriptor");
2694  SIZE_TYPE feat_pos = NStr::FindNoCase(sTitle, " feature");
2696  if (desc_pos != NPOS) {
2697  sTitle = sTitle.substr(0, desc_pos);
2699  } if (feat_pos != NPOS) {
2700  sTitle = sTitle.substr(0, feat_pos);
2701  src_type = CSrcTableColumnBase::eFeature;
2702  }
2703 
2704  if (sTitle.empty()) {
2706  }
2707 
2708  if (sTitle == kSequenceIdColLabel) {
2710  }
2711 
2712  if (NStr::EqualNocase(sTitle, kHost)) {
2713  sTitle = kNatHost;
2714  }
2715 
2717 
2718  if( NStr::EqualNocase(sTitle, "Organism Name") || NStr::EqualNocase(sTitle, "org") || NStr::EqualNocase(sTitle, "taxname") ) {
2720  } else if( NStr::EqualNocase(sTitle, "Taxname after Binomial")) {
2722  } else if (!NStr::Equal(sTitle, kGenomeProjectID, NStr::eNocase) && NStr::StartsWith( sTitle, "genome", NStr::eNocase )) {
2723  string organelle = sTitle.substr(6, NPOS);
2724  NStr::TruncateSpacesInPlace(organelle);
2725  rval = CRef<CSrcTableColumnBase>( new CSrcTableGenomeColumn(organelle) );
2726  } else if (NStr::EqualNocase( sTitle, "origin" )) {
2728  } else if (NStr::EqualNocase(sTitle, kSubSourceNote)
2729  || NStr::EqualNocase(sTitle, "subsource-note")
2730  || NStr::EqualNocase(sTitle, "subsrc-note")
2731  || NStr::EqualNocase(sTitle, "note-subsrc")) {
2733  } else if (NStr::EqualNocase(sTitle, kOrgModNote)
2734  || NStr::EqualNocase(sTitle, "orgmod-note")) {
2736  } else if (IsFwdPrimerName(sTitle)) {
2738  } else if (IsFwdPrimerSeq(sTitle)) {
2740  } else if (IsRevPrimerName(sTitle)) {
2742  } else if (IsRevPrimerSeq(sTitle)) {
2744  } else if (NStr::EqualNocase(sTitle, "common-name") || NStr::EqualNocase(sTitle, "common name")) {
2746  } else if (NStr::EqualNocase(sTitle, "lineage")) {
2748  } else if (NStr::EqualNocase(sTitle, "division")) {
2750  } else if (NStr::StartsWith(sTitle, "dbxref", NStr::eNocase)) {
2751  string dbname = sTitle.substr(6, NPOS);
2754  } else if (NStr::EqualNocase(sTitle, "taxid")) {
2756  } else if (NStr::EqualNocase(sTitle, "all-notes") || NStr::EqualNocase(sTitle, kAllNotes)) {
2758  } else if (NStr::EqualNocase(sTitle, kAllPrimers)) {
2760  }
2761  // see if it is a structured voucher - an orgmod qualifier
2762  else if (NStr::EndsWith(sTitle, "-inst") || NStr::EndsWith(sTitle, "-coll") || NStr::EndsWith(sTitle, "-specid")) {
2764  if ( pos != NPOS) {
2765  string subtype = sTitle.substr(0, pos);
2766  bool isorgmod = COrgMod::IsValidSubtypeName(subtype, COrgMod::eVocabulary_insdc);
2767  if (isorgmod) {
2772  }
2773  }
2774  }
2781  }
2782 
2783  if (rval) {
2784  rval->SetSourceType(src_type);
2785  }
2786  return rval;
2787 }
2788 
2789 
2792 {
2793  // extract the title of the column
2794  if( ! column.IsSetHeader() || ! column.GetHeader().IsSetTitle() ) {
2795  return CRef<CSrcTableColumnBase>( NULL );
2796  }
2797 
2798  string sTitle = column.GetHeader().GetTitle();
2799 
2800  return CSrcTableColumnBaseFactory::Create(sTitle);
2801 }
2802 
2803 
2805 {
2806  CRef<CCmdComposite> cmd( new CCmdComposite("Bulk Source Edit") );
2807 
2809 
2810  if (!id_col) {
2811  return cmd;
2812  }
2813 
2814  if( ! values_table->IsSetColumns() || values_table->GetColumns().empty() ) {
2815  return cmd;
2816  }
2817  const CSeq_table::TColumns & columns = values_table->GetColumns();
2818  size_t num_cols = columns.size();
2819 
2820  // create an edit-command maker for every column. This somewhat byzantine
2821  // system is here to speed things up to avoid re-parsing the meaning
2822  // of each column every time.
2823  vector< CRef<CSrcTableColumnBase> > vecColEditFactories;
2824 
2825  ITERATE( CSeq_table::TColumns, col_iter, columns ) {
2826  if ((*col_iter)->GetHeader().GetTitle().empty() || NStr::EqualNocase((*col_iter)->GetHeader().GetTitle(), kProblems))
2827  {
2829  vecColEditFactories.push_back(bogus);
2830  }
2831  else
2832  {
2833  vecColEditFactories.push_back( CSrcTableColumnBaseFactory::Create(**col_iter) );
2834  }
2835  }
2836 
2837 
2838  for (int row = 0; row < values_table->GetNum_rows() && (size_t) row < id_col->GetData().GetSize(); row++) {
2839  CBioseq_Handle bsh = seh.GetBioseqHandle(*(id_col->GetData().GetId()[row]));
2840 
2841  CRef<CSeqdesc> new_source_desc( new CSeqdesc );
2842  CSeqdesc_CI desc_ci( bsh, CSeqdesc::e_Source);
2843  if (desc_ci) {
2844  new_source_desc->Assign(*desc_ci);
2845  }
2846  CBioSource & bioSource = new_source_desc->SetSource();
2847 
2848  // iterate through the columns, skipping Seq-id column, to erase current values
2849  // need to do this in separate steps, in case of multiple qualifier columns in table
2850  for( size_t col = 1; col < num_cols; ++col ) {
2851  if (vecColEditFactories[col])
2852  vecColEditFactories[col]->ClearInBioSource(bioSource);
2853  // TODO: detect if change occurred to avoid excessive changes
2854  }
2855 
2856  // iterate through the columns, skipping Seq-id column
2857  for( size_t col = 1; col < num_cols; ++col ) {
2858  if (vecColEditFactories[col] && columns[col]->GetData().GetSize() > (size_t) row) {
2859  vecColEditFactories[col]->AddToBioSource(
2860  bioSource, *columns[col]->GetStringPtr(row), eExistingText_replace_old);
2861  }
2862  // TODO: detect if change occurred to avoid excessive changes
2863  }
2864  // automatically populate taxon ID, div, genetic codes if available
2866 
2867  if (desc_ci) {
2868  CRef<CCmdChangeSeqdesc> ecmd(new CCmdChangeSeqdesc(desc_ci.GetSeq_entry_Handle(), *desc_ci, *new_source_desc));
2869  cmd->AddCommand (*ecmd);
2870  } else {
2872  if (bssh && bssh.IsSetClass() && bssh.GetClass() == CBioseq_set::eClass_nuc_prot) {
2873  cmd->AddCommand( *CRef<CCmdCreateDesc>(new CCmdCreateDesc(bssh.GetParentEntry(), *new_source_desc)) );
2874  } else {
2875  cmd->AddCommand( *CRef<CCmdCreateDesc>(new CCmdCreateDesc(bsh.GetParentEntry(), *new_source_desc)) );
2876  }
2877  }
2878  }
2879 
2880  // send composite command
2881  return cmd;
2882 }
2883 
2884 
2886 {
2887  bool found = false;
2888  if (id1->IsLocal()) {
2889  string id1_label = "";
2890  id1->GetLabel(&id1_label, CSeq_id::eContent);
2891  string id2_label = "";
2892  id2->GetLabel(&id2_label, CSeq_id::eContent);
2893  id2->GetLabel(&id2_label, CSeq_id::eContent);
2894  size_t pos = NStr::Find (id2_label, id1_label);
2895  if (pos == 0) {
2896  if (NStr::Equal(id2_label.substr(id1_label.length(), 1), ".")) {
2897  found = true;
2898  }
2899  } else if (pos != string::npos && NStr::EndsWith(id2_label, id1_label)) {
2900  string delim = id2_label.substr(pos - 1, 1);
2901  if (NStr::Equal(delim, "|") || NStr::Equal(delim, "/") || NStr::Equal(delim, ":")) {
2902  found = true;
2903  }
2904  }
2905  }
2906  return found;
2907 }
2908 
2909 
2911 {
2912  if (!id || !id_col) {
2913  return false;
2914  }
2915 
2916  size_t row = 0;
2917  bool found = false;
2918  while (row < id_col->GetData().GetSize() && !found) {
2919  CRef<CSeq_id> row_id = id_col->GetData().GetId()[row];
2920  CSeq_id::E_SIC compare = id->Compare(*row_id);
2921  if (compare == CSeq_id::e_YES) {
2922  found = true;
2923  } else if (compare == CSeq_id::e_DIFF) {
2924  if (RelaxedMatch(id, row_id)) {
2925  found = true;
2926  id->Assign(*row_id);
2927  }
2928  }
2929  row++;
2930  }
2931  row = 0;
2932  while (row < id_col->GetData().GetSize() && !found) {
2933  CRef<CSeq_id> row_id = id_col->GetData().GetId()[row];
2934  CBioseq_Handle bsh = seh.GetBioseqHandle (*row_id);
2935  if (bsh) {
2937  ITERATE (CBioseq::TId, id_it, b->GetId()) {
2938  CSeq_id::E_SIC compare = id->Compare(**id_it);
2939  if (compare == CSeq_id::e_YES) {
2940  found = true;
2941  id->Assign(*row_id);
2942  break;
2943  } else if (compare == CSeq_id::e_DIFF) {
2944  if (RelaxedMatch(id, *id_it)) {
2945  found = true;
2946  id->Assign(*row_id);
2947  break;
2948  }
2949  }
2950  }
2951  }
2952  row++;
2953  }
2954 
2955  return found;
2956 }
2957 
2958 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
static bool AutoFill(objects::COrg_ref &org)
const string & GetLineage(void) const
Definition: BioSource.cpp:360
bool IsSetCommon(void) const
Definition: BioSource.cpp:345
const string & GetTaxname(void) const
Definition: BioSource.cpp:340
bool IsSetOrgMod(void) const
Definition: BioSource.cpp:415
static string GetOrganelleByGenome(unsigned int genome)
Definition: BioSource.cpp:216
const string & GetCommon(void) const
Definition: BioSource.cpp:350
const COrgName & GetOrgname(void) const
Definition: BioSource.cpp:410
const string & GetDivision(void) const
Definition: BioSource.cpp:400
static CBioSource::EOrigin GetOriginByString(const string &origin, NStr::ECase use_case=NStr::eCase, bool starts_with=false)
Definition: BioSource.cpp:254
bool IsSetLineage(void) const
Definition: BioSource.cpp:355
bool IsSetDivision(void) const
Definition: BioSource.cpp:395
static CBioSource::EGenome GetGenomeByOrganelle(const string &organelle, NStr::ECase use_case=NStr::eCase, bool starts_with=false)
Definition: BioSource.cpp:168
static string GetStringFromOrigin(unsigned int origin)
Definition: BioSource.cpp:320
bool IsSetTaxname(void) const
Definition: BioSource.cpp:335
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
CBioseq_set_Handle –.
Definition: Dbtag.hpp:53
CFeat_CI –.
Definition: feat_ci.hpp:64
virtual string GetValue(const objects::CBioSource &src)
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
CObject –.
Definition: ncbiobj.hpp:180
objects::COrgMod::TSubtype m_Subtype
COrgModQual()
Constructors.
virtual string GetValue(const objects::CBioSource &src)
virtual string GetFormatErrors(string value)
@OrgMod.hpp User-defined methods of the data storage class.
Definition: OrgMod.hpp:54
@ eVocabulary_insdc
Definition: OrgMod.hpp:69
static bool IsValidSubtypeName(const string &str, EVocabulary vocabulary=eVocabulary_raw)
Definition: OrgMod.cpp:86
static string GetSubtypeName(TSubtype stype, EVocabulary vocabulary=eVocabulary_raw)
Definition: OrgMod.cpp:108
static TSubtype GetSubtypeValue(const string &str, EVocabulary vocabulary=eVocabulary_raw)
Definition: OrgMod.cpp:62
static string MakeStructuredVoucher(const string &inst, const string &coll, const string &id)
Definition: OrgMod.cpp:540
static bool ParseStructuredVoucher(const string &str, string &inst, string &coll, string &id)
Definition: OrgMod.cpp:188
TTaxId GetTaxId() const
Definition: Org_ref.cpp:72
CPCRPrimerName –.
CPCRPrimerSet –.
CPCRPrimer –.
Definition: PCRPrimer.hpp:66
CPCRReaction –.
Definition: PCRReaction.hpp:66
size_t GetSize(void) const
CSeq_entry_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
void AddColumnsToSeqTable(CRef< objects::CSeq_table > values_table)
void x_AddOneOfProblems(CRef< objects::CSeq_table >, vector< string > one_of_list, CRef< objects::CSeqTable_column > problems)
int x_AddUniquenessProblems(CRef< objects::CSeq_table > values_table, vector< string > uniqueness_list, vector< string > &row_problems)
void SetExamples(EWizardType wizard_type, EWizardSrcType src_type)
CSourceRequirements()
Constructors.
virtual ~CSourceRequirements()
Destructor.
void AddUniquenessList(vector< string > list)
void AddOneOfList(vector< string > list)
TSrcQualList m_Requirements
vector< vector< string > > m_UniquenessLists
void AddRequirement(string name, bool required, string example="")
vector< vector< string > > m_OneOfLists
void PreferentiallyAddRequirement(CRef< objects::CSeq_table > values_table, string choice1, string choice2, bool required)
CRef< objects::CSeqTable_column > CheckSourceQuals(CRef< objects::CSeq_table > values_table)
string m_Example
string m_Name
bool m_Required
virtual ~CSrcQual()
Destructor.
bool m_ReportMissing
virtual string GetValue(const objects::CBioSource &src)
CSrcQual()
Constructors.
void x_ParsePartsFromStructuredVoucher(const string &qualifier, string &inst, string &coll, string &id) const
virtual vector< string > GetValsFromBioSource(const objects::CBioSource &src) const
virtual bool AddToBioSource(objects::CBioSource &src, const string &newValue, objects::edit::EExistingText existing_text)
static const string & GetName_StrVoucherPart(EStructVouchPart stype_part)
virtual string GetFromBioSource(const objects::CBioSource &in_out_bioSource) const
static EStructVouchPart GetStrVoucherPart_FromName(const string &name)
virtual void ClearInBioSource(objects::CBioSource &in_out_bioSource)
virtual vector< string > GetValsFromBioSource(const objects::CBioSource &biosrc) const
virtual string GetFromBioSource(const objects::CBioSource &in_out_bioSource) const
virtual void ClearInBioSource(objects::CBioSource &in_out_bioSource)
virtual void ClearInBioSource(objects::CBioSource &in_out_bioSource)
virtual string GetFromBioSource(const objects::CBioSource &src) const
virtual vector< string > GetValsFromBioSource(const objects::CBioSource &src) const
static CRef< CSrcTableColumnBase > Create(const objects::CSeqTable_column &column)
virtual void ClearInBioSource(objects::CBioSource &in_out_bioSource)
virtual vector< string > GetValsFromBioSource(const objects::CBioSource &src) const
vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(CBioseq_Handle bsh)
string GetVal(const CObject &object)
vector< string > GetVals(const CObject &object)
virtual string GetFromBioSource(const objects::CBioSource &in_out_bioSource) const =0
vector< CConstRef< CObject > > GetObjects(CBioseq_Handle bsh)
void SetSourceType(ESourceType type)
void ClearVal(CObject &object)
virtual string GetFromBioSource(const objects::CBioSource &biosrc) const
virtual bool AllowMultipleValues()
virtual bool AddToBioSource(objects::CBioSource &in_out_bioSource, const string &newValue, objects::edit::EExistingText existing_text)
virtual void ClearInBioSource(objects::CBioSource &in_out_bioSource)
virtual vector< string > GetValsFromBioSource(const objects::CBioSource &biosrc) const
virtual string GetFromBioSource(const objects::CBioSource &biosrc) const
virtual string GetFromBioSource(const objects::CBioSource &biosrc) const
virtual string GetFromBioSource(const objects::CBioSource &in_out_bioSource) const
virtual vector< string > IsValid(const vector< string > &values)
virtual void ClearInBioSource(objects::CBioSource &in_out_bioSource)
virtual bool AddToBioSource(objects::CBioSource &src, const string &newValue, objects::edit::EExistingText existing_text)
CSrcTableGenomeColumn(const string &organelle=kEmptyStr)
virtual string GetFromBioSource(const objects::CBioSource &biosrc) const
virtual bool AddToBioSource(objects::CBioSource &src, const string &newValue, objects::edit::EExistingText existing_text)
virtual vector< string > GetValsFromBioSource(const objects::CBioSource &biosrc) const
virtual void ClearInBioSource(objects::CBioSource &in_out_bioSource)
virtual string GetFromBioSource(const objects::CBioSource &in_out_bioSource) const
objects::COrgMod::TSubtype m_Subtype
virtual void ClearInBioSource(objects::CBioSource &in_out_bioSource)
virtual bool AddToBioSource(objects::CBioSource &src, const string &newValue, objects::edit::EExistingText existing_text)
virtual string GetFromBioSource(const objects::CBioSource &in_out_bioSource) const
virtual void ClearInBioSource(objects::CBioSource &in_out_bioSource)
virtual string GetFromBioSource(const objects::CBioSource &in_out_bioSource) const
virtual vector< string > IsValid(const vector< string > &values)
virtual bool AddToBioSource(objects::CBioSource &src, const string &newValue, objects::edit::EExistingText existing_text)
virtual vector< string > GetValsFromBioSource(const CBioSource &src) const
bool x_ApplyStringToReaction(const string &val, CPCRReaction &reaction, objects::edit::EExistingText existing_text)
bool x_DoesPrimerSetHaveSpace(const CPCRPrimerSet &set)
bool x_DoesReactionMatchConstraint(const CPCRReaction &reaction) const
virtual void SetConstraint(const string &field_name, CConstRef< edit::CStringConstraint > string_constraint)
bool x_AddFieldToPrimerSet(const string &val, CPCRPrimerSet &set)
virtual bool AddToBioSource(objects::CBioSource &src, const string &newValue, objects::edit::EExistingText existing_text)
bool x_ApplyStringToPrimerSet(const string &val, CPCRPrimerSet &set, objects::edit::EExistingText existing_text)
bool x_DoesReactionHaveSpace(const CPCRReaction &reaction)
EPrimerColType m_ColType
void x_RemoveEmptyValues(CBioSource &src)
static EPrimerColType GetPrimerColumnType(const string &field_name)
virtual void ClearInBioSource(objects::CBioSource &src)
virtual string GetFromBioSource(const objects::CBioSource &src) const
CRef< edit::CStringConstraint > m_StringConstraint
EPrimerColType m_ConstraintCol
vector< string > x_GetValues(EPrimerColType col, const CBioSource &src) const
objects::CSubSource::TSubtype m_Subtype
virtual vector< string > GetValsFromBioSource(const objects::CBioSource &biosrc) const
virtual void ClearInBioSource(objects::CBioSource &in_out_bioSource)
virtual bool AddToBioSource(objects::CBioSource &src, const string &newValue, objects::edit::EExistingText existing_text)
virtual string GetFromBioSource(const objects::CBioSource &in_out_bioSource) const
virtual bool AddToBioSource(objects::CBioSource &in_out_bioSource, const string &newValue, objects::edit::EExistingText existing_text)
virtual void ClearInBioSource(objects::CBioSource &in_out_bioSource)
virtual string GetFromBioSource(const objects::CBioSource &in_out_bioSource) const
string x_GetTextAfterNomial(const string &taxname) const
virtual void ClearInBioSource(objects::CBioSource &in_out_bioSource)
virtual string GetFromBioSource(const objects::CBioSource &in_out_bioSource) const
virtual bool AddToBioSource(objects::CBioSource &src, const string &newValue, objects::edit::EExistingText existing_text)
class CStaticArrayMap<> provides access to a static array in much the same way as CStaticArraySet<>,...
Definition: static_map.hpp:175
TBase::const_iterator const_iterator
Definition: static_map.hpp:179
static TSubtype GetSubtypeValue(const string &str, EVocabulary vocabulary=eVocabulary_raw)
Definition: SubSource.cpp:128
static bool IsValidSubtypeName(const string &str, EVocabulary vocabulary=eVocabulary_raw)
Definition: SubSource.cpp:157
@ eVocabulary_insdc
Definition: SubSource.hpp:83
static string GetSubtypeName(CSubSource::TSubtype stype, EVocabulary vocabulary=eVocabulary_raw)
Definition: SubSource.cpp:185
static bool NeedsNoText(const TSubtype &subtype)
Definition: SubSource.cpp:233
vector< string > m_BadIsolationSourceValues
objects::CSubSource::TSubtype m_Subtype
virtual string GetFormatErrors(string value)
CSubSrcQual()
Constructors.
virtual string GetValue(const objects::CBioSource &src)
virtual string GetValue(const objects::CBioSource &src)
virtual string GetFormatErrors(string value)
Definition: map.hpp:338
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator begin() const
Definition: set.hpp:135
size_type size() const
Definition: set.hpp:132
bool empty() const
Definition: set.hpp:133
void erase(iterator pos)
Definition: set.hpp:151
const_iterator end() const
Definition: set.hpp:136
const string kProblems
const char * kOrgModNote
const char * kGenomeProjectID
const char * kDbXref
const char * kAllNotes
const char * kAllPrimers
const char * kSubSourceNote
const char * kNatHost
const char * kHost
const char * kSequenceIdColLabel
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static const struct name_t names[]
#define true
Definition: bool.h:35
static char col1[256]
Definition: compute.c:13
static char col2[256]
Definition: compute.c:13
static const char * str(char *buf, int n)
Definition: stats.c:84
static const char * column
Definition: stats.c:23
static char tmp[3200]
Definition: utf8.c:42
static const column_t columns[]
Definition: utf8_2.c:22
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
#define ENUM_METHOD_NAME(EnumName)
Definition: serialbase.hpp:994
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:2040
E_SIC
Compare return values.
Definition: Seq_id.hpp:579
@ e_DIFF
some problem
Definition: Seq_id.hpp:581
@ e_YES
SeqIds compared, but are different.
Definition: Seq_id.hpp:583
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:605
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
TClass GetClass(void) const
CBioseq_set_Handle GetParentBioseq_set(void) const
Return a handle for the parent Bioseq-set, or null handle.
CSeq_entry_Handle GetParentEntry(void) const
Get parent Seq-entry handle.
CConstRef< CSeq_id > GetSeqId(void) const
Get id which can be used to access this bioseq handle Throws an exception if none is available.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id) const
Get Bioseq handle from the TSE of this Seq-entry.
CSeq_entry_Handle GetParentEntry(void) const
Return a handle for the parent seq-entry of the bioseq.
bool IsSetClass(void) const
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Definition: seqdesc_ci.cpp:326
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
NCBI_NS_STD::string::size_type SIZE_TYPE
Definition: ncbistr.hpp:132
#define kEmptyStr
Definition: ncbistr.hpp:123
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3461
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
Definition: ncbistr.cpp:2993
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
Definition: ncbistr.hpp:5430
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
#define NPOS
Definition: ncbistr.hpp:133
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3201
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
Definition: ncbistr.cpp:2891
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2697
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 bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
Definition: ncbistr.cpp:3554
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5353
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
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 string & ToUpper(string &str)
Convert string to upper case – string& version.
Definition: ncbistr.cpp:424
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
Definition: ncbistr.hpp:2508
@ eReverseSearch
Search in a backward direction.
Definition: ncbistr.hpp:1947
@ eTrunc_End
Truncate trailing spaces only.
Definition: ncbistr.hpp:2241
@ eNocase
Case insensitive compare.
Definition: ncbistr.hpp:1206
@ eCase
Case sensitive compare.
Definition: ncbistr.hpp:1205
static const char label[]
const Tdata & Get(void) const
Get the member data.
const TSubtype & GetSubtype(void) const
Get the Subtype member data.
Definition: BioSource_.hpp:539
const TPcr_primers & GetPcr_primers(void) const
Get the Pcr_primers member data.
Definition: BioSource_.hpp:588
TGenome GetGenome(void) const
Get the Genome member data.
Definition: BioSource_.hpp:422
TOrigin GetOrigin(void) const
Get the Origin member data.
Definition: BioSource_.hpp:472
void ResetGenome(void)
Reset Genome data member.
Definition: BioSource_.hpp:409
void ResetOrigin(void)
Reset Origin data member.
Definition: BioSource_.hpp:459
const Tdata & Get(void) const
Get the member data.
bool IsSetOrg(void) const
Check if a value has been assigned to Org data member.
Definition: BioSource_.hpp:497
list< CRef< CSubSource > > TSubtype
Definition: BioSource_.hpp:145
bool IsSetSubtype(void) const
Check if a value has been assigned to Subtype data member.
Definition: BioSource_.hpp:527
bool IsSetPcr_primers(void) const
Check if a value has been assigned to Pcr_primers data member.
Definition: BioSource_.hpp:576
void SetOrigin(TOrigin value)
Assign a value to Origin data member.
Definition: BioSource_.hpp:478
const TForward & GetForward(void) const
Get the Forward member data.
void SetSeq(const TSeq &value)
Assign a value to Seq data member.
Definition: PCRPrimer_.hpp:220
const TOrg & GetOrg(void) const
Get the Org member data.
Definition: BioSource_.hpp:509
bool IsSetOrigin(void) const
Check if a value has been assigned to Origin data member.
Definition: BioSource_.hpp:447
void SetGenome(TGenome value)
Assign a value to Genome data member.
Definition: BioSource_.hpp:428
void SetForward(TForward &value)
Assign a value to Forward data member.
bool IsSetGenome(void) const
Check if a value has been assigned to Genome data member.
Definition: BioSource_.hpp:397
void ResetReverse(void)
Reset Reverse data member.
void SetPcr_primers(TPcr_primers &value)
Assign a value to Pcr_primers data member.
Definition: BioSource_.cpp:124
void SetReverse(TReverse &value)
Assign a value to Reverse data member.
void SetName(const TName &value)
Assign a value to Name data member.
Definition: PCRPrimer_.hpp:255
void SetOrg(TOrg &value)
Assign a value to Org data member.
Definition: BioSource_.cpp:108
bool IsSetReverse(void) const
Check if a value has been assigned to Reverse data member.
void ResetForward(void)
Reset Forward data member.
const TReverse & GetReverse(void) const
Get the Reverse member data.
list< CRef< CPCRReaction > > Tdata
bool IsSetForward(void) const
Check if a value has been assigned to Forward data member.
bool IsSet(void) const
Check if a value has been assigned to data member.
bool IsSet(void) const
Check if a value has been assigned to data member.
TSubtype & SetSubtype(void)
Assign a value to Subtype data member.
Definition: BioSource_.hpp:545
void ResetPcr_primers(void)
Reset Pcr_primers data member.
Definition: BioSource_.cpp:119
void ResetSubtype(void)
Reset Subtype data member.
Definition: BioSource_.cpp:113
list< CRef< CPCRPrimer > > Tdata
void SetTag(TTag &value)
Assign a value to Tag data member.
Definition: Dbtag_.cpp:66
void SetDb(const TDb &value)
Assign a value to Db data member.
Definition: Dbtag_.hpp:229
const TMod & GetMod(void) const
Get the Mod member data.
Definition: OrgName_.hpp:839
bool IsSetDb(void) const
ids in taxonomic or culture dbases Check if a value has been assigned to Db data member.
Definition: Org_ref_.hpp:479
void SetSubtype(TSubtype value)
Assign a value to Subtype data member.
Definition: OrgMod_.hpp:316
const TTaxname & GetTaxname(void) const
Get the Taxname member data.
Definition: Org_ref_.hpp:372
const TDb & GetDb(void) const
Get the Db member data.
Definition: Org_ref_.hpp:491
bool IsSetMod(void) const
Check if a value has been assigned to Mod data member.
Definition: OrgName_.hpp:827
list< CRef< COrgMod > > TMod
Definition: OrgName_.hpp:332
bool IsSetOrgname(void) const
Check if a value has been assigned to Orgname data member.
Definition: Org_ref_.hpp:529
bool IsSetTaxname(void) const
preferred formal name Check if a value has been assigned to Taxname data member.
Definition: Org_ref_.hpp:360
void SetSubname(const TSubname &value)
Assign a value to Subname data member.
Definition: OrgMod_.hpp:356
const TOrgname & GetOrgname(void) const
Get the Orgname member data.
Definition: Org_ref_.hpp:541
@ eSubtype_other
ASN5: old-name (254) will be added to next spec.
Definition: OrgMod_.hpp:125
@ eSubtype_nat_host
natural host of this specimen
Definition: OrgMod_.hpp:104
const TColumns & GetColumns(void) const
Get the Columns member data.
Definition: Seq_table_.hpp:433
void SetHeader(THeader &value)
Assign a value to Header data member.
vector< CRef< CSeqTable_column > > TColumns
Definition: Seq_table_.hpp:92
void SetData(TData &value)
Assign a value to Data data member.
TNum_rows GetNum_rows(void) const
Get the Num_rows member data.
Definition: Seq_table_.hpp:393
const TString & GetString(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
bool IsSetColumns(void) const
data in columns Check if a value has been assigned to Columns data member.
Definition: Seq_table_.hpp:421
TColumns & SetColumns(void)
Assign a value to Columns data member.
Definition: Seq_table_.hpp:439
const TId & GetId(void) const
Get the variant data.
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
Definition: Seq_feat_.hpp:913
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
const TBiosrc & GetBiosrc(void) const
Get the variant data.
bool IsBiosrc(void) const
Check if variant Biosrc is selected.
bool IsLocal(void) const
Check if variant Local is selected.
Definition: Seq_id_.hpp:775
@ eClass_nuc_prot
nuc acid and coded proteins
Definition: Bioseq_set_.hpp:99
const TSource & GetSource(void) const
Get the variant data.
Definition: Seqdesc_.cpp:566
bool IsSource(void) const
Check if variant Source is selected.
Definition: Seqdesc_.hpp:1190
list< CRef< CSeq_id > > TId
Definition: Bioseq_.hpp:94
TSource & SetSource(void)
Select the variant.
Definition: Seqdesc_.cpp:572
@ e_Source
source of materials, includes Org-ref
Definition: Seqdesc_.hpp:133
@ eMol_na
just a nucleic acid
Definition: Seq_inst_.hpp:113
char * dbname(DBPROCESS *dbproc)
Get name of current database.
Definition: dblib.c:6929
fallback to Cassandra storage</td > n</tr > n</table > n</td > n< td > no and not provided</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is smart and slim</td> n<td> orig</td> n</tr> n<tr> n<td> exclude_blobs</td> n<td> optional</td> n<td> String</td> n<td class=\"description\"> A comma separated list of blob identifiers which client already has If provided then n if the resolution of sequence identifier sequence identifier type matches one of the n blob identifiers in the list then the blob will not be sent The format of the blob n identifier depends on a processor For example
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
int i
yy_size_t n
int len
constexpr auto sort(_Init &&init)
Definition: fix_pub.hpp:45
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
const char * tag
int isdigit(Uchar c)
Definition: ncbictype.hpp:64
static const GLdouble origin[]
#define FOR_EACH_DBXREF_ON_ORGREF(Itr, Var)
FOR_EACH_DBXREF_ON_ORGREF EDIT_EACH_DBXREF_ON_ORGREF.
#define EDIT_EACH_DBXREF_ON_ORGREF(Itr, Var)
bool MatchColumnName(string name1, string name2)
bool IsOrgColumnName(string name)
CRef< CSeqTable_column > FindSeqTableColumnByName(CRef< objects::CSeq_table > values_table, string column_name)
void AddValueToTable(CRef< CSeq_table > table, string subtype_name, string value, size_t row, edit::EExistingText existing_text=edit::eExistingText_replace_old)
CRef< CCmdComposite > ApplySrcTableToSeqEntry(CRef< CSeq_table >values_table, CSeq_entry_Handle seh)
static bool IsExampleTableRowAcceptable(const ExampleTableData *e1, string field_name, CSourceRequirements::EWizardType wizard_type, CSourceRequirements::EWizardSrcType src_type)
CRef< CSeq_table > GetSeqTableForSrcQualFromSeqEntry(CSeq_entry_Handle seh, vector< string > qual_names)
USING_SCOPE(objects)
static bool s_IsAllNumbers(string val)
void SplitValues(const string &name, const string &newValue, vector< string > &values)
static const TStructVoucherPart s_StrVouchPartName[]
bool IsFwdPrimerSeq(string name)
static string s_MakeUniquenessVal(vector< CRef< CSeqTable_column > > cols, size_t row)
bool RelaxedMatch(CRef< CSeq_id > id1, CRef< CSeq_id > id2)
string GetPrimerSetNameValues(const CPCRPrimerSet &primer_set)
static int CompareExampleTableRows(const ExampleTableData *e1, const ExampleTableData *e2)
CRef< CSeq_table > GetSeqTableFromSeqEntry(CSeq_entry_Handle seh)
string JoinValues(const string &name, const vector< string > &values)
string GetPrimerSetSeqValues(const CPCRPrimerSet &primer_set)
static bool OneRowOk(CRef< CSeq_id > id, CRef< CSeqTable_column > id_col, CSeq_entry_Handle seh)
SStaticPair< const char *, CSrcStructuredVoucherPartColumn::EStructVouchPart > TStructVoucherPart
DEFINE_STATIC_ARRAY_MAP(TStrcVouchMap, sm_VouchMap, s_StrVouchPartName)
bool IsRevPrimerSeq(string name)
static const int k_NumExampleTableRows
struct exampletable ExampleTableData
static const string nomial_keywords[]
bool IsFwdPrimerName(string name)
CStaticArrayMap< string, CSrcStructuredVoucherPartColumn::EStructVouchPart > TStrcVouchMap
bool IsRevPrimerName(string name)
CSourceRequirements * GetSrcRequirements(CSourceRequirements::EWizardType wizard_type, CSourceRequirements::EWizardSrcType source_type, CRef< CSeq_table > values_table)
static const ExampleTableData s_ExampleTable[]
void RemoveLastCharacter(string &str)
vector< CSrcQual * > TSrcQualList
#define row(bind, expected)
Definition: string_bind.c:73
EExistingText
@ eExistingText_add_qual
@ eExistingText_leave_old
@ eExistingText_replace_old
bool AddValueToString(string &str, const string &value, EExistingText existing_text)
Add text to an existing string, using the "existing_text" directive to combine new text with existing...
Template structure SStaticPair is simlified replacement of STL pair<> Main reason of introducing this...
Definition: static_set.hpp:60
Modified on Thu Apr 25 08:18:00 2024 by modify_doxy.py rev. 669887