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

Go to the SVN repository for this file.

1 /* $Id: miscedit_util.cpp 47479 2023-05-02 13:24:02Z ucko $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Colleen Bollin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
35 
41 #include <objects/pub/Pub.hpp>
49 #include <objects/biblio/Title.hpp>
50 #include <objects/biblio/Affil.hpp>
59 #include <objmgr/seqdesc_ci.hpp>
60 #include <objmgr/bioseq_ci.hpp>
61 #include <objmgr/util/sequence.hpp>
62 #include <objmgr/seq_vector.hpp>
63 #include <objmgr/seq_entry_ci.hpp>
64 
66 
72 
73 #include <gui/objutils/utils.hpp>
83 
93 
94 
98 
99 
101 CFieldHandlerFactory::Create(const string& field_name)
102 {
104  return CRef<CFieldHandler>(new CSeqIdField());
105  }
107  if (pub_field != CPubFieldType::ePubFieldType_Unknown) {
108  return CRef<CFieldHandler>(new CPubField(pub_field));
109  }
111  if (dblink_field != CDBLinkFieldType::eDBLinkFieldType_Unknown) {
112  return CRef<CFieldHandler>(new CDBLinkField(dblink_field));
113  }
115  if (molinfo_field != CMolInfoFieldType::e_Unknown) {
116  return CRef<CFieldHandler>(new CMolInfoField(molinfo_field));
117  }
118 
119  if (NStr::EqualNocase(field_name, kGenomeProjectID)) {
121  }
124  }
127  }
128  if (NStr::EqualNocase(field_name, kGenbankBlockKeyword)) {
130  }
131  if (NStr::EqualNocase(field_name, kBankITComment)) {
133  }
134  if (NStr::EqualNocase(field_name, kComment)) {
136  }
137  if (NStr::EqualNocase(field_name, kFlatFile)){
138  return CRef<CFieldHandler>(new CFlatFileField());
139  }
140  if (NStr::EqualNocase(field_name, kLocalId)) {
141  return CRef<CFieldHandler>(new CLocalIDField());
142  }
143  if (NStr::EqualNocase(field_name, kFileSeqId)) {
144  return CRef<CFieldHandler>(new CFileIDField());
145  }
148  string db_name = field_name.substr(tag_name.length());
151  }
153  if (genId_field != CGeneralIDField::eUnknown) {
154  return CRef<CFieldHandler>(new CGeneralIDField(genId_field));
155  }
156  if (NStr::EqualNocase(field_name, kStructCommDBName)) {
158  }
159  if (NStr::EqualNocase(field_name, kStructCommFieldName)) {
161  }
163  string field = field_name.substr(string("Structured comment").length() + 1, NPOS);
164  string label = field.substr(string("Field").length() + 1, NPOS);
166  }
167 
168  // empty
170  return empty;
171 }
172 
173 
174 // class CTextDescriptorField
175 vector<CConstRef<CObject> > CTextDescriptorField::GetObjects(CBioseq_Handle bsh)
176 {
177  vector< CConstRef<CObject> > rval;
178  CSeqdesc_CI desc_ci(bsh, m_Subtype);
179  while (desc_ci) {
180  CConstRef<CObject> o(&(*desc_ci));
181  rval.push_back(o);
182  ++desc_ci;
183  }
184  return rval;
185 }
186 
187 vector<CConstRef<CObject> > CTextDescriptorField::GetObjects(CSeq_entry_Handle seh, const string& constraint_field, CRef<edit::CStringConstraint> string_constraint)
188 {
189  vector<CConstRef<CObject> > objs;
190  CRef<CScope> scope(&seh.GetScope());
191 
192  CBioseq_CI bi(seh, objects::CSeq_inst::eMol_na);
193  while (bi) {
194  if (NStr::EqualNocase(constraint_field, kFieldTypeSeqId)) {
195  if (edit::CSeqIdGuesser::DoesSeqMatchConstraint(*bi, string_constraint)) {
196  vector<CConstRef<CObject> > these_objs = GetObjects(*bi);
197  objs.insert(objs.end(), these_objs.begin(), these_objs.end());
198  }
199  }
200  else {
201  vector<CConstRef<CObject> > these_objs = GetObjects(*bi);
202  ITERATE(vector<CConstRef<CObject> >, it, these_objs) {
203  if (DoesObjectMatchFieldConstraint(**it, constraint_field, string_constraint, scope)) {
204  objs.push_back(*it);
205  }
206  }
207  }
208  ++bi;
209  }
210 
211  return objs;
212 }
213 
214 vector<CRef<edit::CApplyObject> > CTextDescriptorField::GetApplyObjects(CBioseq_Handle bsh)
215 {
216  vector<CRef<CApplyObject> > objects;
217 
218  // add existing descriptors
219  CSeqdesc_CI desc_ci(bsh, m_Subtype);
220  while (desc_ci) {
221  CRef<CApplyObject> new_obj(new CApplyObject(bsh, *desc_ci));
222  objects.push_back(new_obj);
223  ++desc_ci;
224  }
225 
226  if (objects.empty()) {
227  CRef<CApplyObject> new_obj(new CApplyObject(bsh, m_Subtype));
228  objects.push_back(new_obj);
229  }
230 
231  return objects;
232 }
233 
234 
235 vector<CConstRef<CObject> > CTextDescriptorField::GetRelatedObjects(const CObject& object, CRef<CScope> scope)
236 {
237  vector<CConstRef<CObject> > related;
238 
239  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&object);
240  const CSeq_feat * obj_feat = dynamic_cast<const CSeq_feat *>(&object);
241 
242  if (obj_feat) {
243  // find closest related DBLink User Objects
244  CBioseq_Handle bsh = scope->GetBioseqHandle(obj_feat->GetLocation());
245  related = GetObjects(bsh);
246  }
247  else if (obj_desc) {
248  if (obj_desc->Which() == m_Subtype) {
249  CConstRef<CObject> obj(obj_desc);
250  related.push_back(obj);
251  }
252  else {
253  CSeq_entry_Handle seh = edit::GetSeqEntryForSeqdesc(scope, *obj_desc);
254  related = GetObjects(seh, "", CRef<edit::CStringConstraint>(NULL));
255  }
256  }
257 
258  return related;
259 }
260 
261 vector<CConstRef<CObject> > CTextDescriptorField::GetRelatedObjects(const CApplyObject& object)
262 {
263  vector<CConstRef<CObject> > related;
264 
265  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&(object.GetObject()));
266  const CSeq_feat * obj_feat = dynamic_cast<const CSeq_feat *>(&(object.GetObject()));
267  const CSeq_inst * inst = dynamic_cast<const CSeq_inst *>(&(object.GetObject()));
268  const CBioseq * bioseq = dynamic_cast<const CBioseq *>(&(object.GetObject()));
269 
270  if (obj_feat) {
271  related = GetObjects(object.GetSEH(), "", CRef<edit::CStringConstraint>(NULL));
272  }
273  else if (obj_desc) {
274  if (obj_desc->Which() == m_Subtype) {
275  CConstRef<CObject> obj(obj_desc);
276  related.push_back(obj);
277  }
278  else {
279  related = GetObjects(object.GetSEH(), "", CRef<edit::CStringConstraint>(NULL));
280  }
281  }
282  else if (bioseq || inst) {
283  related = GetObjects(object.GetSEH(), "", CRef<edit::CStringConstraint>(NULL));
284  }
285 
286  return related;
287 }
288 
289 
290 // class CCommentDescField
291 
292 string CCommentDescField::GetVal(const CObject& object)
293 {
294  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&object);
295  if (obj_desc && obj_desc->IsComment()) {
296  return obj_desc->GetComment();
297  }
298  else {
299  return "";
300  }
301 }
302 
303 vector<string> CCommentDescField::GetVals(const CObject& object)
304 {
305  vector<string> vals;
306  vals.push_back(GetVal(object));
307  return vals;
308 }
309 
310 
311 bool CCommentDescField::IsEmpty(const CObject& object) const
312 {
313  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&object);
314  if (obj_desc && obj_desc->IsComment() && !NStr::IsBlank(obj_desc->GetComment())) {
315  return true;
316  }
317  else {
318  return false;
319  }
320 }
321 
322 
324 {
325  CSeqdesc * obj_desc = dynamic_cast<CSeqdesc *>(&object);
326  if (obj_desc) {
327  obj_desc->SetComment(" ");
328  }
329 }
330 
331 
332 bool CCommentDescField::SetVal(CObject& object, const string& val, EExistingText existing_text)
333 {
334  bool rval = false;
335  CSeqdesc * obj_desc = dynamic_cast<CSeqdesc *>(&object);
336  if (!obj_desc) {
337  return false;
338  }
339  string curr_val = "";
340  if (obj_desc->IsComment()) {
341  curr_val = obj_desc->GetComment();
342  }
343  if (AddValueToString(curr_val, val, existing_text)) {
344  obj_desc->SetComment(curr_val);
345  rval = true;
346  }
347  return rval;
348 }
349 
350 
351 // class CDefinitionLineField
352 
354 {
355  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&object);
356  if (obj_desc && obj_desc->IsTitle()) {
357  return obj_desc->GetTitle();
358  }
359  else {
360  return "";
361  }
362 }
363 
364 
365 vector<string> CDefinitionLineField::GetVals(const CObject& object)
366 {
367  vector<string> vals;
368  vals.push_back(GetVal(object));
369  return vals;
370 }
371 
372 
373 bool CDefinitionLineField::IsEmpty(const CObject& object) const
374 {
375  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&object);
376  if (obj_desc && obj_desc->IsTitle() && !NStr::IsBlank(obj_desc->GetTitle())) {
377  return true;
378  }
379  else {
380  return false;
381  }
382 }
383 
384 
386 {
387  CSeqdesc * obj_desc = dynamic_cast<CSeqdesc *>(&object);
388  if (obj_desc) {
389  obj_desc->SetTitle(" ");
390  }
391 }
392 
393 
394 bool CDefinitionLineField::SetVal(CObject& object, const string& val, EExistingText existing_text)
395 {
396  bool rval = false;
397  CSeqdesc * obj_desc = dynamic_cast<CSeqdesc *>(&object);
398  if (!obj_desc) {
399  return false;
400  }
401  string curr_val = "";
402  if (obj_desc->IsTitle()) {
403  curr_val = obj_desc->GetTitle();
404  }
405  if (AddValueToString(curr_val, val, existing_text)) {
406  obj_desc->SetTitle(curr_val);
407  rval = true;
408  }
409  return rval;
410 }
411 
412 
413 // class CGenbankKeywordField
414 
416 {
417  vector<string> vals = GetVals(object);
418  return (vals.empty()) ? kEmptyStr : vals[0];
419 }
420 
421 
422 vector<string> CGenbankKeywordField::GetVals(const CObject& object)
423 {
424  vector<string> rval;
425 
426  const CSeqdesc* desc = dynamic_cast<const CSeqdesc *>(&object);
427  if (desc && desc->IsGenbank() && desc->GetGenbank().IsSetKeywords()) {
429  rval.push_back(*it);
430  }
431  }
432  return rval;
433 }
434 
435 
436 bool CGenbankKeywordField::IsEmpty(const CObject& object) const
437 {
438  const CSeqdesc* desc = dynamic_cast<const CSeqdesc *>(&object);
439  if (!desc || !desc->IsGenbank()) {
440  return false;
441  }
442  const CGB_block& block = desc->GetGenbank();
443  if (!block.IsSetDate()
444  && !block.IsSetDiv()
445  && !block.IsSetEntry_date()
446  && !block.IsSetExtra_accessions()
447  && !block.IsSetKeywords()
448  && !block.IsSetOrigin()
449  && !block.IsSetSource()
450  && !block.IsSetTaxonomy()) {
451  return true;
452  }
453  else {
454  return false;
455  }
456 }
457 
458 
460 {
461  CSeqdesc* desc = dynamic_cast<CSeqdesc *>(&object);
462  if (!desc || !desc->IsGenbank()) {
463  return;
464  }
465  desc->SetGenbank().ResetKeywords();
466 }
467 
468 
469 bool CGenbankKeywordField::SetVal(CObject& object, const string& val, EExistingText existing_text)
470 {
471  bool rval = false;
472 
473  CSeqdesc* desc = dynamic_cast<CSeqdesc *>(&object);
474  if (!desc) {
475  return false;
476  }
477  if (!desc->IsGenbank()
478  || !desc->GetGenbank().IsSetKeywords()
479  || desc->GetGenbank().GetKeywords().empty()
480  || existing_text == eExistingText_add_qual) {
481  desc->SetGenbank().SetKeywords().push_back(val);
482  rval = true;
483  }
484  else {
485  CGB_block::TKeywords::iterator it = desc->SetGenbank().SetKeywords().begin();
486  while (it != desc->SetGenbank().SetKeywords().end()) {
487  string curr_val = *it;
488  if (!m_StringConstraint || m_StringConstraint->DoesTextMatch(curr_val)) {
489  if (AddValueToString(curr_val, val, existing_text)) {
490  *it = curr_val;
491  rval = true;
492  }
493  }
494  if (NStr::IsBlank(*it)) {
495  it = desc->SetGenbank().SetKeywords().erase(it);
496  }
497  else {
498  ++it;
499  }
500  }
501  }
502  return rval;
503 }
504 
505 
507 {
508  if (NStr::EqualNocase(field, kGenbankBlockKeyword) && string_constraint) {
509  m_StringConstraint = new edit::CStringConstraint(" ");
510  m_StringConstraint->Assign(*string_constraint);
511  }
512  else {
514  }
515 }
516 
517 
518 
519 // class CGenomeProjectField
520 
521 vector<CConstRef<CObject> > CGenomeProjectField::GetObjects(CBioseq_Handle bsh)
522 {
523  vector<CConstRef<CObject> > objects;
524 
525  CSeqdesc_CI desc_ci(bsh, CSeqdesc::e_User);
526  while (desc_ci) {
527  if (IsGenomeProject(desc_ci->GetUser())) {
528  CConstRef<CObject> object;
529  object.Reset(&(*desc_ci));
530  objects.push_back(object);
531  }
532  ++desc_ci;
533  }
534 
535  return objects;
536 }
537 
538 
539 vector<CConstRef<CObject> > CGenomeProjectField::GetObjects(CSeq_entry_Handle seh, const string& constraint_field, CRef<CStringConstraint> string_constraint)
540 {
541  vector<CConstRef<CObject> > objs;
542  CRef<CScope> scope(&seh.GetScope());
543 
544  CBioseq_CI bi(seh, objects::CSeq_inst::eMol_na);
545  while (bi) {
546  if (NStr::EqualNocase(constraint_field, kFieldTypeSeqId)) {
547  if (edit::CSeqIdGuesser::DoesSeqMatchConstraint(*bi, string_constraint)) {
548  vector<CConstRef<CObject> > these_objs = GetObjects(*bi);
549  objs.insert(objs.end(), these_objs.begin(), these_objs.end());
550  }
551  }
552  else {
553  vector<CConstRef<CObject> > these_objs = GetObjects(*bi);
554  ITERATE(vector<CConstRef<CObject> >, it, these_objs) {
555  if (DoesObjectMatchFieldConstraint(**it, constraint_field, string_constraint, scope)) {
556  objs.push_back(*it);
557  }
558  }
559  }
560  ++bi;
561  }
562 
563  return objs;
564 }
565 
566 
567 vector<CRef<CApplyObject> > CGenomeProjectField::GetApplyObjects(CBioseq_Handle bsh)
568 {
569  vector<CRef<CApplyObject> > apply_objs;
570  vector<CConstRef<CObject> > objs = GetObjects(bsh);
572  ITERATE(vector<CConstRef<CObject> >, it, objs) {
573  const CSeqdesc* orig_desc = dynamic_cast<const CSeqdesc*>((*it).GetPointer());
574  CRef<CApplyObject> new_obj(new CApplyObject(bsh, *orig_desc));
575  apply_objs.push_back(new_obj);
576  }
577  if (apply_objs.empty()) {
578  CRef<CApplyObject> new_obj(new CApplyObject(bsh, "GenomeProjectsDB"));
579  apply_objs.push_back(new_obj);
580  }
581 
582  return apply_objs;
583 }
584 
585 
587 {
588  string val = "";
589 
590  const CSeqdesc* seqdesc = dynamic_cast<const CSeqdesc*>(&object);
591  const CUser_object* user = dynamic_cast<const CUser_object*>(&object);
592 
593  if (seqdesc && seqdesc->IsUser()) {
594  user = &(seqdesc->GetUser());
595  }
596  if (IsGenomeProject(*user) && user->IsSetData()) {
597  CUser_object::TData::const_iterator it = user->GetData().begin();
598  while (it != user->GetData().end()) {
599  if (IsGenomeProjectID(**it)
600  && (*it)->IsSetData() && (*it)->GetData().IsInt()) {
601  val = NStr::NumericToString((*it)->GetData().GetInt());
602  break;
603  }
604  ++it;
605  }
606  }
607  return val;
608 }
609 
610 
611 vector<string> CGenomeProjectField::GetVals(const CObject& object)
612 {
613  vector<string> vals;
614  vals.push_back(GetVal(object));
615  return vals;
616 }
617 
618 
619 bool CGenomeProjectField::IsEmpty(const CObject& object) const
620 {
621  bool rval = false;
622  const CSeqdesc* seqdesc = dynamic_cast<const CSeqdesc*>(&object);
623  const CUser_object* user = dynamic_cast<const CUser_object*>(&object);
624  if (seqdesc && seqdesc->IsUser()) {
625  user = &(seqdesc->GetUser());
626  }
627  if (user && IsGenomeProject(*user)) {
628  if (!user->IsSetData() || user->GetData().empty()) {
629  rval = true;
630  }
631  }
632 
633  return rval;
634 }
635 
636 
638 {
639  CSeqdesc* seqdesc = dynamic_cast<CSeqdesc*>(&object);
640  CUser_object* user = dynamic_cast<CUser_object*>(&object);
641 
642  if (seqdesc && seqdesc->IsUser()) {
643  user = &(seqdesc->SetUser());
644  }
645  if (user && user->IsSetData()) {
646  CUser_object::TData::iterator it = user->SetData().begin();
647  while (it != user->SetData().end()) {
648  if (IsGenomeProjectID(**it)) {
649  it = user->SetData().erase(it);
650  }
651  else {
652  it++;
653  }
654  }
655  if (user->GetData().empty()) {
656  user->ResetData();
657  }
658  }
659 }
660 
661 
662 static const string kGenomeProjectId = "ProjectID";
663 
665 {
666  if (field.IsSetLabel() && field.GetLabel().IsStr()
668  return true;
669  }
670  else {
671  return false;
672  }
673 }
674 
675 
676 bool CGenomeProjectField::SetVal(CObject& object, const string& val, EExistingText existing_text)
677 {
678  bool rval = false;
679  CSeqdesc* seqdesc = dynamic_cast<CSeqdesc*>(&object);
680  CUser_object* user = dynamic_cast<CUser_object*>(&object);
681 
682  if (seqdesc && seqdesc->IsUser()) {
683  user = &(seqdesc->SetUser());
684  }
685  if (user && IsGenomeProject(*user)) {
686  bool found = false;
687  if (user->IsSetData()) {
688  CUser_object::TData::iterator it = user->SetData().begin();
689  while (it != user->SetData().end()) {
690  if (IsGenomeProjectID(**it)) {
691  string curr_val = "";
692  bool can_change = false;
693  if ((*it)->IsSetData()) {
694  if ((*it)->GetData().IsStr()) {
695  curr_val = (*it)->GetData().GetStr();
696  can_change = true;
697  }
698  else if ((*it)->GetData().IsInt()) {
699  curr_val = NStr::NumericToString((*it)->GetData().GetInt());
700  can_change = true;
701  }
702  }
703  if (can_change && AddValueToString(curr_val, val, existing_text)) {
704  try {
705  int numval = NStr::StringToInt(curr_val);
706  (*it)->SetData().SetInt(numval);
707  rval = true;
708  }
709  catch (const exception&) {
710  }
711  }
712  found = true;
713  }
714  ++it;
715  }
716  }
717  if (!found) {
718  try {
719  int numval = NStr::StringToInt(val);
720  CRef<CUser_field> new_field(new CUser_field());
721  new_field->SetLabel().SetStr(kGenomeProjectId);
722  new_field->SetData().SetInt(numval);
723  user->SetData().push_back(new_field);
724  rval = true;
725  }
726  catch (const exception&) {
727  }
728  }
729 
730  }
731  return rval;
732 }
733 
734 
735 string CGenomeProjectField::IsValid(const string& val)
736 {
737  string rval = "Genome Project ID should be a number";
738  try {
739  int numval = NStr::StringToInt(val);
740  rval = "";
741  }
742  catch (const exception&) {
743  }
744  return rval;
745 }
746 
747 
748 vector<string> CGenomeProjectField::IsValid(const vector<string>& values)
749 {
750  vector<string> rval;
751  ITERATE(vector<string>, it, values) {
752  rval.push_back(IsValid(*it));
753  }
754  return rval;
755 }
756 
757 
758 vector<CConstRef<CObject> > CGenomeProjectField::GetRelatedObjects(const CObject& object, CRef<CScope> scope)
759 {
760  vector<CConstRef<CObject> > related;
761 
762  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&object);
763  const CSeq_feat * obj_feat = dynamic_cast<const CSeq_feat *>(&object);
764  const CBioseq * bioseq = dynamic_cast<const CBioseq *>(&object);
765 
766  if (obj_feat) {
767  // find closest related DBLink User Objects
768  CBioseq_Handle bsh = scope->GetBioseqHandle(obj_feat->GetLocation());
769  related = GetObjects(bsh);
770  }
771  else if (obj_desc) {
772  if (obj_desc->IsUser() && IsGenomeProject(obj_desc->GetUser())) {
773  CConstRef<CObject> obj(obj_desc);
774  related.push_back(obj);
775  }
776  else {
777  CSeq_entry_Handle seh = edit::GetSeqEntryForSeqdesc(scope, *obj_desc);
778  related = GetObjects(seh, "", CRef<CStringConstraint>(NULL));
779  }
780  }
781  else if (bioseq) {
782  CBioseq_Handle bsh = scope->GetBioseqHandle(*bioseq);
783  related = GetObjects(bsh);
784  }
785 
786  return related;
787 }
788 
789 
790 vector<CConstRef<CObject> > CGenomeProjectField::GetRelatedObjects(const CApplyObject& object)
791 {
792  vector<CConstRef<CObject> > related;
793 
794  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&(object.GetObject()));
795  const CSeq_feat * obj_feat = dynamic_cast<const CSeq_feat *>(&(object.GetObject()));
796 
797  if (obj_feat) {
798  // find closest related DBLink User Objects
799  CBioseq_Handle bsh = object.GetSEH().GetScope().GetBioseqHandle(obj_feat->GetLocation());
800  related = GetObjects(bsh);
801  }
802  else if (obj_desc) {
803  if (obj_desc->IsUser() && IsGenomeProject(obj_desc->GetUser())) {
804  CConstRef<CObject> obj(obj_desc);
805  related.push_back(obj);
806  }
807  else {
808  related = GetObjects(object.GetSEH(), "", CRef<CStringConstraint>(NULL));
809  }
810  }
811 
812  return related;
813 }
814 
815 
817 {
818  if (user.IsSetType()
819  && user.GetType().IsStr()
820  && NStr::EqualNocase(user.GetType().GetStr(), "GenomeProjectsDB")) {
821  return true;
822  }
823  else {
824  return false;
825  }
826 }
827 
828 
829  // class CBankITCommentField
830 vector<CConstRef<CObject> > CBankITCommentField::GetObjects(CBioseq_Handle bsh)
831 {
832  vector<CConstRef<CObject> > objects;
833  objects.push_back(CConstRef<CObject>(bsh.GetCompleteBioseq()));
834  return objects;
835 }
836 
837 vector<CConstRef<CObject> > CBankITCommentField::GetObjects(CSeq_entry_Handle seh,
838  const string& constraint_field, CRef<edit::CStringConstraint> string_constraint)
839 {
840  vector<CConstRef<CObject> > objects;
841  CBioseq_CI bi(seh, objects::CSeq_inst::eMol_na);
842  CRef<CScope> scope(&seh.GetScope());
843  while (bi) {
844  CConstRef<CObject> obj(bi->GetCompleteBioseq());
845  if (CMiscSeqTableColumn::s_IsSequenceIDField(constraint_field)) {
846  if (edit::CSeqIdGuesser::DoesSeqMatchConstraint(*bi, string_constraint)) {
847  objects.push_back(obj);
848  }
849  }
850  else if (DoesObjectMatchFieldConstraint(*obj, constraint_field, string_constraint, scope)) {
851  objects.push_back(obj);
852  }
853  ++bi;
854  }
855 
856  return objects;
857 }
858 
859 vector<CRef<CApplyObject> > CBankITCommentField::GetApplyObjects(CBioseq_Handle bsh)
860 {
861  vector<CRef<CApplyObject> > objects;
862  objects.push_back(CRef<CApplyObject>(new CApplyObject(bsh)));
863  return objects;
864 }
865 
866 vector<CConstRef<CObject> > CBankITCommentField::GetRelatedObjects(const CObject& object, CRef<CScope> scope)
867 {
868  vector<CConstRef<CObject> > objects;
869  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&object);
870  const CSeq_feat * obj_feat = dynamic_cast<const CSeq_feat *>(&object);
871  const CBioseq * bioseq = dynamic_cast<const CBioseq *>(&object);
872  if (obj_desc) {
873  CSeq_entry_Handle seh = edit::GetSeqEntryForSeqdesc(scope, *obj_desc);
874  CBioseq_CI bi(seh, objects::CSeq_inst::eMol_na);
875  while (bi) {
876  objects.push_back(CConstRef<CObject>(bi->GetCompleteBioseq()));
877  ++bi;
878  }
879  } else if (obj_feat) {
880  CBioseq_Handle bsh = scope->GetBioseqHandle(*(obj_feat->GetLocation().GetId()));
881  if (bsh) {
882  objects.push_back(CConstRef<CObject>(bsh.GetCompleteBioseq()));
883  }
884  } else if (bioseq) {
885  objects.push_back(CConstRef<CObject>(bioseq));
886  }
887 
888  return objects;
889 }
890 vector<CConstRef<CObject> > CBankITCommentField::GetRelatedObjects(const CApplyObject& object)
891 {
892  vector<CConstRef<CObject> > objects;
893  CBioseq_CI bi(object.GetSEH(), objects::CSeq_inst::eMol_na);
894  while (bi) {
895  objects.push_back(CConstRef<CObject>(bi->GetCompleteBioseq()));
896  ++bi;
897  }
898  return objects;
899 }
900 
901 
903 {
904  vector<string> vals = GetVals(object);
905  return (vals.empty()) ? kEmptyStr : vals[0];
906 }
907 
908 vector<string> CBankITCommentField::GetVals(const CObject& object)
909 {
910  vector<string> vals;
911  const CBioseq* bioseq = dynamic_cast<const CBioseq *>(&object);
912  CBioseq_Handle bsh = m_Scope->GetBioseqHandle(*bioseq);
913  if (!bsh) {
914  return vals;
915  }
916 
917  for (CSeqdesc_CI desc_it(bsh, CSeqdesc::e_User); desc_it; ++desc_it) {
918  const CUser_object& user_obj = desc_it->GetUser();
919  if (user_obj.IsSetClass() && NStr::EqualCase(user_obj.GetClass(), "SMART_V1.0"))
920  continue;
921 
922  if (user_obj.GetType().IsStr() && NStr::EqualCase(user_obj.GetType().GetStr(), "Submission")) {
923  ITERATE(CUser_object::TData, data_it, user_obj.GetData()) {
924  const CUser_field& field = data_it->GetObject();
925  if (field.IsSetLabel()
926  && field.GetLabel().IsStr()
927  && NStr::EqualCase(field.GetLabel().GetStr(), "AdditionalComment")) {
928 
929  if (field.IsSetData() && field.GetData().IsStr()) {
930  vals.push_back(field.GetData().GetStr());
931  }
932  }
933  }
934  }
935  }
936  return vals;
937 }
938 
939 // class CGeneralCommentField
940 vector<string> CGeneralCommentField::GetVals(const CObject& object)
941 {
942  vector<string> vals;
943  const CBioseq* bioseq = dynamic_cast<const CBioseq *>(&object);
944  CBioseq_Handle bsh = m_Scope->GetBioseqHandle(*bioseq);
945  if (!bsh) {
946  return vals;
947  }
948 
949  // gather the comment descriptors
950  for (CSeqdesc_CI desc_it(bsh, CSeqdesc::e_Comment); desc_it; ++desc_it) {
951  vals.push_back(desc_it->GetComment());
952  }
953 
954  // gather the BankIt comments
955  vector<string> bankit = CBankITCommentField::GetVals(object);
956  copy(bankit.begin(), bankit.end(), back_inserter(vals));
957  return vals;
958 }
959 
960 // class CSeqIdField
961 
962 vector<CConstRef<CObject> > CSeqIdField::GetObjects(CBioseq_Handle bsh)
963 {
964  vector<CConstRef<CObject> > objects;
965  objects.push_back(CConstRef<CObject>(bsh.GetCompleteBioseq()));
966  return objects;
967 }
968 
969 
970 vector<CConstRef<CObject> > CSeqIdField::GetObjects
971 (CSeq_entry_Handle seh,
972 const string& constraint_field,
973 CRef<edit::CStringConstraint> string_constraint)
974 {
975  vector<CConstRef<CObject> > objects;
976  CBioseq_CI bi(seh, objects::CSeq_inst::eMol_na);
977  CRef<CScope> scope(&seh.GetScope());
978  while (bi) {
979  CConstRef<CObject> obj(bi->GetCompleteBioseq());
980  if (CMiscSeqTableColumn::s_IsSequenceIDField(constraint_field)) {
981  if (edit::CSeqIdGuesser::DoesSeqMatchConstraint(*bi, string_constraint)) {
982  objects.push_back(obj);
983  }
984  }
985  else if (DoesObjectMatchFieldConstraint(*obj,
986  constraint_field, string_constraint,
987  scope)) {
988  objects.push_back(obj);
989  }
990  ++bi;
991  }
992 
993  return objects;
994 }
995 
996 
997 vector<CRef<CApplyObject> > CSeqIdField::GetApplyObjects(CBioseq_Handle bsh)
998 {
999  vector<CRef<CApplyObject> > objects;
1000  objects.push_back(CRef<CApplyObject>(new CApplyObject(bsh)));
1001  return objects;
1002 }
1003 
1004 
1005 vector<CConstRef<CObject> > CSeqIdField::GetRelatedObjects(const CObject& object, CRef<CScope> scope)
1006 {
1007  vector<CConstRef<CObject> > objects;
1008  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&object);
1009  const CSeq_feat * obj_feat = dynamic_cast<const CSeq_feat *>(&object);
1010  const CBioseq * bioseq = dynamic_cast<const CBioseq *>(&object);
1011  if (obj_desc) {
1012  CSeq_entry_Handle seh = edit::GetSeqEntryForSeqdesc(scope, *obj_desc);
1013  CBioseq_CI bi(seh, objects::CSeq_inst::eMol_na);
1014  while (bi) {
1015  objects.push_back(CConstRef<CObject>(bi->GetCompleteBioseq()));
1016  ++bi;
1017  }
1018  }
1019  else if (obj_feat) {
1020  CBioseq_Handle bsh = scope->GetBioseqHandle(*(obj_feat->GetLocation().GetId()));
1021  if (bsh) {
1022  objects.push_back(CConstRef<CObject>(bsh.GetCompleteBioseq()));
1023  }
1024  }
1025  else if (bioseq) {
1026  objects.push_back(CConstRef<CObject>(bioseq));
1027  }
1028  return objects;
1029 }
1030 
1031 
1032 vector<CConstRef<CObject> > CSeqIdField::GetRelatedObjects(const CApplyObject& object)
1033 {
1034  vector<CConstRef<CObject> > objects;
1035  CBioseq_CI bi(object.GetSEH(), objects::CSeq_inst::eMol_na);
1036  while (bi) {
1037  objects.push_back(CConstRef<CObject>(bi->GetCompleteBioseq()));
1038  ++bi;
1039  }
1040  return objects;
1041 }
1042 
1043 
1044 string CSeqIdField::GetVal(const CObject& object)
1045 {
1046  string val;
1047  const CBioseq* bioseq = dynamic_cast<const CBioseq *>(&object);
1048  const CSeq_feat* feat = dynamic_cast<const CSeq_feat * >(&object);
1049  if (bioseq && bioseq->IsSetId()) {
1050  bioseq->GetId().front()->GetLabel(&val, CSeq_id::eContent);
1051  }
1052  else if (feat && feat->IsSetLocation()) {
1054  }
1055  return val;
1056 }
1057 
1058 
1059 vector<string> CSeqIdField::GetVals(const CObject& object)
1060 {
1061  vector<string> vals;
1062  vals.push_back(GetVal(object));
1063  return vals;
1064 }
1065 
1066 
1067 // class CFileIDField
1068 
1069 string CFileIDField::GetVal(const CObject& object)
1070 {
1071  string val = kEmptyStr;
1072  const CBioseq* bioseq = dynamic_cast<const CBioseq*>(&object);
1073  if (bioseq && bioseq->IsSetId()) {
1074  FOR_EACH_SEQID_ON_BIOSEQ(seqid_ci, *bioseq) {
1075  if (x_IsNCBIFILEId(**seqid_ci)) {
1076  (*seqid_ci)->GetLabel(&val, CSeq_id::eContent); // returned value: NCBIFILE:fileid_content
1077  val = val.substr(NStr::FindNoCase(val, ":") + 1); // truncate the 'NCBIFILE:' prefix
1078  // assume that there is a single File ID per sequence
1079  break;
1080  }
1081  }
1082  }
1083  return val;
1084 }
1085 
1086 bool CFileIDField::IsEmpty(const CObject& object) const
1087 {
1088  string value = (const_cast<CFileIDField*> (this))->GetVal(object);
1089  if (NStr::IsBlank(value)) {
1090  return true;
1091  }
1092  return false;
1093 }
1094 
1096 {
1097  if (seq_id.IsGeneral() && seq_id.GetGeneral().IsSetDb()
1098  && NStr::EqualCase(seq_id.GetGeneral().GetDb(), "NCBIFILE")) {
1099  return true;
1100  }
1101  return false;
1102 }
1103 
1104 
1105 // class CGeneralIDField
1106 
1109  { "", CGeneralIDField::eUnknown },
1110  { "Entire General ID", CGeneralIDField::eGenId },
1111  { "General ID DB", CGeneralIDField::eGenIdDb },
1112  { "General ID Tag", CGeneralIDField::eGenIdTag },
1113 };
1114 
1117 
1118 
1120 {
1121  TGenIdPartMap::const_iterator iter = sm_GenIdMap.begin();
1122  for (; iter != sm_GenIdMap.end(); ++iter){
1123  if (iter->second == stype_part){
1124  return iter->first;
1125  }
1126  }
1127  return kEmptyStr;
1128 }
1129 
1131 {
1132  TGenIdPartMap::const_iterator iter = sm_GenIdMap.find(name);
1133  if (iter != sm_GenIdMap.end()){
1134  return iter->second;
1135  }
1137 }
1138 
1139 string CGeneralIDField::GetVal(const CObject& object)
1140 {
1141  string val = kEmptyStr;
1142  const CBioseq* bioseq = dynamic_cast<const CBioseq*>(&object);
1143  if (bioseq && bioseq->IsSetId()) {
1144  FOR_EACH_SEQID_ON_BIOSEQ(seqid_ci, *bioseq) {
1145  const CSeq_id& seqid = **seqid_ci;
1146  if (seqid.IsGeneral()) {
1147  if (!NStr::IsBlank(val)) {
1148  val += ";";
1149  }
1150  switch (m_GeneralIDPart) {
1151  case eGenId: {
1152  string name = kEmptyStr;
1153  seqid.GetGeneral().GetLabel(&name);
1154  val += name;
1155  break;
1156  }
1157  case eGenIdDb:
1158  if (seqid.GetGeneral().IsSetDb()) {
1159  val += seqid.GetGeneral().GetDb();
1160  }
1161  break;
1162  case eGenIdTag:
1163  if (seqid.GetGeneral().IsSetTag()) {
1165  (seqid.GetGeneral().IsSetDb() &&
1167  CNcbiOstrstream ostr;
1168  seqid.GetGeneral().GetTag().AsString(ostr);
1169  val += CNcbiOstrstreamToString(ostr);
1170  }
1171  }
1172  break;
1173  default:
1174  break;
1175  }
1176  }
1177  }
1178  }
1179  if (NStr::EndsWith(val, ";")) {
1180  val.erase(val.end() - 1);
1181  }
1182  return val;
1183 }
1184 
1185 
1186 // class CLocalIDField
1187 
1188 vector<CConstRef<CObject> > CLocalIDField::GetObjects(CBioseq_Handle bsh)
1189 {
1190  vector< CConstRef<CObject> > objects;
1191  CSeqdesc_CI desc_ci(bsh, CSeqdesc::e_User);
1192  while (desc_ci){
1193  if (desc_ci->GetUser().GetObjectType() == CUser_object::eObjectType_OriginalId) {
1194  CConstRef<CObject> obj(&(*desc_ci));
1195  objects.push_back(obj);
1196  }
1197  ++desc_ci;
1198  }
1199 
1200  if (objects.empty()) {
1201  objects.push_back(CConstRef<CObject>(bsh.GetCompleteBioseq()));
1202  }
1203 
1204  return objects;
1205 }
1206 
1207 vector<CConstRef<CObject> > CLocalIDField::GetObjects(CSeq_entry_Handle seh,
1208  const string& constraint_field, CRef<edit::CStringConstraint> string_constraint)
1209 {
1210  vector< CConstRef<CObject> > objects;
1211  return objects;
1212 }
1213 
1214 vector<CRef<CApplyObject> > CLocalIDField::GetApplyObjects(CBioseq_Handle bsh)
1215 {
1216  vector<CRef<CApplyObject> > objects;
1217  CSeqdesc_CI desc_ci(bsh, CSeqdesc::e_User);
1218  while (desc_ci) {
1220  CRef<CApplyObject> obj(new CApplyObject(bsh, *desc_ci));
1221  objects.push_back(obj);
1222  }
1223  ++desc_ci;
1224  }
1225 
1226  if (objects.empty()) {
1227  objects.push_back(CRef<CApplyObject>(new CApplyObject(bsh)));
1228  }
1229  return objects;
1230 }
1231 
1232 vector<CConstRef<CObject> > CLocalIDField::GetRelatedObjects(const CObject& object, CRef<CScope> scope)
1233 {
1234  vector< CConstRef<CObject> > objects;
1235  return objects;
1236 }
1237 
1238 vector<CConstRef<CObject> > CLocalIDField::GetRelatedObjects(const CApplyObject& object)
1239 {
1240  vector< CConstRef<CObject> > objects;
1241  return objects;
1242 }
1243 
1244 string CLocalIDField::GetVal(const CObject& object)
1245 {
1246  vector<string> vals = GetVals(object);
1247  return (vals.empty()) ? kEmptyStr : vals[0];
1248 }
1249 
1250 vector<string> CLocalIDField::GetVals(const CObject& object)
1251 {
1252  vector<string> vals;
1253  const CSeqdesc* seqdesc = dynamic_cast<const CSeqdesc*>(&object);
1254  if (seqdesc && seqdesc->IsUser()) {
1255  const CUser_object& user = seqdesc->GetUser();
1257  if (!user.GetData().empty()) {
1258 
1259  const CRef<CUser_field>& user_field = user.GetData().front();
1260  if (user_field->IsSetLabel() && user_field->GetLabel().IsStr()
1261  && user_field->IsSetData()
1262  && NStr::EqualCase(user_field->GetLabel().GetStr(), "LocalId")){
1263 
1264  if (user_field->GetData().IsStr()) {
1265  vals.push_back(user_field->GetData().GetStr());
1266  } //not handling other types of fields
1267  }
1268  }
1269  }
1270  }
1271 
1272  if (!vals.empty()) {
1273  return vals;
1274  }
1275 
1276  const CBioseq* bioseq = dynamic_cast<const CBioseq *>(&object);
1277  if (bioseq && bioseq->IsSetId()) {
1278  const CSeq_id* lcl_id = bioseq->GetLocalId();
1279  if (lcl_id) {
1280  string val;
1281  lcl_id->GetLabel(&val, CSeq_id::eContent);
1282  vals.push_back(val);
1283  }
1284  }
1285 
1286  return vals;
1287 }
1288 
1289 bool CLocalIDField::IsEmpty(const CObject& object) const
1290 {
1291  const CSeqdesc* seqdesc = dynamic_cast<const CSeqdesc*>(&object);
1292  if (seqdesc && seqdesc->IsUser()) {
1293  const CUser_object& user = seqdesc->GetUser();
1295  if (user.GetData().empty()) {
1296  return true;
1297  }
1298 
1299  const CRef<CUser_field>& user_field = user.GetData().front();
1300  if (user_field->IsSetLabel() && user_field->GetLabel().IsStr()
1301  && NStr::EqualCase(user_field->GetLabel().GetStr(), "LocalId")){
1302  if (!user_field->IsSetData()) {
1303  return true;
1304  }
1305  if (!user_field->GetData().IsStr()) {
1306  return true;
1307  }
1308  if (NStr::IsBlank(user_field->GetData().GetStr())) {
1309  return true;
1310  }
1311  }
1312  }
1313  } else {
1314  const CBioseq* bioseq = dynamic_cast<const CBioseq *>(&object);
1315  if (bioseq && bioseq->IsSetId()) {
1316  const CSeq_id* lcl_id = bioseq->GetLocalId();
1317  if (!lcl_id) {
1318  return true;
1319  }
1320  string label;
1321  lcl_id->GetLabel(&label, CSeq_id::eContent);
1322  return (NStr::IsBlank(label)) ? true : false;
1323  }
1324  }
1325  return false;
1326 }
1327 
1328 // class CStructCommFieldValuePair
1329 
1330 vector<CConstRef<CObject> > CStructCommFieldValuePair::GetObjects(CBioseq_Handle bsh)
1331 {
1332  vector< CConstRef<CObject> > rval;
1333  CSeqdesc_CI desc_ci(bsh, CSeqdesc::e_User);
1334  while (desc_ci) {
1335  if (CComment_rule::IsStructuredComment(desc_ci->GetUser())) {
1336  CConstRef<CObject> obj(&(*desc_ci));
1337  rval.push_back(obj);
1338  }
1339  ++desc_ci;
1340  }
1341 
1342  return rval;
1343 }
1344 
1345 vector<CConstRef<CObject> > CStructCommFieldValuePair::GetObjects(CSeq_entry_Handle seh, const string& constraint_field, CRef<edit::CStringConstraint> string_constraint)
1346 {
1347  vector<CConstRef<CObject> > objs;
1348  CRef<CScope> scope(&seh.GetScope());
1349 
1350  CBioseq_CI bi (seh, objects::CSeq_inst::eMol_na);
1351  while (bi) {
1352  if (NStr::EqualNocase(constraint_field, kFieldTypeSeqId)) {
1353  if (edit::CSeqIdGuesser::DoesSeqMatchConstraint(*bi, string_constraint)) {
1354  vector<CConstRef<CObject> > these_objs = GetObjects(*bi);
1355  objs.insert(objs.end(), these_objs.begin(), these_objs.end());
1356  }
1357  } else {
1358  vector<CConstRef<CObject> > these_objs = GetObjects(*bi);
1359  ITERATE (vector<CConstRef<CObject> >, it, these_objs) {
1360  if (DoesObjectMatchFieldConstraint (**it, constraint_field, string_constraint, scope)) {
1361  objs.push_back(*it);
1362  }
1363  }
1364  }
1365  ++bi;
1366  }
1367 
1368  return objs;
1369 }
1370 
1371 static const string kStructComment("StructuredComment");
1372 static const string kStructCommentPrefix("StructuredCommentPrefix");
1373 static const string kStructCommentSuffix("StructuredCommentSuffix");
1374 
1376 {
1377  vector<CRef<CApplyObject> > objects;
1378 
1379  CSeqdesc_CI desc_ci(bsh, CSeqdesc::e_User);
1380  while (desc_ci) {
1381  if (CComment_rule::IsStructuredComment(desc_ci->GetUser())) {
1382  CRef<CApplyObject> obj(new CApplyObject(bsh, *desc_ci));
1383  objects.push_back(obj);
1384  }
1385  ++desc_ci;
1386  }
1387  if (objects.empty()) {
1388  CRef<CUser_object> usr_obj(new CUser_object());
1389  usr_obj->SetType().SetStr(kStructComment);
1390  CRef<CSeqdesc> desc(new CSeqdesc());
1391  desc->SetUser(*usr_obj);
1392  CRef<CApplyObject> new_obj(new CApplyObject(bsh, *desc));
1393  objects.push_back(new_obj);
1394  }
1395 
1396  return objects;
1397 }
1398 
1399 vector<CConstRef<CObject> > CStructCommFieldValuePair::GetRelatedObjects(const CObject& object, CRef<CScope> scope)
1400 {
1401  vector<CConstRef<CObject> > related;
1402 
1403  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&object);
1404  const CSeq_feat * obj_feat = dynamic_cast<const CSeq_feat *>(&object);
1405 
1406  if (obj_feat) {
1407  // find closest related Structured Comment Objects
1408  CBioseq_Handle bsh = scope->GetBioseqHandle(obj_feat->GetLocation());
1409  related = GetObjects(bsh);
1410  } else if (obj_desc && obj_desc->IsUser() && CComment_rule::IsStructuredComment(obj_desc->GetUser())) {
1411  CConstRef<CObject> obj(obj_desc);
1412  related.push_back(obj);
1413  }
1414 
1415  return related;
1416 }
1417 
1418 
1419 vector<CConstRef<CObject> > CStructCommFieldValuePair::GetRelatedObjects(const CApplyObject& object)
1420 {
1421  vector<CConstRef<CObject> > related;
1422 
1423  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&object);
1424  const CSeq_feat * obj_feat = dynamic_cast<const CSeq_feat *>(&object);
1425 
1426  if (obj_feat) {
1427  related = GetObjects(object.GetSEH(), "", CRef<CStringConstraint>(NULL));
1428  } else if (obj_desc && obj_desc->IsUser() && CComment_rule::IsStructuredComment(obj_desc->GetUser())) {
1429  CConstRef<CObject> obj(obj_desc);
1430  related.push_back(obj);
1431  }
1432 
1433  return related;
1434 }
1435 
1437 {
1438  bool rval = false;
1439  const CUser_object* user = x_GetUser_Object(object);
1440 
1441  // empty, is there are no field-value pairs
1442  if (user && CComment_rule::IsStructuredComment(*user)) {
1443  if (!user->IsSetData() || user->GetData().empty()) {
1444  // empty if no fields
1445  rval = true;
1446  }
1447  }
1448  return rval;
1449 }
1450 
1452 {
1453  vector<string> vals = GetVals(object);
1454  return (vals.empty()) ? kEmptyStr : vals[0];
1455 }
1456 
1457 vector<string> CStructCommFieldValuePair::GetVals(const CObject& object)
1458 {
1459  vector<string> vals;
1460  const CUser_object* user = x_GetUser_Object(object);
1461  if (user && CComment_rule::IsStructuredComment(*user) && user->IsSetData()) {
1462  ITERATE(CUser_object::TData, it, user->GetData()) {
1463  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr() && (*it)->IsSetData()
1464  && NStr::Equal((*it)->GetLabel().GetStr(), m_FieldName)) {
1465  switch((*it)->GetData().Which()) {
1467  vals.push_back((*it)->GetData().GetStr());
1468  break;
1470  ITERATE(CUser_field::TData::TStrs, s, (*it)->GetData().GetStrs()) {
1471  vals.push_back(*s);
1472  }
1473  break;
1474  default:
1475  //not handling other types of fields
1476  break;
1477  }
1478  }
1479  }
1480  }
1481  return vals;
1482 }
1483 
1485 {
1486  CUser_object* user = x_GetUser_Object(object);
1487  if (user && user->IsSetData() && CComment_rule::IsStructuredComment(*user)) {
1488  CUser_object::TData::iterator it = user->SetData().begin();
1489  while (it != user->SetData().end()) {
1490  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr() &&
1491  NStr::Equal((*it)->GetLabel().GetStr(), m_FieldName)) {
1492  it = user->SetData().erase(it);
1493  } else {
1494  ++it;
1495  }
1496  }
1497  if (user->GetData().empty()) {
1498  user->ResetData();
1499  }
1500  }
1501 }
1502 
1503 bool CStructCommFieldValuePair::SetVal(CObject& object, const string& newValue, EExistingText existing_text)
1504 {
1505  bool rval = false;
1506  CUser_object* user = x_GetUser_Object(object);
1507  if (user && CComment_rule::IsStructuredComment(*user)) {
1508  bool found = false;
1509  if (user->IsSetData()) {
1510  CUser_object::TData::iterator it = user->SetData().begin();
1511  while (it != user->SetData().end()) {
1512  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr()
1513  && NStr::Equal((*it)->GetLabel().GetStr(), m_FieldName)) {
1514  rval |= SetVal(**it, newValue, existing_text);
1515  found = true;
1516  }
1517  if (!(*it)->IsSetData()) {
1518  it = user->SetData().erase(it);
1519  } else {
1520  it++;
1521  }
1522  }
1523  }
1524  if (!found) {
1525  CRef<CUser_field> new_field(new CUser_field());
1526  new_field->SetLabel().SetStr(m_FieldName);
1527  if (SetVal(*new_field, newValue, eExistingText_replace_old)) {
1528  x_InsertFieldAtCorrectPosition(*user, new_field);
1529  rval = true;
1530  }
1531  }
1532 
1533  // if User object now has no fields, reset so it will be detected as empty
1534  if (user->GetData().empty()) {
1535  user->ResetData();
1536  }
1537  }
1538  return rval;
1539 }
1540 
1541 bool CStructCommFieldValuePair::SetVal(CUser_field& field, const string & newValue, EExistingText existing_text)
1542 {
1543  bool rval = false;
1544 
1545  if (field.IsSetData()) {
1546  if (field.GetData().IsStr()) {
1547  string curr_val = field.GetData().GetStr();
1548  if (AddValueToString(curr_val, newValue, existing_text)) {
1549  field.SetData().SetStr(curr_val);
1550  rval = true;
1551  }
1552  } else if (field.GetData().Which() == CUser_field::TData::e_not_set) {
1553  field.SetData().SetStr(newValue);
1554  rval = true;
1555  }
1556  } else {
1557  field.SetData().SetStr(newValue);
1558  rval = true;
1559  }
1560 
1561  return rval;
1562 }
1563 
1565 {
1566  if (!field) {
1567  return;
1568  }
1569  if (!user.IsSetData()) {
1570  // no fields yet, just add the field
1571  user.SetData().push_back(field);
1572  return;
1573  }
1574  string this_field_label = field->GetLabel().GetStr();
1575 
1576 
1578  vector<string> field_names = CComment_set::GetFieldNames(prefix);
1579  if (field_names.empty()) {
1580  // no information about field order, just add to end
1581  user.SetData().push_back(field);
1582  return;
1583  }
1584 
1585  vector<string>::iterator sit = field_names.begin();
1586  CUser_object::TData::iterator fit = user.SetData().begin();
1587  while (sit != field_names.end() && fit != user.SetData().end()) {
1588  string field_label = (*fit)->GetLabel().GetStr();
1589  if (NStr::EqualNocase(field_label, kStructCommentPrefix)) {
1590  // skip
1591  ++fit;
1592  } else if (NStr::EqualNocase(*sit, (*fit)->GetLabel().GetStr())) {
1593  ++sit;
1594  ++fit;
1595  } else if (NStr::EqualNocase(*sit, this_field_label)) {
1596  // insert field here
1597  user.SetData().insert(fit, field);
1598  return;
1599  } else if (NStr::EqualNocase(field_label, kStructCommentSuffix)){
1600  user.SetData().insert(fit, field);
1601  return;
1602  } else {
1603  // field is missing
1604  ++sit;
1605  }
1606  }
1607  user.SetData().push_back(field);
1608 }
1609 
1611 {
1612  const CSeqdesc * seqdesc = dynamic_cast<const CSeqdesc *>(&object);
1613  const CUser_object* user = dynamic_cast<const CUser_object*>(&object);
1614 
1615  if (seqdesc && seqdesc->IsUser()) {
1616  user = &(seqdesc->GetUser());
1617  }
1618  return user;
1619 }
1620 
1622 {
1623  CSeqdesc* seqdesc = dynamic_cast<CSeqdesc*>(&object);
1624  CUser_object* user = dynamic_cast<CUser_object*>(&object);
1625 
1626  if (seqdesc && seqdesc->IsUser()) {
1627  user = &(seqdesc->SetUser());
1628  }
1629  return user;
1630 }
1631 
1632 
1633 // class CStructCommDBName
1634 
1635 vector<string> CStructCommDBName::GetVals(const CObject& object)
1636 {
1637  vector<string> vals;
1638  const CUser_object* user = x_GetUser_Object(object);
1639  vals.push_back(CComment_rule::GetStructuredCommentPrefix(*user));
1640  return vals;
1641 }
1642 
1644 {
1645  CUser_object* user = x_GetUser_Object(object);
1646  if (user && user->IsSetData() && CComment_rule::IsStructuredComment(*user)) {
1647  CUser_object::TData::iterator it = user->SetData().begin();
1648  while (it != user->SetData().end()) {
1649  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr()
1650  && (NStr::Equal((*it)->GetLabel().GetStr(), kStructCommentPrefix)
1651  || NStr::Equal((*it)->GetLabel().GetStr(), kStructCommentSuffix))) {
1652  it = user->SetData().erase(it);
1653  } else {
1654  it++;
1655  }
1656  }
1657  if (user->GetData().empty()) {
1658  user->ResetData();
1659  }
1660  }
1661 }
1662 
1663 bool CStructCommDBName::SetVal(CObject& object, const string& newValue, EExistingText existing_text)
1664 {
1665  bool rval = false;
1666  CUser_object* user = x_GetUser_Object(object);
1667  if (user && CComment_rule::IsStructuredComment(*user)) {
1668  bool found = false;
1669  if (user->IsSetData()) {
1670  CUser_object::TData::iterator it = user->SetData().begin();
1671  while (it != user->SetData().end()) {
1672  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr()
1673  && (NStr::Equal((*it)->GetLabel().GetStr(), kStructCommentPrefix)
1674  || NStr::Equal((*it)->GetLabel().GetStr(), kStructCommentSuffix))) {
1675  rval |= SetVal(**it, newValue, existing_text);
1676  found = true;
1677  }
1678  if (!(*it)->IsSetData()) {
1679  it = user->SetData().erase(it);
1680  } else {
1681  it++;
1682  }
1683  }
1684  }
1685  if (!found) {
1686  CRef<CUser_field> pre_field(new CUser_field());
1687  pre_field->SetLabel().SetStr(kStructCommentPrefix);
1688  if (SetVal(*pre_field, newValue, eExistingText_replace_old)) {
1689  x_InsertFieldAtCorrectPosition(*user, pre_field);
1690  rval |= true;
1691  }
1692  CRef<CUser_field> suf_field(new CUser_field());
1693  suf_field->SetLabel().SetStr(kStructCommentSuffix);
1694  if (SetVal(*suf_field, newValue, eExistingText_replace_old)) {
1695  x_InsertFieldAtCorrectPosition(*user, suf_field);
1696  rval |= true;
1697  }
1698  }
1699 
1700  // if User object now has no fields, reset so it will be detected as empty
1701  if (user->GetData().empty()) {
1702  user->ResetData();
1703  }
1704  }
1705  return rval;
1706 }
1707 
1708 bool CStructCommDBName::SetVal(CUser_field& field, const string & newValue, EExistingText existing_text)
1709 {
1710  bool rval = false;
1711 
1712  if (field.IsSetData()) {
1713  if (field.GetData().IsStr()) {
1714  string curr_val = field.GetData().GetStr();
1715  string root = curr_val;
1717  if (AddValueToString(root, newValue, existing_text)) {
1718  if (NStr::Equal(field.GetLabel().GetStr(), kStructCommentPrefix)) {
1719  string pre = CComment_rule::MakePrefixFromRoot(root);
1720  field.SetData().SetStr(pre);
1721  rval = true;
1722  } else if (NStr::Equal(field.GetLabel().GetStr(), kStructCommentSuffix)) {
1723  string suf = CComment_rule::MakeSuffixFromRoot(root);
1724  field.SetData().SetStr(suf);
1725  rval = true;
1726  }
1727  }
1728  } else if (field.GetData().Which() == CUser_field::TData::e_not_set) {
1729  if (NStr::Equal(field.GetLabel().GetStr(), kStructCommentPrefix)) {
1730  string pre = CComment_rule::MakePrefixFromRoot(newValue);
1731  field.SetData().SetStr(pre);
1732  rval = true;
1733  } else if (NStr::Equal(field.GetLabel().GetStr(), kStructCommentSuffix)) {
1734  string suf = CComment_rule::MakeSuffixFromRoot(newValue);
1735  field.SetData().SetStr(suf);
1736  rval = true;
1737  }
1738  }
1739  } else {
1740  if (NStr::Equal(field.GetLabel().GetStr(), kStructCommentPrefix)) {
1741  string pre = CComment_rule::MakePrefixFromRoot(newValue);
1742  field.SetData().SetStr(pre);
1743  rval = true;
1744  } else if (NStr::Equal(field.GetLabel().GetStr(), kStructCommentSuffix)) {
1745  string suf = CComment_rule::MakeSuffixFromRoot(newValue);
1746  field.SetData().SetStr(suf);
1747  rval = true;
1748  }
1749  }
1750 
1751  return rval;
1752 }
1753 
1754  // class CStructCommFieldName
1755 
1756 vector<string> CStructCommFieldName::GetVals(const CObject& object)
1757 {
1758  vector<string> vals;
1759  x_Init();
1760  const CUser_object* user = x_GetUser_Object(object);
1761  if (user && user->IsSetData() && CComment_rule::IsStructuredComment(*user)) {
1762  ITERATE (CUser_object::TData, it, user->GetData()) {
1763  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr()
1764  && !(NStr::Equal((*it)->GetLabel().GetStr(), kStructCommentPrefix)
1765  || NStr::Equal((*it)->GetLabel().GetStr(), kStructCommentSuffix))) {
1766  vals.push_back((*it)->GetLabel().GetStr());
1767  CRef<CUser_field> new_field(new CUser_field());
1768  new_field->Assign(**it);
1769  m_FieldValuePairs.push_back(new_field);
1770  }
1771  }
1772  }
1773  return vals;
1774 }
1775 
1777 {
1778  CUser_object* user = x_GetUser_Object(object);
1779  if (user && user->IsSetData() && CComment_rule::IsStructuredComment(*user)) {
1780  CUser_object::TData::iterator it = user->SetData().begin();
1781  while (it != user->SetData().end()) {
1782  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr()
1783  && !(NStr::Equal((*it)->GetLabel().GetStr(), kStructCommentPrefix)
1784  || NStr::Equal((*it)->GetLabel().GetStr(), kStructCommentSuffix))) {
1785  it = user->SetData().erase(it);
1786  m_Cleared = true;
1787  } else {
1788  ++it;
1789  }
1790  }
1791  if (user->GetData().empty()) {
1792  user->ResetData();
1793  }
1794  }
1795 }
1796 
1797 bool CStructCommFieldName::SetVal(CObject& object, const string& newValue, EExistingText existing_text)
1798 {
1799  bool rval = false;
1800  CUser_object* user = x_GetUser_Object(object);
1801  if (user && CComment_rule::IsStructuredComment(*user)) {
1802  if (!m_Cleared && m_NrOfSetting == 0) {
1803  bool found = false;
1804  if (user->IsSetData()) {
1805  CUser_object::TData::iterator it = user->SetData().begin();
1806  while (it != user->SetData().end()) {
1807  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr()
1808  && !(NStr::Equal((*it)->GetLabel().GetStr(), kStructCommentPrefix)
1809  || NStr::Equal((*it)->GetLabel().GetStr(), kStructCommentSuffix))) {
1810  rval |= SetVal(**it, newValue, existing_text);
1811  found = true;
1812  }
1813  it++;
1814  }
1815  }
1816  if (!found) {
1817  CRef<CUser_field> new_field(new CUser_field());
1818  new_field->SetLabel().SetStr(newValue);
1819  new_field->SetData().SetStr(kEmptyStr);
1820  x_InsertFieldAtCorrectPosition(*user, new_field);
1821  rval = true;
1822  }
1823  } else {
1824  // if it was cleared:
1825  size_t members = m_FieldValuePairs.size();
1826  size_t index = m_NrOfSetting % members;
1827  rval |= SetVal(*(m_FieldValuePairs[index]), newValue, eExistingText_replace_old);
1828  m_NrOfSetting++;
1829  if (m_NrOfSetting == members) {
1830  if (!user->IsSetData()) {
1831  // no fields yet, just add the field
1832  user->SetData().assign(m_FieldValuePairs.begin(), m_FieldValuePairs.end());
1833  } else {
1834  CUser_object::TData::iterator it = user->SetData().begin();
1835  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr()
1836  && NStr::Equal((*it)->GetLabel().GetStr(), kStructCommentPrefix)) {
1837  ++it;
1838  }
1839  user->SetData().insert(it, m_FieldValuePairs.begin(), m_FieldValuePairs.end());
1840  m_Cleared = false;
1841  }
1842  }
1843  }
1844 
1845  // if User object now has no fields, reset so it will be detected as empty
1846  if (user->GetData().empty()) {
1847  user->ResetData();
1848  }
1849  }
1850 
1851  return rval;
1852 }
1853 
1854 bool CStructCommFieldName::SetVal(CUser_field& field, const string & newValue, EExistingText existing_text)
1855 {
1856  bool rval = false;
1857  string curr_val = field.GetLabel().GetStr();
1858  if (AddValueToString(curr_val, newValue, existing_text)) {
1859  field.SetLabel().SetStr(curr_val);
1860  rval = true;
1861  }
1862  return rval;
1863 }
1864 
1866 {
1867  m_FieldValuePairs.clear();
1868  m_NrOfSetting = 0;
1869 }
1870 
1871 
1872 // class CFlatFileField
1873 vector<CConstRef<CObject> > CFlatFileField::GetObjects(CBioseq_Handle bsh)
1874 {
1875  vector< CConstRef<CObject> > objects;
1876  objects.push_back(CConstRef<CObject>(bsh.GetCompleteBioseq()));
1877  return objects;
1878 }
1879 
1880 vector<CConstRef<CObject> > CFlatFileField::GetObjects(CSeq_entry_Handle seh,
1881  const string& constraint_field, CRef<edit::CStringConstraint> string_constraint)
1882 {
1883  vector< CConstRef<CObject> > objects;
1884  return objects;
1885 }
1886 
1887 
1888 vector<CRef<CApplyObject> > CFlatFileField::GetApplyObjects(CBioseq_Handle bsh)
1889 {
1890  vector<CRef<CApplyObject> > objects;
1891  objects.push_back(CRef<CApplyObject>(new CApplyObject(bsh)));
1892  return objects;
1893 }
1894 
1895 vector<CConstRef<CObject> > CFlatFileField::GetRelatedObjects(const CObject& object, CRef<CScope> scope)
1896 {
1897  vector< CConstRef<CObject> > objects;
1898  return objects;
1899 }
1900 
1901 vector<CConstRef<CObject> > CFlatFileField::GetRelatedObjects(const CApplyObject& object)
1902 {
1903  vector< CConstRef<CObject> > objects;
1904  return objects;
1905 }
1906 
1907 string CFlatFileField::GetVal(const CObject& object)
1908 {
1909  const CBioseq* bioseq = dynamic_cast<const CBioseq*>(&object);
1910  if (!bioseq)
1911  return kEmptyStr;
1912 
1913  // generate flat file without the features and sequence for the bioseq
1914  CNcbiOstrstream ostr;
1915  try {
1916  CFlatFileConfig cfg;
1917  cfg.SetFormatGenbank();
1918  cfg.SetModeGBench();
1919  cfg.SetStyleNormal();
1927 
1928  ffgen->Generate(*bioseq, *m_Scope, ostr);
1929  }
1930  catch (const CFlatException& e) {
1931  LOG_POST("Failed to generate flat file: " << e.GetMsg());
1932  return kEmptyStr;
1933  }
1934 
1935  return (IsOssEmpty(ostr)) ? kEmptyStr : CNcbiOstrstreamToString(ostr);
1936 }
1937 
1938 
1939 // class CMiscSeqTableColumn
1940 
1942 {
1943  m_Src.Reset(NULL);
1944  m_Feature.Reset(NULL);
1947  if (src_col) {
1948  m_Src = src_col;
1949  } else {
1951  if (!m_FieldHandler) {
1953  size_t pos = NStr::Find(name, " ");
1954  if (pos == string::npos) {
1956  } else {
1957  string key = name.substr(0, pos);
1959  if (NStr::EqualNocase(key, "RNA")) {
1960  major_type = CSeqFeatData::e_Rna;
1961  } else {
1963  }
1964  if (subtype == CSeqFeatData::eSubtype_bad && NStr::StartsWith(name, "protein ")) {
1965  subtype = CSeqFeatData::eSubtype_prot;
1966  }
1967  if (major_type != CSeqFeatData::e_not_set || subtype != CSeqFeatData::eSubtype_bad) {
1968  m_Feature = CFeatureSeqTableColumnBaseFactory::Create(name.substr(pos + 1), subtype);
1969  } else {
1971  }
1972  if (major_type != CSeqFeatData::e_not_set) {
1973  m_Feature->SetMajorType(major_type);
1974  }
1975  }
1976  }
1977  }
1978 }
1979 
1980 
1982 {
1985  return true;
1986  } else {
1987  return false;
1988  }
1989 }
1990 
1992 {
1993  if (m_Feature && NStr::EqualNocase(m_Feature->GetLabel(), "product")) {
1994  return true;
1995  }
1996  return false;
1997 }
1998 
2000 {
2001  if (m_Feature) {
2002  m_Feature->SetScope(scope);
2003  } else if (m_FieldHandler) {
2004  m_FieldHandler->SetScope(scope);
2005  }
2006 }
2007 
2008 vector<CConstRef<CObject> > CMiscSeqTableColumn::GetObjects(CBioseq_Handle bsh)
2009 {
2010  vector<CConstRef<CObject> > objects;
2011  if (m_Src) {
2012  objects = m_Src->GetObjects(bsh);
2013  } else if (m_FieldHandler) {
2014  objects = m_FieldHandler->GetObjects(bsh);
2015  } else if (m_Feature) {
2016  objects = m_Feature->GetObjects(bsh);
2017  }
2018  return objects;
2019 }
2020 
2021 
2022 vector<CConstRef<CObject> > CMiscSeqTableColumn::GetObjects(CSeq_entry_Handle seh, const string& constraint_field, CRef<edit::CStringConstraint> string_constraint)
2023 {
2024  vector<CConstRef<CObject> > objs;
2025  CRef<CScope> scope(&seh.GetScope());
2026 
2027  CBioseq_CI bi (seh, objects::CSeq_inst::eMol_na);
2028  while (bi) {
2029  if (NStr::EqualNocase(constraint_field, kFieldTypeSeqId)) {
2030  if (edit::CSeqIdGuesser::DoesSeqMatchConstraint(*bi, string_constraint)) {
2031  vector<CConstRef<CObject> > these_objs = GetObjects(*bi);
2032  objs.insert(objs.end(), these_objs.begin(), these_objs.end());
2033  }
2034  } else {
2035  vector<CConstRef<CObject> > these_objs = GetObjects(*bi);
2036  ITERATE (vector<CConstRef<CObject> >, it, these_objs) {
2037  if (DoesObjectMatchFieldConstraint (**it, constraint_field, string_constraint, scope)) {
2038  objs.push_back (*it);
2039  }
2040  }
2041  }
2042  ++bi;
2043  }
2044 
2045  return objs;
2046 }
2047 
2048 
2049 vector<CRef<CApplyObject> > CMiscSeqTableColumn::GetApplyObjects(CBioseq_Handle bsh)
2050 {
2051  vector<CRef<CApplyObject> > objs;
2052  if (m_FieldHandler) {
2053  objs = m_FieldHandler->GetApplyObjects(bsh);
2054  } else if (m_Src) {
2055  objs = m_Src->GetApplyObjects(bsh);
2056  } else if (m_Feature) {
2057  objs = m_Feature->GetApplyObjects(bsh);
2058  vector<CConstRef<CObject> > feats = GetObjects(bsh);
2059  }
2060  return objs;
2061 }
2062 
2063 
2064 vector<CRef<CApplyObject> > CMiscSeqTableColumn::GetApplyObjects(CSeq_entry_Handle seh, const string& constraint_field, CRef<edit::CStringConstraint> string_constraint)
2065 {
2066  vector<CRef<CApplyObject> > objs;
2067 
2068  if (m_Src) {
2069  CBioseq_CI bi (seh, objects::CSeq_inst::eMol_na);
2070  while (bi) {
2071  if (NStr::EqualNocase(constraint_field, kFieldTypeSeqId)) {
2072  if (edit::CSeqIdGuesser::DoesSeqMatchConstraint(*bi, string_constraint)) {
2073  vector<CRef<CApplyObject> > these_objs = m_Src->GetApplyObjects(*bi);
2074  objs.insert(objs.end(), these_objs.begin(), these_objs.end());
2075  }
2076  } else {
2077  vector<CRef<CApplyObject> > these_objs = m_Src->GetApplyObjects(*bi);
2078  NON_CONST_ITERATE (vector<CRef<CApplyObject> >, it, these_objs) {
2079  if (DoesApplyObjectMatchFieldConstraint (**it, constraint_field, string_constraint)) {
2080  objs.push_back (*it);
2081  }
2082  }
2083  }
2084  ++bi;
2085  }
2086  } else if (m_FieldHandler) {
2087  CBioseq_CI bi (seh, objects::CSeq_inst::eMol_na);
2088  while (bi) {
2089  if (NStr::EqualNocase(constraint_field, kFieldTypeSeqId)) {
2090  if (edit::CSeqIdGuesser::DoesSeqMatchConstraint(*bi, string_constraint)) {
2091  vector<CRef<CApplyObject> > these_objs = m_FieldHandler->GetApplyObjects(*bi);
2092  objs.insert(objs.end(), these_objs.begin(), these_objs.end());
2093  }
2094  } else {
2095  vector<CRef<CApplyObject> > these_objs = m_FieldHandler->GetApplyObjects(*bi);
2096  NON_CONST_ITERATE (vector<CRef<CApplyObject> >, it, these_objs) {
2097  if (DoesApplyObjectMatchFieldConstraint (**it, constraint_field, string_constraint)) {
2098  objs.push_back (*it);
2099  }
2100  }
2101  }
2102  ++bi;
2103  }
2104  } else if (m_Feature) {
2105  CBioseq_CI bi (seh, objects::CSeq_inst::eMol_na);
2106  while (bi) {
2107  if (NStr::EqualNocase(constraint_field, kFieldTypeSeqId)) {
2108  if (edit::CSeqIdGuesser::DoesSeqMatchConstraint(*bi, string_constraint)) {
2109  vector<CRef<CApplyObject> > these_objs = m_Feature->GetApplyObjects(*bi);
2110  objs.insert(objs.end(), these_objs.begin(), these_objs.end());
2111  }
2112  } else {
2113  vector<CRef<CApplyObject> > these_objs = m_Feature->GetApplyObjects(*bi);
2114  NON_CONST_ITERATE (vector<CRef<CApplyObject> >, it, these_objs) {
2115  if (DoesApplyObjectMatchFieldConstraint (**it, constraint_field, string_constraint)) {
2116  objs.push_back (*it);
2117  }
2118  }
2119  }
2120  ++bi;
2121  }
2122  }
2123 
2124  return objs;
2125 }
2126 
2127 void CMiscSeqTableColumn::GetApplyObjectsValues(CSeq_entry_Handle seh, const string& constraint_field, set<string> &values)
2128 {
2129 
2130  if (m_Src) {
2131  CBioseq_CI bi (seh, objects::CSeq_inst::eMol_na);
2132  while (bi) {
2133  vector<CRef<CApplyObject> > these_objs = m_Src->GetApplyObjects(*bi);
2134  NON_CONST_ITERATE (vector<CRef<CApplyObject> >, it, these_objs) {
2135  AddApplyObjectValue(**it,constraint_field,values);
2136  }
2137  ++bi;
2138  }
2139  } else if (m_FieldHandler) {
2140  CBioseq_CI bi (seh, objects::CSeq_inst::eMol_na);
2141  while (bi) {
2142  vector<CRef<CApplyObject> > these_objs = m_FieldHandler->GetApplyObjects(*bi);
2143  NON_CONST_ITERATE (vector<CRef<CApplyObject> >, it, these_objs) {
2144  AddApplyObjectValue(**it,constraint_field,values);
2145  }
2146  ++bi;
2147  }
2148  } else if (m_Feature) {
2149  CRef<CScope> scope(&(seh.GetScope()));
2150  CBioseq_CI bi (seh, objects::CSeq_inst::eMol_na);
2151  while (bi) {
2152  vector<CConstRef<CObject> > const_objs = m_Feature->GetObjects(*bi);
2153  ITERATE(vector<CConstRef<CObject> >, it, const_objs) {
2154  const CSeq_feat* feat = dynamic_cast<const CSeq_feat*>(it->GetPointer());
2155  if (feat) {
2156  CRef<CApplyObject> obj(new CApplyObject(*bi, *feat));
2157  AddApplyObjectValue(*obj,constraint_field,values);
2158  }
2159  }
2160  ++bi;
2161  }
2162  }
2163 }
2164 
2165 void CMiscSeqTableColumn::AddApplyObjectValue(const CApplyObject& object, const string& field, set<string> &values)
2166 {
2167  if (NStr::IsBlank(field)) {
2168  return;
2169  }
2170 
2172  if (!col) {
2173  return;
2174  }
2175 
2176  vector<CConstRef<CObject> > objs = col->GetRelatedObjects (object);
2177  ITERATE(vector<CConstRef<CObject> >, it, objs) {
2178  vector<string> add = col->GetVals(**it);
2179  values.insert(add.begin(), add.end());
2180  }
2181 }
2182 
2183 
2185 {
2186  string val = "";
2187  if (m_Src) {
2188  val = m_Src->GetVal(object);
2189  } else if (m_FieldHandler) {
2190  val = m_FieldHandler->GetVal(object);
2191  } else if (m_Feature) {
2192  const CSeq_feat* feat = dynamic_cast<const CSeq_feat * >(&object);
2193  if (feat) {
2194  val = m_Feature->GetFromFeat(*feat);
2195  }
2196  }
2197  return val;
2198 }
2199 
2200 
2201 vector<string> CMiscSeqTableColumn::GetVals(const CObject& object)
2202 {
2203  vector<string> vals;
2204  if (m_Src) {
2205  vals = m_Src->GetVals(object);
2206  } else if (m_FieldHandler) {
2207  vals = m_FieldHandler->GetVals(object);
2208  } else if (m_Feature) {
2209  const CSeq_feat* feat = dynamic_cast<const CSeq_feat * >(&object);
2210  if (feat) {
2211  vals.push_back(m_Feature->GetFromFeat(*feat));
2212  }
2213  }
2214  return vals;
2215 }
2216 
2217 
2218 bool CMiscSeqTableColumn::IsEmpty(const CObject& object) const
2219 {
2220  bool rval = false;
2221  if (m_FieldHandler) {
2222  rval = m_FieldHandler->IsEmpty(object);
2223  } else {
2224  rval = false;
2225  }
2226  return rval;
2227 }
2228 
2229 
2231 {
2232  if (m_Src) {
2233  m_Src->ClearVal(object);
2234  } else if (m_FieldHandler) {
2235  m_FieldHandler->ClearVal(object);
2236  } else if (m_Feature) {
2237  CSeq_feat* feat = dynamic_cast<CSeq_feat * >(&object);
2238  if (feat) {
2239  m_Feature->ClearInFeature(*feat);
2240  }
2241  }
2242 }
2243 
2244 
2246 {
2247  CRef<CCmdComposite> cmd(new CCmdComposite("Set Value"));
2248  bool any_change = false;
2249 
2250  string orig_val = GetVal(*object);
2251  if (!NStr::IsBlank(orig_val)) {
2252  const CSeqdesc* old_desc = dynamic_cast<const CSeqdesc *>(object.GetPointer());
2253  const CSeq_feat* old_feat = dynamic_cast<const CSeq_feat * >(object.GetPointer());
2254  if (old_desc) {
2255  CRef<CSeqdesc> new_desc( new CSeqdesc() );
2256  new_desc->Assign(*old_desc);
2257  ClearVal(*((CObject *)new_desc));
2258  CSeq_entry_Handle seh = edit::GetSeqEntryForSeqdesc(Ref(&scope), *old_desc);
2259  if (seh) {
2260  if (IsEmpty(*((CObject *)new_desc))) {
2261  CRef<CCmdDelDesc> ecmd(new CCmdDelDesc(seh, *old_desc));
2262  cmd->AddCommand(*ecmd);
2263  any_change = true;
2264  }
2265  else {
2266  CRef<CCmdChangeSeqdesc> ecmd(new CCmdChangeSeqdesc(seh, *old_desc, *new_desc));
2267  cmd->AddCommand(*ecmd);
2268  any_change = true;
2269  }
2270  }
2271  } else if (old_feat) {
2272  CRef<CSeq_feat> new_feat(new CSeq_feat());
2273  new_feat->Assign(*old_feat);
2274  ClearVal(*((CObject *)new_feat));
2275 
2276  if (IsEmpty(*((CObject*)new_feat))) {
2277  cmd->AddCommand(*CRef<CCmdDelSeq_feat>(new CCmdDelSeq_feat(scope.GetSeq_featHandle(*old_feat))));
2278  any_change = true;
2279  } else {
2280  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(scope.GetSeq_featHandle(*old_feat), *new_feat)));
2281  any_change = true;
2282  }
2283 
2284  // the mRNA product name is required to match the CDS product name
2285  if (update_mrna_product) {
2286  string prot_product = GetVal(*new_feat);
2287  CRef<CCmdComposite> also_change_mrna = UpdatemRNAProduct(prot_product, CConstRef<CObject>(&(*new_feat)), scope);
2288  if (also_change_mrna) {
2289  cmd->AddCommand(*also_change_mrna);
2290  any_change = true;
2291  }
2292  }
2293 
2294  }
2295  }
2296  if (!any_change) {
2297  cmd.Reset(NULL);
2298  }
2299  return cmd;
2300 }
2301 
2302 
2303 bool CMiscSeqTableColumn::SetVal(CObject& object, const string& val, EExistingText existing_text)
2304 {
2305  bool rval = false;
2306  if (m_Src) {
2307  CSeqdesc* desc = dynamic_cast<CSeqdesc * >(&object);
2308  CSeq_feat* feat = dynamic_cast<CSeq_feat * >(&object);
2309  if (desc && desc->IsSource()) {
2310  rval = m_Src->AddToBioSource(desc->SetSource(), val, existing_text);
2311  } else if (feat && feat->IsSetData() && feat->GetData().IsBiosrc()) {
2312  rval = m_Src->AddToBioSource(feat->SetData().SetBiosrc(), val, existing_text);
2313  }
2314  } else if (m_FieldHandler) {
2315  rval = m_FieldHandler->SetVal(object, val, existing_text);
2316  } else if (m_Feature) {
2317  CSeq_feat* feat = dynamic_cast<CSeq_feat * >(&object);
2318  if (feat) {
2319  rval = m_Feature->AddToFeature(*feat, val, existing_text);
2320  }
2321  }
2322  return rval;
2323 }
2324 
2325 
2327  EExistingText existing_text, CScope& scope,
2328  bool update_mrna_product)
2329 {
2331 
2332  CRef<CObject> new_obj = GetNewObject(object);
2333  CRef<CCmdComposite> also_change_mrna(NULL);
2334  if (new_obj) {
2335  if (SetVal(*new_obj, val, existing_text)) {
2336  cmd = GetReplacementCommand(object, new_obj, scope, "Apply Value");
2337  if (update_mrna_product) {
2338  string prot_product = GetVal(*new_obj);
2339  also_change_mrna.Reset(UpdatemRNAProduct(prot_product, new_obj, scope));
2340  if (also_change_mrna) {
2341  cmd->AddCommand(*also_change_mrna);
2342  }
2343  }
2344  }
2345  }
2346 
2347  return cmd;
2348 }
2349 
2350 
2352 {
2353  const CSeqdesc * old_desc = dynamic_cast<const CSeqdesc *>(object.GetPointer());
2354  const CSeq_feat* old_feat = dynamic_cast<const CSeq_feat * >(object.GetPointer());
2355  CRef<CObject> new_obj(NULL);
2356 
2357  if (old_desc) {
2358  // prepare replacement descriptor
2359  CRef<CSeqdesc> new_desc( new CSeqdesc() );
2360  new_desc->Assign(*old_desc);
2361  new_obj = (CObject *)new_desc;
2362  } else if (old_feat) {
2363  // prepare replacement feature
2364  CRef<CSeq_feat> new_feat(new CSeq_feat());
2365  new_feat->Assign(*old_feat);
2366  new_obj = (CObject *)new_feat;
2367  }
2368  return new_obj;
2369 }
2370 
2371 
2373 {
2374  CRef<CCmdComposite> cmd(new CCmdComposite("Convert Value"));
2375  bool success = false;
2376 
2377  const CSeqdesc* old_desc = dynamic_cast<const CSeqdesc *>(oldobj.GetPointer());
2378  const CSeq_feat* old_feat = dynamic_cast<const CSeq_feat * >(oldobj.GetPointer());
2379 
2380  if (old_desc) {
2381  CSeq_entry_Handle seh = edit::GetSeqEntryForSeqdesc(Ref(&scope), *old_desc);
2382  const CSeqdesc* new_desc = dynamic_cast<const CSeqdesc*>(newobj.GetPointer());
2383  if (seh && new_desc) {
2384  CRef<CCmdChangeSeqdesc> ecmd(new CCmdChangeSeqdesc(seh, *old_desc, *new_desc));
2385  cmd->AddCommand(*ecmd);
2386  success = true;
2387  }
2388  } else if (old_feat) {
2389  CSeq_feat* new_feat = dynamic_cast<CSeq_feat * >(newobj.GetPointer());
2390  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(scope.GetSeq_featHandle(*old_feat), *new_feat)));
2391  success = true;
2392  }
2393 
2394  if (!success) {
2395  cmd.Reset(NULL);
2396  }
2397  return cmd;
2398 }
2399 
2401 {
2402  bool src_prot_name = (GetFeatureSubtype() == CSeqFeatData::eSubtype_prot && IsProductField());
2403  bool dest_prot_name = (other.GetFeatureSubtype() == CSeqFeatData::eSubtype_prot && other.IsProductField());
2404  string prot_product = kEmptyStr;
2405  if (src_prot_name) {
2406  prot_product = GetVal(object.SetObject());
2407  } else if (dest_prot_name) {
2408  prot_product = other.GetVal(object.SetObject());
2409  }
2410 
2411  CRef<CCmdComposite> also_change_mrna = UpdatemRNAProduct(prot_product,
2412  CConstRef<CObject>(&(object.SetObject())),
2413  object.GetSEH().GetScope());
2414  return also_change_mrna;
2415 }
2416 
2417 
2419  CApplyObject& dst_object,
2420  CMiscSeqTableColumn& other,
2421  bool& changed_src)
2422 {
2423  bool src_prot_name = (GetFeatureSubtype() == CSeqFeatData::eSubtype_prot && IsProductField());
2424  bool dest_prot_name = (other.GetFeatureSubtype() == CSeqFeatData::eSubtype_prot && other.IsProductField());
2425  bool dest_mRNA_notproduct = (other.GetFeatureSubtype() == CSeqFeatData::eSubtype_mRNA && (!other.IsProductField()));
2427  string prot_product = kEmptyStr;
2428  CRef<CCmdComposite> also_change_mrna(NULL);
2429  if (src_prot_name) {
2430  prot_product = GetVal(src_object.SetObject());
2431  if (dest_mRNA_notproduct) {
2432  CSeq_feat* mrna = dynamic_cast<CSeq_feat*>(&(dst_object.SetObject()));
2433  if (mrna && mrna->GetData().IsRna()) {
2434  string remainder;
2435  SetRnaProductName(mrna->SetData().SetRna(), prot_product, remainder, eExistingText_replace_old);
2436  }
2437  } else {
2438  also_change_mrna.Reset(UpdatemRNAProduct(prot_product,
2439  CConstRef<CObject>(&(src_object.SetObject())),
2440  src_object.GetSEH().GetScope()));
2441  }
2442  } else if (dest_prot_name) {
2443  prot_product = other.GetVal(dst_object.SetObject()); // the updated protein name
2444  if (src_notmRNA_product) {
2445  also_change_mrna.Reset(UpdatemRNAProduct(prot_product,
2446  CConstRef<CObject>(&(dst_object.SetObject())),
2447  src_object.GetSEH().GetScope()));
2448  } else {
2449  CSeq_feat* mrna = dynamic_cast<CSeq_feat*>(&(src_object.SetObject()));
2450  if (mrna && mrna->GetData().IsRna()) {
2451  string remainder;
2452  SetRnaProductName(mrna->SetData().SetRna(), prot_product, remainder, eExistingText_replace_old);
2453  changed_src = true;
2454  }
2455  }
2456  }
2457  return also_change_mrna;
2458 }
2459 
2460 
2462  EExistingText existing_text, ECapChange cap_change, const bool leave_original,
2463  const string& field_name, const bool update_mrna_product)
2464 {
2466  string val = GetVal(object.SetObject());
2467  RemoveFieldNameFromString(field_name, val);
2468 
2469  CSeq_entry_Handle seh = object.GetSEH().GetTopLevelEntry();
2470  FixCapitalizationInString(seh, val, cap_change);
2471 
2472  string orig_val = other.GetVal(object.SetObject());
2473  CRef<CCmdComposite> also_change_mrna(NULL);
2474  if (other.SetVal(object.SetObject(), val, existing_text)) {
2475  if (update_mrna_product) {
2476  also_change_mrna.Reset(x_GetMrnaUpdate(object, other));
2477  }
2478  if ( ! leave_original ) {
2479  ClearVal(object.SetObject());
2480  }
2481  cmd = GetCommandFromApplyObject(object);
2482  if (also_change_mrna) {
2483  cmd->AddCommand(*also_change_mrna);
2484  }
2485  }
2486  return cmd;
2487 }
2488 
2489 
2491 (CRef<CApplyObject> src_object,
2492  CRef<CApplyObject> dst_object,
2493  CMiscSeqTableColumn& other,
2494  EExistingText existing_text,
2495  ECapChange cap_change,
2496  const bool leave_original,
2497  const string& field_name,
2498  const bool update_mrna_product)
2499 {
2501  if (!src_object || !dst_object) {
2502  return cmd;
2503  }
2504 
2505  if (src_object == dst_object || src_object->GetOriginalObject() == dst_object->GetOriginalObject()) {
2506  return ConvertValCmd(*src_object, other, existing_text, cap_change, leave_original, field_name, update_mrna_product);
2507  }
2508 
2509  string val = GetVal(src_object->SetObject());
2510  RemoveFieldNameFromString(field_name, val);
2511 
2512  CSeq_entry_Handle seh = src_object->GetSEH().GetTopLevelEntry();
2513  FixCapitalizationInString(seh, val, cap_change);
2514 
2515  string orig_val = other.GetVal(dst_object->SetObject());
2516  CRef<CCmdComposite> also_change_mrna(NULL);
2517 
2518  if (other.SetVal(dst_object->SetObject(), val, existing_text)) {
2519  cmd.Reset(new CCmdComposite("Convert value"));
2520  bool changed_src = false;
2521 
2522  if (update_mrna_product) {
2523  also_change_mrna = x_GetMrnaUpdate(*src_object, *dst_object, other, changed_src);
2524  }
2525  if ( ! leave_original) {
2526  ClearVal(src_object->SetObject());
2527  changed_src = true;
2528  }
2529 
2530  if (changed_src) {
2531  CRef<CCmdComposite> change_src = GetCommandFromApplyObject(*src_object);
2532  cmd->AddCommand(*change_src);
2533  }
2534 
2535  CRef<CCmdComposite> change_dst = GetCommandFromApplyObject(*dst_object);
2536  cmd->AddCommand(*change_dst);
2537  if (also_change_mrna) {
2538  cmd->AddCommand(*also_change_mrna);
2539  }
2540  }
2541 
2542  return cmd;
2543 }
2544 
2545 
2547  EExistingText existing_text, bool update_mrna_product)
2548 {
2550 
2551  string val = GetVal(object.SetObject());
2552  CRef<CCmdComposite> also_change_mrna(NULL);
2553  if (other.SetVal(object.SetObject(), val, existing_text)) {
2554  if (update_mrna_product) {
2555  also_change_mrna.Reset(x_GetMrnaUpdate(object, other));
2556  }
2557 
2558  cmd = GetCommandFromApplyObject(object);
2559  if (also_change_mrna) {
2560  cmd->AddCommand(*also_change_mrna);
2561  }
2562  }
2563 
2564  return cmd;
2565 }
2566 
2567 
2569 (CRef<CApplyObject> src_object,
2570  CRef<CApplyObject> dst_object,
2571  CMiscSeqTableColumn& other,
2572  EExistingText existing_text,
2573  bool update_mrna_product)
2574 {
2576  if (!src_object || !dst_object) {
2577  return cmd;
2578  }
2579 
2580  if (src_object == dst_object || src_object->GetOriginalObject() == dst_object->GetOriginalObject()) {
2581  return CopyValCmd(*src_object, other, existing_text, update_mrna_product);
2582  }
2583  string val = GetVal(src_object->SetObject());
2584  string orig_val = other.GetVal(dst_object->SetObject());
2585  CRef<CCmdComposite> also_change_mrna(NULL);
2586 
2587  if (other.SetVal(dst_object->SetObject(), val, existing_text)) {
2588  cmd.Reset(new CCmdComposite("Copy value"));
2589  bool changed_src = false;
2590 
2591  if (update_mrna_product) {
2592  also_change_mrna = x_GetMrnaUpdate(*src_object, *dst_object, other, changed_src);
2593  }
2594 
2595  if (changed_src) {
2596  CRef<CCmdComposite> change_src = GetCommandFromApplyObject(*src_object);
2597  cmd->AddCommand(*change_src);
2598  }
2599 
2600  CRef<CCmdComposite> change_dst = GetCommandFromApplyObject(*dst_object);
2601  cmd->AddCommand(*change_dst);
2602  if (also_change_mrna) {
2603  cmd->AddCommand(*also_change_mrna);
2604  }
2605  }
2606 
2607  return cmd;
2608 }
2609 
2610 
2612  EExistingText existing_text, bool update_mrna_product)
2613 {
2615 
2616  string val1 = GetVal(object.SetObject());
2617  string val2 = other.GetVal(object.SetObject());
2618  bool change = true;
2619  CRef<CCmdComposite> also_change_mrna(NULL);
2620 
2621  if (NStr::IsBlank(val1) && NStr::IsBlank(val2)) {
2622  // do nothing
2623  change = false;
2624  } else if (NStr::IsBlank(val1)) {
2625  ClearVal(object.SetObject());
2626  SetVal(object.SetObject(), val2, eExistingText_replace_old);
2627  other.ClearVal(object.SetObject());
2628  } else if (NStr::IsBlank(val2)) {
2629  other.ClearVal(object.SetObject());
2630  other.SetVal(object.SetObject(), val1, eExistingText_replace_old);
2631  ClearVal(object.SetObject());
2632  } else {
2633  ClearVal(object.SetObject());
2634  SetVal(object.SetObject(), val2, eExistingText_replace_old);
2635  other.ClearVal(object.SetObject());
2636  other.SetVal(object.SetObject(), val1, eExistingText_replace_old);
2637  }
2638 
2639  if (update_mrna_product) {
2640  also_change_mrna.Reset(x_GetMrnaUpdate(object, other));
2641  }
2642 
2643  if (change) {
2644  cmd = GetCommandFromApplyObject(object);
2645  if (also_change_mrna) {
2646  cmd->AddCommand(*also_change_mrna);
2647  }
2648  }
2649  return cmd;
2650 }
2651 
2652 
2654 (CRef<CApplyObject> src_object,
2655  CRef<CApplyObject> dst_object,
2656  CMiscSeqTableColumn& other,
2657  EExistingText existing_text,
2658  bool update_mrna_product)
2659 {
2661  if (!src_object || !dst_object) {
2662  return cmd;
2663  }
2664 
2665  if (src_object == dst_object || src_object->GetOriginalObject() == dst_object->GetOriginalObject()) {
2666  return SwapValCmd(*src_object, other, existing_text, update_mrna_product);
2667  }
2668  string val1 = GetVal(src_object->SetObject());
2669  string val2 = other.GetVal(dst_object->SetObject());
2670 
2671  bool change = true;
2672  if (NStr::IsBlank(val1) && NStr::IsBlank(val2)) {
2673  // do nothing
2674  change = false;
2675  } else if (NStr::IsBlank(val1)) {
2676  ClearVal(src_object->SetObject());
2677  SetVal(src_object->SetObject(), val2, eExistingText_replace_old);
2678  other.ClearVal(dst_object->SetObject());
2679  } else if (NStr::IsBlank(val2)) {
2680  other.ClearVal(dst_object->SetObject());
2681  other.SetVal(dst_object->SetObject(), val1, eExistingText_replace_old);
2682  ClearVal(src_object->SetObject());
2683  } else {
2684  ClearVal(src_object->SetObject());
2685  SetVal(src_object->SetObject(), val2, eExistingText_replace_old);
2686  other.ClearVal(dst_object->SetObject());
2687  other.SetVal(dst_object->SetObject(), val1, eExistingText_replace_old);
2688  }
2689 
2690  CRef<CCmdComposite> also_change_mrna(NULL);
2691  if (change && update_mrna_product) {
2692  bool changed_src = false;
2693  also_change_mrna = x_GetMrnaUpdate(*src_object, *dst_object, other, changed_src);
2694  }
2695 
2696  if (change) {
2697  cmd.Reset(new CCmdComposite("Swap Values"));
2698  CRef<CCmdComposite> change_src = GetCommandFromApplyObject(*src_object);
2699  cmd->AddCommand(*change_src);
2700 
2701  CRef<CCmdComposite> change_dst = GetCommandFromApplyObject(*dst_object);
2702  cmd->AddCommand(*change_dst);
2703  if (also_change_mrna) {
2704  cmd->AddCommand(*also_change_mrna);
2705  }
2706  }
2707 
2708  return cmd;
2709 }
2710 
2711 
2713  const CParseTextOptions& parse_options, EExistingText existing_text,
2714  bool update_mrna_product)
2715 {
2717 
2718  string val1 = GetVal(object.SetObject());
2719  string val2 = parse_options.GetSelectedText(val1);
2720  if (NStr::IsBlank(val2)) {
2721  return cmd;
2722  }
2723 
2724  other.SetVal(object.SetObject(), val2, existing_text);
2725  if (parse_options.ShouldRemoveFromParsed()) {
2726  parse_options.RemoveSelectedText(val1);
2727  if (NStr::IsBlank(val1)) {
2728  ClearVal(object.SetObject());
2729  } else {
2730  SetVal(object.SetObject(), val1, eExistingText_replace_old);
2731  }
2732  }
2733 
2734  CRef<CCmdComposite> also_change_mrna(NULL);
2735  if (update_mrna_product) {
2736  also_change_mrna.Reset(x_GetMrnaUpdate(object, other));
2737  }
2738 
2739  cmd = GetCommandFromApplyObject(object);
2740  if (also_change_mrna) {
2741  cmd->AddCommand(*also_change_mrna);
2742  }
2743 
2744  return cmd;
2745 }
2746 
2747 
2749 (CRef<CApplyObject> src_object,
2750  CRef<CApplyObject> dst_object,
2751  CMiscSeqTableColumn& other,
2752  const CParseTextOptions& parse_options,
2753  EExistingText existing_text,
2754  bool update_mrna_product)
2755 {
2757  if (!src_object || !dst_object) {
2758  return cmd;
2759  }
2760 
2761  if (src_object == dst_object || src_object->GetOriginalObject() == dst_object->GetOriginalObject()) {
2762  return ParseValCmd(*src_object, other, parse_options, existing_text, update_mrna_product);
2763  }
2764  string val1 = GetVal(src_object->SetObject());
2765  string val2 = parse_options.GetSelectedText(val1);
2766 
2767  if (NStr::IsBlank(val2)) {
2768  return cmd;
2769  }
2770 
2771  other.SetVal(dst_object->SetObject(), val2, existing_text);
2772 
2773  bool changed_src = false;
2774  if (parse_options.ShouldRemoveFromParsed()) {
2775  parse_options.RemoveSelectedText(val1);
2776  if (NStr::IsBlank(val1)) {
2777  ClearVal(src_object->SetObject());
2778  } else {
2779  SetVal(src_object->SetObject(), val1, eExistingText_replace_old);
2780  }
2781  changed_src = true;
2782  }
2783 
2784  cmd.Reset(new CCmdComposite("Parse Value"));
2785  CRef<CCmdComposite> also_change_mrna(NULL);
2786  if (update_mrna_product) {
2787  also_change_mrna = x_GetMrnaUpdate(*src_object, *dst_object, other, changed_src);
2788  }
2789 
2790  if (changed_src) {
2791  CRef<CCmdComposite> change_src = GetCommandFromApplyObject(*src_object);
2792  cmd->AddCommand(*change_src);
2793  }
2794 
2795  CRef<CCmdComposite> change_dst = GetCommandFromApplyObject(*dst_object);
2796  cmd->AddCommand(*change_dst);
2797  if (also_change_mrna) {
2798  cmd->AddCommand(*also_change_mrna);
2799  }
2800 
2801  return cmd;
2802 }
2803 
2804 
2805 string CMiscSeqTableColumn::IsValid(const string& val)
2806 {
2807  string error = "";
2808  if (m_Src) {
2809  vector<string> values;
2810  values.push_back(val);
2811  vector<string> problems = m_Src->IsValid(values);
2812  if (problems.size() > 0) {
2813  error = problems[0];
2814  }
2815  } else if (m_FieldHandler) {
2816  error = m_FieldHandler->IsValid(val);
2817  } else if (m_Feature) {
2818  vector<string> values;
2819  values.push_back(val);
2820  vector<string> problems = m_Feature->IsValid(values);
2821  if (problems.size() > 0) {
2822  error = problems[0];
2823  }
2824  }
2825  return error;
2826 }
2827 
2828 
2829 vector<string> CMiscSeqTableColumn::IsValid(const vector<string>& values)
2830 {
2831  vector<string> problems;
2832  if (m_Src) {
2833  problems = m_Src->IsValid(values);
2834  } else if (m_FieldHandler) {
2835  problems = m_FieldHandler->IsValid(values);
2836  } else if (m_Feature) {
2837  problems = m_Feature->IsValid(values);
2838  }
2839  return problems;
2840 }
2841 
2842 
2843 int CMiscSeqTableColumn::CountConflicts(const CObject& obj, const string& val)
2844 {
2845  int conflicts = 0;
2846  vector<string> curr_vals = GetVals(obj);
2847  ITERATE(vector<string>, it, curr_vals) {
2848  if (!NStr::IsBlank(*it) && !NStr::Equal(val, *it)) {
2849  conflicts++;
2850  }
2851  }
2852  return conflicts;
2853 }
2854 
2855 
2857 {
2858  int conflicts = 0;
2859 
2860  if (objs.empty() || NStr::IsBlank(val)) {
2861  return 0;
2862  }
2863  ITERATE(set<CConstRef<CObject> >, it, objs) {
2864  if (*it) {
2865  conflicts += CountConflicts(**it, val);
2866  }
2867  }
2868  return conflicts;
2869 }
2870 
2871 
2873 {
2874  if (m_Feature) {
2875  return m_Feature->GetSubtype();
2876  } else {
2878  }
2879 }
2880 
2881 
2883 {
2884  if (m_FieldHandler) {
2885  return m_FieldHandler->GetDescriptorSubtype();
2886  } else {
2887  return CSeqdesc::e_not_set;
2888  }
2889 }
2890 
2891 
2893 {
2894  if (m_Src) {
2895  m_Src->SetConstraint(field, string_constraint);
2896  } else if (m_FieldHandler) {
2897  m_FieldHandler->SetConstraint(field, string_constraint);
2898  }
2899 }
2900 
2901 
2903 {
2904  bool rval = false;
2905  if (m_Src) {
2906  rval = m_Src->AllowMultipleValues();
2907  } else if (m_FieldHandler) {
2908  rval = m_FieldHandler->AllowMultipleValues();
2909  } else if (m_Feature) {
2910  rval = m_Feature->AllowMultipleValues();
2911  }
2912 
2913  return rval;
2914 }
2915 
2916 
2917 void AddMiscColumnsToTable(CRef<CSeq_table> table, const vector<string> &fields, CSeq_entry_Handle entry)
2918 {
2919  TMiscSeqTableColumnList field_list;
2920  vector<CRef<CSeqTable_column> > column_list;
2921 
2922  ITERATE (vector<string>, sit, fields) {
2924  field_list.push_back(col);
2925  column_list.push_back(AddStringColumnToTable(table, *sit));
2926  }
2927 
2928  for (int row = 0; row < table->GetNum_rows(); row++) {
2929  CBioseq_Handle bsh = entry.GetScope().GetBioseqHandle(*(table->GetColumns()[0]->GetData().GetId()[row]));
2930  size_t col_num = 0;
2931  NON_CONST_ITERATE (TMiscSeqTableColumnList, it, field_list) {
2932  if ((*it)->IsFeature()) {
2933  //TODO if this is a feature, need to add feature ID to table
2934  } else {
2935  vector<CConstRef< CObject> > objects = (*it)->GetObjects(bsh);
2936  if (objects.size() > 0) {
2937  string val = (*it)->GetVal(*objects[0]);
2938  AddValueToColumn(column_list[col_num], val, row);
2939  }
2940  }
2941  col_num++;
2942  }
2943  }
2945 }
2946 
2947 static size_t s_GetMaxRows(const vector<size_t> &rows)
2948 {
2949  size_t max_rows = 0;
2950  for (size_t i = 0; i < rows.size(); i++)
2951  if (rows[i] > max_rows)
2952  max_rows = rows[i];
2953  return max_rows;
2954 }
2955 
2957 {
2959 
2960  int top_id = FindHighestFeatureId(entry);
2961 
2962  // first column is sequence ID
2965  id_col->SetHeader().SetTitle(kSequenceIdColLabel);
2966  table->SetColumns().push_back(id_col);
2967 
2968  TMiscSeqTableColumnList field_list;
2969  vector<CRef<CSeqTable_column> > column_list;
2970 
2971  ITERATE (vector<string>, sit, fields) {
2973  field_list.push_back(col);
2974  column_list.push_back(AddStringColumnToTable(table, *sit));
2975  }
2976 
2977  CBioseq_CI bi(entry, objects::CSeq_inst::eMol_na);
2978  vector<size_t> rows(field_list.size(),0);
2979  while (bi) {
2980  size_t row1 = s_GetMaxRows(rows);
2981  size_t col_num = 0;
2982  NON_CONST_ITERATE (TMiscSeqTableColumnList, it, field_list) {
2983  vector<CConstRef< CObject> > objects = (*it)->GetObjects(*bi);
2984  for (size_t i = 0; i < objects.size(); i++) {
2985  string val = (*it)->GetVal(*objects[i]);
2986  AddValueToColumn(column_list[col_num], val, rows[col_num]);
2987  rows[col_num]++;
2988  }
2989  col_num++;
2990  }
2991  size_t row2 = s_GetMaxRows(rows);
2992  for (size_t i = row1; i < row2; i++)
2993  {
2995  CRef<CSeq_id> id(new objects::CSeq_id());
2996  id->Assign(*(best.GetSeqId()));
2997  table->SetColumns()[0]->SetData().SetId().push_back(id);
2998  }
2999  for (size_t i = 0; i < field_list.size(); i++)
3000  rows[i] = row2;
3001  ++bi;
3002  }
3003 
3004  size_t row = s_GetMaxRows(rows);
3005  table->SetNum_rows(static_cast<CSeq_table::TNum_rows>(row));
3007  return table;
3008 }
3009 
3010 void x_AdjustListPair (vector<CRef<CApplyObject> > prev_list, vector<CRef<CApplyObject> > this_list)
3011 {
3012  NON_CONST_ITERATE(vector<CRef<CApplyObject> >, t, this_list) {
3013  NON_CONST_ITERATE(vector<CRef<CApplyObject> >, p, prev_list) {
3014  if ((*t)->GetOriginalObject() == (*p)->GetOriginalObject()) {
3015  (*t)->ReplaceEditable((*p)->SetObject());
3016  break;
3017  }
3018  }
3019  }
3020 }
3021 
3023 {
3024  string rval = "";
3025 
3026  string ur = "";
3027  string sep = "";
3028 
3029  switch (existing) {
3031  ur = "replace";
3032  break;
3034  ur = "append";
3035  sep = ";";
3036  break;
3038  ur = "append";
3039  sep = " ";
3040  break;
3042  ur = "append";
3043  sep = ":";
3044  break;
3046  ur = "append";
3047  sep = ",";
3048  break;
3050  ur = "append";
3051  sep = "";
3052  break;
3054  ur = "prefix";
3055  sep = ";";
3056  break;
3058  ur = "prefix";
3059  sep = " ";
3060  break;
3062  ur = "prefix";
3063  sep = ":";
3064  break;
3066  ur = "prefix";
3067  sep = ",";
3068  break;
3070  ur = "prefix";
3071  sep = "";
3072  break;
3074  ur = "ignore";
3075  sep = "";
3076  break;
3078  ur = "add_new_qual";
3079  sep = "";
3080  break;
3081  case eExistingText_cancel:
3082  break;
3083  }
3084 
3085  if (!NStr::IsBlank(ur)) {
3086  rval = "&update_rule=" + ur + "&text_separator=" + sep;
3087  }
3088 
3089  return rval;
3090 }
3091 
3092 string MakeTableMetaInfoString(EExistingText rule, bool erase_blanks)
3093 {
3094  string value = GetExistingTextInstruction(rule);
3095  value += "&blanks=";
3096  if (erase_blanks) {
3097  value += "erase";
3098  } else {
3099  value += "ignore";
3100  }
3101 
3102  return value;
3103 }
3104 
3105 
3107 {
3108  CRef<CUser_field> field(new CUser_field());
3109  field->SetData().SetStr(MakeTableMetaInfoString(rule, erase_blanks));
3110  return field;
3111 }
3112 
3113 
3114 vector<CConstRef<CSeq_feat> > s_GetProtFeatures(CBioseq_Handle p_bsh, CSeqFeatData::ESubtype constraint_type)
3115 {
3116  vector<CConstRef<CSeq_feat> > feat_list;
3117  if (p_bsh) {
3118  CFeat_CI f(p_bsh, constraint_type);
3119  while (f) {
3120  CConstRef<CSeq_feat> object;
3121  object.Reset(f->GetOriginalSeq_feat());
3122  feat_list.push_back(object);
3123  ++f;
3124  }
3125  }
3126  return feat_list;
3127 }
3128 
3129 
3130 vector<CConstRef<CSeq_feat> > GetRelatedFeatures (const CSeq_feat& obj_feat, CSeqFeatData::ESubtype constraint_type, CRef<CScope> scope)
3131 {
3132  vector<CConstRef<CSeq_feat> > feat_list;
3133 
3134  CSeqFeatData::ESubtype obj_type = obj_feat.GetData().GetSubtype();
3135 
3136  // is one feature type a protein and the other not?
3137  bool obj_is_prot = (CSeqFeatData::GetTypeFromSubtype(obj_type) == CSeqFeatData::e_Prot);
3138  bool constraint_is_prot = (CSeqFeatData::GetTypeFromSubtype(constraint_type) == CSeqFeatData::e_Prot);
3139  if (obj_is_prot && constraint_is_prot) {
3140  // find feature anywhere on protein sequence
3141  CBioseq_Handle p_bsh = scope->GetBioseqHandle(obj_feat.GetLocation());
3142  feat_list = s_GetProtFeatures(p_bsh, constraint_type);
3143  } else if (obj_is_prot && !constraint_is_prot) {
3144  // use coding region for starting point of overlap comparison
3145  CBioseq_Handle p_bsh = scope->GetBioseqHandle(obj_feat.GetLocation());
3146  const CSeq_feat* cds = sequence::GetCDSForProduct(p_bsh);
3147  if (cds) {
3149  feat_list.push_back(CConstRef<CSeq_feat>(cds));
3150  } else {
3151  feat_list = GetRelatedFeatures(*cds, constraint_type, scope);
3152  }
3153  }
3154  } else if (!obj_is_prot && constraint_is_prot) {
3155  // examine objects on protein sequence
3156  // need to find coding region for obj_feat
3157  if (obj_type == CSeqFeatData::eSubtype_cdregion) {
3158  if (obj_feat.IsSetProduct()) {
3159  CBioseq_Handle p_bsh = scope->GetBioseqHandle(obj_feat.GetProduct());
3160  feat_list = s_GetProtFeatures(p_bsh, constraint_type);
3161  }
3162  } else if (obj_type == CSeqFeatData::eSubtype_mRNA) {
3163  const CSeq_feat* cds = sequence::GetBestCdsForMrna(obj_feat, *scope);
3164  if (cds) {
3165  feat_list = GetRelatedFeatures(*cds, constraint_type, scope);
3166  }
3167  } else if (obj_type == CSeqFeatData::eSubtype_gene) {
3168  sequence::TFeatScores scores;
3173  scores, *scope);
3174  ITERATE (sequence::TFeatScores, it, scores) {
3175  vector<CConstRef<CSeq_feat> > this_list = GetRelatedFeatures(*(it->second), constraint_type, scope);
3176  feat_list.insert(feat_list.end(), this_list.begin(), this_list.end());
3177  }
3178  }
3179  } else {
3180  // neither is a protein
3181  if (constraint_type == CSeqFeatData::eSubtype_gene) {
3183  if (f) {
3184  feat_list.push_back(f);
3185  }
3186  } else if (obj_type == CSeqFeatData::eSubtype_gene) {
3187  sequence::TFeatScores scores;
3189  CSeqFeatData::GetTypeFromSubtype(constraint_type),
3190  constraint_type,
3192  scores, *scope);
3193  ITERATE (sequence::TFeatScores, it, scores) {
3194  feat_list.push_back(it->second);
3195  }
3196  } else if (obj_type == CSeqFeatData::eSubtype_cdregion
3197  && constraint_type == CSeqFeatData::eSubtype_mRNA) {
3199  if (f) {
3200  feat_list.push_back(f);
3201  }
3202  } else if (constraint_type == CSeqFeatData::eSubtype_any || constraint_type == obj_type) {
3203  CConstRef<CSeq_feat> f(&obj_feat);
3204  feat_list.push_back(f);
3205  }
3206  }
3207  return feat_list;
3208 }
3209 
3210 
3211 vector<CRef<CApplyObject> > s_GetProtApplyObjectsFeatures(CBioseq_Handle p_bsh, CSeqFeatData::ESubtype constraint_type)
3212 {
3213  vector<CRef<CApplyObject> > feat_list;
3214  if (p_bsh) {
3215  CFeat_CI f(p_bsh, constraint_type);
3216  while (f) {
3217  CRef<CApplyObject> p(new CApplyObject(p_bsh, *(f->GetOriginalSeq_feat())));
3218  feat_list.push_back(p);
3219  ++f;
3220  }
3221  }
3222  if (feat_list.empty() &&
3223  (constraint_type == CSeqFeatData::eSubtype_any || constraint_type == CSeqFeatData::eSubtype_prot)) {
3224  CSeq_entry_Handle seh = p_bsh.GetSeq_entry_Handle();
3225  CRef<CSeq_feat> new_feat(new CSeq_feat());
3226  CRef<CSeq_id> id(new CSeq_id());
3227  id->Assign(*(p_bsh.GetId().front().GetSeqId()));
3228  new_feat->SetLocation().SetInt().SetId(*id);
3229  new_feat->SetLocation().SetInt().SetFrom(0);
3230  new_feat->SetLocation().SetInt().SetTo(p_bsh.GetInst_Length() - 1);
3231  new_feat->SetData().SetProt();
3232  const CSeq_feat* cds = sequence::GetCDSForProduct(p_bsh);
3233  if (cds) {
3235  }
3236  CRef<CObject> new_obj(new_feat.GetPointer());
3237  feat_list.push_back(CRef<CApplyObject>(new CApplyObject(seh, CConstRef<CObject>(NULL), new_obj)));
3238  }
3239  return feat_list;
3240 }
3241 
3242 
3243 vector<CRef<CApplyObject> > GetRelatedFeatureApplyObjects (const CSeq_feat& obj_feat, CSeqFeatData::ESubtype constraint_type, CRef<CScope> scope)
3244 {
3245  vector<CRef<CApplyObject> > feat_list;
3246 
3247  CSeqFeatData::ESubtype obj_type = obj_feat.GetData().GetSubtype();
3248 
3249  // is one feature type a protein and the other not?
3250  bool obj_is_prot = (CSeqFeatData::GetTypeFromSubtype(obj_type) == CSeqFeatData::e_Prot);
3251  bool constraint_is_prot = (CSeqFeatData::GetTypeFromSubtype(constraint_type) == CSeqFeatData::e_Prot);
3252  if (obj_is_prot && constraint_is_prot) {
3253  // find feature anywhere on protein sequence
3254  CBioseq_Handle p_bsh = scope->GetBioseqHandle(obj_feat.GetLocation());
3255  feat_list = s_GetProtApplyObjectsFeatures(p_bsh, constraint_type);
3256  } else if (obj_is_prot && !constraint_is_prot) {
3257  // use coding region for starting point of overlap comparison
3258  CBioseq_Handle p_bsh = scope->GetBioseqHandle(obj_feat.GetLocation());
3259  const CSeq_feat* cds = sequence::GetCDSForProduct(p_bsh);
3260  if (cds) {
3262  CBioseq_Handle c_bsh = scope->GetBioseqHandle(cds->GetLocation());
3263  CRef<CApplyObject> p(new CApplyObject(c_bsh, *cds));
3264  feat_list.push_back(p);
3265  } else {
3266  feat_list = GetRelatedFeatureApplyObjects(*cds, constraint_type, scope);
3267  }
3268  }
3269  } else if (!obj_is_prot && constraint_is_prot) {
3270  // examine objects on protein sequence
3271  // need to find coding region for obj_feat
3272  if (obj_type == CSeqFeatData::eSubtype_cdregion) {
3273  CBioseq_Handle p_bsh = scope->GetBioseqHandle(obj_feat.GetProduct());
3274  feat_list = feat_list = s_GetProtApplyObjectsFeatures(p_bsh, constraint_type);
3275  } else if (obj_type == CSeqFeatData::eSubtype_mRNA) {
3276  const CSeq_feat* cds = sequence::GetBestCdsForMrna(obj_feat, *scope);
3277  if (cds) {
3278  feat_list = GetRelatedFeatureApplyObjects(*cds, constraint_type, scope);
3279  }
3280  } else if (obj_type == CSeqFeatData::eSubtype_gene) {
3281  sequence::TFeatScores scores;
3286  scores, *scope);
3287  ITERATE (sequence::TFeatScores, it, scores) {
3288  vector<CRef<CApplyObject> > this_list = GetRelatedFeatureApplyObjects(*(it->second), constraint_type, scope);
3289  feat_list.insert(feat_list.end(), this_list.begin(), this_list.end());
3290  }
3291  }
3292  } else {
3293  // neither is a protein
3294  if (constraint_type == CSeqFeatData::eSubtype_gene) {
3296  if (f) {
3297  CBioseq_Handle f_bsh = scope->GetBioseqHandle(f->GetLocation());
3298  CRef<CApplyObject> p(new CApplyObject(f_bsh, *f));
3299  feat_list.push_back(p);
3300  } else {
3301  // create new gene for feature
3303  CRef<CSeq_feat> new_feat(new CSeq_feat());
3304  new_feat->SetLocation().Assign(*(obj_feat.GetLocation().Merge(CSeq_loc::fMerge_SingleRange, NULL)));
3305  new_feat->SetData().SetGene();
3306  CRef<CObject> new_obj(new_feat.GetPointer());
3307  feat_list.push_back(CRef<CApplyObject>(new CApplyObject(seh, CConstRef<CObject>(NULL), new_obj)));
3308  }
3309  } else if (obj_type == CSeqFeatData::eSubtype_gene) {
3310  sequence::TFeatScores scores;
3312  CSeqFeatData::GetTypeFromSubtype(constraint_type),
3313  constraint_type,
3315  scores, *scope);
3316  ITERATE (sequence::TFeatScores, it, scores) {
3317  CBioseq_Handle f_bsh = scope->GetBioseqHandle(it->second->GetLocation());
3318  CRef<CApplyObject> p(new CApplyObject(f_bsh, *(it->second)));
3319  feat_list.push_back(p);
3320  }
3321 
3322  } else if (obj_type == CSeqFeatData::eSubtype_cdregion
3323  && constraint_type == CSeqFeatData::eSubtype_mRNA) {
3325  if (f) {
3326  CBioseq_Handle f_bsh = scope->GetBioseqHandle(f->GetLocation());
3327  CRef<CApplyObject> p(new CApplyObject(f_bsh, *f));
3328  feat_list.push_back(p);
3329  }
3330  } else if (constraint_type == CSeqFeatData::eSubtype_any || constraint_type == obj_type) {
3331  CBioseq_Handle f_bsh = scope->GetBioseqHandle(obj_feat.GetLocation());
3332  CRef<CApplyObject> p(new CApplyObject(f_bsh, obj_feat));
3333  feat_list.push_back(p);
3334  }
3335  }
3336  return feat_list;
3337 }
3338 
3339 
3340 
3341 
3342 vector<CConstRef<CObject> > CMiscSeqTableColumn::GetRelatedObjects(const CObject& object, CRef<CScope> scope)
3343 {
3344  vector<CConstRef<CObject> > related;
3345 
3346  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&object);
3347  const CSeq_feat * obj_feat = dynamic_cast<const CSeq_feat *>(&object);
3348  const CBioseq * bioseq = dynamic_cast<const CBioseq *>(&object);
3349 
3350  if (bioseq) {
3351  CBioseq_Handle bsh = scope->GetBioseqHandle(*bioseq);
3352  if (bsh) {
3353  related = GetObjects(bsh);
3354  }
3355  } else if (IsSource()) {
3356  if (obj_desc) {
3357  if (obj_desc->IsSource()) {
3358  CConstRef<CObject> obj(obj_desc);
3359  related.push_back(obj);
3360  } else {
3361  // find closest related BioSource
3362  CSeq_entry_Handle seh = edit::GetSeqEntryForSeqdesc(scope, *obj_desc);
3363  if (seh && obj_desc->IsTitle()) {
3364  CBioseq_set_Handle parent = seh.GetParentBioseq_set();
3365  if (parent && parent.IsSetClass() && parent.GetClass() == CBioseq_set::eClass_nuc_prot) {
3366  seh = parent.GetParentEntry();
3367  }
3368  }
3369  if (seh) {
3370  related = GetObjects(seh, "", CRef<edit::CStringConstraint>(NULL));
3371  }
3372  }
3373  } else if (obj_feat) {
3374  if (obj_feat->IsSetData() && obj_feat->GetData().IsBiosrc()) {
3375  CConstRef<CObject> obj(obj_feat);
3376  related.push_back(obj);
3377  } else {
3378  // find closest related BioSource
3379  CBioseq_Handle bsh = scope->GetBioseqHandle(obj_feat->GetLocation());
3380  if (bsh) {
3381  related = GetObjects(bsh);
3382  }
3383  }
3384  }
3385  } else if (m_FieldHandler) {
3386  related = m_FieldHandler->GetRelatedObjects(object, scope);
3387  } else if (IsFeature()) {
3388  if (obj_feat) {
3389  CSeqFeatData::ESubtype constraint_type = GetFeatureSubtype();
3390  CSeqFeatData::ESubtype obj_type = obj_feat->GetData().GetSubtype();
3391  if (obj_type == constraint_type) {
3392  CConstRef<CObject> obj(obj_feat);
3393  related.push_back(obj);
3394  } else {
3395  vector<CConstRef<CSeq_feat> > feat_list = GetRelatedFeatures(*obj_feat, constraint_type, scope);
3396  related.insert(related.end(), feat_list.begin(), feat_list.end());
3397  }
3398  } else if (obj_desc) {
3399  // find related feature
3400  CSeq_entry_Handle seh = edit::GetSeqEntryForSeqdesc(scope, *obj_desc);
3401  if (seh && obj_desc->IsTitle()) {
3402  CBioseq_set_Handle parent = seh.GetParentBioseq_set();
3403  if (parent && parent.IsSetClass() && parent.GetClass() == CBioseq_set::eClass_nuc_prot) {
3404  seh = parent.GetParentEntry();
3405  }
3406  }
3407  if (seh) {
3409  while (f) {
3410  CConstRef<CObject> obj(f->GetOriginalSeq_feat());
3411  related.push_back(obj);
3412  ++f;
3413  }
3414  }
3415  }
3416  }
3417 
3418 
3419  return related;
3420 }
3421 
3422 
3423 vector<CConstRef<CObject> > CMiscSeqTableColumn::GetRelatedObjects(const CApplyObject& object)
3424 {
3425  vector<CConstRef<CObject> > related;
3426 
3427  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&(object.GetObject()));
3428  const CSeq_feat * obj_feat = dynamic_cast<const CSeq_feat *>(&(object.GetObject()));
3429  const CBioseq * bioseq = dynamic_cast<const CBioseq *>(&(object.GetObject()));
3430  const CSeq_inst * inst = dynamic_cast<const CSeq_inst *>(&(object.GetObject()));
3431 
3432  if (bioseq || inst) {
3433  related = GetObjects(object.GetSEH().GetSeq());
3434  } else if (IsSource()) {
3435  if (obj_desc) {
3436  if (obj_desc->IsSource()) {
3437  CConstRef<CObject> obj(obj_desc);
3438  related.push_back(obj);
3439  } else {
3440  // find closest related BioSource
3441  CSeq_entry_Handle seh = object.GetSEH();
3442  if (seh && obj_desc->IsTitle()) {
3443  CBioseq_set_Handle parent = seh.GetParentBioseq_set();
3444  if (parent && parent.IsSetClass() && parent.GetClass() == CBioseq_set::eClass_nuc_prot) {
3445  seh = parent.GetParentEntry();
3446  }
3447  }
3448  if (seh) {
3449  related = GetObjects(seh, "", CRef<edit::CStringConstraint>(NULL));
3450  }
3451  }
3452  } else if (obj_feat) {
3453  if (obj_feat->IsSetData() && obj_feat->GetData().IsBiosrc()) {
3454  CConstRef<CObject> obj(obj_feat);
3455  related.push_back(obj);
3456  } else {
3457  // find closest related BioSource
3458  related = GetObjects(object.GetSEH(), "", CRef<edit::CStringConstraint>(NULL));
3459  }
3460  }
3461  } else if (m_FieldHandler) {
3462  related = m_FieldHandler->GetRelatedObjects(object);
3463  } else if (IsFeature()) {
3464  if (obj_feat) {
3465  CSeqFeatData::ESubtype constraint_type = GetFeatureSubtype();
3467  CSeqFeatData::ESubtype obj_type = obj_feat->GetData().GetSubtype();
3468  CSeqFeatData::E_Choice obj_major_type = obj_feat->GetData().Which();
3469  if (obj_type == constraint_type ||
3470  (constraint_type == CSeqFeatData::eSubtype_bad && major_type == obj_major_type)) {
3471  CConstRef<CObject> obj(obj_feat);
3472  related.push_back(obj);
3473  } else {
3474  CRef<CScope> scope(&(object.GetSEH().GetScope()));
3475  vector<CConstRef<CSeq_feat> > feat_list = GetRelatedFeatures(*obj_feat, constraint_type, scope);
3476  related.insert(related.end(), feat_list.begin(), feat_list.end());
3477  }
3478  } else if (obj_desc) {
3479  // find related feature
3480  CSeq_entry_Handle seh = object.GetSEH();
3481  if (seh && obj_desc->IsTitle()) {
3482  CBioseq_set_Handle parent = seh.GetParentBioseq_set();
3483  if (parent && parent.IsSetClass() && parent.GetClass() == CBioseq_set::eClass_nuc_prot) {
3484  seh = parent.GetParentEntry();
3485  }
3486  }
3487  if (seh) {
3489  while (f) {
3490  CConstRef<CObject> obj(f->GetOriginalSeq_feat());
3491  related.push_back(obj);
3492  ++f;
3493  }
3494  }
3495  }
3496  }
3497 
3498 
3499  return related;
3500 }
3501 
3502 
3504 {
3505  if (!seh) {
3506  return seh;
3507  }
3508  CBioseq_set_Handle parent = seh.GetParentBioseq_set();
3509  if (parent && parent.IsSetClass() && parent.GetClass() == CBioseq_set::eClass_nuc_prot) {
3510  seh = parent.GetParentEntry();
3511  }
3512  return seh;
3513 }
3514 
3515 
3516 vector<CRef<CApplyObject> > CMiscSeqTableColumn::GetRelatedApplyObjects(CApplyObject& object)
3517 {
3518  vector<CRef<CApplyObject> > related;
3519 
3520  const CSeqdesc * obj_desc = dynamic_cast<const CSeqdesc *>(&(object.GetObject()));
3521  const CSeq_feat * obj_feat = dynamic_cast<const CSeq_feat *>(&(object.GetObject()));
3522  const CBioseq * bioseq = dynamic_cast<const CBioseq *>(&(object.GetObject()));
3523  const CSeq_inst * inst = dynamic_cast<const CSeq_inst *>(&(object.GetObject()));
3524 
3525  if (bioseq || inst) {
3526  related = GetApplyObjects(object.GetSEH().GetSeq());
3527  } else if (IsSource()) {
3528  if (obj_desc) {
3529  CSeq_entry_Handle seh = object.GetSEH();
3530  if (obj_desc->IsSource()) {
3531  CRef<CApplyObject> obj(&object);
3532  related.push_back(obj);
3533  } else {
3534  // find closest related BioSource
3535  seh = s_GetNPParent(seh);
3536 
3537  if (seh) {
3538  related = GetApplyObjects(seh, "", CRef<CStringConstraint>(NULL));
3539  }
3540  }
3541  } else if (obj_feat) {
3542  if (obj_feat->IsSetData() && obj_feat->GetData().IsBiosrc()) {
3543  CRef<CApplyObject> obj(&object);
3544  related.push_back(obj);
3545  } else {
3546  // find closest related BioSource
3547  CSeq_entry_Handle seh = object.GetSEH();
3548  seh = s_GetNPParent(seh);
3549  if (seh) {
3550  related = GetApplyObjects(seh, "", CRef<CStringConstraint>(NULL));
3551  }
3552  }
3553  }
3554  } else if (m_FieldHandler) {
3555  related = GetApplyObjects(object.GetSEH(), "", CRef<CStringConstraint>(NULL));
3556  } else if (IsFeature()) {
3557  if (obj_feat) {
3558  CSeqFeatData::ESubtype constraint_type = GetFeatureSubtype();
3559  CSeqFeatData::ESubtype obj_type = obj_feat->GetData().GetSubtype();
3560  if (obj_type == constraint_type) {
3561  CRef<CApplyObject> obj(&object);
3562  related.push_back(obj);
3563  } else {
3564  CRef<CScope> scope(&(object.GetSEH().GetScope()));
3565  vector<CRef<CApplyObject> > feat_list = GetRelatedFeatureApplyObjects(*obj_feat, constraint_type, scope);
3566  related.insert(related.end(), feat_list.begin(), feat_list.end());
3567  }
3568  } else if (obj_desc) {
3569  // find related feature
3570  CSeq_entry_Handle seh = object.GetSEH();
3571  CBioseq_set_Handle parent = seh.GetParentBioseq_set();
3572  if (parent && parent.IsSetClass() && parent.GetClass() == CBioseq_set::eClass_nuc_prot) {
3573  seh = parent.GetParentEntry();
3574  }
3575  if (seh) {
3577  while (f) {
3578  CBioseq_Handle bsh = seh.GetBioseqHandle(*(f->GetLocation().GetId()));
3579  CRef<CApplyObject> obj(new CApplyObject(bsh, *(f->GetOriginalSeq_feat())));
3580  related.push_back(obj);
3581  ++f;
3582  }
3583  }
3584  }
3585  }
3586 
3587 
3588  return related;
3589 }
3590 
3591 
3592 bool DoesObjectMatchFieldConstraint (const CObject& object, const string& field_name, CRef<CStringConstraint> string_constraint, CRef<CScope> scope)
3593 {
3594  if (NStr::IsBlank(field_name) || !string_constraint) {
3595  return true;
3596  }
3597  CRef<CMiscSeqTableColumn> col(new CMiscSeqTableColumn(field_name));
3598  if (!col) {
3599  return false;
3600  }
3601 
3602  vector<string> val_list;
3603  vector<CConstRef<CObject> > objs = col->GetRelatedObjects (object, scope);
3604  ITERATE(vector<CConstRef<CObject> >, it, objs) {
3605  vector<string> add = col->GetVals(**it);
3606  val_list.insert(val_list.end(), add.begin(), add.end());
3607  }
3608 
3609  return string_constraint->DoesListMatch(val_list);
3610 }
3611 
3612 
3613 bool DoesApplyObjectMatchFieldConstraint (const CApplyObject& object, const string& field_name, CRef<CStringConstraint> string_constraint)
3614 {
3615  if (NStr::IsBlank(field_name) || !string_constraint) {
3616  return true;
3617  }
3618 
3619  CRef<CMiscSeqTableColumn> col(new CMiscSeqTableColumn(field_name));
3620  if (!col) {
3621  return false;
3622  }
3623  vector<string> val_list;
3624  vector<CConstRef<CObject> > objs = col->GetRelatedObjects (object);
3625 
3626  ITERATE(vector<CConstRef<CObject> >, it, objs) {
3627  vector<string> add = col->GetVals(**it);
3628  val_list.insert(val_list.end(), add.begin(), add.end());
3629  }
3630  return string_constraint->DoesListMatch(val_list);
3631 }
3632 
3633 
3635 {
3636  if (entry.IsSeq()) {
3637  return true;
3638  } else if (entry.IsSet() && entry.GetSet().GetClass() == CBioseq_set::eClass_nuc_prot) {
3639  return true;
3640  } else {
3641  return false;
3642  }
3643 }
3644 
3645 
3647 {
3648  bool rval = false;
3649 
3650  if (IsSeqOrNP(entry)) {
3651  CRef<CSeqdesc> new_desc(new CSeqdesc());
3652  new_desc->Assign(desc);
3653  cmd.AddCommand( *CRef<CCmdCreateDesc>(new CCmdCreateDesc(entry, *new_desc)) );
3654  rval = true;
3655  } else if (entry.IsSet()) {
3657  CSeq_entry_Handle e = entry.GetScope().GetSeq_entryHandle(**it);
3658  rval |= PropagateDescriptor(e, desc, cmd);
3659  }
3660  }
3661  return rval;
3662 }
3663 
3664 
3666 {
3667  bool rval = false;
3668  if (IsSeqOrNP(entry)) {
3669  return false;
3670  }
3671  if (entry.IsSetDescr()) {
3673  if ((*it)->IsUser() && (*it)->GetUser().GetObjectType() == CUser_object::eObjectType_DBLink) {
3674  // propagate to sequences inside the set
3675  bool this_success = PropagateDescriptor(entry, **it, cmd);
3676  if (this_success) {
3677  rval = true;
3678  // remove from this set
3679  cmd.AddCommand(*CRef<CCmdDelDesc>(new CCmdDelDesc(entry, **it)) );
3680  }
3681  }
3682  }
3683  }
3684  return rval;
3685 }
3686 
3687 
3689 {
3690  CRef<CCmdComposite> cmd( new CCmdComposite("PropagateDBLink") );
3691 
3692  bool any = PropagateDBLink(entry, *cmd);
3693 
3694  if (!any) {
3695  cmd.Reset(NULL);
3696  }
3697  return cmd;
3698 }
3699 
3700 
3702 {
3703  CRef<CCmdComposite> cmd(new CCmdComposite("Apply"));
3704  bool any = false;
3705 
3706  CSeqdesc* desc = dynamic_cast<CSeqdesc * >(&(obj.SetObject()));
3707  CSeq_feat* feat = dynamic_cast<CSeq_feat * >(&(obj.SetObject()));
3708  CSeq_inst* inst = dynamic_cast<CSeq_inst * >(&(obj.SetObject()));
3709 
3710  CScope& scope = obj.GetSEH().GetScope();
3711  if (desc) {
3712  if (obj.PreExists()) {
3713  const CSeqdesc* orig_desc = dynamic_cast<const CSeqdesc*>(obj.GetOriginalObject());
3714  if (orig_desc) {
3715  CSeq_entry_Handle seh = edit::GetSeqEntryForSeqdesc(Ref(&scope), *orig_desc);
3716  CRef<CCmdChangeSeqdesc> ecmd(new CCmdChangeSeqdesc(seh, *orig_desc, *desc));
3717  cmd->AddCommand(*ecmd);
3718  }
3719  } else {
3720  cmd->AddCommand( *CRef<CCmdCreateDesc>(new CCmdCreateDesc(obj.GetSEH(), *desc)) );
3721  }
3722  any = true;
3723  } else if (feat) {
3724  if (obj.PreExists()) {
3725  const CSeq_feat* old_feat = dynamic_cast<const CSeq_feat * >(obj.GetOriginalObject());
3726  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(scope.GetSeq_featHandle(*old_feat), *feat)));
3727  } else {
3728  CSeq_entry_Handle seh = obj.GetSEH();
3729  cmd->AddCommand(*CRef<CCmdCreateFeat>(new CCmdCreateFeat(seh, *feat)));
3730  }
3731  any = true;
3732  } else if (inst) {
3733  CCmdChangeBioseqInst* ecmd = new CCmdChangeBioseqInst(obj.GetSEH().GetSeq(), *inst);
3734  cmd->AddCommand (*ecmd);
3735  any = true;
3736  }
3737 
3738  if (!any) {
3739  cmd.Reset(NULL);
3740  }
3741  return cmd;
3742 }
3743 
3745 {
3746  if (!workbench)
3747  return;
3748  IViewManagerService* view_srv = workbench->GetServiceByType<IViewManagerService>();
3749  if (!view_srv) return;
3751  view_srv->GetViews(views);
3753  IProjectView* project_view = dynamic_cast<IProjectView*>((*it).GetPointer());
3754  if (project_view && project_view->GetLabel(IProjectView::eType) == "Text View") {
3755  objects.clear();
3756  project_view->GetActiveObjects(objects);
3757  if (objects.empty())
3758  project_view->GetMainObject(objects);
3759  }
3760  }
3761 
3762  if (objects.empty())
3763  {
3765  CProjectTreeView* projectTree = dynamic_cast<CProjectTreeView*>((*it).GetPointer());
3766  if (projectTree && objects.empty()) {
3767  projectTree->GetSelection(objects);
3768  if (objects.empty())
3769  projectTree->GetSingleObject(objects);
3770  }
3771  }
3772  }
3773 }
3774 
3776 {
3777  int bioseqs = 0;
3779  const CObject* ptr = it->object.GetPointer();
3780  const CSeq_loc* seqloc = dynamic_cast<const CSeq_loc*>(ptr);
3781  const CBioseq* bioseq = dynamic_cast<const CBioseq* >(ptr);
3782  if (seqloc || bioseq) {
3783  bioseqs++;
3784  }
3785  }
3786 
3787  return bioseqs;
3788 }
3789 
3791 {
3792  int NAseqs = 0;
3793  CBioseq_CI b_iter(tse, CSeq_inst::eMol_na);
3794  for (; b_iter; ++b_iter, ++NAseqs);
3795 
3796  if (NAseqs == 1 && objects.size() == 2) {
3797  // it might be scoped on the sequence or on 'Nucleotides'
3798  return false;
3799  }
3800 
3801  int viewed_bseqs = GetNumberOfViewedBioseqs(objects);
3802  return (viewed_bseqs == NAseqs);
3803 }
3804 
3805 bool FocusedOnAll(TConstScopedObjects& objects, const objects::CSeq_entry_Handle& tse)
3806 {
3807  int NAseqs = 0;
3808  CBioseq_CI b_iter(tse, CSeq_inst::eMol_na);
3809  for (; b_iter; ++b_iter, ++NAseqs);
3810 
3811  if (NAseqs == 1 && objects.size() == 2) {
3812  // it might be scoped on the sequence or on 'Nucleotides'
3813  return false;
3814  }
3815 
3816  int viewed_bseqs = GetNumberOfViewedBioseqs(objects);
3817  return (viewed_bseqs > NAseqs);
3818 }
3819 
3820 
static CRef< CScope > m_Scope
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.
CSeq_entry_Handle GetSeqEntryForSeqdesc(CRef< CScope > scope, const CSeqdesc &seq_desc)
bool AdjustProteinFeaturePartialsToMatchCDS(CSeq_feat &new_prot, const CSeq_feat &cds)
AdjustProteinFeaturePartialsToMatchCDS A function to change an existing MolInfo to match a coding reg...
Definition: cds_fix.cpp:398
CObject & SetObject()
CSeq_entry_Handle GetSEH() const
bool PreExists() const
const CObject * GetOriginalObject() const
virtual vector< CConstRef< CObject > > GetRelatedObjects(const CObject &object, CRef< objects::CScope > scope)
virtual vector< CConstRef< CObject > > GetObjects(objects::CBioseq_Handle bsh)
virtual string GetVal(const CObject &object)
virtual vector< string > GetVals(const CObject &object)
virtual vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(objects::CBioseq_Handle bsh)
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
CBioseq_set_Handle –.
const CSeq_id * GetLocalId() const
Find a local ID if present.
Definition: Bioseq.cpp:336
virtual bool SetVal(CObject &object, const string &val, objects::edit::EExistingText existing_text)
virtual string GetVal(const CObject &object)
virtual bool IsEmpty(const CObject &object) const
virtual void ClearVal(CObject &object)
virtual vector< string > GetVals(const CObject &object)
static string MakeSuffixFromRoot(const string &root)
static string MakePrefixFromRoot(const string &root)
static void NormalizePrefix(string &prefix)
static string GetStructuredCommentPrefix(const CUser_object &user, bool normalize=true)
static bool IsStructuredComment(const CUser_object &user)
static vector< string > GetFieldNames(const string &prefix)
static EDBLinkFieldType GetTypeForLabel(string label)
void GetLabel(string *label) const
Definition: Dbtag.cpp:187
virtual string GetVal(const CObject &object)
virtual vector< string > GetVals(const CObject &object)
virtual bool SetVal(CObject &object, const string &val, objects::edit::EExistingText existing_text)
virtual bool IsEmpty(const CObject &object) const
virtual void ClearVal(CObject &object)
CFeat_CI –.
Definition: feat_ci.hpp:64
static CRef< CFeatureSeqTableColumnBase > Create(const string &sTitle, objects::CSeqFeatData::ESubtype subtype=objects::CSeqFeatData::eSubtype_any)
virtual vector< CConstRef< CObject > > GetObjects(objects::CBioseq_Handle bsh)
virtual bool AllowMultipleValues()
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
void SetMajorType(objects::CSeqFeatData::E_Choice major_type)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
objects::CSeqFeatData::E_Choice GetMajorType()
void SetScope(CRef< CScope > scope)
virtual vector< string > IsValid(const vector< string > &values)
virtual vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(objects::CBioseq_Handle bsh)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
virtual string GetLabel() const
objects::CSeqFeatData::ESubtype GetSubtype()
static CRef< ncbi::CFieldHandler > Create(const string &field_name)
virtual string GetVal(const CObject &object)
virtual bool IsEmpty(const CObject &object) const
bool x_IsNCBIFILEId(const objects::CSeq_id &seq_id)
void SetFormatGenbank(void)
void SkipGenbankBlock(FGenbankBlocks fTGenbankBlocksMask)
void SetStyleNormal(void)
void SetModeGBench(void)
virtual vector< CConstRef< CObject > > GetObjects(objects::CBioseq_Handle bsh)
virtual vector< CConstRef< CObject > > GetRelatedObjects(const CObject &object, CRef< objects::CScope > scope)
virtual vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(objects::CBioseq_Handle bsh)
virtual string GetVal(const CObject &object)
void Generate(const CSeq_entry_Handle &entry, CFlatItemOStream &item_os, const multiout &={})
virtual bool IsEmpty(const CObject &object) const
virtual void SetConstraint(const string &field, CConstRef< objects::edit::CStringConstraint > string_constraint)
virtual string GetVal(const CObject &object)
virtual void ClearVal(CObject &object)
CRef< objects::edit::CStringConstraint > m_StringConstraint
virtual bool SetVal(CObject &object, const string &val, objects::edit::EExistingText existing_text)
virtual vector< string > GetVals(const CObject &object)
virtual vector< string > GetVals(const CObject &object)
static EGeneralIDPart GetGeneralIDPart_FromName(const string &name)
virtual string GetVal(const CObject &object)
EGeneralIDPart m_GeneralIDPart
static const string & GetName_GeneralIDPart(EGeneralIDPart stype_part)
virtual bool SetVal(CObject &object, const string &val, objects::edit::EExistingText existing_text)
static bool IsGenomeProject(const objects::CUser_object &user)
virtual vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(objects::CBioseq_Handle bsh)
static bool IsGenomeProjectID(const objects::CUser_field &field)
virtual bool IsEmpty(const CObject &object) const
virtual string GetVal(const CObject &object)
virtual string IsValid(const string &val)
virtual vector< CConstRef< CObject > > GetObjects(objects::CBioseq_Handle bsh)
virtual void ClearVal(CObject &object)
virtual vector< string > GetVals(const CObject &object)
virtual vector< CConstRef< CObject > > GetRelatedObjects(const CObject &object, CRef< objects::CScope > scope)
virtual string GetVal(const CObject &object)
virtual vector< CConstRef< CObject > > GetObjects(objects::CBioseq_Handle bsh)
virtual bool IsEmpty(const CObject &object) const
virtual vector< string > GetVals(const CObject &object)
virtual vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(objects::CBioseq_Handle bsh)
virtual vector< CConstRef< CObject > > GetRelatedObjects(const CObject &object, CRef< objects::CScope > scope)
CRef< CCmdComposite > SetValCmd(CConstRef< CObject > object, const string &val, objects::edit::EExistingText existing_text, objects::CScope &scope, bool update_mrna_product=false)
CRef< ncbi::CFieldHandler > m_FieldHandler
CRef< CSrcTableColumnBase > m_Src
CRef< CObject > GetNewObject(CConstRef< CObject > obj)
vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(objects::CBioseq_Handle bsh)
void AddApplyObjectValue(const objects::edit::CApplyObject &object, const string &field, set< string > &values)
void ClearVal(CObject &object)
vector< CConstRef< CObject > > GetRelatedObjects(const CObject &object, CRef< objects::CScope > scope)
static bool s_IsSequenceIDField(const string &field)
CRef< CCmdComposite > SwapValCmd(objects::edit::CApplyObject &object, CMiscSeqTableColumn &other, objects::edit::EExistingText existing_text, bool update_mrna_product)
int CountConflicts(set< CConstRef< CObject > > objs, const string &val)
bool IsEmpty(const CObject &object) const
objects::CSeqdesc::E_Choice GetDescriptorSubtype()
CRef< CCmdComposite > ConvertValCmd(objects::edit::CApplyObject &object, CMiscSeqTableColumn &other, objects::edit::EExistingText existing_text, objects::ECapChange cap_change, const bool leave_original, const string &field_name, const bool update_mrna_product)
void SetConstraint(string field, CRef< objects::edit::CStringConstraint > string_constraint)
bool IsFeature() const
CRef< CCmdComposite > GetReplacementCommand(CConstRef< CObject >, CRef< CObject > newobj, objects::CScope &scope, const string &cmd_name)
CRef< CCmdComposite > CopyValCmd(objects::edit::CApplyObject &object, CMiscSeqTableColumn &other, objects::edit::EExistingText existing_text, bool update_mrna_product)
vector< string > GetVals(const CObject &object)
objects::CSeqFeatData::ESubtype GetFeatureSubtype()
CRef< CCmdComposite > ParseValCmd(objects::edit::CApplyObject &object, CMiscSeqTableColumn &other, const objects::edit::CParseTextOptions &parse_options, objects::edit::EExistingText existing_text, bool update_mrna_product)
CMiscSeqTableColumn(const string &name)
vector< CConstRef< CObject > > GetObjects(objects::CBioseq_Handle bsh)
CRef< CCmdComposite > x_GetMrnaUpdate(objects::edit::CApplyObject &object, CMiscSeqTableColumn &other)
CRef< CFeatureSeqTableColumnBase > m_Feature
vector< CRef< objects::edit::CApplyObject > > GetRelatedApplyObjects(objects::edit::CApplyObject &object)
string IsValid(const string &val)
string GetVal(const CObject &object)
CRef< CCmdComposite > ClearValCmd(CConstRef< CObject > object, bool update_mrna_product, objects::CScope &scope)
bool SetVal(CObject &object, const string &val, objects::edit::EExistingText existing_text)
void GetApplyObjectsValues(objects::CSeq_entry_Handle seh, const string &constraint_field, set< string > &values)
void SetScope(CRef< objects::CScope > scope)
static EMolInfoFieldType GetFieldType(const string &field_name)
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
ostream & AsString(ostream &s) const
Definition: Object_id.cpp:202
CObject –.
Definition: ncbiobj.hpp:180
void RemoveSelectedText(string &input, bool remove_first_only=true) const
string GetSelectedText(const string &input) const
bool ShouldRemoveFromParsed() const
CProjectTreeView - a system view that displays Project Tree.
void GetSingleObject(TConstScopedObjects &objects) const
virtual void GetSelection(TConstScopedObjects &objects) const
shall return data objects representing selected things, return one data object for every selected thi...
static EPubFieldType GetTypeForLabel(string label)
CRef –.
Definition: ncbiobj.hpp:618
CScope –.
Definition: scope.hpp:92
ESubtype GetSubtype(void) const
static E_Choice GetTypeFromSubtype(ESubtype subtype)
@ eSubtype_bad
These no longer need to match the FEATDEF values in the C toolkit's objfdef.h.
static ESubtype SubtypeNameToValue(CTempString sName)
Turn a string into its ESubtype which is NOT necessarily related to the identifier of the enum.
virtual vector< CConstRef< CObject > > GetRelatedObjects(const CObject &object, CRef< objects::CScope > scope)
virtual vector< string > GetVals(const CObject &object)
virtual vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(objects::CBioseq_Handle bsh)
virtual string GetVal(const CObject &object)
virtual vector< CConstRef< CObject > > GetObjects(objects::CBioseq_Handle bsh)
CSeq_entry_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
static CRef< CSrcTableColumnBase > Create(const objects::CSeqTable_column &column)
virtual void SetConstraint(const string &field_name, CConstRef< edit::CStringConstraint > string_constraint)
virtual vector< string > IsValid(const vector< string > &values)
vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(CBioseq_Handle bsh)
string GetVal(const CObject &object)
vector< string > GetVals(const CObject &object)
vector< CConstRef< CObject > > GetObjects(CBioseq_Handle bsh)
void ClearVal(CObject &object)
virtual bool AllowMultipleValues()
virtual bool AddToBioSource(objects::CBioSource &in_out_bioSource, const string &newValue, objects::edit::EExistingText existing_text)
class CStaticArrayMap<> provides access to a static array in much the same way as CStaticArraySet<>,...
Definition: static_map.hpp:175
TBase::const_iterator const_iterator
Definition: static_map.hpp:179
bool DoesListMatch(const vector< string > &vals)
virtual vector< string > GetVals(const CObject &object)
virtual void ClearVal(CObject &object)
virtual bool SetVal(CObject &object, const string &val, objects::edit::EExistingText existing_text)
unsigned int m_NrOfSetting
virtual void ClearVal(CObject &object)
virtual bool SetVal(CObject &object, const string &val, objects::edit::EExistingText existing_text)
virtual vector< string > GetVals(const CObject &object)
objects::CUser_object::TData m_FieldValuePairs
void x_InsertFieldAtCorrectPosition(objects::CUser_object &user, CRef< objects::CUser_field > field)
virtual vector< CConstRef< CObject > > GetRelatedObjects(const CObject &object, CRef< objects::CScope > scope)
virtual vector< string > GetVals(const CObject &object)
virtual void ClearVal(CObject &object)
virtual string GetVal(const CObject &object)
virtual bool IsEmpty(const CObject &object) const
virtual bool SetVal(CObject &object, const string &val, objects::edit::EExistingText existing_text)
virtual vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(objects::CBioseq_Handle bsh)
virtual vector< CConstRef< CObject > > GetObjects(objects::CBioseq_Handle bsh)
const objects::CUser_object * x_GetUser_Object(const CObject &object) const
virtual vector< CConstRef< CObject > > GetRelatedObjects(const CObject &object, CRef< objects::CScope > scope)
virtual vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(objects::CBioseq_Handle bsh)
objects::CSeqdesc::E_Choice m_Subtype
virtual vector< CConstRef< CObject > > GetObjects(objects::CBioseq_Handle bsh)
EObjectType GetObjectType() const
class IProjectView defines the abstract interface for views observing projects.
virtual string GetLabel(ELabelType type) const =0
returns name of the plug-in created this view (view class name)
virtual void GetMainObject(TConstScopedObjects &objects) const =0
Adds the main data objects represented by the client to "objects".
virtual void GetActiveObjects(TConstScopedObjects &objects) const
IViewManagerService IViewManagerService manages views in Workbench.
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
static auto & RemoveFieldNameFromString
static auto & FixCapitalizationInString
int FindHighestFeatureId(const objects::CSeq_entry_Handle &entry)
void SetRnaProductName(objects::CRNA_ref &rna, const string &product, string &remainder, objects::edit::EExistingText existing_text)
const char * kDefinitionLineLabel
const char * kFileSeqId
const char * kStructCommFieldName
const char * kFieldTypeSeqId
const char * kGenomeProjectID
const char * kStructCommDBName
const char * kComment
const char * kLocalId
const char * kStructCommFieldValuePair
const char * kCommentDescriptorLabel
const char * kFlatFile
const char * kBankITComment
const char * kGenbankBlockKeyword
const char * kSequenceIdColLabel
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
Definition: service.hpp:91
vector< CIRef< IView > > TViews
virtual void GetViews(TViews &views)=0
get all registered views
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
Definition: Seq_id.cpp:2040
CConstRef< CSeq_id > GetSeqId(void) const
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:605
CRef< CSeq_loc > Merge(TOpFlags flags, ISynonymMapper *syn_mapper) const
All functions create and return a new seq-loc object.
Definition: Seq_loc.cpp:5037
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
@ fMerge_SingleRange
Definition: Seq_loc.hpp:332
CMappedFeat GetBestMrnaForCds(const CMappedFeat &cds_feat, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0)
Definition: feature.cpp:3341
CMappedFeat GetBestCdsForMrna(const CMappedFeat &mrna_feat, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0)
Definition: feature.cpp:3360
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
@ eOverlap_Contains
2nd contains 1st extremes
@ eOverlap_Contained
2nd contained within 1st extremes
const CSeq_feat * GetCDSForProduct(const CBioseq &product, CScope *scope)
Get the encoding CDS feature of a given protein sequence.
Definition: sequence.cpp:2549
CConstRef< CSeq_feat > GetOverlappingGene(const CSeq_loc &loc, CScope &scope, ETransSplicing eTransSplicing=eTransSplicing_Auto)
Definition: sequence.cpp:1366
vector< TFeatScore > TFeatScores
Definition: sequence.hpp:353
void GetOverlappingFeatures(const CSeq_loc &loc, CSeqFeatData::E_Choice feat_type, CSeqFeatData::ESubtype feat_subtype, EOverlapType overlap_type, TFeatScores &feats, CScope &scope, const TBestFeatOpts opts=0, CGetOverlappingFeaturesPlugin *plugin=NULL)
Find all features overlapping the location.
Definition: sequence.cpp:945
@ eGetId_Best
return the "best" gi (uses FindBestScore(), with CSeq_id::CalculateScore() as the score function
Definition: sequence.hpp:101
CSeq_entry_Handle GetSeq_entryHandle(CDataLoader *loader, const TBlobId &blob_id, EMissing action=eMissing_Default)
Get Seq-entry handle by its blob-id, with possible loading.
Definition: scope.cpp:113
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CSeq_feat_Handle GetSeq_featHandle(const CSeq_feat &feat, EMissing action=eMissing_Default)
Definition: scope.cpp:200
const TDescr & GetDescr(void) const
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
TClass GetClass(void) const
TSet GetSet(void) const
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
CConstRef< CBioseq_set > GetCompleteBioseq_set(void) const
Return the complete bioseq-set object.
CBioseq_set_Handle GetParentBioseq_set(void) const
Get parent bioseq-set handle.
TSeq GetSeq(void) const
CBioseq_Handle GetBioseqHandle(const CSeq_id &id) const
Get Bioseq handle from the TSE of this Seq-entry.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
CSeq_entry_Handle GetParentEntry(void) const
Return a handle for the parent seq-entry of the bioseq.
TInst_Length GetInst_Length(void) const
bool IsSetClass(void) const
bool IsSetDescr(void) const
CScope & GetScope(void) const
Get scope this handle belongs to.
CScope & GetScope(void) const
Get scope this handle belongs to.
bool IsSet(void) const
const TId & GetId(void) const
bool IsSeq(void) const
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:1684
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
Definition: ncbiobj.hpp:2015
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
bool IsOssEmpty(CNcbiOstrstream &oss)
Definition: ncbistre.hpp:831
#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 SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
Definition: ncbistr.cpp:2993
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
Definition: ncbistr.hpp:5430
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
#define NPOS
Definition: ncbistr.hpp:133
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3201
static 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 EqualCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive equality of a substring with another string.
Definition: ncbistr.hpp:5325
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5412
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5353
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
Definition: ncbistr.hpp:5384
@ eNocase
Case insensitive compare.
Definition: ncbistr.hpp:1206
static const char label[]
TKeywords & SetKeywords(void)
Assign a value to Keywords data member.
Definition: GB_block_.hpp:532
bool IsSetExtra_accessions(void) const
Check if a value has been assigned to Extra_accessions data member.
Definition: GB_block_.hpp:442
void ResetKeywords(void)
Reset Keywords data member.
Definition: GB_block_.cpp:63
bool IsSetDiv(void) const
GenBank division Check if a value has been assigned to Div data member.
Definition: GB_block_.hpp:654
bool IsSetTaxonomy(void) const
continuation line of organism Check if a value has been assigned to Taxonomy data member.
Definition: GB_block_.hpp:701
list< string > TKeywords
Definition: GB_block_.hpp:93
bool IsSetSource(void) const
source line Check if a value has been assigned to Source data member.
Definition: GB_block_.hpp:467
bool IsSetEntry_date(void) const
replaces date Check if a value has been assigned to Entry_date data member.
Definition: GB_block_.hpp:633
const TKeywords & GetKeywords(void) const
Get the Keywords member data.
Definition: GB_block_.hpp:526
bool IsSetOrigin(void) const
Check if a value has been assigned to Origin data member.
Definition: GB_block_.hpp:539
bool IsSetKeywords(void) const
Check if a value has been assigned to Keywords data member.
Definition: GB_block_.hpp:514
bool IsSetDate(void) const
OBSOLETE old form Entry Date Check if a value has been assigned to Date data member.
Definition: GB_block_.hpp:586
const TStr & GetStr(void) const
Get the variant data.
bool IsSetData(void) const
the object itself Check if a value has been assigned to Data data member.
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
bool IsSetType(void) const
type of object within class Check if a value has been assigned to Type data member.
const TTag & GetTag(void) const
Get the Tag member data.
Definition: Dbtag_.hpp:267
const TData & GetData(void) const
Get the Data member data.
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
bool IsSetClass(void) const
endeavor which designed this object Check if a value has been assigned to Class data member.
const TClass & GetClass(void) const
Get the Class member data.
bool IsStr(void) const
Check if variant Str is selected.
bool IsSetLabel(void) const
field label Check if a value has been assigned to Label data member.
TData & SetData(void)
Assign a value to Data data member.
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
void SetLabel(TLabel &value)
Assign a value to Label data member.
const TData & GetData(void) const
Get the Data member data.
void SetType(TType &value)
Assign a value to Type data member.
void ResetData(void)
Reset Data data member.
void SetData(TData &value)
Assign a value to Data data member.
const TLabel & GetLabel(void) const
Get the Label member data.
const TType & GetType(void) const
Get the Type member data.
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
vector< CStringUTF8 > TStrs
vector< CRef< CUser_field > > TData
E_Choice Which(void) const
Which variant is currently selected.
@ e_not_set
No variant selected.
void SetHeader(THeader &value)
Assign a value to Header data member.
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
Definition: Seq_feat_.hpp:913
E_Choice Which(void) const
Which variant is currently selected.
void SetLocation(TLocation &value)
Assign a value to Location data member.
Definition: Seq_feat_.cpp:131
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
E_Choice
Choice variants.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
const TProduct & GetProduct(void) const
Get the Product member data.
Definition: Seq_feat_.hpp:1096
bool IsBiosrc(void) const
Check if variant Biosrc is selected.
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
Definition: Seq_feat_.hpp:1084
bool IsRna(void) const
Check if variant Rna is selected.
bool IsSetLocation(void) const
feature made from Check if a value has been assigned to Location data member.
Definition: Seq_feat_.hpp:1105
@ e_not_set
No variant selected.
bool IsGeneral(void) const
Check if variant General is selected.
Definition: Seq_id_.hpp:877
const TGeneral & GetGeneral(void) const
Get the variant data.
Definition: Seq_id_.cpp:369
const TSeq_set & GetSeq_set(void) const
Get the Seq_set member data.
list< CRef< CSeq_entry > > TSeq_set
@ eClass_nuc_prot
nuc acid and coded proteins
Definition: Bioseq_set_.hpp:99
bool IsGenbank(void) const
Check if variant Genbank is selected.
Definition: Seqdesc_.hpp:1090
list< CRef< CSeqdesc > > Tdata
Definition: Seq_descr_.hpp:91
const TUser & GetUser(void) const
Get the variant data.
Definition: Seqdesc_.cpp:384
TTitle & SetTitle(void)
Select the variant.
Definition: Seqdesc_.hpp:1039
bool IsComment(void) const
Check if variant Comment is selected.
Definition: Seqdesc_.hpp:1052
const TTitle & GetTitle(void) const
Get the variant data.
Definition: Seqdesc_.hpp:1032
bool IsSource(void) const
Check if variant Source is selected.
Definition: Seqdesc_.hpp:1190
TGenbank & SetGenbank(void)
Select the variant.
Definition: Seqdesc_.cpp:340
const TId & GetId(void) const
Get the Id member data.
Definition: Bioseq_.hpp:290
const Tdata & Get(void) const
Get the member data.
Definition: Seq_descr_.hpp:166
const TGenbank & GetGenbank(void) const
Get the variant data.
Definition: Seqdesc_.cpp:334
TComment & SetComment(void)
Select the variant.
Definition: Seqdesc_.hpp:1065
TSource & SetSource(void)
Select the variant.
Definition: Seqdesc_.cpp:572
E_Choice
Choice variants.
Definition: Seqdesc_.hpp:109
TUser & SetUser(void)
Select the variant.
Definition: Seqdesc_.cpp:390
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seqdesc_.hpp:903
bool IsSetId(void) const
equivalent identifiers Check if a value has been assigned to Id data member.
Definition: Bioseq_.hpp:278
bool IsTitle(void) const
Check if variant Title is selected.
Definition: Seqdesc_.hpp:1026
const TComment & GetComment(void) const
Get the variant data.
Definition: Seqdesc_.hpp:1058
bool IsUser(void) const
Check if variant User is selected.
Definition: Seqdesc_.hpp:1122
@ e_User
user defined object
Definition: Seqdesc_.hpp:124
@ e_Comment
a more extensive comment
Definition: Seqdesc_.hpp:117
@ e_not_set
No variant selected.
Definition: Seqdesc_.hpp:110
@ eMol_na
just a nucleic acid
Definition: Seq_inst_.hpp:113
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
int i
bool DoesApplyObjectMatchFieldConstraint(const CApplyObject &object, const string &field_name, CRef< CStringConstraint > string_constraint)
CRef< CCmdComposite > GetPropagateDBLinkCmd(CSeq_entry_Handle entry)
void x_AdjustListPair(vector< CRef< CApplyObject > > prev_list, vector< CRef< CApplyObject > > this_list)
vector< CRef< CApplyObject > > s_GetProtApplyObjectsFeatures(CBioseq_Handle p_bsh, CSeqFeatData::ESubtype constraint_type)
vector< CConstRef< CSeq_feat > > GetRelatedFeatures(const CSeq_feat &obj_feat, CSeqFeatData::ESubtype constraint_type, CRef< CScope > scope)
bool FocusedOnNucleotides(TConstScopedObjects &objects, const CSeq_entry_Handle &tse)
CRef< CCmdComposite > GetCommandFromApplyObject(CApplyObject &obj)
void AddMiscColumnsToTable(CRef< CSeq_table > table, const vector< string > &fields, CSeq_entry_Handle entry)
USING_SCOPE(ncbi::objects)
static const string kStructComment("StructuredComment")
static const string kStructCommentSuffix("StructuredCommentSuffix")
static size_t s_GetMaxRows(const vector< size_t > &rows)
bool DoesObjectMatchFieldConstraint(const CObject &object, const string &field_name, CRef< CStringConstraint > string_constraint, CRef< CScope > scope)
static const string kGenomeProjectId
static const string kStructCommentPrefix("StructuredCommentPrefix")
bool PropagateDBLink(CSeq_entry_Handle entry, CCmdComposite &cmd)
SStaticPair< const char *, CGeneralIDField::EGeneralIDPart > TGeneralIDPart
string GetExistingTextInstruction(EExistingText existing)
bool PropagateDescriptor(CSeq_entry_Handle entry, const CSeqdesc &desc, CCmdComposite &cmd)
vector< CRef< CApplyObject > > GetRelatedFeatureApplyObjects(const CSeq_feat &obj_feat, CSeqFeatData::ESubtype constraint_type, CRef< CScope > scope)
CRef< CSeq_table > GetMiscTableFromSeqEntry(const vector< string > &fields, CSeq_entry_Handle entry)
int GetNumberOfViewedBioseqs(TConstScopedObjects &objects)
void GetViewObjects(IWorkbench *workbench, TConstScopedObjects &objects)
vector< CConstRef< CSeq_feat > > s_GetProtFeatures(CBioseq_Handle p_bsh, CSeqFeatData::ESubtype constraint_type)
bool FocusedOnAll(TConstScopedObjects &objects, const objects::CSeq_entry_Handle &tse)
CRef< CUser_field > MakeTableMetaInfoField(EExistingText rule, bool erase_blanks)
DEFINE_STATIC_ARRAY_MAP(TGenIdPartMap, sm_GenIdMap, s_GenIDPartName)
string MakeTableMetaInfoString(EExistingText rule, bool erase_blanks)
bool IsSeqOrNP(CSeq_entry_Handle entry)
CSeq_entry_Handle s_GetNPParent(CSeq_entry_Handle seh)
static const TGeneralIDPart s_GenIDPartName[]
CStaticArrayMap< string, CGeneralIDField::EGeneralIDPart > TGenIdPartMap
vector< CRef< CMiscSeqTableColumn > > TMiscSeqTableColumnList
constexpr bool empty(list< Ts... >) noexcept
Definition: fix_pub.hpp:45
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
EIPRangeType t
Definition: ncbi_localip.c:101
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Definition: njn_matrix.hpp:613
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
static const char * prefix[]
Definition: pcregrep.c:405
#define FOR_EACH_SEQID_ON_BIOSEQ(Itr, Var)
FOR_EACH_SEQID_ON_BIOSEQ EDIT_EACH_SEQID_ON_BIOSEQ.
Definition: seq_macros.hpp:308
Utility macros and typedefs for exploring NCBI objects from seqfeat.asn.
bool QualifierNamesAreEquivalent(string name1, string name2)
CRef< CSeqTable_column > AddStringColumnToTable(CRef< CSeq_table > table, string label)
void AddValueToColumn(CRef< CSeqTable_column > column, string value, size_t row, edit::EExistingText existing_text=edit::eExistingText_replace_old)
void FillShortColumns(CRef< objects::CSeq_table > values_table)
#define row(bind, expected)
Definition: string_bind.c:73
EExistingText
@ eExistingText_cancel
@ eExistingText_append_semi
@ eExistingText_append_space
@ eExistingText_prefix_colon
@ eExistingText_add_qual
@ eExistingText_append_none
@ eExistingText_leave_old
@ eExistingText_prefix_none
@ eExistingText_prefix_space
@ eExistingText_append_colon
@ eExistingText_prefix_comma
@ eExistingText_append_comma
@ eExistingText_prefix_semi
@ eExistingText_replace_old
bool AddValueToString(string &str, const string &value, EExistingText existing_text)
Add text to an existing string, using the "existing_text" directive to combine new text with existing...
SAnnotSelector –.
Template structure SStaticPair is simlified replacement of STL pair<> Main reason of introducing this...
Definition: static_set.hpp:60
CScope & GetScope()
CRef< CCmdComposite > UpdatemRNAProduct(const objects::CSeq_feat &protein, objects::CScope &scope, string &message)
Modified on Wed Apr 24 14:18:11 2024 by modify_doxy.py rev. 669887