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

Go to the SVN repository for this file.

1 /* $Id: featedit_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, J. Chen
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
34 #include <objects/seq/Pubdesc.hpp>
49 
50 #include <objmgr/bioseq_ci.hpp>
51 #include <objmgr/feat_ci.hpp>
53 #include <objmgr/util/sequence.hpp>
54 
57 
59 
63 
67 
71 
73 static const int kNumIgnoreColumns = sizeof (kIgnoreColumns) / sizeof (string);
74 
75 
77 {
78  vector<CConstRef<CObject> > objs;
81  while (f) {
82  if (f->IsSetProduct()) {
83  CBioseq_Handle p_bsh = bsh.GetScope().GetBioseqHandle(f->GetProduct());
84  if (p_bsh) {
86  while (p) {
87  CConstRef<CObject> object;
88  object.Reset(p->GetOriginalSeq_feat());
89  objs.push_back(object);
90  ++p;
91  }
92  }
93  } else {
94  CConstRef<CObject> object;
95  object.Reset(f->GetOriginalSeq_feat());
96  objs.push_back(object);
97  }
98  ++f;
99  }
100  } else {
102  while (f) {
103  CConstRef<CObject> object;
104  object.Reset(f->GetOriginalSeq_feat());
105  objs.push_back(object);
106  ++f;
107  }
108 
109  if (objs.empty() && m_MajorType != CSeqFeatData::e_not_set) {
111  while (f) {
112  CConstRef<CObject> object;
113  object.Reset(f->GetOriginalSeq_feat());
114  objs.push_back(object);
115  ++f;
116  }
117  }
118 
119  }
120  return objs;
121 }
122 
123 
125 {
126  vector<CRef<CApplyObject> > objs;
128  vector<CConstRef<CObject> > feats = GetObjects(bsh);
129  ITERATE(vector<CConstRef<CObject> >, it, feats) {
130  const CSeq_feat* f = dynamic_cast<const CSeq_feat* >(it->GetPointer());
131  if (f) {
132  objs.push_back(CRef<CApplyObject>(new CApplyObject(bsh, *f)));
133  }
134  }
135  } else {
136  objs = GetRelatedGeneApplyObjects(bsh);
137  }
138  return objs;
139 }
140 
141 
143 {
144  vector<CRef<CApplyObject> > objs;
145  vector<CConstRef<CObject> > feats = GetObjects(bsh);
146  ITERATE(vector<CConstRef<CObject> >, it, feats) {
147  const CSeq_feat* f = dynamic_cast<const CSeq_feat* >(it->GetPointer());
148  if (f) {
149  CConstRef <CSeq_feat> gene_for_feat = edit::GetGeneForFeature(*f, bsh.GetScope());
150  if (gene_for_feat) {
151  objs.push_back(CRef<CApplyObject>(new CApplyObject(bsh, *gene_for_feat)));
152  } else {
153  // create new gene for feature
155  CRef<CSeq_feat> new_feat(new CSeq_feat());
156  new_feat->SetLocation().Assign(*(f->GetLocation().Merge(CSeq_loc::fMerge_SingleRange, NULL)));
157  new_feat->SetData().SetGene();
158  CRef<CObject> new_obj(new_feat.GetPointer());
159  objs.push_back(CRef<CApplyObject>(new CApplyObject(seh, CConstRef<CObject>(NULL), new_obj)));
160  }
161  }
162  }
163  return objs;
164 }
165 
166 
167 // J. Chen
169 {
170  string rval(kEmptyStr);
171  if (feat.CanGetDbxref()) {
172  ITERATE (vector <CRef <CDbtag> >, it, feat.GetDbxref()) {
173  string label(kEmptyStr);
174  (*it)->GetLabel(&label);
175  if (!label.empty()) {
176  rval += label + ";";
177  }
178  }
179  rval = CTempString(rval).substr(0, rval.size()-1);
180  }
181  else {
182  rval = CGbQualColumn :: GetFromFeat(feat);
183  }
184  return rval;
185 };
186 
188 {
189  if (feat.IsSetDbxref()) {
190  feat.ResetDbxref();
191  }
192  else {
194  }
195 };
196 
197 
199 {
200  if (feat.CanGetExp_ev()) {
201  return ((feat.GetExp_ev() == CSeq_feat::eExp_ev_experimental) ?
202  "experimental": "non-experimental");
203  } else {
204  return "";
205  }
206 }
207 
208 
210 {
211  if (feat.GetData().IsRegion()) {
212  return (feat.GetData().GetRegion());
213  }
214  else return CGbQualColumn :: GetFromFeat(feat);
215 };
216 
218 {
219  return "";
220  //return (SeqLocPrintUseBestID(feat->GetLocation()));
221 };
222 
224 {
225  string rval(kEmptyStr);
226  if (feat.GetData().IsRna()
227  && feat.GetData().GetRna().CanGetExt()
228  && feat.GetData().GetRna().GetExt().IsTRNA()
229  && feat.GetData().GetRna().GetExt().GetTRNA().CanGetCodon() ) {
230  ITERATE (list <int>, it,
231  feat.GetData().GetRna().GetExt().GetTRNA().GetCodon()) {
232  // should have only 6
233  if ( (*it) < 64) {
234  rval += CGen_code_table :: IndexToCodon(*it) + ", ";
235  }
236  }
237  rval = CTempString(rval).substr(0, rval.size()-2);
238  }
239  else {
240  rval = CGbQualColumn :: GetFromFeat(feat);
241  }
242  return rval;
243 };
244 
245 string GetIntervalString(const CSeq_interval& seq_int)
246 {
247  bool partial5 = seq_int.IsPartialStart(eExtreme_Biological);
248  bool partial3 = seq_int.IsPartialStop(eExtreme_Biological);
249  string rval(kEmptyStr);
250 
251  if (seq_int.CanGetStrand() && seq_int.GetStrand() == eNa_strand_minus) {
252  rval = (string)"complement(" + (partial3 ? "<" : "")
254  + ".." + (partial5 ? ">" : "")
256  } else {
257  rval = (partial5 ? "<" : "")
259  + ".." + (partial3 ? ">" : "")
261  }
262  return rval;
263 };
264 
266 {
267  string rval(kEmptyStr);
268  if (feat.GetData().IsRna()
269  && feat.GetData().GetRna().CanGetExt()
270  && feat.GetData().GetRna().GetExt().IsTRNA()
271  && feat.GetData().GetRna().GetExt().GetTRNA().CanGetAnticodon() ) {
272  const CTrna_ext& trna = feat.GetData().GetRna().GetExt().GetTRNA();
273  if (trna.GetAnticodon().IsInt()) {
274  rval = GetIntervalString(trna.GetAnticodon().GetInt());
275  }
276  else if (trna.GetAnticodon().IsMix()) {
277  ITERATE (list <CRef <CSeq_loc> >, it, trna.GetAnticodon().GetMix().Get()) {
278  if ( (*it)->IsInt()) {
279  rval += GetIntervalString( (*it)->GetInt() ) + ", ";
280  }
281  else return( "complex location" );
282  }
283  rval = CTempString(rval).substr(0, rval.size() - 2);
284  }
285  }
286  else {
287  rval = CGbQualColumn :: GetFromFeat(feat);
288  }
289  return rval;
290 
291 };
292 
294 {
295  string rval;
296  if (feat.GetData().IsRna()
297  && feat.GetData().GetRna().CanGetExt()
298  && feat.GetData().GetRna().GetExt().IsGen()
299  && feat.GetData().GetRna().GetExt().GetGen().CanGetQuals()) {
300  ITERATE (list <CRef <CRNA_qual> >, it,
301  feat.GetData().GetRna().GetExt().GetGen().GetQuals().Get()){
302  if ((*it)->GetQual() == "tag_peptide" && !((*it)->GetVal()).empty()) {
303  rval += (*it)->GetVal() + ";";
304  }
305  }
306  rval = CTempString(rval).substr(0, rval.size()-1);
307  }
308  else {
309  rval = CGbQualColumn :: GetFromFeat(feat);
310  }
311  return rval;
312 };
313 
315 {
316  return kEmptyStr;
317 };
318 
319 
320 // J. Chen end
321 
324 {
325  string member_name = sTitle;
326  size_t pos = NStr::Find(member_name, "\n");
327  if (pos != string::npos) {
328  member_name = member_name.substr(0, pos);
329  }
330 
332 
333  if (NStr::StartsWith(member_name, "gene ")
334  || NStr::StartsWith(member_name, "gene-")) {
335  member_name = member_name.substr(5);
336  major_type = CSeqFeatData::GetTypeFromSubtype(subtype);
337  subtype = CSeqFeatData::eSubtype_gene;
338  } else if (NStr::StartsWith(member_name, "mRNA ", NStr::eNocase)) {
339  member_name = member_name.substr(5);
340  }
342 
343  if (QualifierNamesAreEquivalent(member_name, "Comment")
344  || NStr::EqualNocase(sTitle, "Note")) {
346  } else if (QualifierNamesAreEquivalent(member_name, "Exception")) {
348  } else if (QualifierNamesAreEquivalent(member_name, kPartialStart)) {
350  } else if (QualifierNamesAreEquivalent(member_name, kPartialStop)) {
352  } else if (QualifierNamesAreEquivalent(member_name, "rpt_unit_seq")) {
354  }
355  else if (NStr::EqualNocase(member_name, "db-xref") || NStr::EqualNocase(member_name, "db_xref")) {
357  }
358  else if (NStr::EqualNocase(member_name, "evidence")) {
360  }
361  else if (NStr::EqualNocase(member_name, "citation")) {
363  // don't know how
364  }
365  else if (NStr::EqualNocase(member_name, "inference")) {
367  }
368  else if (NStr::EqualNocase(member_name, "location")) {
370  // move SeqLocPrintUseBestId to seq_loc_util
371  }
372  else if (NStr::EqualNocase(member_name, "pseudo")) {
373  rval =CRef<CFeatureSeqTableColumnBase>( new CGbQualColumn("pseudogene"));
374  }
375  else if (NStr::EqualNocase(member_name, "codons-recognized")) {
377  }
378  else if (NStr::EqualNocase(member_name, "anticodon")) {
380  }
381  else if (NStr::EqualNocase(member_name, "tag-peptide")) {
383  }
384  else if (NStr::EqualNocase(member_name, "region")) {
386  }
387  else if (QualifierNamesAreEquivalent(member_name, "codon-start")) {
389  }
390  else if (QualifierNamesAreEquivalent(member_name, "transl-table")) {
392  }
393  else if (NStr::StartsWith(member_name, "satellite")) {
394  rval = CRef<CFeatureSeqTableColumnBase>(new CSatelliteColumn(member_name));
395  }
396  else {
397  for (int i = 0; i < kNumIgnoreColumns; i++) {
398  if (QualifierNamesAreEquivalent(member_name, kIgnoreColumns[i])) {
400  break;
401  }
402  }
403  if (!rval) {
404  // is this a product field?
405  bool is_protein = QualifierNamesAreEquivalent(member_name, "protein name") || NStr::EqualNocase(member_name, "name");
406  if (NStr::EndsWith(member_name, "product") || is_protein) {
408  if (subtype == CSeqFeatData::eSubtype_cdregion ||
409  (is_protein &&
411  subtype = CSeqFeatData::eSubtype_prot;
412  }
413  }
414  }
415 
416  if (!rval) {
417  // is this a description? could be protein or gene
418  if (NStr::EndsWith(member_name, "description") || NStr::EndsWith(sTitle, "desc")) {
420  }
421  }
422 
423  if (!rval) {
424  if (QualifierNamesAreEquivalent(member_name, "ncRNA class")) {
426  }
427  }
428 
429  if (!rval) {
430  // gene fields
431  if (CGeneRefColumn::IsGeneRefField(member_name)) {
432  rval = CRef<CFeatureSeqTableColumnBase>( new CGeneRefColumn(member_name));
433  }
434  }
435 
436  if (!rval) {
437  // protein fields
438  if (CProtRefColumn::IsProtRefField(member_name)) {
439  rval = CRef<CFeatureSeqTableColumnBase>( new CProtRefColumn(member_name));
441  subtype = CSeqFeatData::eSubtype_prot;
442  }
443  }
444  }
445 
446  if (!rval) {
447  // if nothing else is found, create a GBQual
448  rval = CRef<CFeatureSeqTableColumnBase>( new CGbQualColumn(member_name) );
449  }
450  }
451  if (rval) {
452  rval->SetSubtype(subtype);
453  if (major_type != CSeqFeatData::e_not_set) {
454  rval->SetMajorType(major_type);
455  }
456  }
457  return rval;
458 }
459 
460 
461 bool CPartialStartColumn::AddToFeature( CSeq_feat & in_out_feat, const string & newValue,
462  EExistingText existing_text)
463 {
464  if (NStr::IsBlank(newValue)) {
465  in_out_feat.SetLocation().SetPartialStart(false, eExtreme_Biological);
466  } else {
467  in_out_feat.SetLocation().SetPartialStart(true, eExtreme_Biological);
468  }
470  || in_out_feat.GetLocation().IsPartialStop(eExtreme_Biological)) {
471  in_out_feat.SetPartial(true);
472  } else {
473  in_out_feat.ResetPartial();
474  }
475  return true;
476 }
477 
478 
480 {
481  in_out_feat.SetLocation().SetPartialStart(false, eExtreme_Biological);
483  || in_out_feat.GetLocation().IsPartialStop(eExtreme_Biological)) {
484  in_out_feat.SetPartial(true);
485  } else {
486  in_out_feat.ResetPartial();
487  }
488 }
489 
490 
491 string CPartialStartColumn::GetFromFeat( const CSeq_feat & in_out_feat )
492 {
493  if (in_out_feat.GetLocation().IsPartialStart(eExtreme_Biological)) {
494  return "true";
495  } else {
496  return "";
497  }
498 }
499 
500 
501 bool CPartialStopColumn::AddToFeature( CSeq_feat & in_out_feat, const string & newValue,
502  EExistingText existing_text)
503 {
504  if (NStr::IsBlank(newValue)) {
505  in_out_feat.SetLocation().SetPartialStop(false, eExtreme_Biological);
506  } else {
507  in_out_feat.SetLocation().SetPartialStop(true, eExtreme_Biological);
508  }
510  || in_out_feat.GetLocation().IsPartialStop(eExtreme_Biological)) {
511  in_out_feat.SetPartial(true);
512  } else {
513  in_out_feat.ResetPartial();
514  }
515  return true;
516 }
517 
518 
520 {
521  in_out_feat.SetLocation().SetPartialStop(false, eExtreme_Biological);
523  || in_out_feat.GetLocation().IsPartialStop(eExtreme_Biological)) {
524  in_out_feat.SetPartial(true);
525  } else {
526  in_out_feat.ResetPartial();
527  }
528 }
529 
530 
531 string CPartialStopColumn::GetFromFeat( const CSeq_feat & in_out_feat )
532 {
533  if (in_out_feat.GetLocation().IsPartialStop(eExtreme_Biological)) {
534  return "true";
535  } else {
536  return "";
537  }
538 }
539 
540 
541 bool CExceptionColumn::AddToFeature( CSeq_feat & in_out_feat, const string & newValue,
542  EExistingText existing_text)
543 {
544  if (NStr::IsBlank (newValue)) {
545  return false;
546  } else {
547  in_out_feat.SetExcept(true);
548  string current = kEmptyStr;
549  if (in_out_feat.IsSetExcept_text()) {
550  current = in_out_feat.GetExcept_text();
551  }
552  if (AddValueToString(current, newValue, existing_text)) {
553  in_out_feat.SetExcept_text(current);
554  return true;
555  }
556  }
557  return false;
558 }
559 
560 
562 {
563  in_out_feat.ResetExcept();
564  in_out_feat.ResetExcept_text();
565 }
566 
567 
568 string CExceptionColumn::GetFromFeat( const CSeq_feat & in_out_feat )
569 {
570  if (in_out_feat.IsSetExcept() && in_out_feat.GetExcept() && in_out_feat.IsSetExcept_text()) {
571  return in_out_feat.GetExcept_text();
572  } else {
573  return "";
574  }
575 }
576 
577 
578 bool CCommentColumn::AddToFeature( CSeq_feat & in_out_feat, const string & newValue,
579  EExistingText existing_text)
580 {
581  if (NStr::IsBlank(newValue)) {
582  return false;
583  } else {
584  string current = kEmptyStr;
585  if (in_out_feat.IsSetComment()) {
586  current = in_out_feat.GetComment();
587  }
588  if (AddValueToString(current, newValue, existing_text)) {
589  in_out_feat.SetComment(current);
590  return true;
591  }
592  }
593  return false;
594 }
595 
597 {
598  in_out_feat.ResetComment();
599 }
600 
601 string CCommentColumn::GetFromFeat( const CSeq_feat & in_out_feat )
602 {
603  if (in_out_feat.IsSetComment()) {
604  return in_out_feat.GetComment();
605  } else {
606  return "";
607  }
608 }
609 
610 
611 bool CGbQualColumn::AddToFeature(CSeq_feat & in_out_feat, const string & newValue,
612  EExistingText existing_text)
613 {
614  if (NStr::IsBlank(newValue)) {
615  return false;
616  }
617 
618  bool rval = false;
619  string current = kEmptyStr;
620  NON_CONST_ITERATE (CSeq_feat::TQual, iter, in_out_feat.SetQual()) {
621  if (NStr::EqualNocase((*iter)->GetQual(), m_QualName) && (*iter)->IsSetVal()) {
622  current = (*iter)->GetVal();
623  if (AddValueToString(current, newValue, existing_text)) {
624  (*iter)->SetVal(current);
625  rval = true;
626  }
627  }
628  }
629  if (!rval) {
630  CRef<CGb_qual> qual(new CGb_qual(m_QualName, newValue));
631  in_out_feat.SetQual().push_back(qual);
632  rval = true;
633  }
634  return rval;
635 
636 }
637 
638 
639 
641 {
642  if (in_out_feat.IsSetQual()) {
643  CSeq_feat::TQual::iterator it = in_out_feat.SetQual().begin();
644  while (it != in_out_feat.SetQual().end()) {
645  if ((*it)->IsSetQual() && NStr::EqualNocase((*it)->GetQual(), m_QualName)) {
646  it = in_out_feat.SetQual().erase(it);
647  } else {
648  it++;
649  }
650  }
651  }
652 }
653 
654 
655 string CGbQualColumn::GetFromFeat(const CSeq_feat & in_out_feat )
656 {
657  string val = "";
658  if (in_out_feat.IsSetQual()) {
659  ITERATE (CSeq_feat::TQual, it, in_out_feat.GetQual()) {
660  if ((*it)->IsSetQual() && NStr::EqualNocase((*it)->GetQual(), m_QualName)
661  && (*it)->IsSetVal()) {
662  val += (*it)->GetVal() + ";";
663  }
664  }
665  if (!NStr::IsBlank(val)) {
666  val = val.substr(0, val.length() - 1);
667  }
668  }
669  return val;
670 }
671 
672 
673 CRptUnitRangeColumn::CRptUnitRangeColumn(const vector<size_t> lens)
674  : CGbQualColumn("rpt_unit_range"), m_Lens(lens)
675 {
676 }
677 
678 
679 vector<string> CRptUnitRangeColumn::IsValid(const vector<string>& values)
680 {
681  vector<string> problems;
682  bool any_errors = false;
683  size_t pos = 0;
684  ITERATE(vector<string>, it, values) {
685  string error = "";
686  if (NStr::IsBlank(*it)) {
687  // blank is always allowed
688  problems.push_back("");
689  continue;
690  }
691  size_t div = NStr::Find(*it, "..");
692  if (div == string::npos) {
693  error = "rpt_unit_range has invalid format";
694  } else {
695  string start_str = (*it).substr(0, div);
696  string end_str = (*it).substr(div + 2);
697  int range_start = 1;
698  int range_end = static_cast<int>(m_Lens[pos]);
699  try {
700  range_start = NStr::StringToInt(start_str);
701  range_end = NStr::StringToInt(end_str);
702  } catch (CException&) {
703  error = "rpt_unit_range has invalid format";
704  }
705  if (pos < m_Lens.size()) {
706  if (range_start < 1 || range_end < 1) {
707  error = "rpt_unit_range start and end values must be between 1 and sequence length";
708  } else if ((size_t)range_start > m_Lens[pos]) {
709  error = "rpt_unit_range start exceeds sequence length";
710  } else if ((size_t)range_end > m_Lens[pos]) {
711  error = "rpt_unit_range end exceeds sequence length";
712  }
713  }
714  }
715  pos++;
716  if (!NStr::IsBlank(error)) {
717  any_errors = true;
718  }
719  problems.push_back(error);
720  }
721 
722  if (!any_errors) {
723  problems.clear();
724  }
725  return problems;
726 }
727 
728 
730 {
731 }
732 
733 
734 static bool IsAllRptUnitSeqChars(string seq)
735 {
736  ITERATE(string, it, seq) {
737  if (!isdigit(*it) && !isalpha(*it) && *it != '(' && *it != ')' && *it != ',' && *it != ';') {
738  return false;
739  }
740  }
741  return true;
742 }
743 
744 
745 vector<string> CRptUnitSeqColumn::IsValid(const vector<string>& values)
746 {
747  vector<string> problems;
748  bool any_errors = false;
749  ITERATE(vector<string>, it, values) {
750  if (!IsAllRptUnitSeqChars(*it)) {
751  problems.push_back("rpt_unit_seq value contains invalid characters");
752  any_errors = true;
753  } else {
754  problems.push_back("");
755  }
756  }
757  if (!any_errors) {
758  problems.clear();
759  }
760  return problems;
761 }
762 
763 const string kSatellite = "satellite";
764 
765 CSatelliteColumn::CSatelliteColumn(const string& satellite_field)
766  : CGbQualColumn(kSatellite), m_Field(eSatellite)
767 {
768  if (QualifierNamesAreEquivalent(satellite_field, "satellite-type")) {
770  }
771  else if (QualifierNamesAreEquivalent(satellite_field, "satellite-name")) {
773  }
774 }
775 
776 bool CSatelliteColumn::AddToFeature(CSeq_feat & in_out_feat, const string & newValue, EExistingText existing_text)
777 {
778  if (NStr::IsBlank(newValue)) {
779  return false;
780  }
781 
782  switch (m_Field) {
783  case (eSatellite) : {
784  const string prefixed_value = x_AddSatellitePrefix(newValue, existing_text);
785  return CGbQualColumn::AddToFeature(in_out_feat, prefixed_value, existing_text);
786  }
787  case (eSatelliteType) :
788  return x_AddSatelliteType(in_out_feat, newValue, existing_text);
789  case (eSatelliteName):
790  return x_AddSatelliteName(in_out_feat, newValue, existing_text);
791  }
792  return false;
793 }
794 
795 string CSatelliteColumn::x_AddSatellitePrefix(const string& value, EExistingText existing_text) const
796 {
797  string newValue(value);
798  if (existing_text == eExistingText_replace_old) {
799  bool type_added(false);
800  for (size_t i = 0; i < kNumSatelliteTypes; i++) {
802  type_added = true;
803  }
804  }
805  if (!type_added) {
806  newValue = kSatellite + ":" + value;
807  }
808  }
809  return newValue;
810 }
811 
812 bool CSatelliteColumn::x_AddSatelliteType(CSeq_feat & in_out_feat, const string & newValue, EExistingText existing_text)
813 {
814  // allow adding only satellite types defined in kSatelliteTypes array
815  string value(newValue);
817  bool proper_type(false);
818  for (size_t i = 0; i < kNumSatelliteTypes; i++) {
820  proper_type = true;
821  break;
822  }
823  }
824  if (!proper_type) {
825  return false;
826  }
827 
828  bool rval = false;
829  string current_type, current_name;
830  NON_CONST_ITERATE(CSeq_feat::TQual, iter, in_out_feat.SetQual()) {
831  if (NStr::EqualNocase((*iter)->GetQual(), kSatellite) && (*iter)->IsSetVal()) {
832  current_type = x_GetSatelliteType((*iter)->GetVal());
833  current_name = x_GetSatelliteName((*iter)->GetVal());
834  if (AddValueToString(current_type, value, existing_text)) {
835  (*iter)->SetVal(current_type + ":" + current_name);
836  rval = true;
837  }
838  }
839  }
840  if (!rval) {
842  in_out_feat.SetQual().push_back(qual);
843  rval = true;
844  }
845  return rval;
846 }
847 
848 bool CSatelliteColumn::x_AddSatelliteName(CSeq_feat & in_out_feat, const string & newValue, EExistingText existing_text)
849 {
850  bool rval = false;
851  string current_type, current_name;
852  NON_CONST_ITERATE(CSeq_feat::TQual, iter, in_out_feat.SetQual()) {
853  if (NStr::EqualNocase((*iter)->GetQual(), kSatellite) && (*iter)->IsSetVal()) {
854  current_type = x_GetSatelliteType((*iter)->GetVal());
855  current_name = x_GetSatelliteName((*iter)->GetVal());
856  if (AddValueToString(current_name, newValue, existing_text)) {
857  (*iter)->SetVal(current_type + ":" + current_name);
858  rval = true;
859  }
860  }
861  }
862  if (!rval) {
863  string prefixed_value = x_AddSatellitePrefix(newValue, eExistingText_replace_old);
864  CRef<CGb_qual> qual(new CGb_qual(kSatellite, prefixed_value));
865  in_out_feat.SetQual().push_back(qual);
866  rval = true;
867  }
868  return rval;
869 }
870 
872 {
873  if (!in_out_feat.IsSetQual()) {
874  return;
875  }
876  if (m_Field == eSatellite) {
877  return CGbQualColumn::ClearInFeature(in_out_feat);
878  }
879  x_ClearSatelliteSubFields(in_out_feat);
880 }
881 
883 {
884  CSeq_feat::TQual::iterator it = in_out_feat.SetQual().begin();
885  while (it != in_out_feat.SetQual().end()) {
886  if ((*it)->IsSetQual() && NStr::EqualNocase((*it)->GetQual(), kSatellite)) {
887  if (!(*it)->IsSetVal()) {
888  it = in_out_feat.SetQual().erase(it);
889  } else {
890  string newValue;
891  if (m_Field == eSatelliteType) {
892  newValue = x_GetSatelliteName((*it)->GetVal());
893  } else if (m_Field == eSatelliteName) {
894  newValue = x_GetSatelliteType((*it)->GetVal());
895  }
896  if (newValue.empty()) {
897  it = in_out_feat.SetQual().erase(it);
898  } else {
899  (*it)->SetVal(newValue);
900  ++it;
901  }
902  }
903  }
904  else {
905  ++it;
906  }
907  }
908 }
909 
910 string CSatelliteColumn::GetFromFeat(const CSeq_feat & in_out_feat)
911 {
912  string field = CGbQualColumn::GetFromFeat(in_out_feat);
913  switch (m_Field) {
914  case (eSatellite) :
915  return field;
916  case (eSatelliteType) :
917  return x_GetSatelliteType(field);
918  case (eSatelliteName) :
919  return x_GetSatelliteName(field);
920  }
921 
922  return kEmptyStr;
923 }
924 
925 string CSatelliteColumn::x_GetSatelliteType(const string& field) const
926 {
927  SIZE_TYPE pos = NStr::FindNoCase(field, ":");
928  if (pos != NPOS) {
929  return field.substr(0, pos);
930  }
931 
932  for (size_t i = 0; i < kNumSatelliteTypes; i++) {
933  if (NStr::EqualNocase(field, kSatelliteTypes[i])) {
934  return field;
935  }
936  }
937  return kEmptyStr;
938 }
939 
940 string CSatelliteColumn::x_GetSatelliteName(const string& field) const
941 {
942  SIZE_TYPE pos = NStr::FindNoCase(field, ":");
943  if (pos != NPOS) {
944  return field.substr(pos + 1, NPOS);
945  }
946 
947  for (size_t i = 0; i < kNumSatelliteTypes; i++) {
948  if (NStr::EqualNocase(field, kSatelliteTypes[i])) {
949  return kEmptyStr;
950  }
951  }
952  return field;
953 }
954 
955 
956 bool CSatelliteTypeNameColumn::AddToFeature(CSeq_feat & in_out_feat, const string & newValue, EExistingText existing_text)
957 {
958  string val = m_SatelliteType;
959  if (!NStr::IsBlank(newValue)) {
960  val += ": " + newValue;
961  }
963  in_out_feat.SetQual().push_back(qual);
964  return true;
965 }
966 
968 {
969  if (qual.IsSetQual() && NStr::EqualNocase(qual.GetQual(), kSatellite)
971  return true;
972  } else {
973  return false;
974  }
975 }
976 
977 
979 {
980  if (in_out_feat.IsSetQual()) {
981  CSeq_feat::TQual::iterator it = in_out_feat.SetQual().begin();
982  while (it != in_out_feat.SetQual().end()) {
983  if (x_IsQualAMatch(**it)) {
984  it = in_out_feat.SetQual().erase(it);
985  } else {
986  it++;
987  }
988  }
989  }
990 }
991 
992 
994 {
995  string val = "";
996  if (in_out_feat.IsSetQual()) {
997  ITERATE (CSeq_feat::TQual, it, in_out_feat.GetQual()) {
998  if (x_IsQualAMatch(**it)) {
999  val += (*it)->GetVal() + ";";
1000  }
1001  }
1002  if (!NStr::IsBlank(val)) {
1003  val = val.substr(0, val.length() - 1);
1004  }
1005  }
1006  return val;
1007 }
1008 
1009 
1011 {
1012  if (!f1.IsSetQual() || !f2.IsSetQual()) {
1013  return false;
1014  }
1015  bool yes1 = false;
1016  ITERATE (CSeq_feat::TQual, it, f1.GetQual()) {
1017  if (x_IsQualAMatch(**it)) {
1018  yes1 = true;
1019  break;
1020  }
1021  }
1022  if (!yes1) {
1023  return false;
1024  }
1025  bool yes2 = false;
1026  ITERATE (CSeq_feat::TQual, it, f2.GetQual()) {
1027  if (x_IsQualAMatch(**it)) {
1028  yes2 = true;
1029  break;
1030  }
1031  }
1032  return yes2;
1033 }
1034 
1035 
1036 vector<string> FindNonUniqueStrings(const vector<string>& values)
1037 {
1038  vector<string> sorted;
1039  sorted.assign(values.begin(), values.end());
1040  stable_sort(sorted.begin(), sorted.end());
1041 
1042  if (sorted.size() < 2) {
1043  sorted.clear();
1044  return sorted;
1045  }
1046 
1047  vector<string>::iterator it_p = sorted.begin();
1048  vector<string>::iterator it_n = it_p;
1049  int match_count = 0;
1050  it_n++;
1051  while (it_n != sorted.end()) {
1052  if (NStr::Equal(*it_p, *it_n)) {
1053  it_n = sorted.erase(it_n);
1054  match_count++;
1055  } else {
1056  if (match_count == 0) {
1057  it_p = sorted.erase(it_p);
1058  } else {
1059  it_p++;
1060  }
1061  match_count = 0;
1062  it_n = it_p;
1063  it_n++;
1064  }
1065  }
1066  if (match_count == 0) {
1067  // last item had no duplicates
1068  sorted.pop_back();
1069  }
1070  return sorted;
1071 }
1072 
1073 
1074 vector<string> SortUniqueStrings(const vector<string>& values)
1075 {
1076  vector<string> sorted;
1077  sorted.assign(values.begin(), values.end());
1078  stable_sort(sorted.begin(), sorted.end());
1079 
1080  if (sorted.size() < 2) {
1081  return sorted;
1082  }
1083 
1084  vector<string>::iterator it_p = sorted.begin();
1085  vector<string>::iterator it_n = it_p;
1086  it_n++;
1087  while (it_n != sorted.end()) {
1088  if (NStr::Equal(*it_p, *it_n)) {
1089  it_n = sorted.erase(it_n);
1090  } else {
1091  it_p++;
1092  it_n = it_p;
1093  it_n++;
1094  }
1095  }
1096  return sorted;
1097 }
1098 
1099 
1100 vector<string> CSatelliteTypeNameColumn::IsValid(const vector<string>& values)
1101 {
1102  vector<string> problems;
1103  if (!m_RequireUniqueness) {
1104  return problems;
1105  }
1106  bool any_errors = false;
1107  vector<string> sorted = FindNonUniqueStrings(values);
1108 
1109  ITERATE(vector<string>, it, values) {
1110  if (NStr::IsBlank(*it)) {
1111  problems.push_back("missing " + GetLabel());
1112  any_errors = true;
1113  } else {
1114  bool match = false;
1115  ITERATE(vector<string>, sit, sorted) {
1116  if (NStr::Equal(*it, *sit)) {
1117  match = true;
1118  break;
1119  }
1120  }
1121  if (match) {
1122  problems.push_back("duplicate " + GetLabel());
1123  any_errors = true;
1124  } else {
1125  problems.push_back("");
1126  }
1127  }
1128  }
1129  if (!any_errors) {
1130  problems.clear();
1131  }
1132  return problems;
1133 }
1134 
1135 
1136 void SetRnaProductName( CRNA_ref & rna, const string& product,
1137  string& remainder, EExistingText existing_text )
1138 {
1139  if (NStr::IsBlank(product)) {
1140  rna.SetRnaProductName(product, remainder);
1141  } else {
1142  string current = rna.GetRnaProductName();
1143  if (AddValueToString(current, product, existing_text)) {
1144  rna.SetRnaProductName(current, remainder);
1145  }
1146  }
1147 }
1148 
1149 
1150 vector<CRef<CApplyObject> > CProductColumn::GetApplyObjects(CBioseq_Handle bsh)
1151 {
1152  vector<CRef<CApplyObject> > objs;
1154  if (bsh.IsAa()) {
1155  vector<CConstRef<CObject> > feats = GetObjects(bsh);
1156  ITERATE(vector<CConstRef<CObject> >, it, feats) {
1157  const CSeq_feat* f = dynamic_cast<const CSeq_feat* >(it->GetPointer());
1158  if (f) {
1159  objs.push_back(CRef<CApplyObject>(new CApplyObject(bsh, *f)));
1160  }
1161  }
1163  if (bsh.IsAa()) {
1165  CRef<CSeq_feat> new_feat(new CSeq_feat());
1166  CRef<CSeq_id> id(new CSeq_id());
1167  id->Assign(*(bsh.GetId().front().GetSeqId()));
1168  new_feat->SetLocation().SetInt().SetId(*id);
1169  new_feat->SetLocation().SetInt().SetFrom(0);
1170  new_feat->SetLocation().SetInt().SetTo(bsh.GetInst_Length() - 1);
1171  new_feat->SetData().SetProt();
1172  const CSeq_feat* cds = sequence::GetCDSForProduct(bsh);
1173  if (cds) {
1175  }
1176  CRef<CObject> new_obj(new_feat.GetPointer());
1177  objs.push_back(CRef<CApplyObject>(new CApplyObject(seh, CConstRef<CObject>(NULL), new_obj)));
1178  }
1179  }
1180  } else {
1182  while (f) {
1183  if (f->IsSetProduct()) {
1184  CBioseq_Handle p_bsh = bsh.GetScope().GetBioseqHandle(f->GetProduct());
1185  if (p_bsh) {
1186  vector<CRef<CApplyObject> > p_objs = GetApplyObjects(p_bsh);
1187  objs.insert(objs.end(), p_objs.begin(), p_objs.end());
1188  }
1189  } else {
1190  objs.push_back(CRef<CApplyObject>(new CApplyObject(bsh, *(f->GetOriginalSeq_feat()))));
1191  }
1192  ++f;
1193  }
1194  }
1195  } else {
1196  // not a protein feature
1197  vector<CConstRef<CObject> > feats = GetObjects(bsh);
1198  ITERATE(vector<CConstRef<CObject> >, it, feats) {
1199  const CSeq_feat* f = dynamic_cast<const CSeq_feat* >(it->GetPointer());
1200  if (f) {
1201  objs.push_back(CRef<CApplyObject>(new CApplyObject(bsh, *f)));
1202  }
1203  }
1204  }
1205  return objs;
1206 }
1207 
1208 
1209 bool CProductColumn::AddToFeature( CSeq_feat & in_out_feat, const string & newValue,
1210  EExistingText existing_text)
1211 {
1212  if (in_out_feat.GetData().IsRna()) {
1213  string remainder;
1214  SetRnaProductName(in_out_feat.SetData().SetRna(), newValue, remainder, existing_text);
1215  if (!NStr::IsBlank(remainder)) {
1216  if (in_out_feat.IsSetComment() && !NStr::IsBlank(in_out_feat.GetComment())) {
1217  in_out_feat.SetComment(in_out_feat.GetComment() + "; " + remainder);
1218  } else {
1219  in_out_feat.SetComment(remainder);
1220  }
1221  }
1222  } else {
1223  if (in_out_feat.GetData().Which() == CSeqFeatData::e_Prot) {
1224  if (in_out_feat.GetData().GetProt().IsSetName()) {
1225  if (in_out_feat.GetData().GetProt().GetName().size() > 0) {
1226  string current = in_out_feat.GetData().GetProt().GetName().front();
1227  if (AddValueToString(current, newValue, existing_text)){
1228  in_out_feat.SetData().SetProt().SetName().front() = current;
1229  }
1230  } else {
1231  in_out_feat.SetData().SetProt().SetName().push_back(newValue);
1232  }
1233  } else {
1234  if (!NStr::IsBlank(newValue)) {
1235  in_out_feat.SetData().SetProt().SetName().push_back(newValue);
1236  }
1237  }
1238  } else {
1239  return CGbQualColumn::AddToFeature (in_out_feat, newValue, existing_text);
1240  }
1241  }
1242  return true;
1243 }
1244 
1245 
1247 {
1248  if (in_out_feat.GetData().IsRna()) {
1249  string remainder;
1250  SetRnaProductName(in_out_feat.SetData().SetRna(), "", remainder, eExistingText_replace_old);
1251  } else {
1252  if (in_out_feat.GetData().GetProt().IsSetName()) {
1253  in_out_feat.SetData().SetProt().ResetName();
1254  } else {
1255  CGbQualColumn::ClearInFeature (in_out_feat);
1256  }
1257  }
1258 }
1259 
1260 string CProductColumn::GetFromFeat( const CSeq_feat & in_out_feat )
1261 {
1262  string val = "";
1263  if (in_out_feat.GetData().IsRna()) {
1264  val = in_out_feat.GetData().GetRna().GetRnaProductName();
1265  } else if (in_out_feat.GetData().IsProt()) {
1266  if (in_out_feat.GetData().GetProt().IsSetName() && !in_out_feat.GetData().GetProt().GetName().empty() ) {
1267  val = in_out_feat.GetData().GetProt().GetName().front();
1268  }
1269  } else {
1270  val = CGbQualColumn::GetFromFeat (in_out_feat);
1271  }
1272  return val;
1273 }
1274 
1275 
1276 vector<CRef<CApplyObject> > CCodonStartColumn::GetApplyObjects(CBioseq_Handle bsh)
1277 {
1278  m_Scope.Reset(&(bsh.GetScope()));
1279  vector<CRef<CApplyObject> > objs;
1281  const CSeq_feat* cds = sequence::GetCDSForProduct(bsh);
1282  if (cds) {
1283  CBioseq_Handle n_bsh = bsh.GetScope().GetBioseqHandle(cds->GetLocation());
1284  if (n_bsh) {
1285  objs.push_back(CRef<CApplyObject>(new CApplyObject(n_bsh, *cds)));
1286  }
1287  }
1288  } else {
1290  }
1291  return objs;
1292 }
1293 
1294 
1295 bool CCodonStartColumn::AddToFeature( CSeq_feat & in_out_feat, const string & newValue,
1296  EExistingText existing_text)
1297 {
1298  bool rval = false;
1299  if (in_out_feat.GetData().IsCdregion() && m_Scope) {
1300  edit::ApplyCDSFrame::ECdsFrame f = edit::ApplyCDSFrame::s_GetFrameFromName(newValue);
1302  edit::ApplyCDSFrame::s_SetCDSFrame(in_out_feat, f, *m_Scope);
1303  rval = true;
1304  }
1305  }
1306  if (!rval) {
1307  rval = CGbQualColumn::AddToFeature (in_out_feat, newValue, existing_text);
1308  }
1309  return rval;
1310 }
1311 
1312 
1314 {
1315  if (in_out_feat.GetData().IsCdregion()) {
1316  in_out_feat.SetData().SetCdregion().ResetFrame();
1317  } else {
1318  CGbQualColumn::ClearInFeature (in_out_feat);
1319  }
1320 }
1321 
1322 
1323 string CCodonStartColumn::GetFromFeat( const CSeq_feat & in_out_feat )
1324 {
1325  string val = "";
1326  if (in_out_feat.GetData().IsCdregion()) {
1327  if (in_out_feat.GetData().GetCdregion().IsSetFrame()) {
1328  switch (in_out_feat.GetData().GetCdregion().GetFrame()) {
1329  case CCdregion::eFrame_one:
1331  val = "1";
1332  break;
1333  case CCdregion::eFrame_two:
1334  val = "2";
1335  break;
1337  val = "3";
1338  break;
1339  }
1340  } else {
1341  val = "1";
1342  }
1343  } else {
1344  val = CGbQualColumn::GetFromFeat(in_out_feat);
1345  }
1346  return val;
1347 }
1348 
1349 bool CGeneticCodeColumn::AddToFeature(CSeq_feat & in_out_feat, const string & newValue,
1350  EExistingText existing_text)
1351 {
1352  try {
1354  if (gc > 0 && in_out_feat.GetData().IsCdregion()) {
1355  in_out_feat.SetData().SetCdregion().SetCode().SetId(gc);
1356  return true;
1357  }
1358  }
1359  catch(const CException&)
1360  {
1361  return CGbQualColumn::AddToFeature(in_out_feat, newValue, existing_text);
1362  }
1363  catch (const exception&)
1364  {
1365  return CGbQualColumn::AddToFeature(in_out_feat, newValue, existing_text);
1366  }
1367  return false;
1368 }
1369 
1371 {
1372  if (in_out_feat.GetData().IsCdregion()) {
1373  in_out_feat.SetData().SetCdregion().ResetCode();
1374  }
1375  else {
1376  CGbQualColumn::ClearInFeature(in_out_feat);
1377  }
1378 }
1379 
1380 string CGeneticCodeColumn::GetFromFeat(const CSeq_feat & in_out_feat)
1381 {
1382  if (!in_out_feat.GetData().IsCdregion())
1383  return kEmptyStr;
1384 
1385  const CCdregion& cdregion = in_out_feat.GetData().GetCdregion();
1386  if (cdregion.IsSetCode()) {
1387  int gc = cdregion.GetCode().GetId();
1388  return NStr::IntToString(gc);
1389  }
1390 
1391  return kEmptyStr;
1392 }
1393 
1394 bool CDescriptionColumn::AddToFeature(CSeq_feat & in_out_feat, const string & newValue,
1395  EExistingText existing_text)
1396 {
1397  bool rval = false;
1398  if (in_out_feat.GetData().IsGene()) {
1399  string current = kEmptyStr;
1400  if (in_out_feat.GetData().GetGene().IsSetDesc()) {
1401  current = in_out_feat.GetData().GetGene().GetDesc();
1402  }
1403  if (AddValueToString(current, newValue, existing_text)) {
1404  in_out_feat.SetData().SetGene().SetDesc(current);
1405  rval = true;
1406  }
1407  } else if (in_out_feat.GetData().IsProt()) {
1408  string current = kEmptyStr;
1409  if (in_out_feat.GetData().GetProt().IsSetDesc()) {
1410  current = in_out_feat.GetData().GetProt().GetDesc();
1411  }
1412  if (AddValueToString(current, newValue, existing_text)) {
1413  in_out_feat.SetData().SetProt().SetDesc(current);
1414  rval = true;
1415  }
1416  } else {
1417  rval = CGbQualColumn::AddToFeature(in_out_feat, newValue, existing_text);
1418  }
1419  return rval;
1420 }
1421 
1423 {
1424  if (in_out_feat.GetData().IsGene()) {
1425  in_out_feat.SetData().SetGene().ResetDesc();
1426  } else if (in_out_feat.GetData().IsProt()) {
1427  in_out_feat.SetData().SetProt().ResetDesc();
1428  } else {
1429  CGbQualColumn::ClearInFeature(in_out_feat);
1430  }
1431 }
1432 
1433 
1434 string CDescriptionColumn::GetFromFeat( const CSeq_feat & in_out_feat )
1435 {
1436  string val = "";
1437  if (in_out_feat.GetData().IsGene()) {
1438  if (in_out_feat.GetData().GetGene().IsSetDesc()) {
1439  val = in_out_feat.GetData().GetGene().GetDesc();
1440  }
1441  } else if (in_out_feat.GetData().IsProt()) {
1442  if (in_out_feat.GetData().GetProt().IsSetDesc()) {
1443  val = in_out_feat.GetData().GetProt().GetDesc();
1444  }
1445  } else {
1446  val = CGbQualColumn::GetFromFeat(in_out_feat);
1447  }
1448  return val;
1449 }
1450 
1451 
1453  : CGbQualColumn(qual)
1454 {
1456 }
1457 
1458 
1460 {
1461  EFieldType field_type = eFieldType_other;
1462 
1463  if (QualifierNamesAreEquivalent(qual, "locus")) {
1464  field_type = eFieldType_locus;
1465  } else if (QualifierNamesAreEquivalent(qual, "locus_tag")) {
1466  field_type = eFieldType_locus_tag;
1467  } else if (QualifierNamesAreEquivalent(qual, "maploc")) {
1468  field_type = eFieldType_maploc;
1469  } else if (QualifierNamesAreEquivalent(qual, "synonym")) {
1470  field_type = eFieldType_synonym;
1471  } else if (QualifierNamesAreEquivalent(qual, "allele")) {
1472  field_type = eFieldType_allele;
1473  }
1474  return field_type;
1475 
1476 }
1477 
1478 
1480 {
1481  EFieldType field_type = x_GetFieldTypeFromString(qual);
1482  if (field_type == eFieldType_other) {
1483  return false;
1484  } else {
1485  return true;
1486  }
1487 }
1488 
1489 
1490 bool CGeneRefColumn::AddToFeature(CSeq_feat & in_out_feat, const string & newValue,
1491  EExistingText existing_text)
1492 {
1493  bool rval = false;
1494  string current = kEmptyStr;
1495  if (in_out_feat.GetData().IsGene()) {
1496  CConstRef<CGene_ref> gene(&(in_out_feat.GetData().GetGene()));
1497  switch (m_FieldType) {
1498  case eFieldType_locus:
1499  if (gene->IsSetLocus()) {
1500  current = gene->GetLocus();
1501  }
1502  if (AddValueToString(current, newValue, existing_text)) {
1503  in_out_feat.SetData().SetGene().SetLocus(current);
1504  rval = true;
1505  }
1506  break;
1507  case eFieldType_locus_tag:
1508  if (gene->IsSetLocus_tag()) {
1509  current = gene->GetLocus_tag();
1510  }
1511  if (AddValueToString(current, newValue, existing_text)) {
1512  in_out_feat.SetData().SetGene().SetLocus_tag(current);
1513  rval = true;
1514  }
1515  break;
1516  case eFieldType_maploc:
1517  if (gene->IsSetMaploc()) {
1518  current = gene->GetMaploc();
1519  }
1520  if (AddValueToString(current, newValue, existing_text)) {
1521  in_out_feat.SetData().SetGene().SetMaploc(current);
1522  rval = true;
1523  }
1524  break;
1525  case eFieldType_synonym:
1526  if (gene->IsSetSyn()) {
1527  in_out_feat.SetData().SetGene().SetSyn().front() = newValue;
1528  } else {
1529  in_out_feat.SetData().SetGene().SetSyn().push_back(newValue);
1530  }
1531  break;
1532  case eFieldType_allele:
1533  if (gene->IsSetAllele()) {
1534  current = gene->GetAllele();
1535  }
1536  if (AddValueToString(current, newValue, existing_text)) {
1537  in_out_feat.SetData().SetGene().SetAllele(current);
1538  rval = true;
1539  }
1540  break;
1541  default:
1542  rval = CGbQualColumn::AddToFeature(in_out_feat, newValue, existing_text);
1543  break;
1544  }
1545  } else {
1546  const CGene_ref* gene = in_out_feat.GetGeneXref();
1547  if (gene) {
1548  switch (m_FieldType) {
1549  case eFieldType_locus:
1550  if (gene->IsSetLocus()) {
1551  current = gene->GetLocus();
1552  if (AddValueToString(current, newValue, existing_text)) {
1553  in_out_feat.SetGeneXref().SetLocus(current);
1554  rval = true;
1555  }
1556  } else {
1557  in_out_feat.SetGeneXref().SetLocus(newValue);
1558  rval = true;
1559  }
1560  break;
1561  case eFieldType_locus_tag:
1562  if (gene->IsSetLocus_tag()) {
1563  current = gene->GetLocus_tag();
1564  if (AddValueToString(current, newValue, existing_text)) {
1565  in_out_feat.SetGeneXref().SetLocus_tag(current);
1566  rval = true;
1567  }
1568  } else {
1569  in_out_feat.SetGeneXref().SetLocus_tag(newValue);
1570  rval = true;
1571  }
1572  break;
1573  case eFieldType_maploc:
1574  if (gene->IsSetMaploc()) {
1575  current = gene->GetMaploc();
1576  if (AddValueToString(current, newValue, existing_text)) {
1577  in_out_feat.SetGeneXref().SetMaploc(current);
1578  rval = true;
1579  }
1580  } else {
1581  in_out_feat.SetGeneXref().SetMaploc(newValue);
1582  rval = true;
1583  }
1584  break;
1585  case eFieldType_synonym:
1586  in_out_feat.SetGeneXref().SetSyn().front() = newValue;
1587  break;
1588  case eFieldType_allele:
1589  if (gene->IsSetAllele()) {
1590  current = gene->GetAllele();
1591  if (AddValueToString(current, newValue, existing_text)) {
1592  in_out_feat.SetGeneXref().SetAllele(current);
1593  rval = true;
1594  }
1595  } else {
1596  in_out_feat.SetGeneXref().SetAllele(newValue);
1597  rval = true;
1598  }
1599  break;
1600  default:
1601  break;
1602  }
1603  } else {
1604  rval = CGbQualColumn::AddToFeature(in_out_feat, newValue, existing_text);
1605  }
1606  }
1607  return rval;
1608 }
1609 
1611 {
1612  if (in_out_feat.GetData().IsGene()) {
1613  switch (m_FieldType) {
1614  case eFieldType_locus:
1615  in_out_feat.SetData().SetGene().ResetLocus();
1616  break;
1617  case eFieldType_locus_tag:
1618  in_out_feat.SetData().SetGene().ResetLocus_tag();
1619  break;
1620  case eFieldType_maploc:
1621  in_out_feat.SetData().SetGene().ResetMaploc();
1622  break;
1623  case eFieldType_synonym:
1624  in_out_feat.SetData().SetGene().ResetSyn();
1625  break;
1626  case eFieldType_allele:
1627  in_out_feat.SetData().SetGene().ResetAllele();
1628  break;
1629  default:
1630  CGbQualColumn::ClearInFeature(in_out_feat);
1631  break;
1632  }
1633  } else if ( in_out_feat.IsSetXref()) {
1634  switch (m_FieldType) {
1635  case eFieldType_locus:
1636  in_out_feat.SetGeneXref().ResetLocus();
1637  break;
1638  case eFieldType_locus_tag:
1639  in_out_feat.SetGeneXref().ResetLocus_tag();
1640  break;
1641  case eFieldType_maploc:
1642  in_out_feat.SetGeneXref().ResetMaploc();
1643  break;
1644  case eFieldType_synonym:
1645  in_out_feat.SetGeneXref().ResetSyn();
1646  break;
1647  case eFieldType_allele:
1648  in_out_feat.SetGeneXref().ResetAllele();
1649  break;
1650  default:
1651  CGbQualColumn::ClearInFeature(in_out_feat);
1652  break;
1653  }
1654  }
1655  CGbQualColumn::ClearInFeature(in_out_feat);
1656 }
1657 
1658 
1659 string CGeneRefColumn::GetFromFeat( const CSeq_feat & in_out_feat )
1660 {
1661  string val;
1662  if (in_out_feat.GetData().IsGene()) {
1663  switch (m_FieldType) {
1664  case eFieldType_locus:
1665  if (in_out_feat.GetData().GetGene().IsSetLocus()) {
1666  val = in_out_feat.GetData().GetGene().GetLocus();
1667  }
1668  break;
1669  case eFieldType_locus_tag:
1670  if (in_out_feat.GetData().GetGene().IsSetLocus_tag()) {
1671  val = in_out_feat.GetData().GetGene().GetLocus_tag();
1672  }
1673  break;
1674  case eFieldType_maploc:
1675  if (in_out_feat.GetData().GetGene().IsSetMaploc()) {
1676  val = in_out_feat.GetData().GetGene().GetMaploc();
1677  }
1678  break;
1679  case eFieldType_synonym:
1680  if (in_out_feat.GetData().GetGene().IsSetSyn()
1681  && in_out_feat.GetData().GetGene().GetSyn().size() > 0) {
1682  val = in_out_feat.GetData().GetGene().GetSyn().front();
1683  }
1684  break;
1685  case eFieldType_allele:
1686  if (in_out_feat.GetData().GetGene().IsSetAllele()) {
1687  val = in_out_feat.GetData().GetGene().GetAllele();
1688  }
1689  break;
1690  default:
1691  val = CGbQualColumn::GetFromFeat(in_out_feat);
1692  break;
1693  }
1694  } else {
1695  CConstRef<CGene_ref> gene_ref;
1696  if (in_out_feat.IsSetXref()) {
1697  ITERATE(CSeq_feat::TXref, it, in_out_feat.GetXref()) {
1698  if ((*it)->IsSetData() && (*it)->GetData().IsGene()) {
1699  gene_ref = &((*it)->GetData().GetGene());
1700  break;
1701  }
1702  }
1703  }
1704  if (gene_ref) {
1705  switch (m_FieldType) {
1706  case eFieldType_locus:
1707  if (gene_ref->IsSetLocus()) {
1708  val = gene_ref->GetLocus();
1709  }
1710  break;
1711  case eFieldType_locus_tag:
1712  if (gene_ref->IsSetLocus_tag()) {
1713  val = gene_ref->GetLocus_tag();
1714  }
1715  break;
1716  case eFieldType_maploc:
1717  if (gene_ref->IsSetMaploc()) {
1718  val = gene_ref->GetMaploc();
1719  }
1720  break;
1721  case eFieldType_synonym:
1722  if (gene_ref->IsSetSyn() && gene_ref->GetSyn().size() > 0) {
1723  val = gene_ref->GetSyn().front();
1724  }
1725  break;
1726  case eFieldType_allele:
1727  if (gene_ref->IsSetAllele()) {
1728  val = gene_ref->GetAllele();
1729  }
1730  break;
1731  default:
1732  break;
1733  }
1734  } else {
1735  val = CGbQualColumn::GetFromFeat(in_out_feat);
1736  }
1737  }
1738  if (val.empty())
1739  {
1740  val = CGbQualColumn::GetFromFeat(in_out_feat);
1741  }
1742  return val;
1743 }
1744 
1745 vector<CRef<CApplyObject> > CGeneRefColumn::GetApplyObjects(CBioseq_Handle bsh)
1746 {
1747  vector<CRef<CApplyObject> > objs;
1750  } else {
1751  objs = GetRelatedGeneApplyObjects(bsh);
1752  }
1753  return objs;
1754 }
1755 
1756 
1758  : CGbQualColumn(qual)
1759 {
1761 }
1762 
1763 
1765 {
1766  EFieldType field_type = eFieldType_other;
1767 
1768  if (QualifierNamesAreEquivalent(qual, "name")) {
1769  field_type = eFieldType_name;
1770  } else if (QualifierNamesAreEquivalent(qual, "ec_number")) {
1771  field_type = eFieldType_ec_number;
1772  } else if (QualifierNamesAreEquivalent(qual, "activity")) {
1773  field_type = eFieldType_activity;
1774  }
1775  return field_type;
1776 
1777 }
1778 
1779 
1781 {
1782  EFieldType field_type = x_GetFieldTypeFromString(qual);
1783  if (field_type == eFieldType_other) {
1784  return false;
1785  } else {
1786  return true;
1787  }
1788 }
1789 
1790 bool CProtRefColumn::AddToFeature(CSeq_feat & in_out_feat, const string & newValue,
1791  EExistingText existing_text)
1792 {
1793  bool rval = false;
1794  if (in_out_feat.GetData().IsProt()) {
1795  switch (m_FieldType) {
1796  case eFieldType_name: // only the first one is updated
1797  if (in_out_feat.GetData().GetProt().IsSetName() &&
1798  in_out_feat.GetData().GetProt().GetName().size() > 0) {
1799  string current = in_out_feat.GetData().GetProt().GetName().front();
1800  if (AddValueToString(current, newValue, existing_text)) {
1801  in_out_feat.SetData().SetProt().SetName().front() = current;
1802  rval = true;
1803  }
1804  } else if (!NStr::IsBlank(newValue)){
1805  in_out_feat.SetData().SetProt().SetName().push_back(newValue);
1806  rval = true;
1807  }
1808  break;
1809  case eFieldType_ec_number: // all of them needs to be updated
1810  if (in_out_feat.GetData().GetProt().IsSetEc()) {
1811  NON_CONST_ITERATE(CProt_ref::TEc, it, in_out_feat.SetData().SetProt().SetEc()) {
1812  string current = *it;
1813  if (AddValueToString(current, newValue, existing_text)) {
1814  *it = current;
1815  rval = true;
1816  }
1817  }
1818  } else if (!NStr::IsBlank(newValue)) {
1819  in_out_feat.SetData().SetProt().SetEc().push_back(newValue);
1820  rval = true;
1821  }
1822  break;
1823  case eFieldType_activity: // all of them needs to be updated
1824  if (in_out_feat.GetData().GetProt().IsSetActivity()) {
1825  NON_CONST_ITERATE(CProt_ref::TActivity, it, in_out_feat.SetData().SetProt().SetActivity()) {
1826  string current = *it;
1827  if (AddValueToString(current, newValue, existing_text)) {
1828  *it = current;
1829  rval = true;
1830  }
1831  }
1832  } else if (!NStr::IsBlank(newValue)) {
1833  in_out_feat.SetData().SetProt().SetActivity().push_back(newValue);
1834  rval = true;
1835  }
1836  break;
1837  default:
1838  rval = CGbQualColumn::AddToFeature(in_out_feat, newValue, existing_text);
1839  break;
1840  }
1841  } else {
1842  rval = CGbQualColumn::AddToFeature(in_out_feat, newValue, existing_text);
1843  }
1844  return rval;
1845 }
1846 
1847 
1849 {
1850  if (in_out_feat.GetData().IsProt()) {
1851  switch (m_FieldType) {
1852  case eFieldType_name:
1853  in_out_feat.SetData().SetProt().ResetName();
1854  break;
1855  case eFieldType_ec_number:
1856  in_out_feat.SetData().SetProt().ResetEc();
1857  break;
1858  case eFieldType_activity:
1859  in_out_feat.SetData().SetProt().ResetActivity();
1860  break;
1861  default:
1862  CGbQualColumn::ClearInFeature(in_out_feat);
1863  break;
1864  }
1865  } else {
1866  CGbQualColumn::ClearInFeature(in_out_feat);
1867  }
1868 }
1869 
1870 
1871 string CProtRefColumn::GetFromFeat( const CSeq_feat & in_out_feat )
1872 {
1873  string val = "";
1874  if (in_out_feat.GetData().IsProt()) {
1875  switch (m_FieldType) {
1876  case eFieldType_name:
1877  if (in_out_feat.GetData().GetProt().IsSetName()
1878  && in_out_feat.GetData().GetProt().GetName().size() > 0) {
1879  val = in_out_feat.GetData().GetProt().GetName().front();
1880  }
1881  break;
1882  case eFieldType_ec_number:
1883  if (in_out_feat.GetData().GetProt().IsSetEc()
1884  && in_out_feat.GetData().GetProt().GetEc().size() > 0) {
1885  val = in_out_feat.GetData().GetProt().GetEc().front();
1886  }
1887  break;
1888  case eFieldType_activity:
1889  if (in_out_feat.GetData().GetProt().IsSetActivity()
1890  && in_out_feat.GetData().GetProt().GetActivity().size() > 0) {
1891  val = in_out_feat.GetData().GetProt().GetActivity().front();
1892  }
1893  break;
1894  default:
1895  val = CGbQualColumn::GetFromFeat(in_out_feat);
1896  break;
1897  }
1898  } else {
1899  val = CGbQualColumn::GetFromFeat(in_out_feat);
1900  }
1901 
1902  return val;
1903 }
1904 
1905 
1906 bool CNcrnaClassColumn::AddToFeature(CSeq_feat & in_out_feat, const string & newValue,
1907  EExistingText existing_text)
1908 {
1909  bool rval = false;
1910  if (in_out_feat.GetData().GetSubtype() == CSeqFeatData::eSubtype_ncRNA) {
1911  in_out_feat.SetData().SetRna().SetExt().SetGen().SetClass(newValue);
1912  rval = true;
1913  } else {
1914  rval = CGbQualColumn::AddToFeature(in_out_feat, newValue, existing_text);
1915  }
1916  return rval;
1917 }
1918 
1920 {
1921  if (in_out_feat.GetData().GetSubtype() == CSeqFeatData::eSubtype_ncRNA) {
1922  in_out_feat.SetData().SetRna().SetExt().SetGen().ResetClass();
1923  } else {
1924  CGbQualColumn::ClearInFeature(in_out_feat);
1925  }
1926 }
1927 
1928 
1929 string CNcrnaClassColumn::GetFromFeat( const CSeq_feat & in_out_feat )
1930 {
1931  string val = "";
1932  if (in_out_feat.GetData().GetSubtype() == CSeqFeatData::eSubtype_ncRNA) {
1933  if (in_out_feat.GetData().GetRna().IsSetExt()
1934  && in_out_feat.GetData().GetRna().GetExt().IsGen()
1935  && in_out_feat.GetData().GetRna().GetExt().GetGen().IsSetClass()) {
1936  val = in_out_feat.GetData().GetRna().GetExt().GetGen().GetClass();
1937  }
1938  } else {
1939  val = CGbQualColumn::GetFromFeat(in_out_feat);
1940  }
1941  return val;
1942 }
1943 
1944 
1946 {
1947  int feat_id = 0;
1948  for (CFeat_CI feat_it(entry); feat_it; ++feat_it) {
1949  if (feat_it->IsSetId()) {
1950  const CFeat_id &id = feat_it->GetId();
1951  if (id.IsLocal() && id.GetLocal().IsId() && id.GetLocal().GetId() > feat_id) {
1952  feat_id = id.GetLocal().GetId();
1953  }
1954  }
1955  }
1956  return feat_id;
1957 }
1958 
1959 
1961 {
1962  if (!feat.IsSetId()) {
1963  CSeq_feat_EditHandle fh(feat);
1964  fh.SetFeatId(top_id + 1);
1965  top_id++;
1966  }
1967  const CFeat_id &fid = feat.GetId();
1968  if (fid.IsLocal() && fid.GetLocal().IsId()) {
1970  } else {
1971  AddValueToColumn(column, "non-local int ID", row);
1972  }
1973 }
1974 
1975 
1977 {
1978  CSeq_feat_Handle orig_feat;
1979 
1980  try {
1981  int id = NStr::StringToInt(id_string);
1983  id);
1984  } catch(const CException& e) {
1985  LOG_POST(Error << "GetFeatureFromTableId() failed: " << e.GetMsg());
1986  } catch (const exception& e) {
1987  LOG_POST(Error << "GetFeatureFromTableId() failed: " << e.what());
1988  }
1989 
1990  return orig_feat;
1991 }
1992 
1993 
1995 {
1997 
1998  int top_id = FindHighestFeatureId(entry);
1999 
2000  // first column is sequence ID
2003  id_col->SetHeader().SetTitle(kSequenceIdColLabel);
2004  table->SetColumns().push_back(id_col);
2005  // second column is feature ID
2007 
2008  int row = 0;
2009  CFeat_CI feat (entry, sel);
2010  while (feat) {
2011  CBioseq_Handle bsh = entry.GetBioseqHandle(*(feat->GetLocation().GetId()));
2012  CRef<CSeq_id> id(new CSeq_id());
2013  id->Assign(*(bsh.GetSeqId()));
2014  table->SetColumns()[0]->SetData().SetId().push_back(id);
2015 
2016  AddToFeatureIdColumn(feat->GetSeq_feat_Handle(), table->SetColumns()[1], row, top_id);
2017 
2018  ++feat;
2019  ++row;
2020  }
2021 
2022  table->SetNum_rows(row);
2024 
2025  return table;
2026 }
2027 
2028 
2029 void AddColumnsToFeatureTable(const vector<string> & fields, CRef<CSeq_table> table, CSeq_entry_Handle entry)
2030 {
2031  TFeatureSeqTableColumnList field_list;
2032  vector<CRef<CSeqTable_column> > column_list;
2033  bool need_gene = false;
2034  bool need_mrna = false;
2035  bool need_prot = false;
2036  ITERATE (vector<string>, sit, fields) {
2038  field_list.push_back(featcol);
2039  column_list.push_back(AddStringColumnToTable(table, *sit));
2040  if (NStr::StartsWith(*sit, "gene ")) {
2041  need_gene = true;
2042  } else if (NStr::StartsWith(*sit, "mrna ", NStr::eNocase)) {
2043  need_mrna = true;
2044  } else if (NStr::StartsWith(*sit, "protein ")) {
2045  need_prot = true;
2046  }
2047  }
2048 
2049  for (int row = 0; row < table->GetNum_rows(); row++) {
2050  string id_string = table->GetColumns()[1]->GetData().GetString()[row];
2051  CSeq_feat_Handle orig_feat = GetFeatureFromTableId(id_string, entry);
2052  if (orig_feat) {
2053  CConstRef<CSeq_feat> gene;
2054  if (need_gene) {
2055  gene = sequence::GetOverlappingGene(orig_feat.GetLocation(), entry.GetScope());
2056  }
2057  CConstRef<CSeq_feat> mrna;
2059  if (orig_feat.GetData().IsCdregion() && (need_mrna || need_prot)) {
2060  if (need_mrna) {
2061  mrna = sequence::GetOverlappingmRNA(orig_feat.GetLocation(), entry.GetScope());
2062  }
2063  if (orig_feat.IsSetProduct() && need_prot) {
2064  CBioseq_Handle prot_bsh = entry.GetScope().GetBioseqHandle(*(orig_feat.GetProduct().GetId()));
2065  if (prot_bsh) {
2067  if (f) {
2068  prot = f->GetOriginalSeq_feat();
2069  }
2070  }
2071  }
2072  }
2073  for (size_t i = 0; i < field_list.size(); i++) {
2074  string val = "";
2075  if (NStr::StartsWith(fields[i], "gene ") && !orig_feat.GetData().IsGene()) {
2076  // from gene feature
2077  if (gene) {
2078  val = field_list[i]->GetFromFeat(*gene);
2079  }
2080  } else if (NStr::StartsWith(fields[i], "mRNA ", NStr::eNocase) && orig_feat.GetData().GetSubtype() != CSeqFeatData::eSubtype_mRNA) {
2081  // from mRNA feature
2082  if (mrna) {
2083  val = field_list[i]->GetFromFeat(*mrna);
2084  }
2085  } else if (NStr::StartsWith(fields[i], "protein ") && !orig_feat.GetData().IsProt()) {
2086  if (prot) {
2087  val = field_list[i]->GetFromFeat(*prot);
2088  }
2089  } else {
2090  val = field_list[i]->GetFromFeat(*(orig_feat.GetSeq_feat()));
2091  }
2092  AddValueToColumn(column_list[i], val, row);
2093  }
2094  }
2095  }
2097 }
2098 
2099 
2101 {
2102  CRef<CCmdComposite> cmd( new CCmdComposite("Edit Features") );
2103  bool any_change = false;
2104 
2105  bool need_gene = false;
2106  bool need_mrna = false;
2107  bool need_prot = false;
2108 
2109  TFeatureSeqTableColumnList field_list;
2110  for (size_t col = 2; col < table->GetColumns().size(); col++) {
2111  string title = table->GetColumns()[col]->GetHeader().GetTitle();
2113  field_list.push_back(featcol);
2114  if (NStr::StartsWith(title, "gene ")) {
2115  need_gene = true;
2116  } else if (NStr::StartsWith(title, "mrna ", NStr::eNocase)) {
2117  need_mrna = true;
2118  } else if (NStr::StartsWith(title, "protein ")) {
2119  need_prot = true;
2120  }
2121  }
2122 
2123  for (size_t row = 0; row < table->GetNum_rows(); row++) {
2124  string id_string = table->GetColumns()[1]->GetData().GetString()[row];
2125  CSeq_feat_Handle orig_feat = GetFeatureFromTableId(id_string, entry);
2126  if (orig_feat) {
2127  CConstRef<CSeq_feat> gene;
2128  CConstRef<CSeq_feat> mrna;
2130  if (need_gene) {
2131  gene = sequence::GetOverlappingGene(orig_feat.GetLocation(), entry.GetScope());
2132  }
2133  if (orig_feat.GetData().IsCdregion() && (need_mrna || need_prot)) {
2134  if (need_mrna) {
2135  mrna = sequence::GetOverlappingmRNA(orig_feat.GetLocation(), entry.GetScope());
2136  }
2137  if (orig_feat.IsSetProduct() && need_prot) {
2138  CBioseq_Handle prot_bsh = entry.GetScope().GetBioseqHandle(*(orig_feat.GetProduct().GetId()));
2139  if (prot_bsh) {
2141  if (f) {
2142  prot = f->GetOriginalSeq_feat();
2143  }
2144  }
2145  }
2146  }
2147  CRef<CSeq_feat> new_feat(new CSeq_feat());
2148  new_feat->Assign(*(orig_feat.GetSeq_feat()));
2149  CRef<CSeq_feat> new_gene(new CSeq_feat());
2150  CRef<CSeq_feat> new_mrna(new CSeq_feat());
2151  CRef<CSeq_feat> new_prot(new CSeq_feat());
2152 
2153  if (gene) {
2154  new_gene->Assign(*gene);
2155  } else {
2156  new_gene->SetData().SetGene();
2157  new_gene->SetLocation().Assign(new_feat->GetLocation());
2158  }
2159  if (mrna) {
2160  new_mrna->Assign(*mrna);
2161  } else {
2162  new_mrna->SetData().SetRna().SetType(CRNA_ref::eType_mRNA);
2163  new_mrna->SetLocation().Assign(new_feat->GetLocation());
2164  }
2165  if (prot) {
2166  new_prot->Assign(*prot);
2167  }
2168 
2169  bool changed_feat = false;
2170  bool changed_gene = false;
2171  bool changed_mrna = false;
2172  bool changed_prot = false;
2173  for (size_t col = 2; col < table->GetColumns().size(); col++) {
2174  string title = table->GetColumns()[col]->GetHeader().GetTitle();
2175  string new_val = table->GetColumns()[col]->GetData().GetString()[row];
2176  if (NStr::StartsWith(title, "gene ") && !orig_feat.GetData().IsGene()) {
2177  string orig_val = "";
2178  if (gene) {
2179  orig_val = field_list[col - 2]->GetFromFeat(*gene);
2180  }
2181  if (!NStr::Equal(new_val, orig_val)) {
2182  if (NStr::IsBlank(new_val)) {
2183  field_list[col - 2]->ClearInFeature(*new_gene);
2184  } else {
2185  field_list[col - 2]->AddToFeature(*new_gene, new_val, eExistingText_replace_old);
2186  }
2187  changed_gene = true;
2188  }
2189  } else if (NStr::StartsWith(title, "mrna ", NStr::eNocase) && orig_feat.GetData().GetSubtype() != CSeqFeatData::eSubtype_mRNA) {
2190  string orig_val = "";
2191  if (mrna) {
2192  orig_val = field_list[col - 2]->GetFromFeat(*mrna);
2193  }
2194  if (!NStr::Equal(new_val, orig_val)) {
2195  if (NStr::IsBlank(new_val)) {
2196  field_list[col - 2]->ClearInFeature(*new_mrna);
2197  } else {
2198  field_list[col - 2]->AddToFeature(*new_mrna, new_val, eExistingText_replace_old);
2199  }
2200  changed_mrna = true;
2201  }
2202  } else if (NStr::StartsWith(title, "protein ", NStr::eNocase) && orig_feat.GetData().GetSubtype() != CSeqFeatData::eSubtype_prot && prot) {
2203  string orig_val = "";
2204  orig_val = field_list[col - 2]->GetFromFeat(*prot);
2205  if (!NStr::Equal(new_val, orig_val)) {
2206  if (NStr::IsBlank(new_val)) {
2207  field_list[col - 2]->ClearInFeature(*new_prot);
2208  } else {
2209  field_list[col - 2]->AddToFeature(*new_prot, new_val, eExistingText_replace_old);
2210  }
2211  changed_prot = true;
2212  }
2213  } else {
2214  string orig_val = field_list[col - 2]->GetFromFeat(*(orig_feat.GetSeq_feat()));
2215  if (!NStr::Equal(new_val, orig_val)) {
2216  if (NStr::IsBlank(new_val)) {
2217  field_list[col - 2]->ClearInFeature(*new_feat);
2218  } else {
2219  field_list[col - 2]->AddToFeature(*new_feat, new_val, eExistingText_replace_old);
2220  }
2221  changed_feat = true;
2222  }
2223  }
2224  }
2225  if (changed_gene) {
2226  if (gene) {
2227  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(entry.GetScope().GetSeq_featHandle(*gene), *new_gene)));
2228  } else {
2229  CBioseq_Handle bsh = entry.GetScope().GetBioseqHandle(*(new_feat->GetLocation().GetId()));
2230  CSeq_entry_Handle gene_seh = bsh.GetSeq_entry_Handle();
2231  cmd->AddCommand(*(CRef<CCmdCreateFeat>(new CCmdCreateFeat(gene_seh, *new_gene))));
2232  }
2233  any_change = true;
2234  }
2235  if (changed_mrna) {
2236  if (mrna) {
2237  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(entry.GetScope().GetSeq_featHandle(*mrna), *new_mrna)));
2238  } else {
2239  CBioseq_Handle bsh = entry.GetScope().GetBioseqHandle(*(new_feat->GetLocation().GetId()));
2240  CSeq_entry_Handle mrna_seh = bsh.GetSeq_entry_Handle();
2241  cmd->AddCommand(*(CRef<CCmdCreateFeat>(new CCmdCreateFeat(mrna_seh, *new_mrna))));
2242  }
2243  any_change = true;
2244  }
2245  if (changed_prot) {
2246  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(entry.GetScope().GetSeq_featHandle(*prot), *new_prot)));
2247  }
2248  if (changed_feat) {
2249  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(orig_feat, *new_feat)));
2250  any_change = true;
2251  }
2252  }
2253  }
2254  if (!any_change) {
2255  cmd.Reset(NULL);
2256  }
2257  return cmd;
2258 }
2259 
2260 
2261 CRef<CSeq_loc> CreateFeatLocation(const CBioseq_Handle& bsh, int from, int to, bool ispartial5, bool ispartial3)
2262 {
2263  CRef<CSeq_loc> loc(new CSeq_loc());
2264  loc->SetInt().SetFrom(from);
2265  loc->SetInt().SetTo(to);
2266  loc->SetInt().SetStrand(eNa_strand_plus);
2267  CConstRef<CBioseq> bioseq = bsh.GetCompleteBioseq();
2268  loc->SetInt().SetId().Assign(*bioseq->GetId().front());
2269  if (ispartial5)
2271  if (ispartial3)
2272  loc->SetPartialStop(true, eExtreme_Biological);
2273 
2274  return loc;
2275 }
2276 
2277 
2278 CRef<CSeq_feat> AddMiscRNA(const CBioseq_Handle& bsh, string name, int from, int to, bool ispartial5, bool ispartial3)
2279 {
2280  CRef<CRNA_ref> rna_ref(new CRNA_ref());
2281  rna_ref->SetType(CRNA_ref::eType_miscRNA);
2282  rna_ref->SetExt().SetGen().SetProduct(name);
2283 
2284  CRef<CSeq_loc> loc = CreateFeatLocation(bsh, from, to, ispartial5, ispartial3);
2285  CRef<CSeq_feat> rna(new CSeq_feat());
2286  rna->SetData().SetRna().Assign(*rna_ref);
2287  rna->SetLocation().Assign(*loc);
2288  if (ispartial5 || ispartial3)
2289  rna->SetPartial(true);
2290 
2291  return rna;
2292 }
2293 
2294 
2295 CRef<CSeq_feat> AddRibosomalRNA(const CBioseq_Handle& bsh, string name, int from, int to, bool ispartial5, bool ispartial3)
2296 {
2297  CRef<CRNA_ref> rna_ref(new CRNA_ref());
2298  rna_ref->SetType(CRNA_ref::eType_rRNA);
2299  rna_ref->SetExt().SetName(name);
2300 
2301  CRef<CSeq_loc> loc = CreateFeatLocation(bsh, from, to, ispartial5, ispartial3);
2302 
2303  CRef<CSeq_feat> rna(new CSeq_feat());
2304  rna->SetData().SetRna().Assign(*rna_ref);
2305  rna->SetLocation().Assign(*loc);
2306  if (ispartial5 || ispartial3)
2307  rna->SetPartial(true);
2308 
2309  return rna;
2310 }
2311 
2312 CRef<CCmdComposite> AddNamedrRna(CSeq_entry_Handle entry, string rna_name, bool ispartial5, bool ispartial3)
2313 {
2314  if (NStr::IsBlank(rna_name) || !entry){
2316  return empty;
2317  }
2318 
2319  CRef<CCmdComposite> cmd (new CCmdComposite("Adding named rRNA"));
2320  CBioseq_CI b_iter(entry, CSeq_inst::eMol_na); // only for those bioseqs that contain nucleotide sequences
2321  for ( ; b_iter ; ++b_iter){
2322  int from = 0;
2323  int to = b_iter->GetBioseqLength() - 1;
2324  CRef<CSeq_feat> new_feat = AddRibosomalRNA(*b_iter, rna_name, from, to, ispartial5, ispartial3);
2325  CSeq_entry_Handle seh = b_iter->GetSeq_entry_Handle();
2326  cmd->AddCommand(*CRef<CCmdCreateFeat>(new CCmdCreateFeat(seh, *new_feat)));
2327  }
2328  return cmd;
2329 }
2330 
2332 {
2333  if (!entry){
2335  return empty;
2336  }
2337 
2338  CRef<CCmdComposite> cmd (new CCmdComposite("Creating control region"));
2339  CBioseq_CI b_iter(entry, CSeq_inst::eMol_na); // only for those bioseqs that contain nucleotide sequences
2340  bool partial5 = true;
2341  bool partial3 = true;
2342  for ( ; b_iter ; ++b_iter){
2343  int from = 0;
2344  int to = b_iter->GetBioseqLength() - 1;
2345  CRef<CSeq_loc> loc = CreateFeatLocation(*b_iter, from, to, partial5, partial3);
2346 
2347  CRef<CSeq_feat> new_feat(new CSeq_feat());
2348  new_feat->SetData().SetImp().SetKey("misc_feature");
2349  new_feat->SetComment("control region");
2350  new_feat->SetLocation().Assign(*loc);
2351  new_feat->SetPartial(true);
2352 
2353  CSeq_entry_Handle seh = b_iter->GetSeq_entry_Handle();
2354  cmd->AddCommand(*CRef<CCmdCreateFeat>(new CCmdCreateFeat(seh, *new_feat)));
2355  }
2356  return cmd;
2357 }
2358 
2360 {
2361  if (!entry){
2363  return empty;
2364  }
2365 
2366  CRef<CCmdComposite> cmd (new CCmdComposite("Creating microsatellite common feature"));
2367  CBioseq_CI b_iter(entry, CSeq_inst::eMol_na); // only for those bioseqs that contain nucleotide sequences
2368  bool partial5 = false;
2369  bool partial3 = false;
2370  for ( ; b_iter ; ++b_iter){
2371  int from = 0;
2372  int to = b_iter->GetBioseqLength() - 1;
2373  CRef<CSeq_loc> loc = CreateFeatLocation(*b_iter, from, to, partial5, partial3);
2374 
2375  CRef<CSeq_feat> new_feat(new CSeq_feat());
2376  new_feat->SetData().SetImp().SetKey("repeat_region");
2377  new_feat->SetLocation().Assign(*loc);
2378 
2379  CRef<CGb_qual> qual1(new CGb_qual("rpt_type", "tandem"));
2380  CRef<CGb_qual> qual2(new CGb_qual("satellite", "microsatellite"));
2381  new_feat->SetQual().push_back(qual1);
2382  new_feat->SetQual().push_back(qual2);
2383 
2384  CSeq_entry_Handle seh = b_iter->GetSeq_entry_Handle();
2385  cmd->AddCommand(*CRef<CCmdCreateFeat>(new CCmdCreateFeat(seh, *new_feat)));
2386  }
2387  return cmd;
2388 }
2389 
2390 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
@ eExtreme_Biological
5' and 3'
Definition: Na_strand.hpp:62
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
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
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
CCdregion –.
Definition: Cdregion.hpp:66
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(objects::CBioseq_Handle bsh)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
CFeat_CI –.
Definition: feat_ci.hpp:64
CFeat_id –.
Definition: Feat_id.hpp:66
static CRef< CFeatureSeqTableColumnBase > Create(const string &sTitle, objects::CSeqFeatData::ESubtype subtype=objects::CSeqFeatData::eSubtype_any)
virtual vector< CConstRef< CObject > > GetObjects(objects::CBioseq_Handle bsh)
objects::CSeqFeatData::ESubtype m_Subtype
void SetMajorType(objects::CSeqFeatData::E_Choice major_type)
virtual vector< CRef< objects::edit::CApplyObject > > GetRelatedGeneApplyObjects(objects::CBioseq_Handle bsh)
objects::CSeqFeatData::E_Choice m_MajorType
void SetSubtype(objects::CSeqFeatData::ESubtype subtype)
virtual vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(objects::CBioseq_Handle bsh)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
@Gb_qual.hpp User-defined methods of the data storage class.
Definition: Gb_qual.hpp:61
static string IndexToCodon(int index)
static bool IsGeneRefField(string qual)
static EFieldType x_GetFieldTypeFromString(string qual)
CGeneRefColumn(string qual)
virtual vector< CRef< objects::edit::CApplyObject > > GetApplyObjects(objects::CBioseq_Handle bsh)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
EFieldType m_FieldType
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
int GetId(void) const
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
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 GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
static EFieldType x_GetFieldTypeFromString(string qual)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
static bool IsProtRefField(string qual)
CProtRefColumn(string qual)
EFieldType m_FieldType
@RNA_ref.hpp User-defined methods of the data storage class.
Definition: RNA_ref.hpp:54
string GetRnaProductName(void) const
Definition: RNA_ref.cpp:145
CRef –.
Definition: ncbiobj.hpp:618
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
CRptUnitRangeColumn(const vector< size_t > lens)
vector< size_t > m_Lens
virtual vector< string > IsValid(const vector< string > &values)
virtual vector< string > IsValid(const vector< string > &values)
string x_GetSatelliteName(const string &field) const
string x_AddSatellitePrefix(const string &value, objects::edit::EExistingText existing_text) const
bool x_AddSatelliteName(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
bool x_AddSatelliteType(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
CSatelliteColumn(const string &satellite_field)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
void x_ClearSatelliteSubFields(objects::CSeq_feat &in_out_feat) const
string x_GetSatelliteType(const string &field) const
bool x_IsQualAMatch(const CGb_qual &qual) const
virtual void ClearInFeature(objects::CSeq_feat &in_out_feat)
virtual string GetLabel() const
virtual bool RelaxedMatch(const objects::CSeq_feat &f1, const objects::CSeq_feat &f2) const
virtual vector< string > IsValid(const vector< string > &values)
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
virtual bool AddToFeature(objects::CSeq_feat &in_out_feat, const string &newValue, objects::edit::EExistingText existing_text)
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.
CSeq_entry_Handle –.
CSeq_feat_EditHandle –.
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
const CGene_ref * GetGeneXref(void) const
See related function in util/feature.hpp.
Definition: Seq_feat.cpp:181
void SetGeneXref(CGene_ref &value)
Definition: Seq_feat.cpp:192
bool IsPartialStop(ESeqLocExtremes ext) const
TSeqPos GetStart(ESeqLocExtremes ext) const
bool IsPartialStart(ESeqLocExtremes ext) const
TSeqPos GetStop(ESeqLocExtremes ext) const
CSeq_feat_Handle GetFeatureWithId(CSeqFeatData::E_Choice type, TFeatureIdInt id) const
Definition: tse_handle.cpp:635
virtual string GetFromFeat(const objects::CSeq_feat &in_out_feat)
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
vector< string > FindNonUniqueStrings(const vector< string > &values)
static const int kNumIgnoreColumns
vector< string > SortUniqueStrings(const vector< string > &values)
USING_SCOPE(ncbi::objects)
CRef< CSeq_feat > AddMiscRNA(const CBioseq_Handle &bsh, string name, int from, int to, bool ispartial5, bool ispartial3)
CRef< CSeq_feat > AddRibosomalRNA(const CBioseq_Handle &bsh, string name, int from, int to, bool ispartial5, bool ispartial3)
CRef< CSeq_loc > CreateFeatLocation(const CBioseq_Handle &bsh, int from, int to, bool ispartial5, bool ispartial3)
void SetRnaProductName(CRNA_ref &rna, const string &product, string &remainder, EExistingText existing_text)
CRef< CCmdComposite > ApplyFeatureSeqTableToSeqEntry(CRef< CSeq_table > table, CSeq_entry_Handle entry)
CRef< CCmdComposite > AddNamedrRna(CSeq_entry_Handle entry, string rna_name, bool ispartial5, bool ispartial3)
static const string kIgnoreColumns[]
CSeq_feat_Handle GetFeatureFromTableId(const string &id_string, CSeq_entry_Handle entry)
void AddToFeatureIdColumn(CSeq_feat_Handle feat, CRef< CSeqTable_column > column, size_t row, int &top_id)
static bool IsAllRptUnitSeqChars(string seq)
int FindHighestFeatureId(const CSeq_entry_Handle &entry)
CRef< CSeq_table > BuildFeatureSeqTableFromSeqEntry(CSeq_entry_Handle entry, const SAnnotSelector &sel)
CRef< CCmdComposite > CreateControlRegion(CSeq_entry_Handle entry)
CRef< CCmdComposite > CreateMicrosatellite(CSeq_entry_Handle entry)
void AddColumnsToFeatureTable(const vector< string > &fields, CRef< CSeq_table > table, CSeq_entry_Handle entry)
const string kSatellite
string GetIntervalString(const CSeq_interval &seq_int)
const string kProblems
vector< CRef< CFeatureSeqTableColumnBase > > TFeatureSeqTableColumnList
const string kFeatureID
static const int kNumSatelliteTypes
const string kPartialStart
static const string kSatelliteTypes[]
const string kPartialStop
const string kStopColLabel
const string kStartColLabel
const char * kSequenceIdColLabel
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static const char * column
Definition: stats.c:23
#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
string
Definition: cgiapp.hpp:687
#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
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
bool IsPartialStart(ESeqLocExtremes ext) const
check start or stop of location for e_Lim fuzz
Definition: Seq_loc.cpp:3222
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
Definition: Seq_loc.hpp:941
void SetPartialStart(bool val, ESeqLocExtremes ext)
set / remove e_Lim fuzz on start or stop (lt/gt - indicating partial interval)
Definition: Seq_loc.cpp:3280
void SetPartialStop(bool val, ESeqLocExtremes ext)
Definition: Seq_loc.cpp:3313
bool IsPartialStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:3251
@ fMerge_SingleRange
Definition: Seq_loc.hpp:332
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,...
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 > GetOverlappingmRNA(const CSeq_loc &loc, CScope &scope)
Definition: sequence.cpp:1572
CConstRef< CSeq_feat > GetOverlappingGene(const CSeq_loc &loc, CScope &scope, ETransSplicing eTransSplicing=eTransSplicing_Auto)
Definition: sequence.cpp:1366
CConstRef< CSeq_feat > GetGeneForFeature(const CSeq_feat &feat, CScope &scope)
Finds gene for feature, but obeys SeqFeatXref directives.
Definition: sequence.cpp:1529
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 CFeat_id & GetId(void) const
bool IsSetId(void) const
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
virtual CConstRef< CSeq_feat > GetSeq_feat(void) const
const CSeqFeatData & GetData(void) const
TSeqPos GetBioseqLength(void) const
bool IsAa(void) const
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
const CTSE_Handle & GetTSE_Handle(void) const
virtual const CSeq_loc & GetProduct(void) const
bool IsSetProduct(void) const
CConstRef< CSeq_id > GetSeqId(void) const
Get id which can be used to access this bioseq handle Throws an exception if none is available.
virtual const CSeq_loc & GetLocation(void) const
CBioseq_Handle GetBioseqHandle(const CSeq_id &id) const
Get Bioseq handle from the TSE of this Seq-entry.
void SetFeatId(int id)
Set single feature id.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
TInst_Length GetInst_Length(void) const
CScope & GetScope(void) const
Get scope this handle belongs to.
CScope & GetScope(void) const
Get scope this handle belongs to.
CConstRef< CSeq_feat > GetOriginalSeq_feat(void) const
const TId & GetId(void) const
const CSeq_loc & GetLocation(void) const
const CSeq_feat_Handle & GetSeq_feat_Handle(void) const
Get original feature handle.
Definition: mapped_feat.hpp:71
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
NCBI_NS_STD::string::size_type SIZE_TYPE
Definition: ncbistr.hpp:132
#define kEmptyStr
Definition: ncbistr.hpp:123
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
Definition: ncbistr.cpp:2993
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
Definition: ncbistr.hpp:5430
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
#define NPOS
Definition: ncbistr.hpp:133
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3201
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
Definition: ncbistr.cpp:2891
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
Definition: ncbistr.hpp:5109
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
CTempString substr(size_type pos) const
Obtain a substring from this string, beginning at a given offset.
Definition: tempstr.hpp:776
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
@ fAllowTrailingSpaces
Ignore trailing space characters.
Definition: ncbistr.hpp:297
@ fConvErr_NoThrow
Do not throw an exception on error.
Definition: ncbistr.hpp:285
@ fAllowLeadingSpaces
Ignore leading spaces in converted string.
Definition: ncbistr.hpp:294
@ eNocase
Case insensitive compare.
Definition: ncbistr.hpp:1206
static const char label[]
bool IsSetSyn(void) const
synonyms for locus Check if a value has been assigned to Syn data member.
Definition: Gene_ref_.hpp:756
const TSyn & GetSyn(void) const
Get the Syn member data.
Definition: Gene_ref_.hpp:768
const TDesc & GetDesc(void) const
Get the Desc member data.
Definition: Gene_ref_.hpp:599
bool IsSetLocus_tag(void) const
systematic gene name (e.g., MI0001, ORF0069) Check if a value has been assigned to Locus_tag data mem...
Definition: Gene_ref_.hpp:781
bool IsSetLocus(void) const
Official gene symbol Check if a value has been assigned to Locus data member.
Definition: Gene_ref_.hpp:493
bool IsSetDesc(void) const
descriptive name Check if a value has been assigned to Desc data member.
Definition: Gene_ref_.hpp:587
bool IsSetAllele(void) const
Official allele designation Check if a value has been assigned to Allele data member.
Definition: Gene_ref_.hpp:540
bool IsSetMaploc(void) const
descriptive map location Check if a value has been assigned to Maploc data member.
Definition: Gene_ref_.hpp:634
const TLocus_tag & GetLocus_tag(void) const
Get the Locus_tag member data.
Definition: Gene_ref_.hpp:793
const TLocus & GetLocus(void) const
Get the Locus member data.
Definition: Gene_ref_.hpp:505
const TAllele & GetAllele(void) const
Get the Allele member data.
Definition: Gene_ref_.hpp:552
const TMaploc & GetMaploc(void) const
Get the Maploc member data.
Definition: Gene_ref_.hpp:646
bool IsId(void) const
Check if variant Id is selected.
Definition: Object_id_.hpp:264
TId GetId(void) const
Get the variant data.
Definition: Object_id_.hpp:270
bool IsSetDesc(void) const
description (instead of name) Check if a value has been assigned to Desc data member.
Definition: Prot_ref_.hpp:391
const TActivity & GetActivity(void) const
Get the Activity member data.
Definition: Prot_ref_.hpp:475
list< string > TActivity
Definition: Prot_ref_.hpp:111
const TName & GetName(void) const
Get the Name member data.
Definition: Prot_ref_.hpp:378
bool IsSetEc(void) const
E.C.
Definition: Prot_ref_.hpp:438
list< string > TEc
Definition: Prot_ref_.hpp:110
bool IsSetName(void) const
protein name Check if a value has been assigned to Name data member.
Definition: Prot_ref_.hpp:366
const TDesc & GetDesc(void) const
Get the Desc member data.
Definition: Prot_ref_.hpp:403
bool IsSetActivity(void) const
activities Check if a value has been assigned to Activity data member.
Definition: Prot_ref_.hpp:463
const TEc & GetEc(void) const
Get the Ec member data.
Definition: Prot_ref_.hpp:450
const TQuals & GetQuals(void) const
Get the Quals member data.
Definition: RNA_gen_.hpp:353
const TAnticodon & GetAnticodon(void) const
Get the Anticodon member data.
Definition: Trna_ext_.hpp:649
const TCodon & GetCodon(void) const
Get the Codon member data.
Definition: Trna_ext_.hpp:624
bool IsTRNA(void) const
Check if variant TRNA is selected.
Definition: RNA_ref_.hpp:498
void SetExt(TExt &value)
Assign a value to Ext data member.
Definition: RNA_ref_.cpp:211
bool IsSetExt(void) const
generic fields for ncRNA, tmRNA, miscRNA Check if a value has been assigned to Ext data member.
Definition: RNA_ref_.hpp:604
const Tdata & Get(void) const
Get the member data.
bool IsGen(void) const
Check if variant Gen is selected.
Definition: RNA_ref_.hpp:504
bool CanGetExt(void) const
Check if it is safe to call GetExt method.
Definition: RNA_ref_.hpp:610
bool CanGetAnticodon(void) const
Check if it is safe to call GetAnticodon method.
Definition: Trna_ext_.hpp:643
void SetType(TType value)
Assign a value to Type data member.
Definition: RNA_ref_.hpp:538
const TGen & GetGen(void) const
Get the variant data.
Definition: RNA_ref_.cpp:156
bool IsSetClass(void) const
for ncRNAs, the class of non-coding RNA: examples: antisense_RNA, guide_RNA, snRNA Check if a value h...
Definition: RNA_gen_.hpp:247
const TExt & GetExt(void) const
Get the Ext member data.
Definition: RNA_ref_.hpp:616
const TTRNA & GetTRNA(void) const
Get the variant data.
Definition: RNA_ref_.cpp:134
bool CanGetCodon(void) const
Check if it is safe to call GetCodon method.
Definition: Trna_ext_.hpp:618
bool CanGetQuals(void) const
Check if it is safe to call GetQuals method.
Definition: RNA_gen_.hpp:347
const TClass & GetClass(void) const
Get the Class member data.
Definition: RNA_gen_.hpp:259
void SetHeader(THeader &value)
Assign a value to Header data member.
bool CanGetDbxref(void) const
Check if it is safe to call GetDbxref method.
Definition: Seq_feat_.hpp:1327
bool CanGetExp_ev(void) const
Check if it is safe to call GetExp_ev method.
Definition: Seq_feat_.hpp:1255
const TVal & GetVal(void) const
Get the Val member data.
Definition: Gb_qual_.hpp:259
bool IsSetComment(void) const
Check if a value has been assigned to Comment data member.
Definition: Seq_feat_.hpp:1037
void ResetPartial(void)
Reset Partial data member.
Definition: Seq_feat_.hpp:955
bool IsSetQual(void) const
qualifiers Check if a value has been assigned to Qual data member.
Definition: Seq_feat_.hpp:1135
E_Choice Which(void) const
Which variant is currently selected.
bool IsSetCode(void) const
genetic code used Check if a value has been assigned to Code data member.
Definition: Cdregion_.hpp:700
bool IsProt(void) const
Check if variant Prot is selected.
void SetLocation(TLocation &value)
Assign a value to Location data member.
Definition: Seq_feat_.cpp:131
bool IsCdregion(void) const
Check if variant Cdregion is selected.
const TRegion & GetRegion(void) const
Get the variant data.
void SetComment(const TComment &value)
Assign a value to Comment data member.
Definition: Seq_feat_.hpp:1058
void ResetExcept(void)
Reset Except data member.
Definition: Seq_feat_.hpp:1002
void SetPartial(TPartial value)
Assign a value to Partial data member.
Definition: Seq_feat_.hpp:971
const TQual & GetQual(void) const
Get the Qual member data.
Definition: Seq_feat_.hpp:1147
const TLocal & GetLocal(void) const
Get the variant data.
Definition: Feat_id_.cpp:134
void ResetExcept_text(void)
Reset Except_text data member.
Definition: Seq_feat_.cpp:194
bool IsSetXref(void) const
cite other relevant features Check if a value has been assigned to Xref data member.
Definition: Seq_feat_.hpp:1296
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
E_Choice
Choice variants.
void SetExcept(TExcept value)
Assign a value to Except data member.
Definition: Seq_feat_.hpp:1018
bool IsLocal(void) const
Check if variant Local is selected.
Definition: Feat_id_.hpp:353
bool IsGene(void) const
Check if variant Gene is selected.
TFrame GetFrame(void) const
Get the Frame member data.
Definition: Cdregion_.hpp:534
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
bool IsSetExcept(void) const
something funny about this? Check if a value has been assigned to Except data member.
Definition: Seq_feat_.hpp:990
const TExcept_text & GetExcept_text(void) const
Get the Except_text member data.
Definition: Seq_feat_.hpp:1405
bool IsSetExcept_text(void) const
explain if except=TRUE Check if a value has been assigned to Except_text data member.
Definition: Seq_feat_.hpp:1393
const TCode & GetCode(void) const
Get the Code member data.
Definition: Cdregion_.hpp:712
const TDbxref & GetDbxref(void) const
Get the Dbxref member data.
Definition: Seq_feat_.hpp:1333
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
void ResetComment(void)
Reset Comment data member.
Definition: Seq_feat_.cpp:99
const TCdregion & GetCdregion(void) const
Get the variant data.
bool IsSetQual(void) const
Check if a value has been assigned to Qual data member.
Definition: Gb_qual_.hpp:200
const TComment & GetComment(void) const
Get the Comment member data.
Definition: Seq_feat_.hpp:1049
const TGene & GetGene(void) const
Get the variant data.
void SetExcept_text(const TExcept_text &value)
Assign a value to Except_text data member.
Definition: Seq_feat_.hpp:1414
const TProt & GetProt(void) const
Get the variant data.
TExcept GetExcept(void) const
Get the Except member data.
Definition: Seq_feat_.hpp:1009
const TXref & GetXref(void) const
Get the Xref member data.
Definition: Seq_feat_.hpp:1308
vector< CRef< CSeqFeatXref > > TXref
Definition: Seq_feat_.hpp:122
vector< CRef< CGb_qual > > TQual
Definition: Seq_feat_.hpp:117
const TQual & GetQual(void) const
Get the Qual member data.
Definition: Gb_qual_.hpp:212
const TRna & GetRna(void) const
Get the variant data.
void ResetDbxref(void)
Reset Dbxref data member.
Definition: Seq_feat_.cpp:188
bool IsSetDbxref(void) const
support for xref to other databases Check if a value has been assigned to Dbxref data member.
Definition: Seq_feat_.hpp:1321
TQual & SetQual(void)
Assign a value to Qual data member.
Definition: Seq_feat_.hpp:1153
bool IsSetVal(void) const
Check if a value has been assigned to Val data member.
Definition: Gb_qual_.hpp:247
bool IsRna(void) const
Check if variant Rna is selected.
TExp_ev GetExp_ev(void) const
Get the Exp_ev member data.
Definition: Seq_feat_.hpp:1268
bool IsRegion(void) const
Check if variant Region is selected.
bool IsSetFrame(void) const
Check if a value has been assigned to Frame data member.
Definition: Cdregion_.hpp:509
@ e_not_set
No variant selected.
@ eExp_ev_experimental
any reasonable experimental check
Definition: Seq_feat_.hpp:102
@ eFrame_not_set
not set, code uses one
Definition: Cdregion_.hpp:95
@ eFrame_three
reading frame
Definition: Cdregion_.hpp:98
bool IsMix(void) const
Check if variant Mix is selected.
Definition: Seq_loc_.hpp:552
bool CanGetStrand(void) const
Check if it is safe to call GetStrand method.
const Tdata & Get(void) const
Get the member data.
TStrand GetStrand(void) const
Get the Strand member data.
bool IsInt(void) const
Check if variant Int is selected.
Definition: Seq_loc_.hpp:528
const TInt & GetInt(void) const
Get the variant data.
Definition: Seq_loc_.cpp:194
const TMix & GetMix(void) const
Get the variant data.
Definition: Seq_loc_.cpp:282
@ eNa_strand_plus
Definition: Na_strand_.hpp:66
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
const TId & GetId(void) const
Get the Id member data.
Definition: Bioseq_.hpp:290
@ 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
constexpr bool empty(list< Ts... >) noexcept
Definition: fix_pub.hpp:45
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
int isalpha(Uchar c)
Definition: ncbictype.hpp:61
int isdigit(Uchar c)
Definition: ncbictype.hpp:64
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
static int match(register const pcre_uchar *eptr, register const pcre_uchar *ecode, const pcre_uchar *mstart, int offset_top, match_data *md, eptrblock *eptrb, unsigned int rdepth)
Definition: pcre_exec.c:513
Utility macros and typedefs for exploring NCBI objects from seqset.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)
@ eNotSet
Definition: splign_app.cpp:550
#define row(bind, expected)
Definition: string_bind.c:73
EExistingText
@ 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 –.
Modified on Mon Jun 24 05:20:11 2024 by modify_doxy.py rev. 669887