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

Go to the SVN repository for this file.

1 /* $Id: unit_test_biosample_util.cpp 101360 2023-12-05 16:56:06Z 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 * Author: Colleen Bollin, NCBI
27 *
28 * File Description:
29 * Sample unit tests file for the mainstream test developing.
30 *
31 * This file represents basic most common usage of Ncbi.Test framework (which
32 * is based on Boost.Test framework. For more advanced techniques look into
33 * another sample - unit_test_alt_sample.cpp.
34 *
35 * ===========================================================================
36 */
37 
38 #include <ncbi_pch.hpp>
39 
40 #include <corelib/ncbi_system.hpp>
41 #include <corelib/ncbiapp.hpp>
42 #include <objects/seq/Seqdesc.hpp>
44 
52 
53 #include <objmgr/bioseq_ci.hpp>
54 
55 #include <common/ncbi_export.h>
56 
59 
60 
61 
62 // This header must be included before all Boost.Test headers if there are any
63 #include <corelib/test_boost.hpp>
64 
67 using namespace unit_test_util;
68 
69 // Needed under windows for some reason.
70 #ifdef BOOST_NO_EXCEPTIONS
71 
72 namespace boost
73 {
74  void throw_exception( std::exception const & e ) {
75  throw e;
76  }
77 }
78 
79 #endif
80 
81 
83 {
85 
86 }
87 
88 void CheckDiffs(const TFieldDiffList& expected, const TFieldDiffList& observed)
89 {
90  BOOST_CHECK_EQUAL(expected.size(), observed.size());
91  TFieldDiffList::const_iterator ex = expected.begin();
92  TFieldDiffList::const_iterator ob = observed.begin();
93  while (ex != expected.end() && ob != observed.end()) {
94  string ex_str = (*ex)->GetFieldName() + ":"
95  + (*ex)->GetSrcVal() + ":"
96  + (*ex)->GetSampleVal();
97  string ob_str = (*ob)->GetFieldName() + ":"
98  + (*ob)->GetSrcVal() + ":"
99  + (*ob)->GetSampleVal();
100  BOOST_CHECK_EQUAL(ex_str, ob_str);
101  ex++;
102  ob++;
103  }
104  while (ex != expected.end()) {
105  string ex_str = (*ex)->GetFieldName() + ":"
106  + (*ex)->GetSrcVal() + ":"
107  + (*ex)->GetSampleVal();
108  BOOST_CHECK_EQUAL(ex_str, "");
109  ex++;
110  }
111  while (ob != observed.end()) {
112  string ob_str = (*ob)->GetFieldName() + ":"
113  + (*ob)->GetSrcVal() + ":"
114  + (*ob)->GetSampleVal();
115  BOOST_CHECK_EQUAL("", ob_str);
116  ob++;
117  }
118 }
119 
120 
121 BOOST_AUTO_TEST_CASE(Test_GetBiosampleDiffs)
122 {
123  CRef<CBioSource> test_src(new CBioSource());
124  CRef<CBioSource> test_sample(new CBioSource());
125 
126  test_src->SetOrg().SetTaxname("A");
127  test_sample->SetOrg().SetTaxname("B");
128 
130  expected.push_back(CRef<CFieldDiff>(new CFieldDiff("Organism Name", "A", "B")));
131  TFieldDiffList diff_list = test_src->GetBiosampleDiffs(*test_sample);
132  CheckDiffs(expected, diff_list);
133 
134  // ignore differences that can be autofixed
137  diff_list = test_src->GetBiosampleDiffs(*test_sample);
138  CheckDiffs(expected, diff_list);
139 
140  // ignore differences that are allowed if BioSample is missing a value
142  diff_list = test_src->GetBiosampleDiffs(*test_sample);
143  CheckDiffs(expected, diff_list);
144 
145  // ignore certain diffs in Org-ref
146  unit_test_util::SetOrgMod(*test_sample, COrgMod::eSubtype_acronym, "acronym");
147  diff_list = test_src->GetBiosampleDiffs(*test_sample);
148  CheckDiffs(expected, diff_list);
149 
150  // ignore some case differences
153  diff_list = test_src->GetBiosampleDiffs(*test_sample);
154  CheckDiffs(expected, diff_list);
155 
156  try {
157  test_src->UpdateWithBioSample(*test_sample, false);
158  BOOST_CHECK_EQUAL("Expected exception to be thrown", "Exception not thrown!");
159  } catch (CException& e) {
160  BOOST_CHECK_EQUAL(e.GetMsg(), "Conflicts found");
161  }
162 
163  try {
164  test_src->UpdateWithBioSample(*test_sample, true);
165  BOOST_CHECK_EQUAL(test_src->GetOrg().GetTaxname(), "B");
166  vector<string> vals;
167  vals.push_back("male");
168  vals.push_back("1");
169  vals.push_back("abc");
170  vector<string>::iterator sit = vals.begin();
171  ITERATE(CBioSource::TSubtype, it, test_src->GetSubtype()) {
172  if (sit == vals.end()) {
173  BOOST_CHECK_EQUAL("Unexpected SubSource Value", (*it)->GetName());
174  } else {
175  BOOST_CHECK_EQUAL((*it)->GetName(), *sit);
176  sit++;
177  }
178  }
179  BOOST_CHECK_EQUAL(test_src->GetOrg().IsSetOrgMod(), false);
180  } catch (CException& e) {
181  BOOST_CHECK_EQUAL("Unexpected exception", e.GetMsg());
182  }
183 
184  expected.clear();
185 #if 0
186  // commented out for SQD-4222 (functionality was removed)
187  // ignore name elements if in taxname
189  test_src->SetOrg().SetTaxname("B XYZ");
190  test_sample->SetOrg().SetTaxname("B XYZ");
191 
192  diff_list = test_src->GetBiosampleDiffs(*test_sample);
193  CheckDiffs(expected, diff_list);
194 
195 #endif
196 }
197 
198 
199 BOOST_AUTO_TEST_CASE(Test_UpdateWithBioSample)
200 {
201  CRef<CBioSource> src(new CBioSource());
203  src->SetOrg().SetTaxname("Campylobacter jejuni Cj3");
204  unit_test_util::SetTaxon(*src, 1365660);
206  src->SetOrg().SetOrgname().SetLineage("Bacteria; Proteobacteria; Epsilonproteobacteria; Campylobacterales; Campylobacteraceae; Campylobacter");
207  src->SetOrg().SetOrgname().SetGcode(11);
208  src->SetOrg().SetOrgname().SetDiv("BCT");
210 
211  CRef<CBioSource> biosample(new CBioSource());
212  biosample->SetOrg().SetTaxname("Campylobacter jejuni Cj3");
213  unit_test_util::SetTaxon(*biosample, 1365660);
214  unit_test_util::SetOrgMod(*biosample, COrgMod::eSubtype_nat_host, "Homo sapiens");
216  biosample->SetOrg().SetOrgname().SetLineage("Bacteria; Proteobacteria; Epsilonproteobacteria; Campylobacterales; Campylobacteraceae; Campylobacter");
217  biosample->SetOrg().SetOrgname().SetGcode(11);
218  biosample->SetOrg().SetOrgname().SetDiv("BCT");
222  biosample->SetOrg().SetOrgname().SetMod().push_back(om1);
224  biosample->SetOrg().SetOrgname().SetMod().push_back(om2);
225 
226  src->UpdateWithBioSample(*biosample, true);
227 
228  TFieldDiffList diff_list = src->GetBiosampleDiffs(*biosample);
230  CheckDiffs(expected, diff_list);
231 
232 }
233 
234 
235 const string sc_TestSQD1833_Src = "\
236 BioSource ::= { \
237  genome genomic, \
238  org { \
239  taxname \"Escherichia coli\", \
240  db { \
241  { \
242  db \"taxon\", \
243  tag id 562 \
244  } \
245  }, \
246  orgname { \
247  name binomial { \
248  genus \"Escherichia\", \
249  species \"coli\" \
250  }, \
251  lineage \"Bacteria; Proteobacteria; Gammaproteobacteria; \
252  Enterobacteriales; Enterobacteriaceae; Escherichia\", \
253  gcode 11, \
254  div \"BCT\" \
255  } \
256  } \
257 } \
258 ";
259 
260 
261 const string sc_TestSQD1833_Smpl = "\
262 BioSource ::= { \
263  org { \
264  taxname \"Escherichia coli\", \
265  db { \
266  { \
267  db \"taxon\", \
268  tag id 562 \
269  } \
270  }, \
271  syn { \
272  \"bacterium E3\", \
273  \"Enterococcus coli\", \
274  \"Bacterium coli commune\", \
275  \"Bacterium coli\", \
276  \"Bacillus coli\" \
277  }, \
278  orgname { \
279  name binomial { \
280  genus \"Escherichia\", \
281  species \"coli\" \
282  }, \
283  mod { \
284  { \
285  subtype nat-host, \
286  subname \"Homo sapiens\" \
287  }, \
288  { \
289  subtype strain, \
290  subname \"CS01\" \
291  } \
292  }, \
293  lineage \"Bacteria; Proteobacteria; Gammaproteobacteria; \
294  Enterobacteriales; Enterobacteriaceae; Escherichia\", \
295  gcode 11, \
296  div \"BCT\" \
297  } \
298  }, \
299  subtype { \
300  { \
301  subtype collection-date, \
302  name \"24-Jun-2013\" \
303  }, \
304  { \
305  subtype country, \
306  name \"USA: Santa Clara\" \
307  }, \
308  { \
309  subtype isolation-source, \
310  name \"Human fecal sample\" \
311  } \
312  } \
313 } \
314 ";
315 
316 
317 BOOST_AUTO_TEST_CASE(Test_SQD_1833)
318 {
319  CBioSource src;
320  {{
322  istr >> MSerial_AsnText >> src;
323  }}
324 
325  CBioSource smpl;
326  {{
328  istr >> MSerial_AsnText >> smpl;
329  }}
330 
331 
332  try {
333  src.UpdateWithBioSample(smpl, false);
334  vector<string> vals;
335  vals.push_back("24-Jun-2013");
336  vals.push_back("USA: Santa Clara");
337  vals.push_back("Human fecal sample");
338  vector<string>::iterator sit = vals.begin();
340  if (sit == vals.end()) {
341  BOOST_CHECK_EQUAL("Unexpected SubSource Value", (*it)->GetName());
342  } else {
343  BOOST_CHECK_EQUAL((*it)->GetName(), *sit);
344  sit++;
345  }
346  }
347  } catch (CException& e) {
348  BOOST_CHECK_EQUAL("Unexpected exception", e.GetMsg());
349  }
350 
351 
352 }
353 
354 
355 BOOST_AUTO_TEST_CASE(Test_GP_9113)
356 {
357  CBioSource src;
358  src.SetOrg().SetTaxname("a");
359  CBioSource smpl;
360  smpl.SetOrg().SetTaxname("a");
361  smpl.SetOrg().SetTaxId(TAX_ID_CONST(123));
362 
363  try {
364  src.UpdateWithBioSample(smpl, true);
365  BOOST_CHECK_EQUAL(src.GetOrg().GetDb().front()->GetTag().GetId(), 123);
366  } catch (CException& e) {
367  BOOST_CHECK_EQUAL("Unexpected exception", e.GetMsg());
368  }
369 
370 
371 }
372 
373 
374 BOOST_AUTO_TEST_CASE(Test_FuzzyStrainMatch)
375 {
376  BOOST_CHECK_EQUAL(COrgMod::FuzzyStrainMatch("abc", "ABC"), true);
377  BOOST_CHECK_EQUAL(COrgMod::FuzzyStrainMatch("ab c", "ABC"), true);
378  BOOST_CHECK_EQUAL(COrgMod::FuzzyStrainMatch("a/b c", "ABC"), true);
379  BOOST_CHECK_EQUAL(COrgMod::FuzzyStrainMatch("a/b c", "AB:C"), true);
380  BOOST_CHECK_EQUAL(COrgMod::FuzzyStrainMatch("a/b d", "AB:C"), false);
381 }
382 
383 
384 BOOST_AUTO_TEST_CASE(Test_SQD_1836)
385 {
386  CRef<CBioSource> src(new CBioSource());
387  src->SetOrg().SetTaxname("Porphyromonas sp. KLE 1280");
388  CRef<CDbtag> taxid(new CDbtag());
389  taxid->SetDb("taxon");
390  taxid->SetTag().SetId(997829);
391  src->SetOrg().SetDb().push_back(taxid);
392  CRef<COrgMod> m1(new COrgMod());
394  m1->SetSubname("KLE 1280");
395  src->SetOrg().SetOrgname().SetMod().push_back(m1);
396 
397  CRef<CBioSource> smpl(new CBioSource());
398  smpl->Assign(*src);
399 
400  CRef<CDbtag> hmp(new CDbtag());
401  hmp->SetDb("HMP");
402  hmp->SetTag().SetId(1121);
403  src->SetOrg().SetDb().push_back(hmp);
404 
405  try {
406  src->UpdateWithBioSample(*smpl, false);
407  BOOST_CHECK_EQUAL(src->GetOrg().GetDb().size(), 2);
408  } catch (CException& e) {
409  BOOST_CHECK_EQUAL("Unexpected exception", e.GetMsg());
410  }
411 
412 
413 }
414 
415 
416 BOOST_AUTO_TEST_CASE(Test_SQD_1865)
417 {
418  CRef<CBioSource> src(new CBioSource());
419  src->SetOrg().SetTaxname("Salmo salar");
420 
421  CRef<CBioSource> smpl(new CBioSource());
422  smpl->Assign(*src);
423  CRef<COrgMod> om(new COrgMod());
424  om->SetSubtype(COrgMod::eSubtype_strain);
425  om->SetSubname("missing");
426  smpl->SetOrg().SetOrgname().SetMod().push_back(om);
427 
428  try {
429  src->UpdateWithBioSample(*smpl, false);
430  BOOST_CHECK_EQUAL(src->GetOrg().IsSetOrgMod(), false);
431  } catch (CException& e) {
432  BOOST_CHECK_EQUAL("Unexpected exception", e.GetMsg());
433  }
434 
435  CRef<COrgMod> om2(new COrgMod());
437  om2->SetSubname("wild");
438  src->SetOrg().SetOrgname().SetMod().push_back(om2);
439 
440  try {
441  // this should delete the strain on src
442  src->UpdateWithBioSample(*smpl, true);
443  BOOST_CHECK_EQUAL(src->GetOrg().IsSetOrgMod(), false);
444  } catch (CException& e) {
445  BOOST_CHECK_EQUAL("Unexpected exception", e.GetMsg());
446  }
447 
448 
449 }
450 
451 
452 BOOST_AUTO_TEST_CASE(Test_WGS_693)
453 {
454  CRef<CBioSource> src(new CBioSource());
455  src->SetOrg().SetTaxname("xyz metagenome");
456  CRef<COrgMod> src_om_note(new COrgMod(COrgMod::eSubtype_other, "source om"));
457  src->SetOrg().SetOrgname().SetMod().push_back(src_om_note);
458  CRef<CSubSource> src_ss_note(new CSubSource(CSubSource::eSubtype_other, "source ss"));
459  src->SetSubtype().push_back(src_ss_note);
460 
461  CRef<CBioSource> smpl(new CBioSource());
462  smpl->SetOrg().SetTaxname(src->GetOrg().GetTaxname());
463  CRef<COrgMod> smpl_om_note(new COrgMod(COrgMod::eSubtype_other, "sample om"));
464  smpl->SetOrg().SetOrgname().SetMod().push_back(smpl_om_note);
465  CRef<CSubSource> smpl_ss_note(new CSubSource(CSubSource::eSubtype_other, "sample ss"));
466  smpl->SetSubtype().push_back(smpl_ss_note);
467 
468  // because there is no lineage, should complain about notes differing
469  TFieldDiffList diff_list = src->GetBiosampleDiffs(*smpl);
470  BOOST_CHECK_EQUAL(diff_list.size(), 2);
471 
472  // should not complain if specified lineage is found
473  src->SetOrg().SetOrgname().SetLineage("unclassified sequences; metagenomes");
474  smpl->SetOrg().SetOrgname().SetLineage("unclassified sequences; metagenomes");
475  diff_list = src->GetBiosampleDiffs(*smpl);
476  BOOST_CHECK_EQUAL(diff_list.size(), 0);
477 }
478 
479 
480 BOOST_AUTO_TEST_CASE(Test_SQD_2021)
481 {
482  CRef<CBioSource> src(new CBioSource());
483  src->SetOrg().SetTaxname("Sulfitobacter sp. NB-68");
485  src->SetOrg().SetOrgname().SetMod().push_back(cc1);
487  src->SetOrg().SetOrgname().SetMod().push_back(cc2);
488 
489  CRef<CBioSource> smpl(new CBioSource());
490  smpl->Assign(*src);
491 
492  // no differences should be reported
493  TFieldDiffList diff_list = src->GetBiosampleDiffs(*smpl);
494  BOOST_CHECK_EQUAL(diff_list.size(), 0);
495 
496  src->UpdateWithBioSample(*smpl, true);
497  BOOST_CHECK_EQUAL(src->GetOrg().GetOrgname().GetMod().size(), 2);
498 
499 }
500 
501 
502 BOOST_AUTO_TEST_CASE(Test_SQD_2022)
503 {
504  CRef<CBioSource> src(new CBioSource());
505  src->SetOrg().SetTaxname("Triticum aestivum");
507  src->SetSubtype().push_back(c1);
509  src->SetSubtype().push_back(m1);
510 
511  CRef<CBioSource> smpl(new CBioSource());
512  smpl->SetOrg().SetTaxname("Triticum aestivum");
514  smpl->SetSubtype().push_back(c2);
516  smpl->SetSubtype().push_back(m2);
517 
518  // differences should be reported
519  TFieldDiffList diff_list = src->GetBiosampleDiffs(*smpl);
520  BOOST_CHECK_EQUAL(diff_list.size(), 2);
521  // no differences should be reported if local copy
522  diff_list = src->GetBiosampleDiffs(*smpl, true);
523  BOOST_CHECK_EQUAL(diff_list.size(), 0);
524 
525  src->UpdateWithBioSample(*smpl, true, true);
526  BOOST_CHECK_EQUAL(src->GetSubtype().front()->GetName(), "4D");
527  BOOST_CHECK_EQUAL(src->GetSubtype().back()->GetName(), "short arm");
528 
529 }
530 
531 
532 BOOST_AUTO_TEST_CASE(Test_SQD_2028)
533 {
534  CRef<CBioSource> src(new CBioSource());
535  src->SetOrg().SetTaxname("Triticum aestivum");
536  CRef<COrgMod> n1(new COrgMod(COrgMod::eSubtype_old_name, "old name 1"));
537  src->SetOrg().SetOrgname().SetMod().push_back(n1);
538  CRef<COrgMod> l1(new COrgMod(COrgMod::eSubtype_old_lineage, "old lineage 1"));
539  src->SetOrg().SetOrgname().SetMod().push_back(l1);
540  CRef<COrgMod> s1(new COrgMod(COrgMod::eSubtype_gb_synonym, "synonym 1"));
541  src->SetOrg().SetOrgname().SetMod().push_back(s1);
542 
543  CRef<CBioSource> smpl(new CBioSource());
544  smpl->SetOrg().SetTaxname("Triticum aestivum");
545  CRef<COrgMod> n2(new COrgMod(COrgMod::eSubtype_old_name, "old name 2"));
546  smpl->SetOrg().SetOrgname().SetMod().push_back(n2);
547  CRef<COrgMod> l2(new COrgMod(COrgMod::eSubtype_old_lineage, "old lineage 2"));
548  smpl->SetOrg().SetOrgname().SetMod().push_back(l2);
549  CRef<COrgMod> s2(new COrgMod(COrgMod::eSubtype_gb_synonym, "synonym 2"));
550  smpl->SetOrg().SetOrgname().SetMod().push_back(s2);
551 
552  // no differences should be reported
553  TFieldDiffList diff_list = src->GetBiosampleDiffs(*smpl);
554  BOOST_CHECK_EQUAL(diff_list.size(), 0);
555 
556 }
557 
558 
559 BOOST_AUTO_TEST_CASE(Test_SQD_2189)
560 {
561  // need to report diffs if one BioSource is metagenomic and the other is not
562  CRef<CBioSource> src(new CBioSource());
563  src->SetOrg().SetTaxname("Bacteria");
564 
565  CRef<CBioSource> smpl(new CBioSource());
566  smpl->Assign(*src);
567 
568  // both do not have metagenomic
569  TFieldDiffList diff_list = src->GetBiosampleDiffs(*smpl);
570  BOOST_CHECK_EQUAL(diff_list.size(), 0);
571 
572  // only one has metagenomice
573  CRef<CSubSource> mt(new CSubSource());
575  mt->SetName("");
576  src->SetSubtype().push_back(mt);
577 
578  diff_list = src->GetBiosampleDiffs(*smpl);
579  BOOST_CHECK_EQUAL(diff_list.size(), 1);
580  BOOST_CHECK_EQUAL(diff_list[0]->GetFieldName(), "metagenomic");
581  BOOST_CHECK_EQUAL(diff_list[0]->GetSrcVal(), "true");
582  BOOST_CHECK_EQUAL(diff_list[0]->GetSampleVal(), "");
583 
584  // both have metagenomic
585  CRef<CSubSource> mt2(new CSubSource());
587  mt2->SetName("true");
588  smpl->SetSubtype().push_back(mt2);
589  diff_list = src->GetBiosampleDiffs(*smpl);
590  BOOST_CHECK_EQUAL(diff_list.size(), 0);
591 
592 }
593 
594 
595 void CheckDiff(const CFieldDiff& diff, const string& dname, const string& src_val, const string& sample_val)
596 {
597  BOOST_CHECK_EQUAL(diff.GetFieldName(), dname);
598  BOOST_CHECK_EQUAL(diff.GetSrcVal(), src_val);
599  BOOST_CHECK_EQUAL(diff.GetSampleVal(), sample_val);
600 }
601 
602 
603 BOOST_AUTO_TEST_CASE(Test_GB_7214)
604 {
605  // need to report correctly when there are multiple qualifiers with the same name
606  CRef<CBioSource> src(new CBioSource());
607  src->SetOrg().SetTaxname("Bacteria");
608 
609  CRef<CBioSource> smpl(new CBioSource());
610  smpl->Assign(*src);
611 
614 
615  CRef<COrgMod> om1_copy(new COrgMod());
616  om1_copy->Assign(*om1);
617  CRef<COrgMod> om2_copy(new COrgMod());
618  om2_copy->Assign(*om2);
619 
620  // report two missing quals on sample
621  src->SetOrg().SetOrgname().SetMod().push_back(om1);
622  src->SetOrg().SetOrgname().SetMod().push_back(om2);
623 
624  TFieldDiffList diff_list = src->GetBiosampleDiffs(*smpl);
625  BOOST_CHECK_EQUAL(diff_list.size(), 2);
626  CheckDiff(*diff_list[0], "isolate", "val1", "");
627  CheckDiff(*diff_list[1], "isolate", "val2", "");
628 
629  // only one missing
630  smpl->SetOrg().SetOrgname().SetMod().push_back(om2_copy);
631  diff_list = src->GetBiosampleDiffs(*smpl);
632  BOOST_CHECK_EQUAL(diff_list.size(), 1);
633  CheckDiff(*diff_list[0], "isolate", "val1", "");
634 }
635 
636 
637 void CheckReturnedFields(const biosample_util::TBiosampleFieldDiffList& diff_list, bool expect_response)
638 {
639  if (expect_response) {
640  BOOST_CHECK_EQUAL(diff_list.size(), 6);
641  BOOST_CHECK_EQUAL(diff_list[0]->GetFieldName(), "Organism Name");
642  BOOST_CHECK_EQUAL(diff_list[0]->GetSampleVal(), "Escherichia coli");
643  BOOST_CHECK_EQUAL(diff_list[0]->GetSrcVal(), "Sebaea microphylla");
644  BOOST_CHECK_EQUAL(diff_list[1]->GetFieldName(), "Tax ID");
645  BOOST_CHECK_EQUAL(diff_list[1]->GetSampleVal(), "562");
646  BOOST_CHECK_EQUAL(diff_list[1]->GetSrcVal(), "592768");
647  BOOST_CHECK_EQUAL(diff_list[2]->GetFieldName(), "collection-date");
648  BOOST_CHECK_EQUAL(diff_list[2]->GetSampleVal(), "2016");
649  BOOST_CHECK_EQUAL(diff_list[2]->GetSrcVal(), "");
650  BOOST_CHECK_EQUAL(diff_list[3]->GetFieldName(), "country");
651  BOOST_CHECK_EQUAL(diff_list[3]->GetSampleVal(), "USA");
652  BOOST_CHECK_EQUAL(diff_list[3]->GetSrcVal(), "");
653  BOOST_CHECK_EQUAL(diff_list[4]->GetFieldName(), "nat-host");
654  BOOST_CHECK_EQUAL(diff_list[4]->GetSampleVal(), "Homo sapiens");
655  BOOST_CHECK_EQUAL(diff_list[4]->GetSrcVal(), "");
656  BOOST_CHECK_EQUAL(diff_list[5]->GetFieldName(), "strain");
657  BOOST_CHECK_EQUAL(diff_list[5]->GetSampleVal(), "aaa");
658  BOOST_CHECK_EQUAL(diff_list[5]->GetSrcVal(), "");
659  } else {
660  BOOST_CHECK_EQUAL(diff_list.size(), 0);
661  }
662 }
663 
664 
vector< CRef< CFieldDiff > > TFieldDiffList
Definition: BioSource.hpp:53
vector< CRef< CBiosampleFieldDiff > > TBiosampleFieldDiffList
CRef< CSeq_descr > GetBiosampleData(const string &accession, bool use_dev_server=false, TBioSamples *cache=NULL)
void UpdateWithBioSample(const CBioSource &biosample, bool force, bool is_local_copy=false)
Definition: BioSource.cpp:704
TFieldDiffList GetBiosampleDiffs(const CBioSource &biosample, bool is_local_copy=false) const
Definition: BioSource.cpp:1327
Definition: Dbtag.hpp:53
const string & GetSampleVal() const
Definition: BioSource.hpp:227
const string & GetFieldName() const
Definition: BioSource.hpp:225
const string & GetSrcVal() const
Definition: BioSource.hpp:226
@OrgMod.hpp User-defined methods of the data storage class.
Definition: OrgMod.hpp:54
static bool FuzzyStrainMatch(const string &strain1, const string &strain2)
Definition: OrgMod.cpp:1094
bool IsSetOrgMod(void) const
Definition: Org_ref.cpp:169
static const char * expected[]
Definition: bcp.c:42
#define TAX_ID_CONST(id)
Definition: ncbimisc.hpp:1112
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
const TSubtype & GetSubtype(void) const
Get the Subtype member data.
Definition: BioSource_.hpp:539
void SetSubtype(TSubtype value)
Assign a value to Subtype data member.
Definition: SubSource_.hpp:319
list< CRef< CSubSource > > TSubtype
Definition: BioSource_.hpp:145
const TOrg & GetOrg(void) const
Get the Org member data.
Definition: BioSource_.hpp:509
void SetGenome(TGenome value)
Assign a value to Genome data member.
Definition: BioSource_.hpp:428
void SetOrg(TOrg &value)
Assign a value to Org data member.
Definition: BioSource_.cpp:108
void SetName(const TName &value)
Assign a value to Name data member.
Definition: SubSource_.hpp:359
TSubtype & SetSubtype(void)
Assign a value to Subtype data member.
Definition: BioSource_.hpp:545
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
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
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_gb_synonym
used by taxonomy database
Definition: OrgMod_.hpp:117
@ eSubtype_other
ASN5: old-name (254) will be added to next spec.
Definition: OrgMod_.hpp:125
@ eSubtype_nat_host
natural host of this specimen
Definition: OrgMod_.hpp:104
@ eSubtype_strain
Definition: OrgMod_.hpp:85
@ eSubtype_biovar
Definition: OrgMod_.hpp:96
@ eSubtype_old_name
Definition: OrgMod_.hpp:124
@ eSubtype_acronym
Definition: OrgMod_.hpp:102
@ eSubtype_culture_collection
Definition: OrgMod_.hpp:118
@ eSubtype_old_lineage
Definition: OrgMod_.hpp:123
@ eSubtype_isolate
Definition: OrgMod_.hpp:100
Defines to provide correct exporting from DLLs in some configurations.
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
CRef< objects::CObjectManager > om
Utility stuff for more convenient using of Boost.Test library.
USING_SCOPE(objects)
BOOST_AUTO_TEST_CASE(TEST_First)
void CheckDiffs(const TFieldDiffList &expected, const TFieldDiffList &observed)
void CheckReturnedFields(const biosample_util::TBiosampleFieldDiffList &diff_list, bool expect_response)
const string sc_TestSQD1833_Src
void CheckDiff(const CFieldDiff &diff, const string &dname, const string &src_val, const string &sample_val)
const string sc_TestSQD1833_Smpl
void SetTaxon(objects::CBioSource &src, size_t taxon)
void SetSubSource(objects::CBioSource &src, objects::CSubSource::TSubtype subtype, string val)
void SetOrgMod(objects::CBioSource &src, objects::COrgMod::TSubtype subtype, string val)
This file contains the definition of the xml::init class.
Modified on Sun Jul 21 04:12:45 2024 by modify_doxy.py rev. 669887