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

Go to the SVN repository for this file.

1 /* $Id: unit_test_util.cpp 101604 2024-01-10 17:07:04Z kans $
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: Jonathan Kans, Clifford Clausen, Aaron Ucko.......
27  *
28  * File Description:
29  * Validates objects::CSeq_entries and objects::CSeq_submits
30  *
31  */
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbistd.hpp>
42 #include <objects/biblio/Title.hpp>
48 #include <objects/pub/Pub.hpp>
49 #include <objects/seq/GIBB_mol.hpp>
50 #include <objects/seq/Seq_ext.hpp>
54 #include <objects/seq/Ref_ext.hpp>
55 #include <objects/seq/Map_ext.hpp>
56 #include <objects/seq/Seg_ext.hpp>
57 #include <objects/seq/Seq_gap.hpp>
58 #include <objects/seq/Seq_data.hpp>
60 #include <objects/seq/Seqdesc.hpp>
61 #include <objects/seq/MolInfo.hpp>
62 #include <objects/seq/Pubdesc.hpp>
63 #include <objects/seq/Seq_hist.hpp>
80 #include <objmgr/util/sequence.hpp>
82 
84 
85 #include <functional>
86 
89 BEGIN_SCOPE(unit_test_util)
90 
91 
92 void SetDbxref(CBioSource& src, string db, CObject_id::TId id)
93 {
94  CRef<CDbtag> dbtag(new CDbtag());
95  dbtag->SetDb(db);
96  dbtag->SetTag().SetId(id);
97  src.SetOrg().SetDb().push_back(dbtag);
98 }
99 
100 
101 void RemoveDbxref(CBioSource& src, string db, CObject_id::TId id)
102 {
103  if (src.IsSetOrg() && src.GetOrg().IsSetDb()) {
104  COrg_ref::TDb::iterator it = src.SetOrg().SetDb().begin();
105  while (it != src.SetOrg().SetDb().end()) {
106  if ((NStr::IsBlank(db) || ((*it)->IsSetDb() && NStr::Equal((*it)->GetDb(), db)))
107  && (id == 0 || ((*it)->IsSetTag() && (*it)->GetTag().IsId() && (*it)->GetTag().GetId() == id))) {
108  it = src.SetOrg().SetDb().erase(it);
109  } else {
110  ++it;
111  }
112  }
113  }
114 }
115 
116 
117 void SetTaxon(CBioSource& src, size_t taxon)
118 {
119  if (taxon == 0) {
120  RemoveDbxref (src, "taxon", 0);
121  } else {
122  SetDbxref(src, "taxon", taxon);
123  }
124 }
125 
126 
128 {
129  CRef<CSeq_entry> entry(new CSeq_entry());
130  entry->SetSeq().SetInst().SetMol(CSeq_inst::eMol_dna);
131  entry->SetSeq().SetInst().SetRepr(CSeq_inst::eRepr_raw);
132  entry->SetSeq().SetInst().SetSeq_data().SetIupacna().Set("AATTGGCCAAAATTGGCCAAAATTGGCCAAAATTGGCCAAAATTGGCCAAAATTGGCCAA");
133  entry->SetSeq().SetInst().SetLength(60);
134 
135  CRef<CSeq_id> id(new CSeq_id());
136  id->SetLocal().SetStr ("good");
137  entry->SetSeq().SetId().push_back(id);
138 
139  CRef<CSeqdesc> mdesc(new CSeqdesc());
141  entry->SetSeq().SetDescr().Set().push_back(mdesc);
142 
143  AddGoodSource (entry);
144  AddGoodPub(entry);
145 
146  return entry;
147 }
148 
149 
151 {
152  CRef<CSeqdesc> pdesc(new CSeqdesc());
153  CRef<CPub> pub(new CPub());
155  pdesc->SetPub().SetPub().Set().push_back(pub);
156 
157  return pdesc;
158 }
159 
160 
162 {
164 
165  if (entry->IsSeq()) {
166  entry->SetSeq().SetDescr().Set().push_back(pdesc);
167  } else if (entry->IsSet()) {
168  entry->SetSet().SetDescr().Set().push_back(pdesc);
169  }
170 
172  pdesc2->SetPub().SetPub().Set().front()->Assign(*BuildGoodCitSubPub());
173  if (entry->IsSeq()) {
174  entry->SetSeq().SetDescr().Set().push_back(pdesc2);
175  } else if (entry->IsSet()) {
176  entry->SetSet().SetDescr().Set().push_back(pdesc2);
177  }
178 
179 }
180 
181 
183 {
184  CRef<CSeqdesc> odesc(new CSeqdesc());
185  odesc->SetSource().SetOrg().SetTaxname("Sebaea microphylla");
186  odesc->SetSource().SetOrg().SetOrgname().SetLineage("some lineage");
187  SetTaxon(odesc->SetSource(), 592768);
188  CRef<CSubSource> subsrc(new CSubSource());
190  subsrc->SetName("1");
191  odesc->SetSource().SetSubtype().push_back(subsrc);
192 
193  if (entry->IsSeq()) {
194  entry->SetSeq().SetDescr().Set().push_back(odesc);
195  } else if (entry->IsSet()) {
196  entry->SetSet().SetDescr().Set().push_back(odesc);
197  }
198 }
199 
200 
201 void SetDbxref(CBioSource& src, string db, string id)
202 {
203  CRef<CDbtag> dbtag(new CDbtag());
204  dbtag->SetDb(db);
205  dbtag->SetTag().SetStr(id);
206  src.SetOrg().SetDb().push_back(dbtag);
207 }
208 
209 
210 void SetDbxref(CRef<CSeq_entry> entry, string db, CObject_id::TId id)
211 {
212  if (!entry) {
213  return;
214  }
215  if (entry->IsSeq()) {
216  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
217  if ((*it)->IsSource()) {
218  SetDbxref((*it)->SetSource(), db, id);
219  }
220  }
221  } else if (entry->IsSet()) {
222  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
223  if ((*it)->IsSource()) {
224  SetDbxref((*it)->SetSource(), db, id);
225  }
226  }
227  }
228 }
229 
230 
231 void SetDbxref(CRef<CSeq_entry> entry, string db, string id)
232 {
233  if (!entry) {
234  return;
235  }
236  if (entry->IsSeq()) {
237  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
238  if ((*it)->IsSource()) {
239  SetDbxref((*it)->SetSource(), db, id);
240  }
241  }
242  } else if (entry->IsSet()) {
243  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
244  if ((*it)->IsSource()) {
245  SetDbxref((*it)->SetSource(), db, id);
246  }
247  }
248  }
249 }
250 
251 
252 void SetDbxref(CRef<CSeq_feat> feat, string db, CObject_id::TId id)
253 {
254  if (!feat) {
255  return;
256  }
257  CRef<CDbtag> dbtag(new CDbtag());
258  dbtag->SetDb(db);
259  dbtag->SetTag().SetId(id);
260  feat->SetDbxref().push_back(dbtag);
261 }
262 
263 
264 void SetDbxref(CRef<CSeq_feat> feat, string db, string id)
265 {
266  if (!feat) {
267  return;
268  }
269  CRef<CDbtag> dbtag(new CDbtag());
270  dbtag->SetDb(db);
271  dbtag->SetTag().SetStr(id);
272  feat->SetDbxref().push_back(dbtag);
273 }
274 
275 
276 
278 {
279  if (!entry) {
280  return;
281  }
282  if (entry->IsSeq()) {
283  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
284  if ((*it)->IsSource()) {
285  RemoveDbxref((*it)->SetSource(), db, id);
286  }
287  }
288  } else if (entry->IsSet()) {
289  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
290  if ((*it)->IsSource()) {
291  RemoveDbxref((*it)->SetSource(), db, id);
292  }
293  }
294  }
295 }
296 
297 
298 void RemoveDbxref (CRef<CSeq_feat> feat, string db, CObject_id::TId id)
299 {
300  if (!feat) {
301  return;
302  }
303  if (feat->IsSetDbxref()) {
304  CSeq_feat::TDbxref::iterator it = feat->SetDbxref().begin();
305  while (it != feat->SetDbxref().end()) {
306  if ((NStr::IsBlank(db) || ((*it)->IsSetDb() && NStr::Equal((*it)->GetDb(), db)))
307  && (id == 0 || ((*it)->IsSetTag() && (*it)->GetTag().IsId() && (*it)->GetTag().GetId() == id))) {
308  it = feat->SetDbxref().erase(it);
309  } else {
310  ++it;
311  }
312  }
313  }
314 }
315 
316 
317 void SetTaxon(CRef<CSeq_entry> entry, size_t taxon)
318 {
319  if (!entry) {
320  return;
321  }
322  if (entry->IsSeq()) {
323  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
324  if ((*it)->IsSource()) {
325  SetTaxon((*it)->SetSource(), taxon);
326  }
327  }
328  } else if (entry->IsSet()) {
329  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
330  if ((*it)->IsSource()) {
331  SetTaxon((*it)->SetSource(), taxon);
332  }
333  }
334  }
335 }
336 
337 
339 {
340  if (!entry || !annot) {
341  return;
342  }
343  if (entry->IsSeq()) {
344  entry->SetSeq().SetAnnot().push_back(annot);
345  } else if (entry->IsSet()) {
346  if (entry->GetSet().IsSetSeq_set()) {
347  AddFeatAnnotToSeqEntry (annot, entry->SetSet().SetSeq_set().front());
348  }
349  }
350 }
351 
352 
354 {
355  CRef<CSeq_annot> annot;
356 
357  if (entry->IsSeq()) {
358  if (!entry->GetSeq().IsSetAnnot()
359  || !entry->GetSeq().GetAnnot().front()->IsFtable()) {
360  CRef<CSeq_annot> new_annot(new CSeq_annot());
361  entry->SetSeq().SetAnnot().push_back(new_annot);
362  annot = new_annot;
363  } else {
364  annot = entry->SetSeq().SetAnnot().front();
365  }
366  } else if (entry->IsSet()) {
367  if (!entry->GetSet().IsSetAnnot()
368  || !entry->GetSet().GetAnnot().front()->IsFtable()) {
369  CRef<CSeq_annot> new_annot(new CSeq_annot());
370  entry->SetSet().SetAnnot().push_back(new_annot);
371  annot = new_annot;
372  } else {
373  annot = entry->SetSet().SetAnnot().front();
374  }
375  }
376  annot->SetData().SetFtable().push_back(feat);
377  return annot;
378 }
379 
381 {
382  CRef<CSeq_feat> feat (new CSeq_feat());
383  feat->SetData().SetProt().SetName().push_back("fake protein name");
384  feat->SetLocation().SetInt().SetId().Assign(*(entry->GetSeq().GetId().front()));
385  feat->SetLocation().SetInt().SetFrom(0);
386  feat->SetLocation().SetInt().SetTo(entry->GetSeq().GetInst().GetLength() - 1);
387  AddFeat (feat, entry);
388  return feat;
389 }
390 
391 
393 {
394  CRef<CSeq_feat> feat(new CSeq_feat());
395  feat->SetData().SetBiosrc().SetOrg().SetTaxname("Trichechus manatus");
396  SetTaxon (feat->SetData().SetBiosrc(), 9778);
397  feat->SetData().SetBiosrc().SetOrg().SetOrgname().SetLineage("some lineage");
398  feat->SetLocation().SetInt().SetId().SetLocal().SetStr("good");
399  feat->SetLocation().SetInt().SetFrom(0);
400  feat->SetLocation().SetInt().SetTo(5);
401  CRef<CSeq_annot> annot(new CSeq_annot());
402  annot->SetData().SetFtable().push_back(feat);
403  AddFeatAnnotToSeqEntry (annot, entry);
404  return feat;
405 }
406 
407 
408 CRef<CSeq_feat> MakeMiscFeature(CRef<CSeq_id> id, size_t right_end, size_t left_end)
409 {
410  CRef<CSeq_feat> feat(new CSeq_feat());
411  feat->SetLocation().SetInt().SetId().Assign(*id);
412  feat->SetLocation().SetInt().SetFrom(left_end);
413  feat->SetLocation().SetInt().SetTo(right_end);
414  feat->SetData().SetImp().SetKey("misc_feature");
415  return feat;
416 }
417 
418 
420 {
421  CRef<CSeq_feat> feat(new CSeq_feat());
422  feat->SetLocation().SetInt().SetId().SetLocal().SetStr("good");
423  feat->SetLocation().SetInt().SetFrom(0);
424  feat->SetLocation().SetInt().SetTo(59);
425  feat->SetData().SetImp().SetKey("misc_feature");
426 
427  return feat;
428 }
429 
430 
432 {
433  if (entry->IsSeq()) {
434  return entry->SetSeq().SetId().front();
435  } else if (entry->IsSet()) {
436  return IdFromEntry (entry->SetSet().SetSeq_set().front());
437  } else {
439  return empty;
440  }
441 }
442 
443 
445 {
446  CRef<CSeq_feat> feat = MakeMiscFeature(IdFromEntry(entry), right_end);
447  feat->SetComment("misc_feature needs a comment");
448  AddFeat (feat, entry);
449  return feat;
450 }
451 
452 
454 {
455  return AddMiscFeature (entry, 10);
456 }
457 
458 
459 void SetTaxname(CRef<CSeq_entry> entry, string taxname)
460 {
461  if (!entry) {
462  return;
463  }
464  if (entry->IsSeq()) {
465  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
466  if ((*it)->IsSource()) {
467  if (NStr::IsBlank(taxname)) {
468  (*it)->SetSource().SetOrg().ResetTaxname();
469  } else {
470  (*it)->SetSource().SetOrg().SetTaxname(taxname);
471  }
472  }
473  }
474  } else if (entry->IsSet()) {
475  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
476  if ((*it)->IsSource()) {
477  if (NStr::IsBlank(taxname)) {
478  (*it)->SetSource().SetOrg().ResetTaxname();
479  } else {
480  (*it)->SetSource().SetOrg().SetTaxname(taxname);
481  }
482  }
483  }
484  }
485 }
486 
487 
489 {
490  SetTaxname(entry, "Sebaea microphylla");
491  SetTaxon(entry, 0);
492  SetTaxon(entry, 592768);
493 }
494 
495 
497 {
498  SetTaxname(entry, "synthetic construct");
499  SetTaxon(entry, 0);
500  SetTaxon(entry, 32630);
501 }
502 
503 
505 {
506  SetTaxname(entry, "Drosophila melanogaster");
507  SetTaxon(entry, 0);
508  SetTaxon(entry, 7227);
509 }
510 
511 void SetCommon(CRef<CSeq_entry> entry, string common)
512 {
513  if (!entry) {
514  return;
515  }
516  if (entry->IsSeq()) {
517  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
518  if ((*it)->IsSource()) {
519  if (NStr::IsBlank(common)) {
520  (*it)->SetSource().SetOrg().ResetCommon();
521  } else {
522  (*it)->SetSource().SetOrg().SetCommon(common);
523  }
524  }
525  }
526  } else if (entry->IsSet()) {
527  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
528  if ((*it)->IsSource()) {
529  if (NStr::IsBlank(common)) {
530  (*it)->SetSource().SetOrg().ResetCommon();
531  } else {
532  (*it)->SetSource().SetOrg().SetCommon(common);
533  }
534  }
535  }
536  }
537 }
538 
539 
540 void SetLineage(CRef<CSeq_entry> entry, string lineage)
541 {
542  if (!entry) {
543  return;
544  }
545  if (entry->IsSeq()) {
546  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
547  if ((*it)->IsSource()) {
548  if (NStr::IsBlank(lineage)) {
549  (*it)->SetSource().SetOrg().SetOrgname().ResetLineage();
550  } else {
551  (*it)->SetSource().SetOrg().SetOrgname().SetLineage(lineage);
552  }
553  }
554  }
555  } else if (entry->IsSet()) {
556  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
557  if ((*it)->IsSource()) {
558  if (NStr::IsBlank(lineage)) {
559  (*it)->SetSource().SetOrg().SetOrgname().ResetLineage();
560  } else {
561  (*it)->SetSource().SetOrg().SetOrgname().SetLineage(lineage);
562  }
563  }
564  }
565  }
566 }
567 
568 
569 void SetDiv(CRef<CSeq_entry> entry, string div)
570 {
571  if (!entry) {
572  return;
573  }
574  if (entry->IsSeq()) {
575  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
576  if ((*it)->IsSource()) {
577  if (NStr::IsBlank(div)) {
578  (*it)->SetSource().SetOrg().SetOrgname().ResetDiv();
579  } else {
580  (*it)->SetSource().SetOrg().SetOrgname().SetDiv(div);
581  }
582  }
583  }
584  } else if (entry->IsSet()) {
585  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
586  if ((*it)->IsSource()) {
587  if (NStr::IsBlank(div)) {
588  (*it)->SetSource().SetOrg().SetOrgname().ResetDiv();
589  } else {
590  (*it)->SetSource().SetOrg().SetOrgname().SetDiv(div);
591  }
592  }
593  }
594  }
595 }
596 
597 
599 {
600  if (!entry) {
601  return;
602  }
603  if (entry->IsSeq()) {
604  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
605  if ((*it)->IsSource()) {
606  (*it)->SetSource().SetOrigin(origin);
607  }
608  }
609  } else if (entry->IsSet()) {
610  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
611  if ((*it)->IsSource()) {
612  (*it)->SetSource().SetOrigin(origin);
613  }
614  }
615  }
616 }
617 
618 
620 {
621  if (!entry) {
622  return;
623  }
624  if (entry->IsSeq()) {
625  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
626  if ((*it)->IsSource()) {
627  (*it)->SetSource().SetOrg().SetOrgname().SetGcode(gcode);
628  }
629  }
630  } else if (entry->IsSet()) {
631  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
632  if ((*it)->IsSource()) {
633  (*it)->SetSource().SetOrg().SetOrgname().SetGcode(gcode);
634  }
635  }
636  }
637 }
638 
639 
641 {
642  if (!entry) {
643  return;
644  }
645  if (entry->IsSeq()) {
646  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
647  if ((*it)->IsSource()) {
648  (*it)->SetSource().SetOrg().SetOrgname().SetMgcode(mgcode);
649  }
650  }
651  } else if (entry->IsSet()) {
652  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
653  if ((*it)->IsSource()) {
654  (*it)->SetSource().SetOrg().SetOrgname().SetMgcode(mgcode);
655  }
656  }
657  }
658 }
659 
660 
662 {
663  if (!entry) {
664  return;
665  }
666  if (entry->IsSeq()) {
667  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
668  if ((*it)->IsSource()) {
669  (*it)->SetSource().SetOrg().SetOrgname().SetPgcode(pgcode);
670  }
671  }
672  } else if (entry->IsSet()) {
673  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
674  if ((*it)->IsSource()) {
675  (*it)->SetSource().SetOrg().SetOrgname().SetPgcode(pgcode);
676  }
677  }
678  }
679 }
680 
681 
683 {
684  if (!entry) {
685  return;
686  }
687  if (entry->IsSeq()) {
688  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
689  if ((*it)->IsSource()) {
690  (*it)->SetSource().SetOrg().ResetOrgname();
691  }
692  }
693  } else if (entry->IsSet()) {
694  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
695  if ((*it)->IsSource()) {
696  (*it)->SetSource().SetOrg().ResetOrgname();
697  }
698  }
699  }
700 }
701 
702 
704 {
705  if (!entry) {
706  return;
707  }
708  if (entry->IsSeq()) {
709  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
710  if ((*it)->IsSource()) {
711  (*it)->SetSource().SetIs_focus();
712  }
713  }
714  } else if (entry->IsSet()) {
715  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
716  if ((*it)->IsSource()) {
717  (*it)->SetSource().SetIs_focus();
718  }
719  }
720  }
721 }
722 
723 
725 {
726  if (!entry) {
727  return;
728  }
729  if (entry->IsSeq()) {
730  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
731  if ((*it)->IsSource()) {
732  (*it)->SetSource().ResetIs_focus();
733  }
734  }
735  } else if (entry->IsSet()) {
736  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
737  if ((*it)->IsSource()) {
738  (*it)->SetSource().ResetIs_focus();
739  }
740  }
741  }
742 }
743 
744 
746 {
747  if (!entry) {
748  return;
749  }
750  if (entry->IsSeq()) {
751  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
752  if ((*it)->IsSource()) {
753  (*it)->SetSource().SetGenome(genome);
754  }
755  }
756  } else if (entry->IsSet()) {
757  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
758  if ((*it)->IsSource()) {
759  (*it)->SetSource().SetGenome(genome);
760  }
761  }
762  }
763 }
764 
765 
766 void SetSubSource(CBioSource& src, CSubSource::TSubtype subtype, string val)
767 {
768  if (NStr::IsBlank(val)) {
769  if (src.IsSetSubtype()) {
770  CBioSource::TSubtype::iterator it = src.SetSubtype().begin();
771  while (it != src.SetSubtype().end()) {
772  if ((*it)->IsSetSubtype() && (*it)->GetSubtype() == subtype) {
773  it = src.SetSubtype().erase(it);
774  } else {
775  ++it;
776  }
777  }
778  }
779  } else {
780  CRef<CSubSource> sub(new CSubSource(subtype, val));
781  if (NStr::EqualNocase(val, "true")) {
782  sub->SetName("");
783  }
784  src.SetSubtype().push_back(sub);
785  }
786 }
787 
788 
789 void SetSubSource(CRef<CSeq_entry> entry, CSubSource::TSubtype subtype, string val)
790 {
791  if (!entry) {
792  return;
793  }
794  if (entry->IsSeq()) {
795  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
796  if ((*it)->IsSource()) {
797  SetSubSource((*it)->SetSource(), subtype, val);
798  }
799  }
800  } else if (entry->IsSet()) {
801  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
802  if ((*it)->IsSource()) {
803  SetSubSource((*it)->SetSource(), subtype, val);
804  }
805  }
806  }
807 }
808 
809 
810 void SetChromosome(CBioSource& src, string chromosome)
811 {
812  if (NStr::IsBlank(chromosome)) {
813  if (src.IsSetSubtype()) {
814  CBioSource::TSubtype::iterator it = src.SetSubtype().begin();
815  while (it != src.SetSubtype().end()) {
816  if ((*it)->IsSetSubtype() && (*it)->GetSubtype() == CSubSource::eSubtype_chromosome) {
817  it = src.SetSubtype().erase(it);
818  } else {
819  ++it;
820  }
821  }
822  }
823  } else {
825  src.SetSubtype().push_back(sub);
826  }
827 }
828 
829 
830 void SetChromosome(CRef<CSeq_entry> entry, string chromosome)
831 {
832  if (!entry) {
833  return;
834  }
835  if (entry->IsSeq()) {
836  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
837  if ((*it)->IsSource()) {
838  SetChromosome((*it)->SetSource(), chromosome);
839  }
840  }
841  } else if (entry->IsSet()) {
842  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
843  if ((*it)->IsSource()) {
844  SetChromosome((*it)->SetSource(), chromosome);
845  }
846  }
847  }
848 }
849 
850 
851 void SetTransgenic(CBioSource& src, bool do_set)
852 {
853  if (do_set) {
855  src.SetSubtype().push_back(sub);
856  } else if (src.IsSetSubtype()) {
857  CBioSource::TSubtype::iterator it = src.SetSubtype().begin();
858  while (it != src.SetSubtype().end()) {
859  if ((*it)->IsSetSubtype() && (*it)->GetSubtype() == CSubSource::eSubtype_transgenic) {
860  it = src.SetSubtype().erase(it);
861  } else {
862  ++it;
863  }
864  }
865  }
866 }
867 
868 
869 void SetTransgenic(CRef<CSeq_entry> entry, bool do_set)
870 {
871  if (!entry) {
872  return;
873  }
874  if (entry->IsSeq()) {
875  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
876  if ((*it)->IsSource()) {
877  SetTransgenic((*it)->SetSource(), do_set);
878  }
879  }
880  } else if (entry->IsSet()) {
881  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
882  if ((*it)->IsSource()) {
883  SetTransgenic((*it)->SetSource(), do_set);
884  }
885  }
886  }
887 }
888 
889 
890 void SetOrgMod(CBioSource& src, COrgMod::TSubtype subtype, string val)
891 {
892  if (NStr::IsBlank(val)) {
893  if (src.IsSetOrg() && src.GetOrg().IsSetOrgname() && src.GetOrg().GetOrgname().IsSetMod()) {
894  COrgName::TMod::iterator it = src.SetOrg().SetOrgname().SetMod().begin();
895  while (it != src.SetOrg().SetOrgname().SetMod().end()) {
896  if ((*it)->IsSetSubtype() && (*it)->GetSubtype() == subtype) {
897  it = src.SetOrg().SetOrgname().SetMod().erase(it);
898  } else {
899  ++it;
900  }
901  }
902  }
903  } else {
904  CRef<COrgMod> sub(new COrgMod(subtype, val));
905  src.SetOrg().SetOrgname().SetMod().push_back(sub);
906  }
907 }
908 
909 
910 void SetOrgMod(CRef<CSeq_entry> entry, COrgMod::TSubtype subtype, string val)
911 {
912  if (!entry) {
913  return;
914  }
915  if (entry->IsSeq()) {
916  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
917  if ((*it)->IsSource()) {
918  SetOrgMod((*it)->SetSource(), subtype, val);
919  }
920  }
921  } else if (entry->IsSet()) {
922  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSet().SetDescr().Set()) {
923  if ((*it)->IsSource()) {
924  SetOrgMod((*it)->SetSource(), subtype, val);
925  }
926  }
927  }
928 }
929 
930 
932 {
933  CRef<CAuthor> author(new CAuthor());
934  author->SetName().SetName().SetLast("Darwin");
935  author->SetName().SetName().SetFirst("Charles");
936  author->SetName().SetName().SetMiddle("R");
937  return author;
938 }
939 
940 
942 {
943  CRef<CPub> pub(new CPub());
944 
946  art_title->SetName("article title");
947  pub->SetArticle().SetTitle().Set().push_back(art_title);
949  journal_title->SetName("journal_title");
950  pub->SetArticle().SetFrom().SetJournal().SetTitle().Set().push_back(journal_title);
952  iso_jta->SetIso_jta("abbr");
953  pub->SetArticle().SetFrom().SetJournal().SetTitle().Set().push_back(iso_jta);
954  pub->SetArticle().SetAuthors().SetNames().SetStd().push_back(BuildGoodAuthor());
955  pub->SetArticle().SetFrom().SetJournal().SetImp().SetVolume("vol 1");
956  pub->SetArticle().SetFrom().SetJournal().SetImp().SetPages("14-32");
957  pub->SetArticle().SetFrom().SetJournal().SetImp().SetDate().SetStd().SetYear(2009);
958  return pub;
959 }
960 
961 
962 CRef<CPub> BuildGoodCitGenPub(CRef<CAuthor> author, int serial_number)
963 {
964  CRef<CPub> pub(new CPub());
965  if (!author) {
966  author = BuildGoodAuthor();
967  }
968  pub->SetGen().SetAuthors().SetNames().SetStd().push_back(author);
969  pub->SetGen().SetTitle("gen title");
970  pub->SetGen().SetDate().SetStd().SetYear(2009);
971  if (serial_number > -1) {
972  pub->SetGen().SetSerial_number(serial_number);
973  }
974  return pub;
975 }
976 
977 
979 {
980  CRef<CPub> pub(new CPub());
981  CRef<CAuthor> author = BuildGoodAuthor();
982  pub->SetSub().SetAuthors().SetNames().SetStd().push_back(author);
983  pub->SetSub().SetAuthors().SetAffil().SetStd().SetAffil("A Major University");
984  pub->SetSub().SetAuthors().SetAffil().SetStd().SetSub("Maryland");
985  pub->SetSub().SetAuthors().SetAffil().SetStd().SetCountry("USA");
986  pub->SetSub().SetDate().SetStd().SetYear(2009);
987  return pub;
988 }
989 
990 
992 {
993  if (seq.SetInst().IsSetSeq_data()) {
994  if (seq.GetInst().GetSeq_data().IsIupacna()) {
995  seq.SetInst().SetSeq_data().SetIupacna().Set().clear();
996  for (int i = 0; i < 100; i++) {
997  seq.SetInst().SetSeq_data().SetIupacna().Set().append(
998  "AAAAATTTTTGGGGGCCCCCTTTTTAAAAATTTTTGGGGGCCCCCTTTTTAAAAATTTTTGGGGGCCCCCTTTTTAAAAATTTTTGGGGGCCCCCTTTTT");
999  }
1000  seq.SetInst().SetLength(10000);
1001  } else if (seq.GetInst().GetSeq_data().IsIupacaa()) {
1002  seq.SetInst().SetSeq_data().SetIupacaa().Set().clear();
1003  for (int i = 0; i < 100; i++) {
1004  seq.SetInst().SetSeq_data().SetIupacaa().Set().append(
1005  "MPRKTEINSLMPRKTEINSLMPRKTEINSLMPRKTEINSLMPRKTEINSLMPRKTEINSLMPRKTEINSLMPRKTEINSLMPRKTEINSLMPRKTEINSL");
1006  }
1007  seq.SetInst().SetLength(10000);
1008  }
1009  }
1010 }
1011 
1012 
1014 {
1015  bool found = false;
1016 
1017  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
1018  if ((*it)->IsMolinfo()) {
1019  (*it)->SetMolinfo().SetBiomol(biomol);
1020  found = true;
1021  }
1022  }
1023  if (!found) {
1024  CRef<CSeqdesc> mdesc(new CSeqdesc());
1025  mdesc->SetMolinfo().SetBiomol(biomol);
1026  entry->SetSeq().SetDescr().Set().push_back(mdesc);
1027  }
1028 }
1029 
1030 
1032 {
1033  bool found = false;
1034 
1035  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
1036  if ((*it)->IsMolinfo()) {
1037  (*it)->SetMolinfo().SetTech(tech);
1038  found = true;
1039  }
1040  }
1041  if (!found) {
1042  CRef<CSeqdesc> mdesc(new CSeqdesc());
1043  mdesc->SetMolinfo().SetTech(tech);
1044  entry->SetSeq().SetDescr().Set().push_back(mdesc);
1045  }
1046 }
1047 
1048 
1050 {
1051  if (entry->IsSeq()) {
1052  bool found = false;
1053  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
1054  if ((*it)->IsMolinfo()) {
1055  (*it)->SetMolinfo().SetCompleteness (completeness);
1056  found = true;
1057  }
1058  }
1059  if (!found) {
1060  CRef<CSeqdesc> mdesc(new CSeqdesc());
1061  if (entry->GetSeq().IsAa()) {
1063  } else {
1065  }
1066  mdesc->SetMolinfo().SetCompleteness (completeness);
1067  entry->SetSeq().SetDescr().Set().push_back(mdesc);
1068  }
1069  }
1070 }
1071 
1072 
1074 {
1075  CRef<CSeq_entry> entry = BuildGoodSeq();
1076 
1077  entry->SetSeq().SetInst().SetMol(CSeq_inst::eMol_aa);
1078  entry->SetSeq().SetInst().SetSeq_data().SetIupacaa().Set("PRKTEIN");
1079  entry->SetSeq().SetInst().SetLength(7);
1080  NON_CONST_ITERATE (CSeq_descr::Tdata, it, entry->SetSeq().SetDescr().Set()) {
1081  if ((*it)->IsMolinfo()) {
1082  (*it)->SetMolinfo().SetBiomol(CMolInfo::eBiomol_peptide);
1083  }
1084  }
1085 
1086  AddProtFeat (entry);
1087 
1088  return entry;
1089 }
1090 
1091 
1093 {
1094  // make protein
1095  CRef<CBioseq> pseq(new CBioseq());
1096  pseq->SetInst().SetMol(CSeq_inst::eMol_aa);
1097  pseq->SetInst().SetRepr(CSeq_inst::eRepr_raw);
1098  pseq->SetInst().SetSeq_data().SetIupacaa().Set("MPRKTEIN");
1099  pseq->SetInst().SetLength(8);
1100 
1101  CRef<CSeq_id> pid(new CSeq_id());
1102  pid->SetLocal().SetStr (id);
1103  pseq->SetId().push_back(pid);
1104 
1105  CRef<CSeqdesc> mpdesc(new CSeqdesc());
1108  pseq->SetDescr().Set().push_back(mpdesc);
1109 
1110  CRef<CSeq_entry> pentry(new CSeq_entry());
1111  pentry->SetSeq(*pseq);
1112 
1113  CRef<CSeq_feat> feat (new CSeq_feat());
1114  feat->SetData().SetProt().SetName().push_back("fake protein name");
1115  feat->SetLocation().SetInt().SetId().SetLocal().SetStr(id);
1116  feat->SetLocation().SetInt().SetFrom(0);
1117  feat->SetLocation().SetInt().SetTo(7);
1118  AddFeat (feat, pentry);
1119 
1120  return pentry;
1121 }
1122 
1123 
1124 CRef<CSeq_feat> MakeCDSForGoodNucProtSet(const string& nuc_id, const string& prot_id)
1125 {
1126  CRef<CSeq_feat> cds (new CSeq_feat());
1127  cds->SetData().SetCdregion();
1128  cds->SetProduct().SetWhole().SetLocal().SetStr(prot_id);
1129  cds->SetLocation().SetInt().SetId().SetLocal().SetStr(nuc_id);
1130  cds->SetLocation().SetInt().SetFrom(0);
1131  cds->SetLocation().SetInt().SetTo(26);
1132  return cds;
1133 }
1134 
1135 
1137 {
1139  set->SetClass(CBioseq_set::eClass_nuc_prot);
1140 
1141  // make nucleotide
1142  CRef<CBioseq> nseq(new CBioseq());
1143  nseq->SetInst().SetMol(CSeq_inst::eMol_dna);
1144  nseq->SetInst().SetRepr(CSeq_inst::eRepr_raw);
1145  nseq->SetInst().SetSeq_data().SetIupacna().Set("ATGCCCAGAAAAACAGAGATAAACTAAGGGATGCCCAGAAAAACAGAGATAAACTAAGGG");
1146  nseq->SetInst().SetLength(60);
1147 
1148  CRef<CSeq_id> id(new CSeq_id());
1149  id->SetLocal().SetStr ("nuc");
1150  nseq->SetId().push_back(id);
1151 
1152  CRef<CSeqdesc> mdesc(new CSeqdesc());
1154  nseq->SetDescr().Set().push_back(mdesc);
1155 
1156  CRef<CSeq_entry> nentry(new CSeq_entry());
1157  nentry->SetSeq(*nseq);
1158 
1159  set->SetSeq_set().push_back(nentry);
1160 
1161  // make protein
1163 
1164  set->SetSeq_set().push_back(pentry);
1165 
1166  CRef<CSeq_entry> set_entry(new CSeq_entry());
1167  set_entry->SetSet(*set);
1168 
1169  CRef<CSeq_feat> cds = MakeCDSForGoodNucProtSet("nuc", "prot");
1170  AddFeat (cds, set_entry);
1171 
1172  AddGoodSource (set_entry);
1173  AddGoodPub(set_entry);
1174  return set_entry;
1175 }
1176 
1177 
1179 {
1181  CRef<CSeq_entry> prot_seq;
1182 
1183  if (!entry) {
1184  return;
1185  }
1186  if (entry->IsSeq()) {
1187  prot_seq = entry;
1188  prot = entry->SetSeq().SetAnnot().front()->SetData().SetFtable().front();
1189  } else if (entry->IsSet()) {
1190  prot_seq = entry->SetSet().SetSeq_set().back();
1191  prot = prot_seq->SetSeq().SetAnnot().front()->SetData().SetFtable().front();
1192  }
1193  if (prot && prot_seq) {
1194  prot->SetLocation().SetInt().SetTo(prot_seq->SetSeq().SetInst().SetLength() - 1);
1195  }
1196 }
1197 
1198 
1199 void SetNucProtSetProductName(CRef<CSeq_entry> entry, string new_name)
1200 {
1202  CRef<CSeq_entry> prot_seq;
1203 
1204  if (!entry) {
1205  return;
1206  }
1207  if (entry->IsSeq()) {
1208  prot_seq = entry;
1209  prot = entry->SetSeq().SetAnnot().front()->SetData().SetFtable().front();
1210  } else if (entry->IsSet()) {
1211  prot_seq = entry->SetSet().SetSeq_set().back();
1212  prot = prot_seq->SetSeq().SetAnnot().front()->SetData().SetFtable().front();
1213  }
1214  if (prot) {
1215  if (prot->SetData().SetProt().SetName().size() > 0) {
1216  prot->SetData().SetProt().SetName().pop_front();
1217  }
1218  prot->SetData().SetProt().SetName().push_front(new_name);
1219  }
1220 }
1221 
1222 
1224 {
1225  return entry->SetSet().SetAnnot().front()->SetData().SetFtable().front();
1226 }
1227 
1228 
1230 {
1231  return entry->SetSet().SetSeq_set().front();
1232 }
1233 
1234 
1236 {
1237  return entry->SetSet().SetSeq_set().back();
1238 }
1239 
1240 
1242 {
1244  return pentry->SetSeq().SetAnnot().front()->SetData().SetFtable().front();
1245 }
1246 
1247 
1249 {
1251  CRef<CBioseq> bioseq = CSeqTranslator::TranslateToProtein(*cds, scope);
1253  pentry->SetSeq().SetInst().Assign(bioseq->GetInst());
1255 }
1256 
1257 
1258 void SetProteinPartial(CRef<CSeq_entry> pentry, bool partial5, bool partial3)
1259 {
1260  CRef<CSeq_feat> prot = pentry->SetAnnot().front()->SetData().SetFtable().front();
1261  prot->SetPartial(partial5 || partial3);
1262  prot->SetLocation().SetPartialStart(partial5, eExtreme_Biological);
1263  prot->SetLocation().SetPartialStop(partial3, eExtreme_Biological);
1264 
1265  // molinfo completeness
1266  if (partial5 && partial3) {
1268  } else if (partial5) {
1270  } else if (partial3) {
1272  } else {
1274  }
1275 }
1276 
1277 
1278 void SetNucProtSetPartials(CRef<CSeq_entry> entry, bool partial5, bool partial3)
1279 {
1280  // partials for CDS
1282  cds->SetPartial(partial5 || partial3);
1283  cds->SetLocation().SetPartialStart(partial5, eExtreme_Biological);
1284  cds->SetLocation().SetPartialStop(partial3, eExtreme_Biological);
1285 
1287  SetProteinPartial(pentry, partial5, partial3);
1288 }
1289 
1290 
1292 {
1294  pseq->SetSeq().SetId().front()->Assign(*id);
1295 
1297  pfeat->SetLocation().SetInt().SetId().Assign(*id);
1298 
1300  cds->SetProduct().SetWhole().Assign(*id);
1301 }
1302 
1303 
1305 {
1307  nseq->SetSeq().SetId().front()->Assign(*id);
1308 
1310  if(cds->GetLocation().IsInt()) {
1311  cds->SetLocation().SetInt().SetId().Assign(*id);
1312  } else if (cds->GetLocation().IsMix()) {
1313  cds->SetLocation().SetMix().Set().front()->SetInt().SetId().Assign(*id);
1314  cds->SetLocation().SetMix().Set().back()->SetInt().SetId().Assign(*id);
1315  }
1316 }
1317 
1318 
1320 {
1322  cds->SetLocation().SetInt().SetTo(59);
1323  cds->SetLocation().SetPartialStop(true, eExtreme_Biological);
1324  cds->SetPartial(true);
1325  CRef<CSeq_entry> nuc_seq = entry->SetSet().SetSeq_set().front();
1326  nuc_seq->SetSeq().SetInst().SetSeq_data().SetIupacna().Set("ATGCCCAGAAAAACAGAGATAAACAAAGGGATGCCCAGAAAAACAGAGATAAACAAAGGG");
1327  CRef<CSeq_entry> prot_seq = entry->SetSet().SetSeq_set().back();
1328  prot_seq->SetSeq().SetInst().SetSeq_data().SetIupacaa().Set("MPRKTEINKGMPRKTEINKG");
1329  prot_seq->SetSeq().SetInst().SetLength(20);
1331  CRef<CSeq_feat> prot = prot_seq->SetSeq().SetAnnot().front()->SetData().SetFtable().front();
1332  prot->SetLocation().SetInt().SetTo(19);
1333  prot->SetLocation().SetPartialStop(true, eExtreme_Biological);
1334  prot->SetPartial(true);
1335 }
1336 
1337 
1339 {
1340  if (annot && annot->IsFtable()) {
1341  CSeq_annot::C_Data::TFtable::iterator it = annot->SetData().SetFtable().begin();
1342  while (it != annot->SetData().SetFtable().end()) {
1343  (*it)->SetLocation().SetInt().SetId().Assign(*id);
1344  ++it;
1345  }
1346  }
1347 }
1348 
1349 
1351 {
1352  if (annot && annot->IsFtable()) {
1353  CSeq_annot::C_Data::TFtable::iterator it = annot->SetData().SetFtable().begin();
1354  while (it != annot->SetData().SetFtable().end()) {
1355  if ((*it)->IsSetProduct()) {
1356  (*it)->SetProduct().SetWhole().Assign(*id);
1357  }
1358  ++it;
1359  }
1360  }
1361 }
1362 
1363 
1365 {
1366  if (!np_set || !np_set->IsSet()) {
1367  return;
1368  }
1369 
1370  CRef<CSeq_entry> nuc_entry = np_set->SetSet().SetSeq_set().front();
1371 
1372  nuc_entry->SetSeq().SetId().front()->Assign(*id);
1373  if (nuc_entry->SetSeq().IsSetAnnot()) {
1374  NON_CONST_ITERATE(CSeq_entry::TAnnot, annot_it, nuc_entry->SetSeq().SetAnnot()) {
1375  ChangeId (*annot_it, id);
1376  }
1377  }
1378  if (np_set->SetSet().IsSetAnnot()) {
1379  NON_CONST_ITERATE(CSeq_entry::TAnnot, annot_it, np_set->SetSet().SetAnnot()) {
1380  ChangeId (*annot_it, id);
1381  }
1382  }
1383 }
1384 
1385 
1387 {
1388  if (!np_set || !np_set->IsSet()) {
1389  return;
1390  }
1391 
1392  CRef<CSeq_entry> prot_entry = np_set->SetSet().SetSeq_set().back();
1394 
1395  prot_entry->SetSeq().SetId().front()->Assign(*id);
1396  EDIT_EACH_SEQANNOT_ON_BIOSEQ (annot_it, prot_entry->SetSeq()) {
1397  ChangeId (*annot_it, id);
1398  }
1399 
1400  EDIT_EACH_SEQANNOT_ON_SEQSET (annot_it, np_set->SetSet()) {
1401  ChangeProductId (*annot_it, id);
1402  }
1403 }
1404 
1405 
1407 {
1408  CRef<CSeq_id> id(new CSeq_id());
1409  id->SetOther().SetAccession("NC_123456");
1410  return id;
1411 }
1412 
1413 
1415 {
1416  if (entry->IsSeq()) {
1417  entry->SetSeq().SetId().front()->Assign(*id);
1418  if (entry->SetSeq().IsSetAnnot()) {
1419  CBioseq::TAnnot::iterator annot_it = entry->SetSeq().SetAnnot().begin();
1420  while (annot_it != entry->SetSeq().SetAnnot().end()) {
1421  if ((*annot_it)->IsFtable()) {
1422  CSeq_annot::C_Data::TFtable::iterator it = (*annot_it)->SetData().SetFtable().begin();
1423  while (it != (*annot_it)->SetData().SetFtable().end()) {
1424  (*it)->SetLocation().SetId(*id);
1425  ++it;
1426  }
1427  }
1428  ++annot_it;
1429  }
1430  }
1431  }
1432 }
1433 
1434 
1435 void ChangeId(CRef<CSeq_annot> annot, string suffix)
1436 {
1437  if (annot && annot->IsFtable()) {
1438  CSeq_annot::C_Data::TFtable::iterator it = annot->SetData().SetFtable().begin();
1439  while (it != annot->SetData().SetFtable().end()) {
1440  (*it)->SetLocation().SetInt().SetId().SetLocal().SetStr().append(suffix);
1441  if ((*it)->IsSetProduct()) {
1442  (*it)->SetProduct().SetWhole().SetLocal().SetStr().append(suffix);
1443  }
1444  ++it;
1445  }
1446  }
1447 }
1448 
1449 
1450 void ChangeId(CRef<CSeq_entry> entry, string suffix)
1451 {
1452  if (entry->IsSeq()) {
1453  entry->SetSeq().SetId().front()->SetLocal().SetStr().append(suffix);
1454  if (entry->SetSeq().IsSetAnnot()) {
1455  CBioseq::TAnnot::iterator annot_it = entry->SetSeq().SetAnnot().begin();
1456  while (annot_it != entry->SetSeq().SetAnnot().end()) {
1457  ChangeId(*annot_it, suffix);
1458  ++annot_it;
1459  }
1460  }
1461  } else if (entry->IsSet()) {
1462  CBioseq_set::TSeq_set::iterator it = entry->SetSet().SetSeq_set().begin();
1463  while (it != entry->SetSet().SetSeq_set().end()) {
1464  ChangeId(*it, suffix);
1465  ++it;
1466  }
1467  if (entry->SetSet().IsSetAnnot()) {
1468  CBioseq_set::TAnnot::iterator annot_it = entry->SetSet().SetAnnot().begin();
1469  while (annot_it != entry->SetSet().SetAnnot().end()) {
1470  ChangeId(*annot_it, suffix);
1471  ++annot_it;
1472  }
1473  }
1474  }
1475 }
1476 
1477 
1479 {
1482  nuc->SetSeq().SetInst().SetSeq_data().SetIupacna().Set("ATGCCCAGAAAAACAGAGATAAACTAA");
1483  nuc->SetSeq().SetInst().SetLength(27);
1484  nuc->SetSeq().SetInst().SetMol(CSeq_inst::eMol_rna);
1486  if (nuc_id) {
1487  ChangeNucProtSetNucId(np, nuc_id);
1488  }
1489  if (prot_id) {
1490  ChangeNucProtSetProteinId(np, prot_id);
1491  }
1492  return np;
1493 }
1494 
1495 
1497 {
1498  CRef<CSeq_feat> mrna(new CSeq_feat);
1499  mrna->SetData().SetRna().SetType(CRNA_ref::eType_mRNA);
1500  mrna->SetLocation().Assign(feat->GetLocation());
1501  return mrna;
1502 }
1503 
1504 
1506 {
1507  CRef<CSeq_entry> entry(new CSeq_entry());
1509  CRef<CSeq_entry> contig = BuildGoodSeq();
1510  contig->SetSeq().SetInst().SetSeq_data().SetIupacna().Set("ATGCCCAGAAAAACAGAGATAAACTAAGGGATGCCCAGAAAAACAGAGATAAACTAAGGG");
1511  contig->SetSeq().SetInst().SetLength(60);
1512  entry->SetSet().SetSeq_set().push_back (contig);
1513  CRef<CSeq_id> nuc_id(new CSeq_id());
1514  nuc_id->SetLocal().SetStr("nuc");
1515  CRef<CSeq_id> prot_id(new CSeq_id());
1516  prot_id->SetLocal().SetStr("prot");
1517  CRef<CSeq_entry> np = BuildGenProdSetNucProtSet(nuc_id, prot_id);
1518  entry->SetSet().SetSeq_set().push_back (np);
1519 
1520  CRef<CSeq_feat> cds(new CSeq_feat());
1521  cds->Assign (*(GetCDSFromGoodNucProtSet(np)));
1522  cds->SetLocation().SetInt().SetId().SetLocal().SetStr("good");
1523  AddFeat (cds, contig);
1524  CRef<CSeq_feat> mrna = MakemRNAForCDS(cds);
1525  mrna->SetProduct().SetWhole().Assign(*nuc_id);
1526  AddFeat (mrna, contig);
1527 
1528  return entry;
1529 }
1530 
1531 
1533 {
1534  return entry->SetSet().SetSeq_set().front();
1535 }
1536 
1537 
1539 {
1540  CRef<CSeq_entry> genomic = GetGenomicFromGenProdSet(entry);
1541  CRef<CSeq_feat> mrna = genomic->SetSeq().SetAnnot().front()->SetData().SetFtable().back();
1542  return mrna;
1543 }
1544 
1545 
1547 {
1548  return entry->SetSet().SetSeq_set().back();
1549 }
1550 
1551 
1553 {
1554  CRef<CSeq_entry> genomic = GetGenomicFromGenProdSet(entry);
1555  CRef<CSeq_feat> cds = genomic->SetSeq().SetAnnot().front()->SetData().SetFtable().front();
1556  return cds;
1557 }
1558 
1559 
1560 void RevComp(CBioseq& bioseq)
1561 {
1562  if (!bioseq.IsNa() || !bioseq.IsSetInst()
1563  || !bioseq.GetInst().IsSetSeq_data()
1564  || !bioseq.GetInst().GetSeq_data().IsIupacna()) {
1565  return;
1566  }
1567  string seq = bioseq.GetInst().GetSeq_data().GetIupacna().Get();
1568  string new_seq = "";
1569  string::iterator sit = seq.end();
1570  while (sit != seq.begin()) {
1571  --sit;
1572  string new_ch = "";
1573  new_ch += *sit;
1574  if (NStr::Equal(new_ch, "A")) {
1575  new_ch = "T";
1576  } else if (NStr::Equal(new_ch, "T")) {
1577  new_ch = "A";
1578  } else if (NStr::Equal(new_ch, "G")) {
1579  new_ch = "C";
1580  } else if (NStr::Equal(new_ch, "C")) {
1581  new_ch = "G";
1582  }
1583  new_seq.append(new_ch);
1584  }
1585 
1586  bioseq.SetInst().SetSeq_data().SetIupacna().Set(new_seq);
1587  size_t len = bioseq.GetLength();
1588  if (bioseq.IsSetAnnot()) {
1589  EDIT_EACH_SEQFEAT_ON_SEQANNOT (feat_it, *(bioseq.SetAnnot().front())) {
1590  TSeqPos new_from = len - (*feat_it)->GetLocation().GetInt().GetTo() - 1;
1591  TSeqPos new_to = len - (*feat_it)->GetLocation().GetInt().GetFrom() - 1;
1592  (*feat_it)->SetLocation().SetInt().SetFrom(new_from);
1593  (*feat_it)->SetLocation().SetInt().SetTo(new_to);
1594  if ((*feat_it)->GetLocation().GetInt().IsSetStrand()
1595  && (*feat_it)->GetLocation().GetInt().GetStrand() == eNa_strand_minus) {
1596  (*feat_it)->SetLocation().SetInt().SetStrand(eNa_strand_plus);
1597  } else {
1598  (*feat_it)->SetLocation().SetInt().SetStrand(eNa_strand_minus);
1599  }
1600  }
1601  }
1602 }
1603 
1604 
1605 void RevComp(CSeq_loc& loc, size_t len)
1606 {
1607  if (loc.IsInt()) {
1608  TSeqPos new_from = len - loc.GetInt().GetTo() - 1;
1609  TSeqPos new_to = len - loc.GetInt().GetFrom() - 1;
1610  loc.SetInt().SetFrom(new_from);
1611  loc.SetInt().SetTo(new_to);
1612  if (loc.GetInt().IsSetStrand()
1613  && loc.GetInt().GetStrand() == eNa_strand_minus) {
1614  loc.SetInt().SetStrand(eNa_strand_plus);
1615  } else {
1616  loc.SetInt().SetStrand(eNa_strand_minus);
1617  }
1618  } else if (loc.IsMix()) {
1619  NON_CONST_ITERATE (CSeq_loc_mix::Tdata, it, loc.SetMix().Set()) {
1620  RevComp (**it, len);
1621  }
1622  }
1623 }
1624 
1625 
1627 {
1628  if (entry->IsSeq()) {
1629  RevComp(entry->SetSeq());
1630  } else if (entry->IsSet()) {
1631  if (entry->GetSet().IsSetClass()
1632  && entry->GetSet().GetClass() == CBioseq_set::eClass_nuc_prot) {
1633  RevComp(entry->SetSet().SetSeq_set().front());
1634  size_t len = entry->GetSet().GetSeq_set().front()->GetSeq().GetLength();
1635  EDIT_EACH_SEQFEAT_ON_SEQANNOT (feat_it, *(entry->SetSet().SetAnnot().front())) {
1636  RevComp ((*feat_it)->SetLocation(), len);
1637  }
1638  }
1639  }
1640 }
1641 
1642 
1644 {
1645  CRef<CSeq_entry> entry = BuildGoodSeq();
1646 
1647  entry->SetSeq().SetInst().ResetSeq_data();
1648  entry->SetSeq().SetInst().SetRepr(CSeq_inst::eRepr_delta);
1649  entry->SetSeq().SetInst().SetExt().SetDelta().AddLiteral("ATGATGATGCCC", CSeq_inst::eMol_dna);
1650  CRef<CDelta_seq> gap_seg(new CDelta_seq());
1651  gap_seg->SetLiteral().SetSeq_data().SetGap();
1652  gap_seg->SetLiteral().SetLength(10);
1653  entry->SetSeq().SetInst().SetExt().SetDelta().Set().push_back(gap_seg);
1654  entry->SetSeq().SetInst().SetExt().SetDelta().AddLiteral("CCCATGATGATG", CSeq_inst::eMol_dna);
1655  entry->SetSeq().SetInst().SetLength(34);
1656 
1657  return entry;
1658 }
1659 
1660 
1662 {
1663  CDelta_ext::Tdata::iterator seg_it = entry->SetSeq().SetInst().SetExt().SetDelta().Set().begin();
1664  while (seg_it != entry->SetSeq().SetInst().SetExt().SetDelta().Set().end()) {
1665  if ((*seg_it)->IsLiteral()
1666  && (!(*seg_it)->GetLiteral().IsSetSeq_data()
1667  || (*seg_it)->GetLiteral().GetSeq_data().IsGap())) {
1668  TSeqPos len = entry->SetSeq().SetInst().GetLength();
1669  len -= (*seg_it)->GetLiteral().GetLength();
1670  seg_it = entry->SetSeq().SetInst().SetExt().SetDelta().Set().erase(seg_it);
1671  entry->SetSeq().SetInst().SetLength(len);
1672  } else {
1673  ++seg_it;
1674  }
1675  }
1676 }
1677 
1678 
1679 void AddToDeltaSeq(CRef<CSeq_entry> entry, string seq)
1680 {
1681  size_t orig_len = entry->GetSeq().GetLength();
1682  size_t add_len = seq.length();
1683 
1684  CRef<CDelta_seq> gap_seg(new CDelta_seq());
1685  gap_seg->SetLiteral().SetSeq_data().SetGap();
1686  gap_seg->SetLiteral().SetLength(10);
1687  entry->SetSeq().SetInst().SetExt().SetDelta().Set().push_back(gap_seg);
1688  entry->SetSeq().SetInst().SetExt().SetDelta().AddLiteral(seq, CSeq_inst::eMol_dna);
1689  entry->SetSeq().SetInst().SetLength(orig_len + 10 + add_len);
1690 }
1691 
1692 
1694 {
1695  CRef<CSeq_entry> part(new CSeq_entry());
1696  part->SetSeq().SetInst().SetMol(CSeq_inst::eMol_dna);
1697  part->SetSeq().SetInst().SetRepr(CSeq_inst::eRepr_raw);
1698  part->SetSeq().SetInst().SetSeq_data().SetIupacna().Set("AATTGGCCAAAATTGGCCAAAATTGGCCAAAATTGGCCAAAATTGGCCAAAATTGGCCAA");
1699  part->SetSeq().SetInst().SetLength(60);
1700  CRef<CSeq_id> id(new CSeq_id(id_str));
1701  part->SetSeq().SetId().push_back(id);
1703  return part;
1704 }
1705 
1706 
1708 {
1709  CRef<CSeq_entry> segset(new CSeq_entry());
1711 
1712  CRef<CSeq_entry> seg_seq(new CSeq_entry());
1713  seg_seq->SetSeq().SetInst().SetMol(CSeq_inst::eMol_dna);
1714  seg_seq->SetSeq().SetInst().SetRepr(CSeq_inst::eRepr_seg);
1715 
1716  CRef<CSeq_loc> loc1(new CSeq_loc());
1717  loc1->SetWhole().SetLocal().SetStr("part1");
1718  CRef<CSeq_loc> loc2(new CSeq_loc());
1719  loc2->SetWhole().SetLocal().SetStr("part2");
1720  CRef<CSeq_loc> loc3(new CSeq_loc());
1721  loc3->SetWhole().SetLocal().SetStr("part3");
1722 
1723  seg_seq->SetSeq().SetInst().SetExt().SetSeg().Set().push_back(loc1);
1724  seg_seq->SetSeq().SetInst().SetExt().SetSeg().Set().push_back(loc2);
1725  seg_seq->SetSeq().SetInst().SetExt().SetSeg().Set().push_back(loc3);
1726  seg_seq->SetSeq().SetInst().SetLength(180);
1727 
1728  CRef<CSeq_id> id(new CSeq_id());
1729  id->SetLocal().SetStr ("master");
1730  seg_seq->SetSeq().SetId().push_back(id);
1731  seg_seq->SetSeq().SetInst().SetLength(180);
1733 
1734  segset->SetSet().SetSeq_set().push_back(seg_seq);
1735 
1736  // create parts set
1737  CRef<CSeq_entry> parts_set(new CSeq_entry());
1739  parts_set->SetSet().SetSeq_set().push_back(BuildSegSetPart("lcl|part1"));
1740  parts_set->SetSet().SetSeq_set().push_back(BuildSegSetPart("lcl|part2"));
1741  parts_set->SetSet().SetSeq_set().push_back(BuildSegSetPart("lcl|part3"));
1742 
1743  segset->SetSet().SetSeq_set().push_back(parts_set);
1744 
1745 // CRef<CSeqdesc> pdesc(new CSeqdesc());
1746 // CRef<CPub> pub(new CPub());
1747 // pub->SetPmid((CPub::TPmid)1);
1748 // pdesc->SetPub().SetPub().Set().push_back(pub);
1749 // segset->SetDescr().Set().push_back(pdesc);
1750  AddGoodPub(segset);
1751  CRef<CSeqdesc> odesc(new CSeqdesc());
1752  odesc->SetSource().SetOrg().SetTaxname("Sebaea microphylla");
1753  odesc->SetSource().SetOrg().SetOrgname().SetLineage("some lineage");
1754  CRef<CDbtag> taxon_id(new CDbtag());
1755  taxon_id->SetDb("taxon");
1756  taxon_id->SetTag().SetId(592768);
1757  odesc->SetSource().SetOrg().SetDb().push_back(taxon_id);
1758  CRef<CSubSource> subsrc(new CSubSource());
1760  subsrc->SetName("1");
1761  odesc->SetSource().SetSubtype().push_back(subsrc);
1762  segset->SetDescr().Set().push_back(odesc);
1763 
1764  return segset;
1765 }
1766 
1767 
1769 {
1770  CRef<CSeq_entry> entry(new CSeq_entry());
1772  CRef<CSeq_entry> seq1 = BuildGoodSeq();
1773  ChangeId(seq1, "1");
1774  CRef<CSeq_entry> seq2 = BuildGoodSeq();
1775  ChangeId(seq2, "2");
1776  CRef<CSeq_entry> seq3 = BuildGoodSeq();
1777  ChangeId(seq3, "3");
1778  entry->SetSet().SetSeq_set().push_back(seq1);
1779  entry->SetSet().SetSeq_set().push_back(seq2);
1780  entry->SetSet().SetSeq_set().push_back(seq3);
1781 
1782  CRef<CSeqdesc> desc(new CSeqdesc());
1783  desc->SetTitle("popset title");
1784  entry->SetSet().SetDescr().Set().push_back(desc);
1785 
1786  return entry;
1787 }
1788 
1789 
1791 {
1793 
1794  CRef<CSeq_align> align(new CSeq_align());
1796  align->SetDim(entry->GetSet().GetSeq_set().size());
1797  size_t offset = 0;
1798  for (auto& s : entry->SetSet().SetSeq_set()) {
1799  CRef<CSeq_id> id(new CSeq_id());
1800  id->Assign(*(s->GetSeq().GetId().front()));
1801  align->SetSegs().SetDenseg().SetIds().push_back(id);
1802  if (offset > 0) {
1803  const string& orig = s->SetSeq().SetInst().SetSeq_data().SetIupacna().Set();
1804  size_t orig_len = s->GetSeq().GetInst().GetLength();
1805  string add = "";
1806  for (auto i = (size_t)0; i < offset; i++) {
1807  add += "A";
1808  }
1809  s->SetSeq().SetInst().SetSeq_data().SetIupacna().Set(add + orig);
1810  s->SetSeq().SetInst().SetLength(orig_len + offset);
1811  }
1812  align->SetSegs().SetDenseg().SetStarts().push_back(offset);
1813  offset += front_insert;
1814  }
1815  align->SetSegs().SetDenseg().SetNumseg(1);
1816  align->SetSegs().SetDenseg().SetLens().push_back(entry->GetSet().GetSeq_set().front()->GetSeq().GetInst().GetLength());
1817  align->SetSegs().SetDenseg().SetDim(3);
1818 
1819  CRef<CSeq_annot> annot(new CSeq_annot());
1820  annot->SetData().SetAlign().push_back(align);
1821  entry->SetSet().SetAnnot().push_back(annot);
1822  return entry;
1823 }
1824 
1825 
1826 // assumes that sequence has been reverse-complemented
1827 void ReverseAlignmentStrand(CDense_seg& denseg, size_t pos, size_t seq_len)
1828 {
1829  // prepopulate the strand array if not already present
1830  auto num_pieces = denseg.GetDim() * denseg.GetNumseg();
1831  if (!denseg.IsSetStrands()) {
1832  for (auto i = 0; i < num_pieces; i++) {
1833  denseg.SetStrands().push_back(eNa_strand_plus);
1834  }
1835  } else if (denseg.GetStrands().size() < num_pieces) {
1836  for (auto i = denseg.GetStrands().size(); i < num_pieces; i++) {
1837  denseg.SetStrands().push_back(eNa_strand_plus);
1838  }
1839  }
1840  for (auto i = 0; i < denseg.GetNumseg(); i++) {
1841  auto offset = i * denseg.GetDim() + pos;
1842  auto orig = denseg.GetStarts()[offset];
1843  if (orig > -1) {
1844  denseg.SetStarts()[offset] = seq_len - orig - denseg.GetLens()[i];
1845  }
1846  if (denseg.GetStrands()[offset] == eNa_strand_minus) {
1847  denseg.SetStrands()[offset] = eNa_strand_plus;
1848  } else {
1849  denseg.SetStrands()[offset] = eNa_strand_minus;
1850  }
1851  }
1852 }
1853 
1854 
1856 {
1857  CRef<CSeq_align> align(new CSeq_align());
1858  CRef<CSeq_id> id1(new CSeq_id());
1859  id1->SetGenbank().SetAccession("FJ375734.2");
1860  id1->SetGenbank().SetVersion(2);
1861  CRef<CSeq_id> id2(new CSeq_id());
1862  id2->SetGenbank().SetAccession("FJ375735.2");
1863  id2->SetGenbank().SetVersion(2);
1864  align->SetDim(2);
1866  align->SetSegs().SetDenseg().SetIds().push_back(id1);
1867  align->SetSegs().SetDenseg().SetIds().push_back(id2);
1868  align->SetSegs().SetDenseg().SetDim(2);
1869  align->SetSegs().SetDenseg().SetStarts().push_back(0);
1870  align->SetSegs().SetDenseg().SetStarts().push_back(0);
1871  align->SetSegs().SetDenseg().SetNumseg(1);
1872  align->SetSegs().SetDenseg().SetLens().push_back(812);
1873 
1874  return align;
1875 }
1876 
1877 
1879 {
1880  CRef<CSeq_graph> graph(new CSeq_graph());
1881  graph->SetLoc().SetInt().SetFrom(0);
1882  graph->SetLoc().SetInt().SetTo(10);
1883  graph->SetLoc().SetInt().SetId().SetLocal().SetStr(id);
1884 
1885  CRef<CSeq_annot> annot(new CSeq_annot());
1886  annot->SetData().SetGraph().push_back(graph);
1887 
1888  return annot;
1889 }
1890 
1891 
1893 {
1894  EDIT_EACH_DESCRIPTOR_ON_SEQENTRY (dit, *entry) {
1895  if ((*dit)->Which() == desc_choice) {
1896  ERASE_DESCRIPTOR_ON_SEQENTRY (dit, *entry);
1897  }
1898  }
1899 }
1900 
1901 
1903 {
1904  CRef<CSeq_feat> feat(new CSeq_feat());
1905  feat->SetLocation().SetInt().SetId().Assign(*id);
1906  feat->SetLocation().SetInt().SetFrom(0);
1907  feat->SetLocation().SetInt().SetTo(10);
1908 
1909  feat->SetData().SetRna().SetType(CRNA_ref::eType_tRNA);
1910  feat->SetData().SetRna().SetExt().SetTRNA().SetAa().SetIupacaa('N');
1911  feat->SetData().SetRna().SetExt().SetTRNA().SetAnticodon().SetInt().SetId().Assign(*id);
1912  feat->SetData().SetRna().SetExt().SetTRNA().SetAnticodon().SetInt().SetFrom(11);
1913  feat->SetData().SetRna().SetExt().SetTRNA().SetAnticodon().SetInt().SetTo(13);
1914 
1915  return feat;
1916 }
1917 
1918 
1920 {
1921  CRef<CSeq_feat> trna = BuildtRNA(id);
1922  trna->SetData().SetRna().SetExt().SetTRNA().SetAnticodon().SetInt().SetFrom(8);
1923  trna->SetData().SetRna().SetExt().SetTRNA().SetAnticodon().SetInt().SetTo(10);
1924  trna->SetData().SetRna().SetExt().SetTRNA().SetAa().SetIupacaa('F');
1925  return trna;
1926 }
1927 
1928 
1930 {
1931  CRef<CSeq_loc> loc1(new CSeq_loc());
1932  loc1->SetInt().SetFrom(0);
1933  loc1->SetInt().SetTo(15);
1934  loc1->SetInt().SetId().Assign(*id);
1935  CRef<CSeq_loc> loc2(new CSeq_loc());
1936  loc2->SetInt().SetFrom(46);
1937  loc2->SetInt().SetTo(56);
1938  loc2->SetInt().SetId().Assign(*id);
1939  CRef<CSeq_loc> mixloc(new CSeq_loc());
1940  mixloc->SetMix().Set().push_back(loc1);
1941  mixloc->SetMix().Set().push_back(loc2);
1942  return mixloc;
1943 }
1944 
1945 
1947 {
1948  CRef<CSeq_feat> intron(new CSeq_feat());
1949  intron->SetData().SetImp().SetKey("intron");
1950  intron->SetLocation().SetInt().SetFrom(16);
1951  intron->SetLocation().SetInt().SetTo(45);
1952  intron->SetLocation().SetInt().SetId().Assign(*id);
1953  return intron;
1954 }
1955 
1956 
1958 {
1959  seq.SetInst().SetSeq_data().SetIupacna().Set()[16] = 'G';
1960  seq.SetInst().SetSeq_data().SetIupacna().Set()[17] = 'T';
1961  seq.SetInst().SetSeq_data().SetIupacna().Set()[44] = 'A';
1962  seq.SetInst().SetSeq_data().SetIupacna().Set()[45] = 'G';
1963 }
1964 
1965 
1967 {
1968  CRef<CSeq_feat> gene(new CSeq_feat());
1969  gene->SetData().SetGene().SetLocus("gene locus");
1970  gene->SetLocation().SetInt().SetId().Assign(*(feat->GetLocation().GetId()));
1971  gene->SetLocation().SetInt().SetStrand(feat->GetLocation().GetStrand());
1972  gene->SetLocation().SetInt().SetFrom(feat->GetLocation().GetStart(eExtreme_Positional));
1973  gene->SetLocation().SetInt().SetTo(feat->GetLocation().GetStop(eExtreme_Positional));
1976  if (feat->IsSetPartial() && feat->GetPartial()) {
1977  gene->SetPartial(true);
1978  }
1979  return gene;
1980 }
1981 
1982 
1984 {
1985  CRef<CSeq_feat> imp_feat = AddMiscFeature (entry, 10);
1986  imp_feat->SetData().SetImp().SetKey(key);
1987  if (NStr::Equal(key, "conflict")) {
1988  imp_feat->AddQualifier("citation", "1");
1989  } else if (NStr::Equal(key, "intron")) {
1990  entry->SetSeq().SetInst().SetSeq_data().SetIupacna().Set()[0] = 'G';
1991  entry->SetSeq().SetInst().SetSeq_data().SetIupacna().Set()[1] = 'T';
1992  entry->SetSeq().SetInst().SetSeq_data().SetIupacna().Set()[9] = 'A';
1993  entry->SetSeq().SetInst().SetSeq_data().SetIupacna().Set()[10] = 'G';
1994  } else if (NStr::Equal(key, "misc_binding") || NStr::Equal(key, "protein_bind")) {
1995  imp_feat->AddQualifier("bound_moiety", "foo");
1996  } else if (NStr::Equal(key, "modified_base")) {
1997  imp_feat->AddQualifier("mod_base", "foo");
1998  } else if (NStr::Equal(key, "old_sequence")) {
1999  imp_feat->AddQualifier("citation", "1");
2000  } else if (NStr::Equal(key, "operon")) {
2001  imp_feat->AddQualifier("operon", "foo");
2002  } else if (NStr::Equal(key, "polyA_site")) {
2003  imp_feat->SetLocation().SetPnt().SetId().SetLocal().SetStr("good");
2004  imp_feat->SetLocation().SetPnt().SetPoint(5);
2005  } else if (NStr::Equal(key, "source")) {
2006  imp_feat->AddQualifier("organism", "foo");
2007  }
2008  return imp_feat;
2009 }
2010 
2011 // helper classes for TraverseAndRunTestCases
2012 namespace {
2013 
2014  // This just accumulates all the files in the path
2015  struct SFileRememberer
2016  {
2017  void operator()( const CDirEntry & dir_entry ) {
2018  m_filesFound.push_back(CFile(dir_entry));
2019  }
2020 
2021  vector<CFile> m_filesFound;
2022  };
2023 
2024  // a simple function object that extracts the
2025  // first of a pair. (Unfortunately, "select1st" is not part of
2026  // the STL standard so it can't be relied upon to exist)
2027  template<typename Pair>
2028  struct SFirstOfPair
2029  {
2030  typename Pair::first_type operator()( const Pair & a_pair ) const
2031  {
2032  return a_pair.first;
2033  }
2034  };
2035 }
2036 
2038  ITestRunner *pTestRunner,
2039  CDir dirWithTestCases,
2040  const set<string> & setOfRequiredSuffixes,
2041  const set<string> & setOfOptionalSuffixes,
2042  const set<string> & setOfIgnoredSuffixes,
2044 {
2045  if( ! pTestRunner ) {
2046  NCBI_USER_THROW_FMT("NULL pTestRunner");
2047  }
2048  if( ! dirWithTestCases.Exists() ) {
2049  pTestRunner->OnError("Top-level test-cases dir not found: " + dirWithTestCases.GetPath() );
2050  return;
2051  }
2052  if( ! dirWithTestCases.IsDir() ) {
2053  pTestRunner->OnError("Top-level test-cases dir is actually not a dir: " + dirWithTestCases.GetPath() );
2054  return;
2055  }
2056 
2057  const vector<string> kEmptyVectorOfStrings;
2058 
2059  SFileRememberer fileRememberer;
2061  dirWithTestCases,
2062  kEmptyVectorOfStrings,
2063  kEmptyVectorOfStrings,
2064  fileRememberer,
2065  fFF_File | fFF_Recursive );
2066 
2067  // this is what we search for to see if there is a hidden directory
2068  // or file anywhere along the path.
2069  const string kHiddenSubstring = CDirEntry::GetPathSeparator() + string(".svn") + CDirEntry::GetPathSeparator();
2070 
2071  typedef map<string, ITestRunner::TMapSuffixToFile> TMapTestNameToItsFiles;
2072  TMapTestNameToItsFiles mapTestNameToItsFiles;
2073  // this loop loads mapTestNameToItsFiles
2074  ITERATE( vector<CFile>, file_it, fileRememberer.m_filesFound ) {
2075  const string sFileName = file_it->GetName();
2076  const string sFileAbsPath = CDirEntry::CreateAbsolutePath(file_it->GetPath());
2077 
2078  // hidden folders or files of any kind are silently ignored
2079  if( NStr::Find(sFileAbsPath, kHiddenSubstring) != NPOS ) {
2080  continue;
2081  }
2082 
2084  NStr::StartsWith(sFileName, "README") )
2085  {
2086  // if requested, silently ignore files starting with README
2087  continue;
2088  }
2089 
2090  // extract out testname and suffix
2091  string sTestName;
2092  string sSuffix;
2093  NStr::SplitInTwo(sFileName, ".", sTestName, sSuffix);
2094  if( sTestName.empty() || sSuffix.empty() ) {
2095  pTestRunner->OnError("Bad file name: " + file_it->GetPath());
2096  continue;
2097  }
2098 
2099  if( setOfIgnoredSuffixes.find(sSuffix) != setOfIgnoredSuffixes.end() ) {
2100  // silently ignores suffixes requested to be ignored by the user
2101  continue;
2102  }
2103 
2104  // load this entry, with error if not inserted
2105  const bool bWasInserted =
2106  mapTestNameToItsFiles[sTestName].insert(make_pair(sSuffix, *file_it)).second;
2107  if( ! bWasInserted ) {
2108  pTestRunner->OnError(
2109  "File with same name appears multiple times in different dirs: " +
2110  file_it->GetPath() );
2111  continue;
2112  }
2113  }
2114 
2115  // sanity check all tests and remove the unusable ones
2116  ERASE_ITERATE(TMapTestNameToItsFiles, test_it, mapTestNameToItsFiles) {
2117  const string & sTestName = test_it->first;
2118  const ITestRunner::TMapSuffixToFile & mapSuffixToFile =
2119  test_it->second;
2120 
2121  // get the keys (that is, the suffixes) of the map
2122  set<string> setOfAllSuffixes;
2123  transform(mapSuffixToFile.begin(), mapSuffixToFile.end(),
2124  inserter(setOfAllSuffixes, setOfAllSuffixes.begin()),
2125  SFirstOfPair<ITestRunner::TMapSuffixToFile::value_type>() );
2126 
2127  // get the non-required suffixes that were used
2128  set<string> setOfNonRequiredSuffixes;
2129  set_difference( setOfAllSuffixes.begin(), setOfAllSuffixes.end(),
2130  setOfRequiredSuffixes.begin(), setOfRequiredSuffixes.end(),
2131  inserter(setOfNonRequiredSuffixes, setOfNonRequiredSuffixes.begin() ) );
2132 
2133  // make sure it has all required suffixes
2134  // (the set of suffixes should have shrunk by exactly the number of required
2135  // suffixes on the set_difference just above)
2136  const size_t szNumOfSuffixes = setOfAllSuffixes.size();
2137  const size_t szNumOfNonRequiredSuffixes = setOfNonRequiredSuffixes.size();
2138  if( (szNumOfSuffixes - szNumOfNonRequiredSuffixes) != setOfRequiredSuffixes.size() )
2139  {
2140  pTestRunner->OnError("Skipping this test because it's missing some files: " + sTestName);
2141  mapTestNameToItsFiles.erase(test_it);
2142  continue;
2143  }
2144 
2145  // all non-required suffixes should be in the optional set
2146  if( ! includes( setOfOptionalSuffixes.begin(), setOfOptionalSuffixes.end(),
2147  setOfNonRequiredSuffixes.begin(), setOfNonRequiredSuffixes.end() ) )
2148  {
2149  pTestRunner->OnError("Skipping this test because it has unexpected suffix(es): " + sTestName);
2150  mapTestNameToItsFiles.erase(test_it);
2151  continue;
2152  }
2153  }
2154 
2155  // there should be at least one test to run
2156  if( mapTestNameToItsFiles.empty() ) {
2157  pTestRunner->OnError("There are no tests to run");
2158  return;
2159  }
2160 
2161  // Now, actually run the tests
2162  ITERATE(TMapTestNameToItsFiles, test_it, mapTestNameToItsFiles) {
2163  const string & sTestName = test_it->first;
2164  const ITestRunner::TMapSuffixToFile & mapSuffixToFile =
2165  test_it->second;
2166 
2167  cerr << "Running test: " << sTestName << endl;
2168  pTestRunner->RunTest(sTestName, mapSuffixToFile);
2169  }
2170 }
2171 
2172 END_SCOPE(unit_test_util)
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.
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
@ eExtreme_Biological
5' and 3'
Definition: Na_strand.hpp:62
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.
void transform(Container &c, UnaryFunction *op)
Definition: chainer.hpp:86
CAuthor –.
Definition: Author.hpp:59
TSeqPos GetLength(void) const
Definition: Bioseq.cpp:360
bool IsNa(void) const
Definition: Bioseq.cpp:345
bool IsAa(void) const
Definition: Bioseq.cpp:350
Definition: Dbtag.hpp:53
CDelta_seq –.
Definition: Delta_seq.hpp:66
CDirEntry –.
Definition: ncbifile.hpp:262
CDir –.
Definition: ncbifile.hpp:1695
CFile –.
Definition: ncbifile.hpp:1604
@OrgMod.hpp User-defined methods of the data storage class.
Definition: OrgMod.hpp:54
Definition: Pub.hpp:56
CScope –.
Definition: scope.hpp:92
bool IsFtable(void) const
Definition: Seq_annot.cpp:177
Definition: Seq_entry.hpp:56
void SetDescr(CSeq_descr &value)
Definition: Seq_entry.cpp:134
TAnnot & SetAnnot(void)
Definition: Seq_entry.cpp:195
list< CRef< CSeq_annot > > TAnnot
Definition: Seq_entry.hpp:86
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
void AddQualifier(const string &qual_name, const string &qual_val)
Add a qualifier to this feature.
Definition: Seq_feat.cpp:291
C_E –.
Definition: Title_.hpp:96
virtual void RunTest(const string &sTestNAme, const TMapSuffixToFile &mapSuffixToFile)=0
This function is called for each test.
virtual void OnError(const string &sErrorText)=0
This is called when an error occurs, and if ITestRunner is using boost it should indicate that using,...
const_iterator begin() const
Definition: map.hpp:151
const_iterator end() const
Definition: map.hpp:152
Definition: map.hpp:338
Definition: set.hpp:45
const_iterator begin() const
Definition: set.hpp:135
size_type size() const
Definition: set.hpp:132
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
Include a standard set of the NCBI C++ Toolkit most basic headers.
int offset
Definition: replacements.h:160
#define ENTREZ_ID_CONST(id)
Definition: ncbimisc.hpp:1099
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define ERASE_ITERATE(Type, Var, Cont)
Non-constant version with ability to erase current element, if container permits.
Definition: ncbimisc.hpp:843
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
string
Definition: cgiapp.hpp:687
#define NCBI_USER_THROW_FMT(message)
Throw a "user exception" with message processed as output to ostream.
Definition: ncbiexpt.hpp:724
static string CreateAbsolutePath(const string &path, ERelativeToWhat rtw=eRelativeToCwd)
Get an absolute path from some, possibly relative, path.
Definition: ncbifile.cpp:665
void FindFilesInDir(const CDir &dir, const vector< string > &masks, const vector< string > &masks_subdir, TFindFunc &find_func, TFindFiles flags=fFF_Default)
Find files in the specified directory.
Definition: ncbifile.hpp:3022
virtual bool Exists(void) const
Check if directory "dirname" exists.
Definition: ncbifile.hpp:4065
bool IsDir(EFollowLinks follow=eFollowLinks) const
Check whether a directory entry is a directory.
Definition: ncbifile.hpp:3946
static char GetPathSeparator(void)
Get path separator symbol specific for the current platform.
Definition: ncbifile.cpp:433
const string & GetPath(void) const
Get entry path.
Definition: ncbifile.hpp:3910
@ fFF_Recursive
descend into sub-dirs
Definition: ncbifile.hpp:3012
@ fFF_File
find files
Definition: ncbifile.hpp:3008
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
const TPrim & Get(void) const
Definition: serialbase.hpp:347
void SetMix(TMix &v)
Definition: Seq_loc.hpp:987
void SetWhole(TWhole &v)
Definition: Seq_loc.hpp:982
bool IsPartialStart(ESeqLocExtremes ext) const
check start or stop of location for e_Lim fuzz
Definition: Seq_loc.cpp:3222
ENa_strand GetStrand(void) const
Get the location's strand.
Definition: Seq_loc.cpp:882
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
Definition: Seq_loc.cpp:915
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
Definition: Seq_loc.hpp:941
bool IsPartialStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:3251
TSeqPos GetStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:963
static CRef< CBioseq > TranslateToProtein(const CSeq_feat &cds, CScope &scope)
Definition: sequence.cpp:3839
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
static bool 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 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 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 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
void SetTitle(TTitle &value)
Assign a value to Title data member.
Definition: Cit_art_.cpp:210
void SetDate(TDate &value)
Assign a value to Date data member.
Definition: Cit_sub_.cpp:101
void SetName(TName &value)
Assign a value to Name data member.
Definition: Author_.cpp:81
void SetFrom(TFrom &value)
Assign a value to From data member.
Definition: Cit_art_.cpp:248
void SetAuthors(TAuthors &value)
Assign a value to Authors data member.
Definition: Cit_art_.cpp:227
void SetSerial_number(TSerial_number value)
Assign a value to Serial_number data member.
Definition: Cit_gen_.hpp:902
void SetDate(TDate &value)
Assign a value to Date data member.
Definition: Cit_gen_.cpp:116
void SetAuthors(TAuthors &value)
Assign a value to Authors data member.
Definition: Cit_sub_.cpp:74
void SetTitle(const TTitle &value)
Assign a value to Title data member.
Definition: Cit_gen_.hpp:942
void SetAuthors(TAuthors &value)
Assign a value to Authors data member.
Definition: Cit_gen_.cpp:64
void SetSubtype(TSubtype value)
Assign a value to Subtype data member.
Definition: SubSource_.hpp:319
bool IsSetOrg(void) const
Check if a value has been assigned to Org data member.
Definition: BioSource_.hpp:497
bool IsSetSubtype(void) const
Check if a value has been assigned to Subtype data member.
Definition: BioSource_.hpp:527
const TOrg & GetOrg(void) const
Get the Org member data.
Definition: BioSource_.hpp:509
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
TStr & SetStr(void)
Select the variant.
Definition: Object_id_.hpp:304
void SetDb(const TDb &value)
Assign a value to Db data member.
Definition: Dbtag_.hpp:229
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
bool IsSetMod(void) const
Check if a value has been assigned to Mod data member.
Definition: OrgName_.hpp:827
bool IsSetOrgname(void) const
Check if a value has been assigned to Orgname data member.
Definition: Org_ref_.hpp:529
const TOrgname & GetOrgname(void) const
Get the Orgname member data.
Definition: Org_ref_.hpp:541
TPmid & SetPmid(void)
Select the variant.
Definition: Pub_.hpp:690
TSub & SetSub(void)
Select the variant.
Definition: Pub_.cpp:195
TGen & SetGen(void)
Select the variant.
Definition: Pub_.cpp:173
TArticle & SetArticle(void)
Select the variant.
Definition: Pub_.cpp:239
bool IsSetStrands(void) const
Check if a value has been assigned to Strands data member.
Definition: Dense_seg_.hpp:568
const TStarts & GetStarts(void) const
Get the Starts member data.
Definition: Dense_seg_.hpp:530
void SetSegs(TSegs &value)
Assign a value to Segs data member.
Definition: Seq_align_.cpp:310
const TLens & GetLens(void) const
Get the Lens member data.
Definition: Dense_seg_.hpp:555
void SetDim(TDim value)
Assign a value to Dim data member.
Definition: Seq_align_.hpp:865
void SetType(TType value)
Assign a value to Type data member.
Definition: Seq_align_.hpp:818
TDim GetDim(void) const
Get the Dim member data.
Definition: Dense_seg_.hpp:421
TStarts & SetStarts(void)
Assign a value to Starts data member.
Definition: Dense_seg_.hpp:536
TStrands & SetStrands(void)
Assign a value to Strands data member.
Definition: Dense_seg_.hpp:586
TNumseg GetNumseg(void) const
Get the Numseg member data.
Definition: Dense_seg_.hpp:465
const TStrands & GetStrands(void) const
Get the Strands member data.
Definition: Dense_seg_.hpp:580
TDbxref & SetDbxref(void)
Assign a value to Dbxref data member.
Definition: Seq_feat_.hpp:1339
void SetLocation(TLocation &value)
Assign a value to Location data member.
Definition: Seq_feat_.cpp:131
void SetComment(const TComment &value)
Assign a value to Comment data member.
Definition: Seq_feat_.hpp:1058
void SetPartial(TPartial value)
Assign a value to Partial data member.
Definition: Seq_feat_.hpp:971
void SetProduct(TProduct &value)
Assign a value to Product data member.
Definition: Seq_feat_.cpp:110
bool IsSetPartial(void) const
incomplete in some way? Check if a value has been assigned to Partial data member.
Definition: Seq_feat_.hpp:943
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
TPartial GetPartial(void) const
Get the Partial member data.
Definition: Seq_feat_.hpp:962
bool IsSetDbxref(void) const
support for xref to other databases Check if a value has been assigned to Dbxref data member.
Definition: Seq_feat_.hpp:1321
bool IsMix(void) const
Check if variant Mix is selected.
Definition: Seq_loc_.hpp:552
void SetAccession(const TAccession &value)
Assign a value to Accession data member.
TFrom GetFrom(void) const
Get the From member data.
list< CRef< CSeq_loc > > Tdata
TLocal & SetLocal(void)
Select the variant.
Definition: Seq_id_.cpp:199
bool IsSetStrand(void) const
Check if a value has been assigned to Strand data member.
TStrand GetStrand(void) const
Get the Strand member data.
TTo GetTo(void) const
Get the To member data.
TGenbank & SetGenbank(void)
Select the variant.
Definition: Seq_id_.cpp:243
bool IsInt(void) const
Check if variant Int is selected.
Definition: Seq_loc_.hpp:528
const TInt & GetInt(void) const
Get the variant data.
Definition: Seq_loc_.cpp:194
void SetVersion(TVersion value)
Assign a value to Version data member.
@ eNa_strand_plus
Definition: Na_strand_.hpp:66
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
void SetLoc(TLoc &value)
Assign a value to Loc data member.
Definition: Seq_graph_.cpp:224
const TSeq & GetSeq(void) const
Get the variant data.
Definition: Seq_entry_.cpp:102
bool IsSetClass(void) const
Check if a value has been assigned to Class data member.
TSet & SetSet(void)
Select the variant.
Definition: Seq_entry_.cpp:130
TClass GetClass(void) const
Get the Class member data.
TAnnot & SetAnnot(void)
Assign a value to Annot data member.
const TSet & GetSet(void) const
Get the variant data.
Definition: Seq_entry_.cpp:124
bool IsSeq(void) const
Check if variant Seq is selected.
Definition: Seq_entry_.hpp:257
bool IsSetAnnot(void) const
Check if a value has been assigned to Annot data member.
bool IsSetSeq_set(void) const
Check if a value has been assigned to Seq_set data member.
bool IsSet(void) const
Check if variant Set is selected.
Definition: Seq_entry_.hpp:263
const TSeq_set & GetSeq_set(void) const
Get the Seq_set member data.
void SetClass(TClass value)
Assign a value to Class data member.
const TAnnot & GetAnnot(void) const
Get the Annot member data.
void SetDescr(TDescr &value)
Assign a value to Descr data member.
TSeq & SetSeq(void)
Select the variant.
Definition: Seq_entry_.cpp:108
TSeq_set & SetSeq_set(void)
Assign a value to Seq_set data member.
@ eClass_parts
parts for 2 or 3
@ eClass_eco_set
ecological sample study
@ eClass_nuc_prot
nuc acid and coded proteins
Definition: Bioseq_set_.hpp:99
@ eClass_gen_prod_set
genomic products, chrom+mRNA+protein
@ eClass_segset
segmented sequence + parts
void SetCompleteness(TCompleteness value)
Assign a value to Completeness data member.
Definition: MolInfo_.hpp:600
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_annot_.cpp:244
list< CRef< CSeqdesc > > Tdata
Definition: Seq_descr_.hpp:91
TId & SetId(void)
Assign a value to Id data member.
Definition: Bioseq_.hpp:296
bool IsSetSeq_data(void) const
the sequence Check if a value has been assigned to Seq_data data member.
Definition: Seq_inst_.hpp:805
void SetPub(TPub &value)
Assign a value to Pub data member.
Definition: Pubdesc_.cpp:72
const TInst & GetInst(void) const
Get the Inst member data.
Definition: Bioseq_.hpp:336
TTitle & SetTitle(void)
Select the variant.
Definition: Seqdesc_.hpp:1039
TPub & SetPub(void)
Select the variant.
Definition: Seqdesc_.cpp:362
bool IsIupacaa(void) const
Check if variant Iupacaa is selected.
Definition: Seq_data_.hpp:524
const TIupacna & GetIupacna(void) const
Get the variant data.
Definition: Seq_data_.hpp:510
bool IsSetAnnot(void) const
Check if a value has been assigned to Annot data member.
Definition: Bioseq_.hpp:354
TAnnot & SetAnnot(void)
Assign a value to Annot data member.
Definition: Bioseq_.hpp:372
const TAnnot & GetAnnot(void) const
Get the Annot member data.
Definition: Bioseq_.hpp:366
const TId & GetId(void) const
Get the Id member data.
Definition: Bioseq_.hpp:290
bool IsSetInst(void) const
the sequence data Check if a value has been assigned to Inst data member.
Definition: Bioseq_.hpp:324
TLength GetLength(void) const
Get the Length member data.
Definition: Seq_inst_.hpp:659
void SetInst(TInst &value)
Assign a value to Inst data member.
Definition: Bioseq_.cpp:86
TSource & SetSource(void)
Select the variant.
Definition: Seqdesc_.cpp:572
E_Choice
Choice variants.
Definition: Seqdesc_.hpp:109
void SetBiomol(TBiomol value)
Assign a value to Biomol data member.
Definition: MolInfo_.hpp:453
void SetDescr(TDescr &value)
Assign a value to Descr data member.
Definition: Bioseq_.cpp:65
const TSeq_data & GetSeq_data(void) const
Get the Seq_data member data.
Definition: Seq_inst_.hpp:817
void SetTech(TTech value)
Assign a value to Tech data member.
Definition: MolInfo_.hpp:503
bool IsIupacna(void) const
Check if variant Iupacna is selected.
Definition: Seq_data_.hpp:504
TMolinfo & SetMolinfo(void)
Select the variant.
Definition: Seqdesc_.cpp:594
@ eRepr_seg
segmented sequence
Definition: Seq_inst_.hpp:95
@ eRepr_delta
sequence made by changes (delta) to others
Definition: Seq_inst_.hpp:100
@ eRepr_raw
continuous sequence
Definition: Seq_inst_.hpp:94
@ eCompleteness_complete
complete biological entity
Definition: MolInfo_.hpp:156
@ eCompleteness_no_left
missing 5' or NH3 end
Definition: MolInfo_.hpp:158
@ eCompleteness_no_right
missing 3' or COOH end
Definition: MolInfo_.hpp:159
@ eCompleteness_no_ends
missing both ends
Definition: MolInfo_.hpp:160
where boath are integers</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 orig
int i
int len
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::KEY key
static const GLdouble origin[]
static const char * suffix[]
Definition: pcregrep.c:408
#define EDIT_EACH_SEQFEAT_ON_SEQANNOT(Itr, Var)
Definition: seq_macros.hpp:413
#define EDIT_EACH_SEQANNOT_ON_BIOSEQ(Itr, Var)
Definition: seq_macros.hpp:266
#define ERASE_DESCRIPTOR_ON_SEQENTRY
#define EDIT_EACH_DESCRIPTOR_ON_SEQENTRY
#define EDIT_EACH_SEQANNOT_ON_SEQSET(Itr, Var)
CRef< CSeq_feat > GetCDSFromGenProdSet(CRef< CSeq_entry > entry)
CRef< CSeq_annot > BuildGoodGraphAnnot(string id)
CRef< CSeq_entry > BuildGoodEcoSet()
CRef< CSeq_feat > AddMiscFeature(CRef< CSeq_entry > entry, size_t right_end)
CRef< CSeq_loc > MakeMixLoc(CRef< CSeq_id > id)
void MakeSeqLong(CBioseq &seq)
CRef< CSeq_feat > GetProtFeatFromGoodNucProtSet(CRef< CSeq_entry > entry)
void RemoveDescriptorType(CRef< CSeq_entry > entry, CSeqdesc::E_Choice desc_choice)
CRef< CSeq_entry > GetGenomicFromGenProdSet(CRef< CSeq_entry > entry)
CRef< CSeq_entry > BuildSegSetPart(string id_str)
CRef< CSeq_entry > BuildGoodDeltaSeq()
void RemoveDeltaSeqGaps(CRef< CSeq_entry > entry)
void SetCompleteness(CRef< CSeq_entry > entry, CMolInfo::TCompleteness completeness)
void SetSpliceForMixLoc(CBioseq &seq)
CRef< CPub > BuildGoodCitSubPub()
CRef< CSeq_feat > AddGoodImpFeat(CRef< CSeq_entry > entry, string key)
void ChangeProtId(CRef< CSeq_entry > np_set, CRef< CSeq_id > id)
void SetLineage(CRef< CSeq_entry > entry, string lineage)
void SetNucProtSetPartials(CRef< CSeq_entry > entry, bool partial5, bool partial3)
void SetSynthetic_construct(CRef< CSeq_entry > entry)
void ResetOrgname(CRef< CSeq_entry > entry)
void AdjustProtFeatForNucProtSet(CRef< CSeq_entry > entry)
void SetDiv(CRef< CSeq_entry > entry, string div)
CRef< CSeq_feat > GetmRNAFromGenProdSet(CRef< CSeq_entry > entry)
CRef< CSeq_feat > BuildGoodFeat()
void ReverseAlignmentStrand(CDense_seg &denseg, size_t pos, size_t seq_len)
CRef< CSeq_entry > BuildGoodSeq()
CRef< CSeq_feat > MakemRNAForCDS(CRef< CSeq_feat > feat)
CRef< CSeq_annot > AddFeat(CRef< CSeq_feat > feat, CRef< CSeq_entry > entry)
void SetBiomol(CRef< CSeq_entry > entry, CMolInfo::TBiomol biomol)
void SetDrosophila_melanogaster(CRef< CSeq_entry > entry)
CRef< CSeq_entry > BuildGoodProtSeq()
CRef< CSeq_feat > MakeCDSForGoodNucProtSet(const string &nuc_id, const string &prot_id)
void ChangeProductId(CRef< CSeq_annot > annot, CRef< CSeq_id > id)
void AddToDeltaSeq(CRef< CSeq_entry > entry, string seq)
CRef< CSeq_id > BuildRefSeqId()
void SetGenome(CRef< CSeq_entry > entry, CBioSource::TGenome genome)
void SetChromosome(CBioSource &src, string chromosome)
void SetOrgMod(CBioSource &src, COrgMod::TSubtype subtype, string val)
CRef< CSeq_feat > MakeMiscFeature(CRef< CSeq_id > id, size_t right_end, size_t left_end)
CRef< CSeq_feat > GetCDSFromGoodNucProtSet(CRef< CSeq_entry > entry)
void ChangeNucProtSetNucId(CRef< CSeq_entry > entry, CRef< CSeq_id > id)
void ChangeId(CRef< CSeq_annot > annot, CRef< CSeq_id > id)
void SetTaxname(CRef< CSeq_entry > entry, string taxname)
CRef< CSeq_feat > BuildGoodtRNA(CRef< CSeq_id > id)
void SetFocus(CRef< CSeq_entry > entry)
CRef< CSeq_feat > MakeGeneForFeature(CRef< CSeq_feat > feat)
void MakeNucProtSet3Partial(CRef< CSeq_entry > entry)
CRef< CSeq_entry > BuildGoodNucProtSet()
void TraverseAndRunTestCases(ITestRunner *pTestRunner, CDir dirWithTestCases, const set< string > &setOfRequiredSuffixes, const set< string > &setOfOptionalSuffixes, const set< string > &setOfIgnoredSuffixes, TTraverseAndRunTestCasesFlags fFlags)
This is for running data-driven test cases below the given top-level test directory.
void SetMGcode(CRef< CSeq_entry > entry, COrgName::TGcode mgcode)
CRef< CSeq_feat > BuildtRNA(CRef< CSeq_id > id)
void SetNucProtSetProductName(CRef< CSeq_entry > entry, string new_name)
void RevComp(CBioseq &bioseq)
CRef< CSeq_entry > BuildGenProdSetNucProtSet(CRef< CSeq_id > nuc_id, CRef< CSeq_id > prot_id)
void SetDbxref(CBioSource &src, string db, CObject_id::TId id)
void ChangeNucId(CRef< CSeq_entry > np_set, CRef< CSeq_id > id)
void SetSebaea_microphylla(CRef< CSeq_entry > entry)
void RemoveDbxref(CBioSource &src, string db, CObject_id::TId id)
void SetTaxon(CBioSource &src, size_t taxon)
void RetranslateCdsForNucProtSet(CRef< CSeq_entry > entry, CScope &scope)
CRef< CSeq_entry > MakeProteinForGoodNucProtSet(string id)
CRef< CSeq_id > IdFromEntry(CRef< CSeq_entry > entry)
void AddFeatAnnotToSeqEntry(CRef< CSeq_annot > annot, CRef< CSeq_entry > entry)
CRef< CSeq_feat > AddProtFeat(CRef< CSeq_entry > entry)
void SetGcode(CRef< CSeq_entry > entry, COrgName::TGcode gcode)
CRef< CAuthor > BuildGoodAuthor()
void ChangeNucProtSetProteinId(CRef< CSeq_entry > entry, CRef< CSeq_id > id)
CRef< CSeq_entry > GetNucleotideSequenceFromGoodNucProtSet(CRef< CSeq_entry > entry)
CRef< CSeq_feat > AddGoodSourceFeature(CRef< CSeq_entry > entry)
void SetProteinPartial(CRef< CSeq_entry > pentry, bool partial5, bool partial3)
CRef< CSeq_align > BuildGoodAlign()
CRef< CSeqdesc > BuildGoodPubSeqdesc()
CRef< CSeq_entry > GetNucProtSetFromGenProdSet(CRef< CSeq_entry > entry)
void SetTech(CRef< CSeq_entry > entry, CMolInfo::TTech tech)
void AddGoodSource(CRef< CSeq_entry > entry)
CRef< CSeq_entry > BuildGoodGenProdSet()
void SetOrigin(CRef< CSeq_entry > entry, CBioSource::TOrigin origin)
CRef< CSeq_entry > GetProteinSequenceFromGoodNucProtSet(CRef< CSeq_entry > entry)
void SetSubSource(CBioSource &src, CSubSource::TSubtype subtype, string val)
void SetCommon(CRef< CSeq_entry > entry, string common)
CRef< CSeq_feat > MakeIntronForMixLoc(CRef< CSeq_id > id)
CRef< CSeq_entry > BuildGoodSegSet()
void SetTransgenic(CBioSource &src, bool do_set)
void AddGoodPub(CRef< CSeq_entry > entry)
void ClearFocus(CRef< CSeq_entry > entry)
void SetPGcode(CRef< CSeq_entry > entry, COrgName::TGcode pgcode)
CRef< CSeq_entry > BuildGoodEcoSetWithAlign(size_t front_insert)
CRef< CPub > BuildGoodCitGenPub(CRef< CAuthor > author, int serial_number)
CRef< CPub > BuildGoodArticlePub()
@ fTraverseAndRunTestCasesFlags_DoNOTIgnoreREADMEFiles
Overrides default behavior (which is to disregard files whose prefix is "README")
int TTraverseAndRunTestCasesFlags
Modified on Sat Apr 20 12:18:21 2024 by modify_doxy.py rev. 669887