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

Go to the SVN repository for this file.

1 /* $Id: editing_action_biosource.cpp 45101 2020-05-29 20:53:24Z asztalos $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Igor Filippov
27  */
28 
29 #include <ncbi_pch.hpp>
31 #include <objmgr/util/feature.hpp>
32 #include <objmgr/seqdesc_ci.hpp>
33 #include <objmgr/bioseq_ci.hpp>
44 #include <objects/seq/Seq_data.hpp>
45 #include <objmgr/seq_vector.hpp>
49 
50 
53 
54 
55 IEditingActionBiosource::IEditingActionBiosource(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature, const string &name)
56  : IEditingAction(seh, name), m_is_descriptor(is_descriptor), m_is_feature(is_feature), m_EditedBiosource(NULL), m_Desc(NULL)
57 {
58 
59 }
60 
62 {
65  m_EditedBiosource = &m_EditedFeat->SetData().SetBiosrc();
66 }
67 
69 {
71  m_EditedDesc->Assign(*desc);
73 }
74 
76 {
77  if (!m_TopSeqEntry)
78  return;
79  size_t count = 0;
80  for (CBioseq_CI b_iter(m_TopSeqEntry, objects::CSeq_inst::eMol_na); b_iter; ++b_iter)
81  {
85  CBioseq_Handle bsh = *b_iter;
87  if (m_constraint->Match(bsh))
88  {
89  if (m_is_descriptor)
90  {
91  bool found = false;
92  CSeq_entry_Handle found_seh;
93  for (CSeqdesc_CI desc_ci( bsh, CSeqdesc::e_Source); desc_ci; ++desc_ci)
94  {
95  found = true;
97  m_Desc = &*desc_ci;
98  //m_CurrentSeqEntry = desc_ci.GetSeq_entry_Handle();
99  CSeq_entry_Handle seh = desc_ci.GetSeq_entry_Handle();
100  if (IsFrom(action) && found_seh && seh != found_seh)
101  break;
102  if (m_constraint->Match(m_Desc))
103  {
106  else
107  {
110  }
112  m_DescContext = seh;
113  Modify(action);
114  found_seh = seh;
115  }
116  }
117  if (!found && !IsNOOP(action))
118  {
122  if (m_constraint->Match(m_Desc))
123  {
126  Modify(action);
127  }
128  }
129  }
130 
132  if (m_is_feature)
133  {
134  for (CFeat_CI feat_ci(bsh, CSeqFeatData::e_Biosrc); feat_ci; ++feat_ci)
135  {
137  m_Feat = feat_ci->GetSeq_feat_Handle();
138  if (m_constraint->Match(m_Feat))
139  {
142  else
143  {
146  }
147  m_EditedBiosource = &m_EditedFeat->SetData().SetBiosrc();
148  Modify(action);
149  }
150  }
151  }
152  }
153  ++count;
154  if (count >= m_max_records)
155  break;
156  }
157 // TODO create if none found?
158 }
159 
161 {
162  Find(action);
163 }
164 
166 {
167  Action(action);
168  if (m_modified)
169  {
170  if (m_EditedDesc) {
173  }
174  if (m_EditedFeat)
176  }
177 }
178 
180 {
182  if (other)
183  return true;
184  return false;
185 }
186 
188 {
189  IEditingActionBiosource *src_source = dynamic_cast<IEditingActionBiosource*>(source);
190  if (src_source)
191  {
192  swap(m_EditedDesc, src_source->m_EditedDesc);
193  swap(m_EditedFeat, src_source->m_EditedFeat);
195  swap(m_Desc, src_source->m_Desc);
196  swap(m_Feat, src_source->m_Feat);
197  swap(m_DescContext, src_source->m_DescContext);
198  }
200 }
201 
203  : IEditingActionBiosource(seh, is_descriptor, is_feature, "CEditingActionBiosourceTaxname")
204 {
205 }
206 
208 {
210 }
211 
213 {
214  m_EditedBiosource->SetOrg().SetTaxname(value);
215 }
216 
218 {
219  return m_EditedBiosource->GetOrg().GetTaxname();
220 }
221 
223 {
224  m_EditedBiosource->SetOrg().ResetTaxname();
225 }
226 
228  : IEditingActionBiosource(seh, is_descriptor, is_feature, "CEditingActionBiosourceTaxnameAfterBinomial")
229 {
230 }
231 
232 static const char* nomial_keywords[] = {
233 "f. sp. ",
234 "var",
235 "pv.",
236 "bv.",
237 "serovar",
238 "subsp.",
239 NULL
240 };
241 
243 {
244  if (NStr::IsBlank(taxname)) {
245  return kEmptyStr;
246  }
247 
248  SIZE_TYPE pos = NStr::FindNoCase(taxname, " ");
249  vector<string> names;
250  if (pos != NPOS) {
251  NStr::Split(taxname, " ", names, NStr::fSplit_Tokenize);
252  }
253 
254  if (names.empty()) {
255  return kEmptyStr;
256  }
257 
258  pos = 0;
259  if (NStr::EqualNocase(names[0], "uncultured")) {
260  pos = 2; // skipping the first three words
261  } else {
262  pos = 1; // skipping the first two words
263  }
264 
265  if (names.size() <= pos + 1) {
266  return kEmptyStr;
267  }
268  pos++;
269  bool found_keyword = true;
270  while (pos < names.size() && found_keyword) {
271  /* if the next word is a nomial keyword, skip that plus the first word that follows it */
272  found_keyword = false;
273  if (NStr::EqualCase(names[pos], "f.") && (pos+1 < names.size() && NStr::EqualCase(names[pos+1],"sp."))) {
274  pos = pos + 3;
275  found_keyword = true;
276  } else {
277  size_t n = 1;
278  while (nomial_keywords[n] && !found_keyword) {
279  if (NStr::EqualCase(nomial_keywords[n], names[pos])) {
280  pos = pos + 2;
281  found_keyword = true;
282  }
283  ++n;
284  }
285  }
286  }
287  string taxname_after_binomial = kEmptyStr;
288  while (pos < names.size()) {
289  taxname_after_binomial += names[pos] + " ";
290  pos++;
291  }
292  NStr::TruncateSpacesInPlace(taxname_after_binomial, NStr::eTrunc_End);
293  return taxname_after_binomial;
294 }
295 
297 {
298  string taxname;
301  return !taxname.empty();
302 }
303 
305 {
306  if (IsSetValue())
307  {
308  string taxname = GetValue();
309  NStr::ReplaceInPlace(m_EditedBiosource->SetOrg().SetTaxname(), taxname, value);
310  }
311  else
312  {
313  m_EditedBiosource->SetOrg().SetTaxname() += value;
314  }
315 }
316 
318 {
320 }
321 
323 {
324  string taxname = GetValue();
325  NStr::ReplaceInPlace(m_EditedBiosource->SetOrg().SetTaxname(), taxname, kEmptyStr);
326 }
327 
329  : IEditingActionBiosource(seh, is_descriptor, is_feature, "CEditingActionBiosourceCommonName")
330 {
331 }
332 
334 {
336 }
337 
339 {
340  m_EditedBiosource->SetOrg().SetCommon(value);
341 }
342 
344 {
345  return m_EditedBiosource->GetOrg().GetCommon();
346 }
347 
349 {
350  m_EditedBiosource->SetOrg().ResetCommon();
351 }
352 
354  : IEditingActionBiosource(seh, is_descriptor, is_feature, "CEditingActionBiosourceDivision")
355 {
356 }
357 
359 {
362 }
363 
365 {
366  m_EditedBiosource->SetOrg().SetOrgname().SetDiv(value);
367 }
368 
370 {
372 }
373 
375 {
376  m_EditedBiosource->SetOrg().SetOrgname().ResetDiv();
377 }
378 
380  : IEditingActionBiosource(seh, is_descriptor, is_feature, "CEditingActionBiosourceLineage")
381 {
382 }
383 
385 {
388 }
389 
391 {
392  m_EditedBiosource->SetOrg().SetOrgname().SetLineage(value);
393 }
394 
396 {
398 }
399 
401 {
402  m_EditedBiosource->SetOrg().SetOrgname().ResetLineage();
403 }
404 
405 
407  : IEditingActionBiosource(seh, is_descriptor, is_feature, "CEditingActionBiosourceLocation")
408 {
409 }
410 
412 {
414 }
415 
417 {
418  if (CBioSource::ENUM_METHOD_NAME(EGenome)()->IsValidName(value))
419  {
421  }
422 }
423 
425 {
426  return CBioSource::ENUM_METHOD_NAME(EGenome)()->FindName(m_EditedBiosource->GetGenome(), true);
427 }
428 
430 {
432 }
433 
434 
436  : IEditingActionBiosource(seh, is_descriptor, is_feature, "CEditingActionBiosourceOrigin")
437 {
438 }
439 
441 {
443 }
444 
446 {
447  if (CBioSource::ENUM_METHOD_NAME(EOrigin)()->IsValidName(value))
448  {
450  }
451 }
452 
454 {
455  return CBioSource::ENUM_METHOD_NAME(EOrigin)()->FindName(m_EditedBiosource->GetOrigin(), true);
456 }
457 
459 {
461 }
462 
463 CEditingActionBiosourcePrimers::CEditingActionBiosourcePrimers(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature, bool is_fwd, bool is_rev, bool is_name, bool is_seq)
464  : IEditingActionBiosource(seh, is_descriptor, is_feature, "CEditingActionBiosourcePrimers"), m_is_fwd(is_fwd), m_is_rev(is_rev), m_is_name(is_name), m_is_seq(is_seq), m_val(NULL)
465 {
466 }
467 
469 {
470  bool found = false;
472  {
474  {
475  if (!IsCreateNew(action))
476  {
477  m_reaction.Reset();
478  if (m_is_fwd && (*qual_it)->IsSetForward())
479  {
480  EDIT_EACH_PCRPRIMER_IN_PCRPRIMERSET(primer_it, (*qual_it)->SetForward())
481  {
482  m_primer.Reset();
483  if (m_is_name && (*primer_it)->IsSetName())
484  {
485  found = true;
486  m_val = &(*primer_it)->SetName().Set();
488  }
489  if (m_is_seq && (*primer_it)->IsSetSeq())
490  {
491  found = true;
492  m_val = &(*primer_it)->SetSeq().Set();
494  }
495  if (!found)
496  {
497  found = true;
498  m_val = NULL;
499  m_primer = *primer_it;
501  }
502  if ( (!(*primer_it)->IsSetName() || (*primer_it)->GetName().Get().empty()) &&
503  (!(*primer_it)->IsSetSeq() || (*primer_it)->GetSeq().Get().empty()) )
504  ERASE_PCRPRIMER_IN_PCRPRIMERSET(primer_it, (*qual_it)->SetForward());
505  }
506  }
507  if (m_is_rev && (*qual_it)->IsSetReverse())
508  {
509  EDIT_EACH_PCRPRIMER_IN_PCRPRIMERSET(primer_it, (*qual_it)->SetReverse())
510  {
511  m_primer.Reset();
512  if (m_is_name && (*primer_it)->IsSetName())
513  {
514  found = true;
515  m_val = &(*primer_it)->SetName().Set();
517  }
518  if (m_is_seq && (*primer_it)->IsSetSeq())
519  {
520  found = true;
521  m_val = &(*primer_it)->SetSeq().Set();
523  }
524  if (!found)
525  {
526  found = true;
527  m_val = NULL;
528  m_primer = *primer_it;
530  }
531  if ( (!(*primer_it)->IsSetName() || (*primer_it)->GetName().Get().empty()) &&
532  (!(*primer_it)->IsSetSeq() || (*primer_it)->GetSeq().Get().empty()) )
533  ERASE_PCRPRIMER_IN_PCRPRIMERSET(primer_it, (*qual_it)->SetReverse());
534  }
535  }
536  }
537  if (!found)
538  {
539  found = true;
540  m_val = NULL;
541  m_primer.Reset();
542  m_reaction = *qual_it;
544  }
545  if ( (!(*qual_it)->IsSetForward() || !(*qual_it)->GetForward().IsSet() || (*qual_it)->GetForward().Get().empty()) &&
546  (!(*qual_it)->IsSetReverse() || !(*qual_it)->GetReverse().IsSet() || (*qual_it)->GetReverse().Get().empty()) )
548  }
549  }
550  if (!found)
551  {
552  m_val = NULL;
553  m_primer.Reset();
554  m_reaction.Reset();
556  }
559 }
560 
562 {
563  return m_val != NULL;
564 }
565 
567 {
568  if (m_val)
569  {
570  *m_val = value;
571  }
572  else if ( m_primer)
573  {
574  if (m_is_name)
575  {
577  }
578  if (m_is_seq)
579  {
581  }
582  }
583  else if (m_reaction)
584  {
585  CRef< CPCRPrimer > primer(new CPCRPrimer);
586  if (m_is_name)
587  {
588  primer->SetName(CPCRPrimerName(value));
589  }
590  if (m_is_seq)
591  {
592  primer->SetSeq(CPCRPrimerSeq(value));
593  }
594  if (m_is_fwd)
595  {
596  m_reaction->SetForward().Set().push_back(primer);
597  }
598  if (m_is_rev)
599  {
600  m_reaction->SetReverse().Set().push_back(primer);
601  }
602  }
603  else
604  {
605  CRef< CPCRReaction > reaction(new CPCRReaction);
606  CRef< CPCRPrimer > primer(new CPCRPrimer);
607  if (m_is_name)
608  {
609  primer->SetName(CPCRPrimerName(value));
610  }
611  if (m_is_seq)
612  {
613  primer->SetSeq(CPCRPrimerSeq(value));
614  }
615  if (m_is_fwd)
616  {
617  reaction->SetForward().Set().push_back(primer);
618  }
619  if (m_is_rev)
620  {
621  reaction->SetReverse().Set().push_back(primer);
622  }
623  m_EditedBiosource->SetPcr_primers().Set().push_back(reaction);
624  }
625 }
626 
628 {
629  if (m_val)
630  return *m_val;
631  return kEmptyStr;
632 }
633 
635 {
636  m_val->clear();
637 }
638 
639 
640 
641 CEditingActionBiosourceOrgMod::CEditingActionBiosourceOrgMod(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature, const COrgMod::ESubtype subtype, const string &name)
642  : IEditingActionBiosource(seh, is_descriptor, is_feature, name), m_qual(subtype), m_erase(false)
643 {
644 }
645 
647 {
648  bool found = false;
649  if (!IsCreateNew(action))
650  {
652  {
653  if ((*qual_it)->IsSetSubtype() && (*qual_it)->GetSubtype() == m_qual)
654  {
655  found = true;
656  m_erase = false;
657  m_OrgMod = *qual_it;
659  if (m_erase)
661  }
662  }
663  }
664  if (!found)
665  {
666  m_OrgMod.Reset();
667  m_erase = false;
669  }
670 }
671 
673 {
674  return m_OrgMod && m_OrgMod->IsSetSubname();
675 }
676 
678 {
679  if (m_OrgMod)
681  else
682  {
683  CRef<COrgMod> new_mod(new COrgMod);
684  new_mod->SetSubtype(m_qual);
685  new_mod->SetSubname(value);
686  m_EditedBiosource->SetOrg().SetOrgname().SetMod().push_back(new_mod);
687  }
688 }
689 
691 {
692  return m_OrgMod->GetSubname();
693 }
694 
696 {
697  m_erase = true;
698 }
699 
700 CEditingActionBiosourceSubSource::CEditingActionBiosourceSubSource(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature, const CSubSource::ESubtype subtype, const string &name)
701  : IEditingActionBiosource(seh, is_descriptor, is_feature, name), m_qual(subtype), m_erase(false)
702 {
703 }
704 
706 {
707  bool found = false;
708  if (!IsCreateNew(action))
709  {
711  {
712  if ((*qual_it)->IsSetSubtype() && (*qual_it)->GetSubtype() == m_qual)
713  {
714  found = true;
715  m_erase = false;
716  m_SubSource = *qual_it;
718  if (m_erase)
720  }
721  }
722  }
723  if (!found)
724  {
725  m_SubSource.Reset();
726  m_erase = false;
728  }
729 }
730 
732 {
733  return m_SubSource && m_SubSource->IsSetName();
734 }
735 
737 {
738  if (m_SubSource)
740  else
741  {
742  CRef<CSubSource> new_mod(new CSubSource);
743  new_mod->SetSubtype(m_qual);
744  new_mod->SetName(value);
745  m_EditedBiosource->SetSubtype().push_back(new_mod);
746  }
747 }
748 
750 {
751  return m_SubSource->GetName();
752 }
753 
755 {
756  m_erase = true;
757 }
758 
759 
761  : IEditingActionBiosource(seh, is_descriptor, is_feature, "CEditingActionBiosourceAllNotes"), m_erase(false)
762 {
763 }
764 
766 {
767  bool found = false;
769  {
770  if ((*qual_it)->IsSetSubtype() && (*qual_it)->GetSubtype() == COrgMod::eSubtype_other)
771  {
772  m_erase = false;
773  m_OrgMod = *qual_it;
775  if (m_erase)
777  }
778  }
779  m_OrgMod.Reset();
781  {
782  if ((*qual_it)->IsSetSubtype() && (*qual_it)->GetSubtype() == CSubSource::eSubtype_other)
783  {
784  m_erase = false;
785  m_SubSource = *qual_it;
787  if (m_erase)
789  }
790  }
791 }
792 
794 {
796 }
797 
799 {
800  if (m_OrgMod)
802  if (m_SubSource)
804 }
805 
807 {
808  if (m_OrgMod)
809  return m_OrgMod->GetSubname();
810  if (m_SubSource)
811  return m_SubSource->GetName();
812  return kEmptyStr;
813 }
814 
816 {
817  m_erase = true;
818 }
819 
820 
821 CEditingActionBiosourceStructuredVoucher::CEditingActionBiosourceStructuredVoucher(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature, const COrgMod::ESubtype subtype, const int voucher_type)
822  : CEditingActionBiosourceOrgMod(seh, is_descriptor, is_feature, subtype, "CEditingActionBiosourceStructuredVoucher"), m_voucher_type(voucher_type)
823 {
824 }
825 
827 {
828  bool res = false;
829  if (m_OrgMod && m_OrgMod->IsSetSubname())
830  {
831  string str = m_OrgMod->GetSubname();
832  string inst, coll, id;
833  Parse(str, inst, coll, id);
834  switch (m_voucher_type)
835  {
836  case eVoucher_inst : res = !inst.empty(); break;
837  case eVoucher_coll : res = !coll.empty(); break;
838  case eVoucher_id : res = !id.empty(); break;
839  default: break;
840  }
841  }
842  return res;
843 }
844 
845 void CEditingActionBiosourceStructuredVoucher::Parse(const string &str, string &inst, string &coll, string &id)
846 {
847  vector<string> values;
848  NStr::Split(str, ":", values);
849  if (values.size() == 3)
850  {
851  inst = values[0];
852  coll = values[1];
853  id = values[2];
854  }
855  else if (values.size() == 2)
856  {
857  inst = values[0];
858  id = values[1];
859  }
860  else if (values.size() == 1)
861  {
862  id = values[0];
863  }
864 }
865 
867 {
868  if (m_OrgMod)
869  {
870  string inst, coll, id;
871  if (m_OrgMod->IsSetSubname())
872  {
873  string str = m_OrgMod->GetSubname();
874  Parse(str, inst, coll, id);
875  }
876  switch (m_voucher_type)
877  {
878  case eVoucher_inst : inst = value; break;
879  case eVoucher_coll : coll = value; break;
880  case eVoucher_id : id = value; break;
881  default: break;
882  }
883  string str = COrgMod::MakeStructuredVoucher(inst, coll, id);
885  }
886  else
887  {
888  CRef<COrgMod> new_mod(new COrgMod);
889  new_mod->SetSubtype(m_qual);
890  string inst, coll, id;
891  switch (m_voucher_type)
892  {
893  case eVoucher_inst : inst = value; break;
894  case eVoucher_coll : coll = value; break;
895  case eVoucher_id : id = value; break;
896  default: break;
897  }
898  string str = COrgMod::MakeStructuredVoucher(inst, coll, id);
899 
900  new_mod->SetSubname(str);
901  m_EditedBiosource->SetOrg().SetOrgname().SetMod().push_back(new_mod);
902  }
903 }
904 
906 {
907  string res;
908  string str = m_OrgMod->GetSubname();
909  string inst, coll, id;
910  Parse(str, inst, coll, id);
911  switch (m_voucher_type)
912  {
913  case eVoucher_inst : res = inst; break;
914  case eVoucher_coll : res = coll; break;
915  case eVoucher_id : res = id; break;
916  default: break;
917  }
918  return res;
919 }
920 
922 {
923  if (m_OrgMod)
924  {
925  string inst, coll, id;
926  if (m_OrgMod->IsSetSubname())
927  {
928  string str = m_OrgMod->GetSubname();
929  Parse(str, inst, coll, id);
930  }
931  switch (m_voucher_type)
932  {
933  case eVoucher_inst : inst.clear(); break;
934  case eVoucher_coll : coll.clear(); break;
935  case eVoucher_id : id.clear(); break;
936  default: break;
937  }
938  string str = COrgMod::MakeStructuredVoucher(inst, coll, id);
940  }
941 }
942 
944  : IEditingActionBiosource(seh, is_descriptor, is_feature, "CEditingActionBiosourceDbxrefs"), m_erase(false)
945 {
946 }
947 
948 
950 {
951  bool found = false;
952  if (IsFrom(action) &&
954  && m_EditedBiosource->GetOrg().GetDb().capacity() < 2 * m_EditedBiosource->GetOrg().GetDb().size())
955  {
956  m_EditedBiosource->SetOrg().SetDb().reserve(2 * m_EditedBiosource->GetOrg().GetDb().size());
957  }
958  if (!IsCreateNew(action))
959  {
961  {
962  found = true;
963  m_erase = false;
964  m_Dbtag = *dbxref_it;
966  if (m_erase)
968  }
969  }
970 
971  if (!found)
972  {
973  m_Dbtag.Reset();
974  m_erase = false;
976  }
978  {
979  m_EditedBiosource->SetOrg().SetDb().shrink_to_fit();
980  }
982  {
983  m_EditedBiosource->SetOrg().ResetDb();
984  }
985 }
986 
988 {
989  return m_Dbtag && m_Dbtag->IsSetDb() && m_Dbtag->IsSetTag();
990 }
991 
993 {
994  string db, tag;
995  NStr::SplitInTwo(value, ":", db, tag);
997 
998  if (!db.empty() && !tag.empty())
999  {
1000  if (m_Dbtag)
1001  {
1002  m_Dbtag->SetDb(db);
1003  m_Dbtag->ResetTag();
1004  if (id != 0)
1005  m_Dbtag->SetTag().SetId(id);
1006  else
1007  m_Dbtag->SetTag().SetStr(tag);
1008  }
1009  else
1010  {
1011  CRef<CDbtag> dbtag(new CDbtag);
1012  dbtag->SetDb(db);
1013  if (id != 0)
1014  dbtag->SetTag().SetId(id);
1015  else
1016  dbtag->SetTag().SetStr(tag);
1017  m_EditedBiosource->SetOrg().SetDb().push_back(dbtag);
1018  }
1019  }
1020 }
1021 
1023 {
1024  string db = m_Dbtag->GetDb();
1025  string tag;
1026  if (m_Dbtag->GetTag().IsStr())
1027  tag = m_Dbtag->GetTag().GetStr();
1028  if (m_Dbtag->GetTag().IsId())
1030  return db + ":" + tag;
1031 }
1032 
1034 {
1035  m_erase = true;
1036 }
1037 
1038 
1040 {
1041  bool is_descriptor = true;
1042  bool is_feature = true;
1043  if (NStr::EndsWith(field, " descriptor"))
1044  {
1045  is_feature = false;
1046  NStr::ReplaceInPlace(field, " descriptor", kEmptyStr);
1047  }
1048  else if (NStr::EndsWith(field, " feature"))
1049  {
1050  is_descriptor = false;
1051  NStr::ReplaceInPlace(field, " feature", kEmptyStr);
1052  }
1053  if (NStr::EqualNocase(field, "taxname") || field == "organism name" || field == "org")
1054  return new CEditingActionBiosourceTaxname(seh, is_descriptor, is_feature);
1055  if (field == "Taxname after Binomial")
1056  return new CEditingActionBiosourceTaxnameAfterBinomial(seh, is_descriptor, is_feature);
1057  if (NStr::EqualNocase(field, "Dbxref"))
1058  return new CEditingActionBiosourceDbxref(seh, is_descriptor, is_feature);
1059  if (field == "common name" || field == "common-name")
1060  return new CEditingActionBiosourceCommonName(seh, is_descriptor, is_feature);
1061  if (field == "division")
1062  return new CEditingActionBiosourceDivision(seh, is_descriptor, is_feature);
1063  if (field == "lineage")
1064  return new CEditingActionBiosourceLineage(seh, is_descriptor, is_feature);
1065  if (field == "genome")
1066  return new CEditingActionBiosourceLocation(seh, is_descriptor, is_feature);
1067  if (field == "origin")
1068  return new CEditingActionBiosourceOrigin(seh, is_descriptor, is_feature);
1069  if (field == "fwd-primer-name")
1070  return new CEditingActionBiosourcePrimers(seh, is_descriptor, is_feature, true, false, true, false);
1071  if (field == "fwd-primer-seq")
1072  return new CEditingActionBiosourcePrimers(seh, is_descriptor, is_feature, true, false, false, true);
1073  if (field == "rev-primer-name")
1074  return new CEditingActionBiosourcePrimers(seh, is_descriptor, is_feature, false, true, true, false);
1075  if (field == "rev-primer-seq")
1076  return new CEditingActionBiosourcePrimers(seh, is_descriptor, is_feature, false, true, false, true);
1077  if (field == "host")
1078  return new CEditingActionBiosourceOrgMod(seh, is_descriptor, is_feature, COrgMod::eSubtype_nat_host);
1079  if (field == "note-orgmod" || field == "orgmod-note")
1080  return new CEditingActionBiosourceOrgMod(seh, is_descriptor, is_feature, COrgMod::eSubtype_other);
1081  if (field == "note-subsource" || field == "subsource-note" || field == "note-subsrc" || field == "subsrc-note")
1082  return new CEditingActionBiosourceSubSource(seh, is_descriptor, is_feature, CSubSource::eSubtype_other);
1083  if (field == "All primers")
1084  return new CEditingActionBiosourcePrimers(seh, is_descriptor, is_feature, true, true, true, true);
1085  if (field == "All notes" || field == "all-notes" || field == "note")
1086  return new CEditingActionBiosourceAllNotes(seh, is_descriptor, is_feature);
1087  if (field == "bio-material-coll")
1089  if (field == "bio-material-inst")
1091  if (field == "bio-material-specid")
1093  if (field == "culture-collection-coll")
1095  if (field == "culture-collection-inst")
1097  if (field == "culture-collection-specid")
1099  if (field == "specimen-voucher-coll")
1101  if (field == "specimen-voucher-inst")
1103  if (field == "specimen-voucher-specid")
1105  if (COrgMod::IsValidSubtypeName(field))
1106  return new CEditingActionBiosourceOrgMod(seh, is_descriptor, is_feature, static_cast<COrgMod::ESubtype>(COrgMod::GetSubtypeValue(field)));
1107  if (CSubSource::IsValidSubtypeName(field))
1108  return new CEditingActionBiosourceSubSource(seh, is_descriptor, is_feature, static_cast<CSubSource::ESubtype>(CSubSource::GetSubtypeValue(field)));
1109  return NULL;
1110 }
1111 
1112 
1113 
1115 
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
Definition: Dbtag.hpp:53
virtual void Modify(EActionType action)
CEditingActionBiosourceAllNotes(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature)
virtual void SetValue(const string &value)
virtual void SetValue(const string &value)
CEditingActionBiosourceCommonName(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature)
CEditingActionBiosourceDbxref(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature)
virtual void SetValue(const string &value)
virtual void Modify(EActionType action)
virtual void SetValue(const string &value)
CEditingActionBiosourceDivision(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature)
CEditingActionBiosourceLineage(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature)
virtual void SetValue(const string &value)
virtual void SetValue(const string &value)
CEditingActionBiosourceLocation(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature)
CEditingActionBiosourceOrgMod(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature, const COrgMod::ESubtype subtype, const string &name="CEditingActionBiosourceOrgMod")
virtual void Modify(EActionType action)
virtual void SetValue(const string &value)
CEditingActionBiosourceOrigin(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature)
virtual void SetValue(const string &value)
CEditingActionBiosourcePrimers(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature, bool is_fwd, bool is_rev, bool is_name, bool is_seq)
virtual void SetValue(const string &value)
virtual void Modify(EActionType action)
void Parse(const string &str, string &inst, string &coll, string &id)
CEditingActionBiosourceStructuredVoucher(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature, const COrgMod::ESubtype subtype, const int voucher_type)
virtual void Modify(EActionType action)
virtual void SetValue(const string &value)
CEditingActionBiosourceSubSource(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature, const CSubSource::ESubtype subtype, const string &name="CEditingActionBiosourceSubSource")
string x_GetTextAfterNomial(const string &taxname) const
CEditingActionBiosourceTaxnameAfterBinomial(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature)
virtual void SetValue(const string &value)
CEditingActionBiosourceTaxname(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature)
virtual bool Match(const string &value)
CFeat_CI –.
Definition: feat_ci.hpp:64
@OrgMod.hpp User-defined methods of the data storage class.
Definition: OrgMod.hpp:54
static bool IsValidSubtypeName(const string &str, EVocabulary vocabulary=eVocabulary_raw)
Definition: OrgMod.cpp:86
static TSubtype GetSubtypeValue(const string &str, EVocabulary vocabulary=eVocabulary_raw)
Definition: OrgMod.cpp:62
static string MakeStructuredVoucher(const string &inst, const string &coll, const string &id)
Definition: OrgMod.cpp:541
CPCRPrimerName –.
CPCRPrimer –.
Definition: PCRPrimer.hpp:66
CPCRReaction –.
Definition: PCRReaction.hpp:66
CSeq_entry_Handle –.
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
static TSubtype GetSubtypeValue(const string &str, EVocabulary vocabulary=eVocabulary_raw)
Definition: SubSource.cpp:126
static bool IsValidSubtypeName(const string &str, EVocabulary vocabulary=eVocabulary_raw)
Definition: SubSource.cpp:155
virtual void Find(EActionType action)
virtual void Modify(EActionType action)
virtual void SwapContext(IEditingAction *source)
virtual void FindRelated(EActionType action)
void SetFeat(CSeq_feat_Handle fh)
void SetDesc(const CSeqdesc *desc)
IEditingActionBiosource(CSeq_entry_Handle seh, bool is_descriptor, bool is_feature, const string &name)
map< const CSeqdesc *, CSeq_entry_Handle > m_ContextForDescriptors
map< const CSeqdesc *, CSeq_entry_Handle > m_CreatedDescriptors
CSeq_entry_Handle m_TopSeqEntry
map< const CSeqdesc *, CRef< CSeqdesc > > m_ChangedDescriptors
map< CSeq_feat_Handle, CRef< CSeq_feat > > m_ChangedFeatures
IEditingAction * m_Other
CSeq_entry_Handle m_CurrentSeqEntry
void Action(EActionType action)
virtual void SwapContext(IEditingAction *source)
bool IsFrom(EActionType action)
CRef< CEditingActionConstraint > m_constraint
bool IsCreateNew(EActionType action)
bool IsNOOP(EActionType action)
const_iterator end() const
Definition: map.hpp:152
const_iterator find(const key_type &key) const
Definition: map.hpp:153
USING_SCOPE(objects)
static const char * nomial_keywords[]
IEditingActionBiosource * CreateActionBiosource(CSeq_entry_Handle seh, string field)
static const struct name_t names[]
#define false
Definition: bool.h:36
static const char * str(char *buf, int n)
Definition: stats.c:84
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
Definition: ncbimisc.hpp:1508
#define NULL
Definition: ncbistd.hpp:225
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
#define ENUM_METHOD_NAME(EnumName)
Definition: serialbase.hpp:994
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
CConstRef< CSeq_feat > GetOriginalSeq_feat(void) const
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
NCBI_NS_STD::string::size_type SIZE_TYPE
Definition: ncbistr.hpp:132
#define kEmptyStr
Definition: ncbistr.hpp:123
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3452
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
Definition: ncbistr.cpp:2984
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
Definition: ncbistr.hpp:5424
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
#define NPOS
Definition: ncbistr.hpp:133
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
Definition: ncbistr.cpp:3192
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5078
static bool EqualCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive equality of a substring with another string.
Definition: ncbistr.hpp:5319
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:3545
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:5347
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3396
@ fConvErr_NoThrow
Do not throw an exception on error.
Definition: ncbistr.hpp:285
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
Definition: ncbistr.hpp:2510
@ eTrunc_End
Truncate trailing whitespace only.
Definition: ncbistr.hpp:2241
const Tdata & Get(void) const
Get the member data.
const TPcr_primers & GetPcr_primers(void) const
Get the Pcr_primers member data.
Definition: BioSource_.hpp:588
TGenome GetGenome(void) const
Get the Genome member data.
Definition: BioSource_.hpp:422
TOrigin GetOrigin(void) const
Get the Origin member data.
Definition: BioSource_.hpp:472
void ResetGenome(void)
Reset Genome data member.
Definition: BioSource_.hpp:409
void ResetOrigin(void)
Reset Origin data member.
Definition: BioSource_.hpp:459
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 IsSetPcr_primers(void) const
Check if a value has been assigned to Pcr_primers data member.
Definition: BioSource_.hpp:576
void SetOrigin(TOrigin value)
Assign a value to Origin data member.
Definition: BioSource_.hpp:478
void SetSeq(const TSeq &value)
Assign a value to Seq data member.
Definition: PCRPrimer_.hpp:220
const TOrg & GetOrg(void) const
Get the Org member data.
Definition: BioSource_.hpp:509
bool IsSetOrigin(void) const
Check if a value has been assigned to Origin data member.
Definition: BioSource_.hpp:447
void SetGenome(TGenome value)
Assign a value to Genome data member.
Definition: BioSource_.hpp:428
void SetForward(TForward &value)
Assign a value to Forward data member.
bool IsSetGenome(void) const
Check if a value has been assigned to Genome data member.
Definition: BioSource_.hpp:397
void SetPcr_primers(TPcr_primers &value)
Assign a value to Pcr_primers data member.
Definition: BioSource_.cpp:124
void SetReverse(TReverse &value)
Assign a value to Reverse data member.
void SetName(const TName &value)
Assign a value to Name data member.
Definition: PCRPrimer_.hpp:255
void SetOrg(TOrg &value)
Assign a value to Org data member.
Definition: BioSource_.cpp:108
void SetName(const TName &value)
Assign a value to Name data member.
Definition: SubSource_.hpp:359
const TName & GetName(void) const
Get the Name member data.
Definition: SubSource_.hpp:350
EGenome
biological context
Definition: BioSource_.hpp:97
bool IsSet(void) const
Check if a value has been assigned to data member.
bool IsSetName(void) const
Check if a value has been assigned to Name data member.
Definition: SubSource_.hpp:338
TSubtype & SetSubtype(void)
Assign a value to Subtype data member.
Definition: BioSource_.hpp:545
void ResetPcr_primers(void)
Reset Pcr_primers data member.
Definition: BioSource_.cpp:119
bool IsStr(void) const
Check if variant Str is selected.
Definition: Object_id_.hpp:291
bool IsSetDb(void) const
name of database or system Check if a value has been assigned to Db data member.
Definition: Dbtag_.hpp:208
const TTag & GetTag(void) const
Get the Tag member data.
Definition: Dbtag_.hpp:267
void SetTag(TTag &value)
Assign a value to Tag data member.
Definition: Dbtag_.cpp:66
bool IsId(void) const
Check if variant Id is selected.
Definition: Object_id_.hpp:264
bool IsSetTag(void) const
appropriate tag Check if a value has been assigned to Tag data member.
Definition: Dbtag_.hpp:255
const TDb & GetDb(void) const
Get the Db member data.
Definition: Dbtag_.hpp:220
void ResetTag(void)
Reset Tag data member.
Definition: Dbtag_.cpp:57
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
void SetDb(const TDb &value)
Assign a value to Db data member.
Definition: Dbtag_.hpp:229
TId GetId(void) const
Get the variant data.
Definition: Object_id_.hpp:270
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
const TLineage & GetLineage(void) const
Get the Lineage member data.
Definition: OrgName_.hpp:864
const TDiv & GetDiv(void) const
Get the Div member data.
Definition: OrgName_.hpp:1005
const TSubname & GetSubname(void) const
Get the Subname member data.
Definition: OrgMod_.hpp:347
bool IsSetCommon(void) const
common name Check if a value has been assigned to Common data member.
Definition: Org_ref_.hpp:407
bool IsSetLineage(void) const
lineage with semicolon separators Check if a value has been assigned to Lineage data member.
Definition: OrgName_.hpp:852
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 TCommon & GetCommon(void) const
Get the Common member data.
Definition: Org_ref_.hpp:419
const TDb & GetDb(void) const
Get the Db member data.
Definition: Org_ref_.hpp:491
bool IsSetDiv(void) const
GenBank division code Check if a value has been assigned to Div data member.
Definition: OrgName_.hpp:993
bool IsSetOrgname(void) const
Check if a value has been assigned to Orgname data member.
Definition: Org_ref_.hpp:529
bool IsSetSubname(void) const
Check if a value has been assigned to Subname data member.
Definition: OrgMod_.hpp:335
bool IsSetTaxname(void) const
preferred formal name Check if a value has been assigned to Taxname data member.
Definition: Org_ref_.hpp:360
void SetSubname(const TSubname &value)
Assign a value to Subname data member.
Definition: OrgMod_.hpp:356
const TOrgname & GetOrgname(void) const
Get the Orgname member data.
Definition: Org_ref_.hpp:541
@ eSubtype_other
ASN5: old-name (254) will be added to next spec.
Definition: OrgMod_.hpp:125
@ eSubtype_nat_host
natural host of this specimen
Definition: OrgMod_.hpp:104
@ eSubtype_specimen_voucher
Definition: OrgMod_.hpp:106
@ eSubtype_bio_material
Definition: OrgMod_.hpp:119
@ eSubtype_culture_collection
Definition: OrgMod_.hpp:118
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
TSource & SetSource(void)
Select the variant.
Definition: Seqdesc_.cpp:572
@ e_Source
source of materials, includes Org-ref
Definition: Seqdesc_.hpp:133
yy_size_t n
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
const CharType(& source)[N]
Definition: pointer.h:1149
const char * tag
The Object manager core.
#define count
Utility macros and typedefs for exploring NCBI objects from seqfeat.asn.
#define ERASE_DBXREF_ON_ORGREF(Itr, Var)
ERASE_DBXREF_ON_ORGREF.
#define ERASE_ORGMOD_ON_BIOSOURCE(Itr, Var)
ERASE_ORGMOD_ON_BIOSOURCE.
#define EDIT_EACH_DBXREF_ON_ORGREF(Itr, Var)
#define EDIT_EACH_PCRPRIMER_IN_PCRPRIMERSET(Itr, Var)
EDIT_EACH_PCRPRIMER_IN_PCRPRIMERSET.
#define EDIT_EACH_ORGMOD_ON_BIOSOURCE(Itr, Var)
#define ERASE_SUBSOURCE_ON_BIOSOURCE(Itr, Var)
ERASE_SUBSOURCE_ON_BIOSOURCE.
#define EDIT_EACH_SUBSOURCE_ON_BIOSOURCE(Itr, Var)
#define ERASE_PCRPRIMER_IN_PCRPRIMERSET(Itr, Var)
ERASE_PCRPRIMER_IN_PCRPRIMERSET.
#define EDIT_EACH_PCRREACTION_IN_PCRREACTIONSET(Itr, Var)
EDIT_EACH_PCRREACTION_IN_PCRREACTIONSET.
#define ERASE_PCRREACTION_IN_PCRREACTIONSET(Itr, Var)
ERASE_PCRREACTION_IN_PCRREACTIONSET.
Modified on Fri Sep 20 14:58:09 2024 by modify_doxy.py rev. 669887