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

Go to the SVN repository for this file.

1 /* $Id: macro_biodata_iter.cpp 47404 2023-03-13 15:21:12Z asztalos $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Andrea Asztalos
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbimisc.hpp>
34 
35 #include <objmgr/bioseq_ci.hpp>
36 #include <objmgr/seqdesc_ci.hpp>
37 #include <objmgr/util/sequence.hpp>
43 #include <util/line_reader.hpp>
44 
47 #include <gui/objutils/utils.hpp>
62 
63 
64 
65 /** @addtogroup GUI_MACRO_SCRIPTS_UTIL
66  *
67  * @{
68  */
69 
71 BEGIN_SCOPE(macro)
73 
74 
75 bool IMacroBioDataIter::GetChoiceType(const string& field_name, string& choice_type) const
76 {
79 
80  if (!GetFieldsByName(&nodes, oi, field_name) || nodes.size() != 1)
81  return false;
82 
83  oi = nodes.front().field;
84  if (oi.GetTypeFamily() == eTypeFamilyPointer) {
85  oi = oi.GetPointedObject();
86  }
87 
88  if (oi.GetTypeFamily() != eTypeFamilyChoice)
89  return false;
90 
92  choice_type = cv.GetAlias();
93  return true;
94 }
95 
96 
98 {
99  _ASSERT(cmd_composite);
100  if (cmd) {
101  cmd->Execute();
102  cmd_composite->AddCommand(*cmd);
103  }
104 }
105 
107 {
108  if (!IsEnd()) {
110  m_DeleteObject = false;
111  m_Modified = false;
112  }
113 }
114 
115 void IMacroBioDataIter::SetHugeContext(const shared_ptr<CHugeMacroContext>& context)
116 {
118 }
119 
121 {
122  if (m_MacroContext) {
123  return m_MacroContext->m_TopLevel;
124  }
125  NCBI_USER_THROW("IMacroBioDataIter::TopLevelObject(): context is not set");
126 }
128 {
129  if (m_MacroContext) {
130  return m_MacroContext->m_MaxFeatId;
131  }
132  NCBI_USER_THROW("IMacroBioDataIter::MaxFeatureId(): context is not set");
133 }
134 
135 void IMacroBioDataIter::SetTableToApply(const string& file_name, size_t match_col, const string& delimiter,
136  bool merge_del, bool split_firstcol, bool convert_multi, bool merge_firstcols, bool multiple_sp_only)
137 {
138  if (file_name.empty()) {
139  LOG_POST(Error << "Applying table macro has empty table name");
140  return;
141  }
142  // it can only handle one table at a time
143  if (m_TableToApply.m_Name.empty()) {
146  if (m_TableToApply.m_Delimiter == "\\t")
149  m_TableToApply.m_SplitFirstCol = split_firstcol;
150  m_TableToApply.m_ConvertMulti = convert_multi;
151  m_TableToApply.m_MergeFirstCols = merge_firstcols;
152  m_TableToApply.m_MultipleSpaceOnly = multiple_sp_only;
153 
154  bool set = m_TableToApply.SetTableToApply(file_name, match_col);
155  if (!set) {
156  NCBI_USER_THROW("Unknown error occurred while reading the table");
157  }
158  }
159 }
160 
161 const string& IMacroBioDataIter::GetTableName() const
162 {
163  return m_TableToApply.m_Name;
164 }
165 
167 {
168  string value;
169  bool found = m_TableToApply.GetValueFromTable(col, value);
170  if (!found) {
171  NCBI_USER_THROW("Value from table in column " + NStr::NumericToString(col) + " was not found");
172  }
173  return value;
174 }
175 
177 {
178  x_InitAndCheck(file_name, match_col);
179 
181 
182  string line;
183  unsigned nr = 0;
184  while (!line_reader->AtEOF()) {
185  line_reader->ReadLine();
186  line = line_reader->GetCurrentLine();
187  if (line.empty())
188  continue;
189 
190  if (m_ConvertMulti) {
192  }
193 
194  vector<string> cols;
196  for (auto& it : cols) {
198  }
199 
200  auto token_it = find_if(cols.begin(), cols.end(), [](const string& elem) { return !elem.empty(); });
201  if (token_it == cols.end()) {
202  continue;
203  }
204 
205  string value = cols[match_col];
206  if (m_MergeFirstCols && match_col == 0) {
207  value = cols[0] + "/" + cols[1];
208  cols.erase(cols.begin() + 1);
209  }
210 
211  if (m_SplitFirstCol) {
212  if (match_col < 2) {
213  string first, second;
214  NStr::SplitInTwo(cols[0], " ", first, second);
215  if (match_col == 0) {
216  value = first;
217  }
218  else if (match_col == 1) {
219  value = second;
220  }
221  }
222  else {
223  value = cols[match_col - 1];
224  }
225  }
226 
228  auto it = m_Index.find(value);
229  if (it == m_Index.end()) {
230  m_Index.emplace(value, nr);
231  m_State.emplace_back(value, false);
232  }
233  else {
234  auto ident_it = m_IdenticalItems.find(value);
235  if (ident_it != m_IdenticalItems.end()) {
236  ident_it->second++;
237  }
238  else {
239  m_IdenticalItems.emplace(value, 2);
240  }
241  }
242  ++nr;
243  }
244 
245  if (!m_IdenticalItems.empty()) {
246  string msg = "Table contains entries that appear multiple times:\n";
247  for (auto& it : m_IdenticalItems) {
248  msg += "'" + it.first + "' " + NStr::IntToString(it.second) + " times\n";
249  }
251  }
252 
253  return (nr == m_Index.size());
254 }
255 
257 {
258  m_Index.clear();
259  m_IdenticalItems.clear();
260 
261  CRef<ILineReader> line_reader(ILineReader::New(m_Name));
262  if (line_reader.Empty()) {
264  "Could not open table file: '" + m_Name, nullptr);
265  }
266 
267  // read the first line, to check that the specified column number is correct
268  if (!line_reader->AtEOF()) {
269  line_reader->ReadLine();
270  string line = line_reader->GetCurrentLine();
271  if (m_ConvertMulti) {
272  NMacroUtil::ConvertMultiSpaces(line, m_Delimiter);
273  }
274 
275  if (m_MultipleSpaceOnly && m_Delimiter == " ") {
276  m_Delimiter = " ";
277  }
278 
279  vector<string> cols;
280  NStr::SplitByPattern(line, m_Delimiter, cols, m_SplitFlags);
281  for (auto& it : cols) {
283  }
284 
285  _ASSERT(!cols.empty());
286  m_NrCols = cols.size();
287  if (m_MergeFirstCols)
288  m_NrCols--;
289 
290  if (m_SplitFirstCol) {
291  string first, second;
292  NStr::SplitInTwo(cols[0], " ", first, second);
293  if (!first.empty() && !second.empty())
294  m_NrCols++;
295  }
296  }
297 
298  if (col >= m_NrCols) {
299  NCBI_USER_THROW("Table has only " + NStr::NumericToString(m_NrCols) + " columns");
300  }
301 }
302 
304 {
305  size_t pos = m_CurrentPos->second;
306  _ASSERT(col < m_NrCols);
307 
308  auto col_it = find_if(m_TableValues.begin(), m_TableValues.end(),
309  [&col](const pair<size_t, TTableValues>& elem) { return elem.first == col; });
310 
311  if (col_it == m_TableValues.end()) {
312  x_CacheColFromTable(col);
313  }
314 
315  auto it = m_TableValues.begin();
316  bool found = false;
317  for (; !found && it != m_TableValues.end(); ++it) {
318  if (col == it->first) {
319  auto& values = it->second;
320  value = values[pos];
321  found = true;
322  }
323  }
324 
325  return found;
326 }
327 
329 {
330  if (col >= m_NrCols) {
331  NCBI_USER_THROW("Table has only " + NStr::NumericToString(m_NrCols) + " columns");
332  }
333 
334  CRef<ILineReader> line_reader(ILineReader::New(m_Name));
335 
336  STableToApply::TTableValues values; // stores the values from the col(th) column
337  string line;
338 
339  while (!line_reader->AtEOF()) {
340  line_reader->ReadLine();
341  line = line_reader->GetCurrentLine();
342  if (line.empty())
343  continue;
344 
345  if (m_ConvertMulti) {
346  NMacroUtil::ConvertMultiSpaces(line, m_Delimiter);
347  }
348 
349  vector<string> cols;
350  NStr::SplitByPattern(line, m_Delimiter, cols, m_SplitFlags);
351  for (auto& it : cols) {
353  }
354 
355  if (m_MergeFirstCols) {
356  cols[0] = cols[0] + "/" + cols[1];
357  cols.erase(cols.begin() + 1);
358  }
359 
360  if (m_SplitFirstCol) {
361  if (col < 2) {
362  string first, second;
363  NStr::SplitInTwo(cols[0], " ", first, second);
364  if (col == 0) {
365  values.push_back(first);
366  }
367  else if (col == 1) {
368  values.push_back(second);
369  }
370  }
371  else {
372  values.push_back(cols[col - 1]);
373  }
374  }
375  else {
376  values.push_back(cols[col]);
377  }
378  }
379 
380  m_TableValues.push_back(make_pair(col, values));
381  return (line_reader->GetLineNumber() == values.size());
382 }
383 
384 bool IMacroBioDataIter::FindInTable(const CMQueryNodeValue::TObs& objs, bool case_sensitive)
385 {
386  bool found = false;
387  vector<string> values_from_data;
388  for (auto it = objs.begin(); it != objs.end() && !found; ++it) {
391  string value;
392  for (auto iter = objects.begin(); iter != objects.end() && !found; ++iter) {
393  CObjectInfo oi = iter->field;
396  }
398  Int8 nr = oi.GetPrimitiveValueInt8();
400  }
401 
402  else if (oi.GetPrimitiveValueType() == ePrimitiveValueEnum) {
403  try {
405  }
406  catch (const CException&) {
408  }
409  }
410  auto found_it = m_TableToApply.m_Index.end();
411  if (case_sensitive) {
412  found_it = m_TableToApply.m_Index.find(value);
413  }
414  else {
415  found_it = find_if(m_TableToApply.m_Index.begin(), m_TableToApply.m_Index.end(),
416  [&value](const pair<string, unsigned int>& elem)
417  { return NStr::EqualNocase(elem.first, value); });
418  }
419 
420  if (found_it != m_TableToApply.m_Index.end()) {
421  m_TableToApply.m_CurrentPos = found_it;
422  m_TableToApply.m_State[m_TableToApply.m_CurrentPos->second].second = true;
423  found = true;
424  }
425  else {
426  values_from_data.push_back(value);
427  }
428  }
429  }
430 
431  /*
432  if (!values_from_data.empty()) {
433  string msg = "These values were not found in the table:\n";
434  for (auto& it : values_from_data) {
435  msg += it + "\n";
436  }
437  LOG_POST(Info << msg); // add as a function report
438  }
439  */
440 
441  return found;
442 }
443 
444 bool IMacroBioDataIter::FindInTable(const vector<string>& strs, bool case_sensitive)
445 {
446  bool found = false;
447  for (auto&& it : strs) {
448  auto found_it = m_TableToApply.m_Index.end();
449  if (case_sensitive) {
450  found_it = m_TableToApply.m_Index.find(it);
451  }
452  else {
453  found_it = find_if(m_TableToApply.m_Index.begin(), m_TableToApply.m_Index.end(),
454  [&it](const pair<string, unsigned int>& elem)
455  { return NStr::EqualNocase(elem.first, it); });
456  }
457 
458  if (found_it != m_TableToApply.m_Index.end()) {
459  m_TableToApply.m_CurrentPos = found_it;
460  m_TableToApply.m_State[m_TableToApply.m_CurrentPos->second].second = true;
461  found = true;
462  break;
463  }
464  }
465  return found;
466 }
467 
469 {
470  string report;
471  count = 0;
472  if (!m_TableToApply.m_Name.empty()) {
473  report = "No matches were found for values present in the table:";
474  for (auto& it : m_TableToApply.m_State) {
475  if (!it.second) {
476  report += "\n" + it.first;
477  count++;
478  }
479  }
480  if (count == 0)
481  report.resize(0);
482  else {
483  NStr::ReplaceInPlace(report, "for values", "for " + NStr::IntToString(count) + " values");
484  }
485  }
486  return report;
487 }
488 
489 //////////////////////////////////////////////////////////////////////////////
490 /// CMacroBioData_FeatIterBase
491 ///
493  const SAnnotSelector& sel)
494  : IMacroBioDataIter(entry), m_FeatIter(entry, sel)
495 {
496 }
497 
499  const CBioseq_Handle& bsh, const SAnnotSelector& sel, const CSeq_loc& loc)
500  : IMacroBioDataIter(bsh.GetSeq_entry_Handle()), m_FeatIter(bsh.GetScope(), loc, sel)
501 {
502 }
503 
505 {
506  m_FeatIter.Rewind();
507  if (m_FeatIter) {
508  m_FirstFeat = m_FeatIter->GetOriginalSeq_feat();
509  }
510  x_Init();
511  return *this;
512 }
513 
515 {
516  ++m_FeatIter;
517  x_Init();
518  return *this;
519 }
520 
522 {
523  if (m_FeatIter) {
524  return false;
525  }
526  return true;
527 }
528 
530 {
531  return (m_FirstFeat == m_FeatIter->GetOriginalSeq_feat());
532 }
533 
535 {
536  return m_FeatIter.GetSize();
537 }
538 
539 
541 {
542  SConstScopedObject sobject;
543 
544  CConstRef<CSeq_feat> seqfeat = m_FeatIter->GetSeq_feat();
545  sobject.object.Reset(seqfeat.GetPointer());
546 
547  CRef<CScope> pscope(&(m_FeatIter->GetScope()));
548  sobject.scope = pscope;
549 
550  return sobject;
551 }
552 
553 
555 {
556  string subtype = CSeqFeatData::SubtypeValueToName(m_FeatIter->GetData().GetSubtype());
557 
558  CConstRef<CSeq_feat> seqfeat = m_FeatIter->GetSeq_feat();
559  CSeq_loc loc;
560  loc.Assign(seqfeat->GetLocation());
561  sequence::ChangeSeqLocId(&loc, true, &(m_FeatIter->GetScope()));
562 
563  string label;
564  loc.GetLabel(&label);
565  subtype.append(" " + label);
566  return subtype;
567 }
568 
569 
571 {
572  m_OrigFeat.Reset(&(*m_FeatIter->GetSeq_feat()));
574  m_EditedFeat->Assign(*m_OrigFeat);
575 
576  CObjectInfo oi(m_EditedFeat, m_EditedFeat->GetThisTypeInfo());
577  m_CurIterOI = oi;
578 }
579 
581 {
583 
584  CSeq_feat_Handle orig_fh = m_FeatIter->GetSeq_feat_Handle();
586  cmd->Execute();
587  cmd_composite->AddCommand(*cmd);
588 }
589 
591 {
592  m_DeleteObject = intent;
593  if (IsBegin()) {
596  }
597 }
598 
600 {
601  CSeq_feat_Handle fh = m_FeatIter->GetSeq_feat_Handle();
602  bool remove_proteins(true);
603  CRef<CCmdComposite> del_cmd = GetDeleteFeatureCommand(fh, remove_proteins, m_ProductToCDS);
604  del_cmd->Execute();
605  cmd_composite->AddCommand(*del_cmd);
606 
607  Next();
608 }
609 
611 {
612  try {
613  return GetBioseqForSeqFeat(m_FeatIter->GetOriginalFeature(), m_Seh.GetScope());
614  }
615  catch (const CException& err)
616  {
618  "The feature iterator failed to obtain a bioseq handle.",
619  CConstRef<CSerialObject>(&(m_FeatIter->GetLocation())));
620  }
621 }
622 
624 {
625  const CSeq_feat* const_seq_feat = &(*m_FeatIter->GetSeq_feat());
626  CSeq_feat* seq_feat = const_cast<CSeq_feat*>(const_seq_feat);
627  CObjectInfo oi(seq_feat, seq_feat->GetThisTypeInfo());
628  m_CurIterOI = oi;
629 }
630 
632 {
633  m_CreateGeneralId = false;
634  CScope::TTSE_Handles vec_tse;
635  m_Seh.GetScope().GetAllTSEs(vec_tse, CScope::eAllTSEs);
636  if (!vec_tse.empty()) {
638  }
639 }
640 
641 const vector<string>& CMacroBioData_FeatIterBase::GetTaxnames() const
642 {
643  if (m_HugeData) {
644  if (m_MacroContext) {
645  return m_MacroContext->GetTaxnames();
646  }
647  NCBI_USER_THROW("CMacroBioData_FeatIterBase::GetTaxnames(): context is not set");
648  }
649  else {
650  if (!m_Completed) {
651  CSeq_entry_Handle seh;
652  try {
653  CScope& scope = m_Seh.GetScope();
654  CBioseq_Handle protein_bsh = scope.GetBioseqHandle(m_FeatIter->GetLocation());
655  seh = protein_bsh.GetTSE_Handle().GetTopLevelEntry();
656  }
657  catch (const CException& e) {
659  "The feature iterator failed to obtain TSE handle",
660  CConstRef<CSerialObject>(&(m_FeatIter->GetLocation())));
661  }
662 
663  if (seh) {
664  FindOrgNames(seh, m_Taxnames);
665  m_Completed = true;
666  }
667  }
668  }
669  return m_Taxnames;
670 }
671 
672 //////////////////////////////////////////////////////////////////////////////
673 /// CMacroBioData_FeatIntervalIter
674 ///
676  const SAnnotSelector& sel, const SFeatInterval& feat_interval)
677  : IMacroBioDataIter(bsh.GetSeq_entry_Handle()), m_FeatInterval(feat_interval)
678 {
679  CRef<CSeq_loc> loc = bsh.GetRangeSeq_loc(m_FeatInterval.m_Range.GetFrom(), m_FeatInterval.m_Range.GetTo());
680  if (loc) {
681  CFeat_CI feat_it(bsh.GetScope(), *loc, sel);
682  m_FeatIter = feat_it;
683  }
684 }
685 
687 {
688  m_FeatIter.Rewind();
690  if (m_FeatIter) {
691  m_FirstFeat = m_FeatIter->GetOriginalSeq_feat();
692  }
693  x_Init();
694  return *this;
695 }
696 
698 {
699  ++m_FeatIter;
701  x_Init();
702  return *this;
703 }
704 
706 {
707  if (m_FeatIter) {
708  return false;
709  }
710  return true;
711 }
712 
714 {
715  return (m_FirstFeat == m_FeatIter->GetOriginalSeq_feat());
716 }
717 
719 {
721  (m_FeatInterval.left_closed == true)) {
722  // do not adjust the iterator
723  return;
724  }
725 
727  bool left_closed = m_FeatInterval.left_closed;
728  bool right_closed = m_FeatInterval.right_closed;
729 
730  auto good_feat = [&range, left_closed, right_closed](const CSeq_loc& feat_loc)
731  {
732  auto feat_start = feat_loc.GetStart(eExtreme_Positional);
733  auto feat_stop = feat_loc.GetStop(eExtreme_Positional);
734  bool good = true; // assume that it belongs to this interval
735 
736  if (left_closed == false) {
737  if (feat_start <= range.GetFrom()) {
738  good = false;
739  }
740  }
741  if (right_closed == false) {
742  if (feat_stop >= range.GetTo()) {
743  good = false;
744  }
745  }
746  return good;
747  };
748 
749  while (m_FeatIter && !good_feat(m_FeatIter->GetOriginalFeature().GetLocation())) {
750  ++m_FeatIter;
751  }
752 }
753 
754 
756 {
757  SConstScopedObject sobject;
758 
759  CConstRef<CSeq_feat> seqfeat = m_FeatIter->GetSeq_feat();
760  sobject.object.Reset(seqfeat.GetPointer());
761 
762  CRef<CScope> pscope(&(m_FeatIter->GetScope()));
763  sobject.scope = pscope;
764 
765  return sobject;
766 }
767 
769 {
770  string subtype = CSeqFeatData::SubtypeValueToName(m_FeatIter->GetData().GetSubtype());
771 
772  CConstRef<CSeq_feat> seqfeat = m_FeatIter->GetSeq_feat();
773  CSeq_loc loc;
774  loc.Assign(seqfeat->GetLocation());
775  sequence::ChangeSeqLocId(&loc, true, &(m_FeatIter->GetScope()));
776 
777  string label;
778  loc.GetLabel(&label);
779  subtype.append(" " + label);
780  return subtype;
781 }
782 
784 {
785  m_OrigFeat.Reset(&(*m_FeatIter->GetSeq_feat()));
787  m_EditedFeat->Assign(*m_OrigFeat);
788 
789  CObjectInfo oi(m_EditedFeat, m_EditedFeat->GetThisTypeInfo());
790  m_CurIterOI = oi;
791 }
792 
794 {
795  try {
796  return GetBioseqForSeqFeat(m_FeatIter->GetOriginalFeature(), m_Seh.GetScope());
797  }
798  catch (const CException& err)
799  {
801  "The feature iterator failed to obtain a bioseq handle.",
802  CConstRef<CSerialObject>(&(m_FeatIter->GetLocation())));
803  }
804 }
805 
807 {
808  const CSeq_feat* const_seq_feat = &(*m_FeatIter->GetSeq_feat());
809  CSeq_feat* seq_feat = const_cast<CSeq_feat*>(const_seq_feat);
810  CObjectInfo oi(seq_feat, seq_feat->GetThisTypeInfo());
811  m_CurIterOI = oi;
812 }
813 
814 //////////////////////////////////////////////////////////////////////////////
815 /// CMacroBioData_BioSourceIter
816 ///
818  : IMacroBioDataIter(entry), m_CollDateType(eCollDateType_NotSet)
819 {
820 }
821 
823 {
826  while (m_OrigSource.IsNull() && m_SeqIter) {
828  if (m_SrcFeatIter) {
829  m_OrigSource = ConstRef(&m_SrcFeatIter->GetData().GetBiosrc());
830  }
831 
832  if (m_OrigSource.IsNull()) {
833  if (++m_SeqIter) {
835  }
836  }
837  }
838 
840 
841  x_Init();
842  return *this;
843 }
844 
846 {
848  while (m_OrigSource.IsNull() && m_SeqIter) {
849  if (m_SrcFeatIter) {
850  if (++m_SrcFeatIter) {
851  m_OrigSource = ConstRef(&m_SrcFeatIter->GetData().GetBiosrc());
852  }
853  }
854  else {
856  if (m_SrcFeatIter) {
857  m_OrigSource = ConstRef(&m_SrcFeatIter->GetData().GetBiosrc());
858  }
859  }
860 
861  if (m_OrigSource.IsNull()) {
862  if (++m_SeqIter) {
864  }
865  }
866  }
867 
868  x_Init();
869  return *this;
870 }
871 
873 {
874  if (!m_SeqIter) return nullptr;
875  {{
877  if (desc) {
878  m_SrcDescrIter = desc;
879  return &m_SrcDescrIter->GetSource();
880  }
881  }}
882  {{
883  CSeqdesc_CI desc(m_SeqIter->GetTopLevelEntry(), CSeqdesc::e_Source);
884  if (desc) {
885  m_SrcDescrIter = desc;
886  return &m_SrcDescrIter->GetSource();
887  }
888  }}
889  return nullptr;
890 }
891 
893 {
894  return m_OrigSource.IsNull();
895 }
896 
898 {
899  return (m_FirstSource == m_OrigSource);
900 }
901 
903 {
904  SConstScopedObject sobject;
905  sobject.object.Reset(m_OrigSource);
906 
907  CRef<CScope> pscope(&(m_Seh.GetScope()));
908  sobject.scope = pscope;
909 
910  return sobject;
911 }
912 
914 {
915  string seq_id;
917  CSeq_id_Handle::GetHandle(*(m_SeqIter->GetCompleteBioseq()->GetFirstId())),
918  m_Seh.GetScope(), seq_id);
919 
920  return string("Biosource ").append(seq_id);
921 }
922 
924 {
926  m_EditedSource->Assign(*m_OrigSource);
927 
928  CObjectInfo oi(m_EditedSource, m_EditedSource->GetThisTypeInfo());
929  m_CurIterOI = oi;
930 }
931 
933 {
935  if (m_SrcFeatIter) {
936  CSeq_feat_Handle orig_fh = m_SrcFeatIter->GetSeq_feat_Handle();
937  CRef<CSeq_feat> new_feat(new CSeq_feat);
938  new_feat->Assign(m_SrcFeatIter->GetOriginalFeature());
939  new_feat->SetData().SetBiosrc(m_EditedSource.GetNCObject());
940  cmd.Reset(new CCmdChangeSeq_feat(orig_fh, *new_feat));
941  }
942  else if (m_SrcDescrIter) {
943  CRef<CSeqdesc> new_desc(new CSeqdesc);
944  new_desc->SetSource(m_EditedSource.GetNCObject());
945  cmd.Reset(new CCmdChangeSeqdesc(m_SrcDescrIter.GetSeq_entry_Handle(), *m_SrcDescrIter, *new_desc));
946  }
947  if (cmd) {
948  cmd->Execute();
949  cmd_composite->AddCommand(*cmd);
950  }
951 }
952 
954 {
955  if (m_SrcFeatIter) {
956  CSeq_feat_Handle fh = m_SrcFeatIter->GetSeq_feat_Handle();
957  bool remove_proteins(false);
958  CRef<CCmdComposite> del_cmd = GetDeleteFeatureCommand(fh, remove_proteins);
959  del_cmd->Execute();
960  cmd_composite->AddCommand(*del_cmd);
961  Next();
962  }
963  else {
964  CRef<CCmdDelDesc> del_cmd(new CCmdDelDesc(m_SrcDescrIter.GetSeq_entry_Handle(), *m_SrcDescrIter));
965  if (del_cmd) {
966  del_cmd->Execute();
967  cmd_composite->AddCommand(*del_cmd);
968  }
969  Next();
970  }
971 }
972 
974 {
975  return *m_SeqIter;
976 }
977 
979 {
980  CBioSource* biosource = const_cast<CBioSource*>(m_OrigSource.GetPointer());
981  CObjectInfo oi(biosource, biosource->GetThisTypeInfo());
982  m_CurIterOI = oi;
983 }
984 
986 {
987  return !IsFeature();
988 }
989 
991 {
992  return (m_SrcFeatIter) ? true : false;
993 }
994 
995 
996 
997 //////////////////////////////////////////////////////////////////////////////
998 /// CMacroBioData_MolInfoIter
999 ///
1001  : CMacroBioData_SeqdescIter(entry)
1002 {
1003 }
1004 
1006 {
1008  if (m_SeqIter) {
1010  while (m_OrigMolinfo.IsNull() && m_SeqIter) {
1011  if (++m_SeqIter) {
1013  }
1014  }
1015  }
1016  else {
1018  if (m_SeqSetIter) {
1020  }
1021 
1022  }
1024 
1025  x_Init();
1026  return *this;
1027 }
1028 
1030 {
1031  m_OrigMolinfo.Reset();
1032  while (m_OrigMolinfo.IsNull() && m_SeqIter) {
1033  if (++m_SeqIter) {
1035  }
1036  }
1037 
1038  x_Init();
1039  return *this;
1040 }
1041 
1043 {
1044  if (m_SeqIter) {
1046  if (desc) {
1047  m_DescIter = desc;
1048  return &m_DescIter->GetMolinfo();
1049  }
1050  }
1051  else if (m_SeqSetIter) {
1053  if (desc) {
1054  m_DescIter = desc;
1055  return &m_DescIter->GetMolinfo();
1056  }
1057  }
1058  return nullptr;
1059 }
1060 
1062 {
1063  return m_OrigMolinfo.IsNull();
1064 }
1065 
1067 {
1068  return (m_FirstMolinfo == m_OrigMolinfo);
1069 }
1070 
1072 {
1073  SConstScopedObject sobject;
1074  sobject.object.Reset(m_OrigMolinfo);
1075 
1076  CRef<CScope> pscope(&(m_Seh.GetScope()));
1077  sobject.scope = pscope;
1078 
1079  return sobject;
1080 }
1081 
1083 {
1084  return x_GetDescription("MolInfo");
1085 }
1086 
1088 {
1090  m_EditedMolinfo->Assign(*m_OrigMolinfo);
1091 
1092  CObjectInfo oi(m_EditedMolinfo, m_EditedMolinfo->GetThisTypeInfo());
1093  m_CurIterOI = oi;
1094 }
1095 
1097 {
1098  CRef<CSeqdesc> new_desc(new CSeqdesc);
1099  new_desc->SetMolinfo(m_EditedMolinfo.GetNCObject());
1100  CRef<CCmdChangeSeqdesc> cmd(new CCmdChangeSeqdesc(m_DescIter.GetSeq_entry_Handle(), *m_DescIter, *new_desc));
1101  if (cmd) {
1102  cmd->Execute();
1103  cmd_composite->AddCommand(*cmd);
1104  }
1105 }
1106 
1108 {
1109  CRef<CCmdDelDesc> del_cmd(new CCmdDelDesc(m_DescIter.GetSeq_entry_Handle(), *m_DescIter));
1110  if (del_cmd) {
1111  del_cmd->Execute();
1112  cmd_composite->AddCommand(*del_cmd);
1113  }
1114  Next();
1115 }
1116 
1118 {
1119  CMolInfo* molinfo = const_cast<CMolInfo*>(m_OrigMolinfo.GetPointer());
1120  CObjectInfo oi(molinfo, molinfo->GetThisTypeInfo());
1121  m_CurIterOI = oi;
1122 }
1123 
1124 
1125 //////////////////////////////////////////////////////////////////////////////
1126 /// CMacroBioData_PubdescIter
1127 ///
1129  : IMacroBioDataIter(entry)
1130 {
1131 }
1132 
1134 {
1136  if (m_SeqIter) {
1138  if (m_PubDescrIter) {
1139  m_OrigPubdesc = ConstRef(&m_PubDescrIter->GetPub());
1140  }
1141  while (m_OrigPubdesc.IsNull() && m_SeqIter) {
1143  if (m_PubFeatIter) {
1144  m_OrigPubdesc = ConstRef(&m_PubFeatIter->GetData().GetPub());
1145  }
1146 
1147  if (m_OrigPubdesc.IsNull()) {
1148  if (++m_SeqIter) {
1150  if (m_PubDescrIter) {
1151  m_OrigPubdesc = ConstRef(&m_PubDescrIter->GetPub());
1152  }
1153  }
1154  }
1155  }
1156  }
1157  else { // there might be a set in this entry that has a descriptor
1159  if (m_SeqSetIter) {
1161  if (m_PubDescrIter) {
1162  m_OrigPubdesc = ConstRef(&m_PubDescrIter->GetPub());
1163  }
1164  }
1165  }
1166 
1168 
1169  if (m_FirstPubdesc.IsNull() && !m_SeqSubmit.IsNull()) {
1170  if (m_SubmitBlockIter.IsNull()) {
1171  if (m_SeqSubmit->IsSetSub() && m_SeqSubmit->GetSub().IsSetCit()) {
1173  }
1174  }
1175  else {
1176  m_SubmitBlockIter->MarkProcessed();
1177  }
1178  }
1179 
1180  x_Init();
1181  return *this;
1182 }
1183 
1185 {
1186  CConstRef<CPubdesc> current_pubdesc(m_OrigPubdesc);
1187  m_OrigPubdesc.Reset();
1188  while (m_OrigPubdesc.IsNull() && m_SeqIter) {
1189  if (m_PubDescrIter) {
1190  if (++m_PubDescrIter) {
1191  m_OrigPubdesc = ConstRef(&m_PubDescrIter->GetPub());
1192  }
1193  }
1194 
1195  if (m_OrigPubdesc.IsNull()) {
1196  if (m_PubFeatIter) {
1197  if (++m_PubFeatIter) {
1198  m_OrigPubdesc = ConstRef(&m_PubFeatIter->GetData().GetPub());
1199  }
1200  }
1201  else {
1203  if (m_PubFeatIter) {
1204  m_OrigPubdesc = ConstRef(&m_PubFeatIter->GetData().GetPub());
1205  }
1206  }
1207  }
1208 
1209  if (m_OrigPubdesc.IsNull()) {
1210  if (++m_SeqIter) {
1212  if (new_iter) {
1213  if (current_pubdesc.GetPointer() != &new_iter->GetPub()) {
1214  m_PubDescrIter = new_iter;
1215  m_OrigPubdesc = ConstRef(&m_PubDescrIter->GetPub());
1216  }
1217  }
1218  }
1219  }
1220  }
1221 
1222  if (m_OrigPubdesc.IsNull() && m_SeqSetIter) {
1223  if (m_PubDescrIter && ++m_PubDescrIter) {
1224  m_OrigPubdesc = ConstRef(&m_PubDescrIter->GetPub());
1225  }
1226  }
1227 
1228  if (m_OrigPubdesc.IsNull() && !m_SeqSubmit.IsNull()) {
1229  if (m_SubmitBlockIter.IsNull()) {
1230  if (m_SeqSubmit->IsSetSub() && m_SeqSubmit->GetSub().IsSetCit()) {
1232  }
1233  }
1234  else {
1235  m_SubmitBlockIter->MarkProcessed();
1236  }
1237 
1238  }
1239 
1240  x_Init();
1241  return *this;
1242 }
1243 
1245 {
1246  if (m_OrigPubdesc.IsNull()) {
1247  return (m_SubmitBlockIter) ? m_SubmitBlockIter->Processed() : true;
1248  }
1249  return false;
1250 }
1251 
1253 {
1254  if (m_FirstPubdesc) {
1255  return (m_FirstPubdesc == m_OrigPubdesc);
1256  }
1257  return true;
1258 }
1259 
1261 {
1262  SConstScopedObject sobject;
1263  CRef<CScope> pscope(&(m_Seh.GetScope()));
1264  sobject.scope = pscope;
1265 
1266  if (m_OrigPubdesc) {
1267  sobject.object.Reset(m_OrigPubdesc);
1268  }
1269  else if (m_SubmitBlockIter) {
1270  sobject.object.Reset(&m_SubmitBlockIter->GetOrigSubmitBlock());
1271  }
1272  return sobject;
1273 }
1274 
1276 {
1277  if (m_SubmitBlockIter) {
1278  return "Submitter block: ";
1279  }
1280 
1281  string description;
1282  if (m_SeqIter) {
1283  string seq_id;
1284  CWriteUtil::GetBestId(CSeq_id_Handle::GetHandle(*(m_SeqIter->GetCompleteBioseq()->GetFirstId())), m_Seh.GetScope(), seq_id);
1285  description = "Publication " + seq_id;
1286  }
1287  else if (m_SeqSetIter) {
1288  description = "Publication at set level";
1289  }
1290 
1291  return description;
1292 }
1293 
1295 {
1296  if (m_OrigPubdesc) {
1298  m_EditedPubdesc->Assign(*m_OrigPubdesc);
1299 
1300  CObjectInfo oi(m_EditedPubdesc, m_EditedPubdesc->GetThisTypeInfo());
1301  m_CurIterOI = oi;
1302  }
1303  else if (m_SubmitBlockIter) {
1304  CRef<CSubmit_block> edited_subblock = m_SubmitBlockIter->BuildEditedObject();
1305  CObjectInfo oi(edited_subblock, edited_subblock->GetThisTypeInfo());
1306  m_CurIterOI = oi;
1307  }
1308 }
1309 
1311 {
1312  if (m_OrigPubdesc) {
1314 
1315  if (m_PubFeatIter) {
1316  CSeq_feat_Handle orig_fh = m_PubFeatIter->GetSeq_feat_Handle();
1317  CRef<CSeq_feat> new_feat(new CSeq_feat);
1318  new_feat->Assign(m_PubFeatIter->GetOriginalFeature());
1319  new_feat->SetData().SetPub(m_EditedPubdesc.GetNCObject());
1320  cmd.Reset(new CCmdChangeSeq_feat(orig_fh, *new_feat));
1321  }
1322  else if (m_PubDescrIter) {
1323  CRef<CSeqdesc> new_desc(new CSeqdesc);
1324  new_desc->SetPub(m_EditedPubdesc.GetNCObject());
1325  cmd.Reset(new CCmdChangeSeqdesc(m_PubDescrIter.GetSeq_entry_Handle(), *m_PubDescrIter, *new_desc));
1326  }
1327  if (cmd) {
1328  cmd->Execute();
1329  cmd_composite->AddCommand(*cmd);
1330  }
1331  }
1332  else if (m_SubmitBlockIter) {
1333  const CSubmit_block& orig_block = m_SubmitBlockIter->GetOrigSubmitBlock();
1335  CObject* actual = (CObject*)(&orig_block);
1336  cmd->Add(actual, CConstRef<CObject>(&m_SubmitBlockIter->GetEditedSubmitBlock()));
1337 
1338  cmd->Execute();
1339  cmd_composite->AddCommand(*cmd);
1340  m_SubmitBlockIter->MarkProcessed();
1341  }
1342 }
1343 
1345 {
1346  if (m_PubFeatIter) {
1347  CSeq_feat_Handle fh = m_PubFeatIter->GetSeq_feat_Handle();
1348  bool remove_proteins(false);
1349  CRef<CCmdComposite> del_cmd = GetDeleteFeatureCommand(fh, remove_proteins);
1350  if (del_cmd) {
1351  del_cmd->Execute();
1352  cmd_composite->AddCommand(*del_cmd);
1353  }
1354  Next();
1355  }
1356  else if (m_OrigPubdesc) {
1357  CRef<CCmdDelDesc> del_cmd(new CCmdDelDesc(m_PubDescrIter.GetSeq_entry_Handle(), *m_PubDescrIter));
1358  Next();
1359  if (del_cmd) {
1360  del_cmd->Execute();
1361  cmd_composite->AddCommand(*del_cmd);
1362  }
1363  }
1364 }
1365 
1367 {
1368  return *m_SeqIter;
1369 }
1370 
1372 {
1373  if (m_OrigPubdesc) {
1374  CPubdesc* pubdesc = const_cast<CPubdesc*>(m_OrigPubdesc.GetPointer());
1375  CObjectInfo oi(pubdesc, pubdesc->GetThisTypeInfo());
1376  m_CurIterOI = oi;
1377  }
1378  else if (m_SubmitBlockIter) {
1379  const CSubmit_block& const_block = m_SubmitBlockIter->GetOrigSubmitBlock();
1380  CSubmit_block* block = const_cast<CSubmit_block*>(&const_block);
1381  CObjectInfo oi(block, block->GetThisTypeInfo());
1382  m_CurIterOI = oi;
1383  }
1384 }
1385 
1387 {
1388  return (m_PubDescrIter) ? true : false;
1389 }
1390 
1392 {
1393  return (m_PubFeatIter) ? true : false;
1394 }
1395 
1396 
1397 // CSubmitblockIter
1399 {
1400  _ASSERT(seqsubmit);
1401  _ASSERT(seqsubmit->GetSub().IsSetCit());
1402  m_OrigSubmitBlock.Reset(&seqsubmit->GetSub());
1403 }
1404 
1406 {
1407  m_EditedSubmitBlock.Reset(new CSubmit_block);
1408  m_EditedSubmitBlock->Assign(*m_OrigSubmitBlock);
1409  return m_EditedSubmitBlock;
1410 
1411 }
1412 
1413 ///////////////////////////////////////////////////////////////////////////////
1414 /// CMacroBioData_UserObjectIter
1415 ///
1417  : CMacroBioData_SeqdescIter(entry)
1418 {
1419 }
1420 
1422 {
1424  if (m_SeqIter) {
1425  m_DescIter = CSeqdesc_CI(*m_SeqIter, CSeqdesc::e_User);
1426  if (m_DescIter) {
1427  m_OrigUserObj = ConstRef(&m_DescIter->GetUser());
1428  }
1429 
1430  while (m_OrigUserObj.IsNull() && m_SeqIter) {
1431  if (++m_SeqIter) {
1432  m_DescIter = CSeqdesc_CI(*m_SeqIter, CSeqdesc::e_User);
1433  if (m_DescIter) {
1434  m_OrigUserObj = ConstRef(&m_DescIter->GetUser());
1435  }
1436  }
1437  }
1438  }
1439  else { // there might be a set in this entry that has a descriptor
1441  if (m_SeqSetIter) {
1442  m_DescIter = CSeqdesc_CI(*m_SeqSetIter, CSeqdesc::e_User);
1443  if (m_DescIter) {
1444  m_OrigUserObj = ConstRef(&m_DescIter->GetUser());
1445  }
1446  }
1447  }
1448 
1449  m_FirstUserObj = m_OrigUserObj;
1450 
1451  x_Init();
1452  return *this;
1453 }
1454 
1456 {
1457  m_OrigUserObj.Reset();
1458  while (m_OrigUserObj.IsNull() && m_SeqIter) {
1459  if (m_DescIter && ++m_DescIter) {
1460  m_OrigUserObj = ConstRef(&m_DescIter->GetUser());
1461  }
1462 
1463  if (m_OrigUserObj.IsNull()) {
1464  if (++m_SeqIter) {
1465  m_DescIter = CSeqdesc_CI(*m_SeqIter, CSeqdesc::e_User);
1466  if (m_DescIter) {
1467  m_OrigUserObj = ConstRef(&m_DescIter->GetUser());
1468  }
1469  }
1470  }
1471  }
1472 
1473  if (m_OrigUserObj.IsNull() && m_SeqSetIter) {
1474  if (m_DescIter && ++m_DescIter) {
1475  m_OrigUserObj = ConstRef(&m_DescIter->GetUser());
1476  }
1477  }
1478 
1479  x_Init();
1480  return *this;
1481 }
1482 
1484 {
1485  return m_OrigUserObj.IsNull();
1486 }
1487 
1489 {
1490  return (m_FirstUserObj == m_OrigUserObj);
1491 }
1492 
1494 {
1495  SConstScopedObject sobject;
1496  sobject.object.Reset(m_OrigUserObj);
1497 
1498  CRef<CScope> pscope(&(m_Seh.GetScope()));
1499  sobject.scope = pscope;
1500 
1501  return sobject;
1502 }
1503 
1505 {
1506  return x_GetDescription("User object");
1507 }
1508 
1510 {
1511  m_EditedUserObj.Reset(new CUser_object);
1512  m_EditedUserObj->Assign(*m_OrigUserObj);
1513 
1514  CObjectInfo oi(m_EditedUserObj, m_EditedUserObj->GetThisTypeInfo());
1515  m_CurIterOI = oi;
1516 }
1517 
1519 {
1520  CRef<CSeqdesc> new_desc(new CSeqdesc);
1521  new_desc->SetUser(m_EditedUserObj.GetNCObject());
1522  CRef<CCmdChangeSeqdesc> cmd(new CCmdChangeSeqdesc(m_DescIter.GetSeq_entry_Handle(), *m_DescIter, *new_desc));
1523  if (cmd) {
1524  cmd->Execute();
1525  cmd_composite->AddCommand(*cmd);
1526  }
1527 }
1528 
1530 {
1531  CRef<CCmdDelDesc> del_cmd(new CCmdDelDesc(m_DescIter.GetSeq_entry_Handle(), *m_DescIter));
1532  Next();
1533  if (del_cmd) {
1534  del_cmd->Execute();
1535  cmd_composite->AddCommand(*del_cmd);
1536  }
1537 }
1538 
1540 {
1541  CUser_object* user = const_cast<CUser_object*>(m_OrigUserObj.GetPointer());
1542  CObjectInfo oi(user, user->GetThisTypeInfo());
1543  m_CurIterOI = oi;
1544 }
1545 
1546 
1547 //////////////////////////////////////////////////////////////////////////////
1548 /// CMacroBioData_StructCommentIter
1549 ///
1552 {
1553 }
1554 
1556 {
1558  if (m_SeqIter) {
1561 
1562  while (m_OrigUserObj.IsNull() && m_SeqIter) {
1563  if (++m_SeqIter) {
1566  }
1567  }
1568  } else {// there might be a set in this entry that has a descriptor
1570  if (m_SeqSetIter) {
1573  }
1574  }
1575 
1577 
1578  x_Init();
1579  return *this;
1580 }
1581 
1583 {
1584  auto tmp_orig_user_object = m_OrigUserObj;
1585  m_OrigUserObj.Reset();
1586  while (m_OrigUserObj.IsNull() && m_SeqIter) {
1587  if (m_DescIter) {
1588  ++m_DescIter;
1590  }
1591 
1592  if (m_OrigUserObj.IsNull()) {
1593  if (++m_SeqIter) {
1596  }
1597  }
1598  if (m_OrigUserObj == tmp_orig_user_object) {
1599  m_OrigUserObj.Reset();
1600  }
1601  }
1602 
1603  if (m_OrigUserObj.IsNull() && m_SeqSetIter) {
1604  if (m_DescIter && ++m_DescIter) {
1606  }
1607  }
1608 
1609  x_Init();
1610  return *this;
1611 }
1612 
1614 {
1615  return x_GetDescription("Structured comment");
1616 }
1617 
1619 {
1620  while (m_DescIter) {
1622  m_OrigUserObj = ConstRef(&m_DescIter->GetUser());
1623  break;
1624  }
1625  ++m_DescIter;
1626  }
1627 }
1628 
1629 
1630 //////////////////////////////////////////////////////////////////////////////
1631 /// CMacroBioData_DBLinkIter
1632 ///
1635 {
1636 }
1637 
1639 {
1641  if (m_SeqIter) {
1643  while (m_OrigUserObj.IsNull() && m_SeqIter) {
1644  ++m_SeqIter;
1646  }
1647  }
1648  else {// there might be a set in this entry that has a descriptor
1650  if (m_SeqSetIter) {
1652  }
1653  }
1654 
1656 
1657  x_Init();
1658  return *this;
1659 }
1660 
1662 {
1663  m_OrigUserObj.Reset();
1664  while (m_OrigUserObj.IsNull() && m_SeqIter) {
1665  ++m_SeqIter;
1667  }
1668 
1669  x_Init();
1670  return *this;
1671 }
1672 
1674 {
1675  return x_GetDescription("DBLink");
1676 }
1677 
1678 const objects::CUser_object* CMacroBioData_DBLinkIter::x_GetDBLink()
1679 {
1680  if (m_SeqIter) {
1681  for (CSeqdesc_CI desc_it(*m_SeqIter, CSeqdesc::e_User); desc_it; ++desc_it) {
1682  if (desc_it->GetUser().GetType().IsStr()
1683  && desc_it->GetUser().GetType().GetStr() == "DBLink") {
1684  m_DescIter = desc_it;
1685  return &desc_it->GetUser();
1686  }
1687  }
1688  }
1689  else if (m_SeqSetIter) {
1690  for (CSeqdesc_CI desc_it(*m_SeqSetIter, CSeqdesc::e_User); desc_it; ++desc_it) {
1691  if (desc_it->GetUser().GetType().IsStr()
1692  && desc_it->GetUser().GetType().GetStr() == "DBLink") {
1693  m_DescIter = desc_it;
1694  return &desc_it->GetUser();
1695  }
1696  }
1697  }
1698  return nullptr;
1699 }
1700 
1701 //////////////////////////////////////////////////////////////////////////////
1702 /// CMacroBioData_AutodefOptsIter
1703 ///
1706 {
1707 }
1708 
1710 {
1712  if (m_SeqIter) {
1714  while (m_OrigUserObj.IsNull() && m_SeqIter) {
1715  ++m_SeqIter;
1717  }
1718  }
1719 
1721 
1722  x_Init();
1723  return *this;
1724 }
1725 
1727 {
1728  m_OrigUserObj.Reset();
1729  while (m_OrigUserObj.IsNull() && m_SeqIter) {
1730  ++m_SeqIter;
1732  }
1733 
1734  x_Init();
1735  return *this;
1736 }
1737 
1739 {
1740  return x_GetDescription("AutodefOptions");
1741 }
1742 
1744 {
1745  if (!m_SeqIter) return nullptr;
1746  for (CSeqdesc_CI desc_it(*m_SeqIter, CSeqdesc::e_User); desc_it; ++desc_it) {
1747  if (desc_it->GetUser().GetType().IsStr()
1748  && desc_it->GetUser().GetType().GetStr() == "AutodefOptions") {
1749  m_DescIter = desc_it;
1750  return &desc_it->GetUser();
1751  }
1752  }
1753  return nullptr;
1754 }
1755 
1756 
1757 //////////////////////////////////////////////////////////////////////////////
1758 /// CMacroBioData_SeqdescIter
1759 ///
1761  : IMacroBioDataIter(entry)
1762 {
1763 }
1764 
1766 {
1768  if (m_SeqIter) {
1770  if (m_DescIter) {
1772  }
1773  while (m_OrigSeqdesc.IsNull() && m_SeqIter) {
1774  if (++m_SeqIter) {
1776  if (m_DescIter) {
1778  }
1779  }
1780  }
1781  }
1782  else { // there might be a set in this entry that has a descriptor
1784  if (m_SeqSetIter) {
1786  if (m_DescIter) {
1788  }
1789  }
1790  }
1792 
1793  x_Init();
1794  return *this;
1795 }
1796 
1798 {
1799  m_OrigSeqdesc.Reset();
1800  while (m_OrigSeqdesc.IsNull() && m_SeqIter) {
1801  if (m_DescIter && ++m_DescIter) {
1803  }
1804 
1805  if (m_OrigSeqdesc.IsNull()) {
1806  if (++m_SeqIter) {
1808  if (m_DescIter) {
1810  }
1811  }
1812  }
1813  }
1814 
1815  if (m_OrigSeqdesc.IsNull() && m_SeqSetIter) {
1816  if (m_DescIter && ++m_DescIter) {
1818  }
1819  }
1820 
1821  x_Init();
1822  return *this;
1823 }
1824 
1826 {
1827  return m_OrigSeqdesc.IsNull();
1828 }
1829 
1831 {
1832  return (m_FirstSeqdesc == m_OrigSeqdesc);
1833 }
1834 
1836 {
1837  SConstScopedObject sobject;
1838  sobject.object.Reset(m_OrigSeqdesc);
1839 
1840  CRef<CScope> pscope(&(m_Seh.GetScope()));
1841  sobject.scope = pscope;
1842 
1843  return sobject;
1844 }
1845 
1847 {
1848  string seq_id;
1850  CSeq_id_Handle::GetHandle(*(m_SeqIter->GetCompleteBioseq()->GetFirstId())),
1851  m_Seh.GetScope(), seq_id);
1852  return seq_id;
1853 }
1854 
1856 {
1857  return x_GetDescription("Descriptor");
1858 }
1859 
1860 string CMacroBioData_SeqdescIter::x_GetDescription(const string& descr_name) const
1861 {
1862  string description;
1863  if (m_SeqIter) {
1864  const string& seq_id = x_GetSeqId();
1865  description = descr_name + " " + seq_id;
1866  }
1867  else if (m_SeqSetIter) {
1868  description = descr_name + " at set level";
1869  }
1870  return description;
1871 }
1872 
1874 {
1876  m_EditedSeqdesc->Assign(*m_OrigSeqdesc);
1877 
1878  CObjectInfo objInfo(m_EditedSeqdesc, m_EditedSeqdesc->GetThisTypeInfo());
1879  m_CurIterOI = objInfo;
1880 }
1881 
1883 {
1885  if (cmd) {
1886  cmd->Execute();
1887  cmd_composite->AddCommand(*cmd);
1888  }
1889 }
1890 
1892 {
1893  CRef<CCmdDelDesc> del_cmd(new CCmdDelDesc(m_DescIter.GetSeq_entry_Handle(), *m_OrigSeqdesc));
1894  Next();
1895  if (del_cmd) {
1896  del_cmd->Execute();
1897  cmd_composite->AddCommand(*del_cmd);
1898  }
1899 }
1900 
1902 {
1903  return *m_SeqIter;
1904 }
1905 
1907 {
1908  CSeqdesc* seqdesc = const_cast<CSeqdesc*>(m_OrigSeqdesc.GetPointer());
1909  CObjectInfo objInfo(seqdesc, seqdesc->GetThisTypeInfo());
1910  m_CurIterOI = objInfo;
1911 }
1912 
1913 //////////////////////////////////////////////////////////////////////////////
1914 /// CMacroBioData_SeqAlignIter
1915 ///
1917  : IMacroBioDataIter(entry), m_AlignIter(entry, SAnnotSelector(CSeq_annot::C_Data::e_Align))
1918 {
1919 }
1920 
1922 {
1923  m_AlignIter.Rewind();
1924  x_Init();
1925  return *this;
1926 }
1927 
1929 {
1930  ++m_AlignIter;
1931  x_Init();
1932  return *this;
1933 }
1934 
1936 {
1937  if (m_AlignIter) {
1938  return false;
1939  }
1940  return true;
1941 }
1942 
1944 {
1945  CAlign_CI align_it(m_AlignIter);
1946  align_it.Rewind();
1947  if (&(*m_AlignIter) == &(*align_it))
1948  return true;
1949  return false;
1950 
1951 }
1952 
1954 {
1955  SConstScopedObject sobject;
1956 
1957  const CSeq_align& align = *m_AlignIter;
1958  sobject.object.Reset(&align);
1959 
1960  CRef<CScope> pscope(&(m_Seh.GetScope()));
1961  sobject.scope = pscope;
1962 
1963  return sobject;
1964 }
1965 
1967 {
1968  return "Alignment";
1969 }
1970 
1972 {
1975  m_EditedSeqalign->Assign(*m_OrigSeqalign);
1976 
1977  CObjectInfo objInfo(m_EditedSeqalign, m_EditedSeqalign->GetThisTypeInfo());
1978  m_CurIterOI = objInfo;
1979 }
1980 
1982 {
1983  CRef<CCmdChangeAlign> chgAlign(new CCmdChangeAlign(m_AlignIter.GetSeq_align_Handle(), *m_EditedSeqalign.GetNCPointerOrNull()));
1984  chgAlign->Execute();
1985  cmd_composite->AddCommand(*chgAlign);
1986 }
1987 
1989 {
1990  CSeq_align_Handle ah = m_AlignIter.GetSeq_align_Handle();
1991  CRef<CCmdDelSeq_align> del_cmd(new CCmdDelSeq_align(ah));
1992  del_cmd->Execute();
1993  cmd_composite->AddCommand(*del_cmd);
1994 
1995  Next();
1996 }
1997 
1999 {
2000  const CSeq_align* const_seqalign = &(*m_AlignIter);
2001  CSeq_align* seqalign = const_cast<CSeq_align*>(const_seqalign);
2002  CObjectInfo objInfo(seqalign, seqalign->GetThisTypeInfo());
2003  m_CurIterOI = objInfo;
2004 }
2005 
2006 
2007 //////////////////////////////////////////////////////////////////////////////
2008 /// CMacroBioData_SeqIter
2009 ///
2011  : IMacroBioDataIter(entry)
2012 {
2013 }
2014 
2015 CMacroBioData_SeqIter* CMacroBioData_SeqIter::s_MakeSeqIterator(const objects::CSeq_entry_Handle& entry, objects::CSeq_inst::EMol mol_type)
2016 {
2017  switch (mol_type) {
2018  case CSeq_inst::eMol_na:
2019  return new CMacroBioData_SeqNAIter(entry);
2020  case CSeq_inst::eMol_aa:
2021  return new CMacroBioData_SeqAAIter(entry);
2022  default:
2023  return new CMacroBioData_SeqIter(entry);
2024  }
2025  return nullptr;
2026 }
2027 
2029 {
2031  x_Init();
2032  return *this;
2033 }
2034 
2036 {
2037  ++m_SeqIter;
2038  x_Init();
2039  return *this;
2040 }
2041 
2043 {
2044  return (!m_SeqIter);
2045 }
2046 
2048 {
2049  CBioseq_CI seq_it(m_Seh);
2050  return (*m_SeqIter == *seq_it);
2051 }
2052 
2054 {
2055  SConstScopedObject sobject;
2056 
2057  const CBioseq& bseq = *m_SeqIter->GetCompleteBioseq();
2058  sobject.object.Reset(&bseq);
2059 
2060  CRef<CScope> pscope(&(m_Seh.GetScope()));
2061  sobject.scope = pscope;
2062 
2063  return sobject;
2064 }
2065 
2066 
2068 {
2069  const CBioseq& bseq = *m_SeqIter->GetCompleteBioseq();
2070  CBioseq_Handle bsh = m_Seh.GetScope().GetBioseqHandle(bseq);
2071  string best_id;
2072  CWriteUtil::GetBestId(bsh.GetAccessSeq_id_Handle(), m_Seh.GetScope(), best_id);
2073  return best_id;
2074 }
2075 
2077 {
2078  // build editable Bioseq/Seq-entry:
2079  m_OrigSeq.Reset(m_SeqIter->GetCompleteBioseq().GetPointer());
2080  m_EditedSeq.Reset(new CBioseq);
2081  m_EditedSeq->Assign(*m_OrigSeq);
2082 
2084  m_EditedEntry->SetSeq(*m_EditedSeq);
2085 
2086  CObjectInfo objInfo(m_EditedSeq, m_EditedSeq->GetThisTypeInfo());
2087  m_CurIterOI = objInfo;
2088 }
2089 
2091 {
2092  const CBioseq& bseq = *m_SeqIter->GetCompleteBioseq();
2093  CBioseq_Handle bsh = m_Seh.GetScope().GetBioseqHandle(bseq);
2094  CSeq_entry_Handle b_seh = bsh.GetSeq_entry_Handle();
2095 
2097  chg_seq->Execute();
2098  cmd_composite->AddCommand(*chg_seq);
2099 }
2100 
2102 {
2103  const CBioseq& bseq = *m_SeqIter->GetCompleteBioseq();
2104  CBioseq_Handle bsh = m_Seh.GetScope().GetBioseqHandle(bseq);
2105 
2106  Next();
2107  CRef<CCmdDelBioseq> del_cmd(new CCmdDelBioseq(bsh));
2108  del_cmd->Execute();
2109  cmd_composite->AddCommand(*del_cmd);
2110  // when protein sequences are deleted, this command does not renormalize the nuc-prot set
2111 }
2112 
2114 {
2115  return *m_SeqIter;
2116 }
2117 
2119 {
2120  const CBioseq* const_bseq = m_SeqIter->GetCompleteBioseq().GetPointerOrNull();
2121  CBioseq* bseq = const_cast<CBioseq*>(const_bseq);
2122  CObjectInfo oi(bseq, bseq->GetThisTypeInfo());
2123  m_CurIterOI = oi;
2124 }
2125 
2126 
2128  : CMacroBioData_SeqIter(entry)
2129 {
2130 }
2131 
2133 {
2135  x_Init();
2136  return *this;
2137 }
2138 
2140 {
2142  // check if handles point to the same bioseq
2143  return (*m_SeqIter == *seq_it);
2144 }
2145 
2146 
2148  : CMacroBioData_SeqIter(entry)
2149 {
2150 }
2151 
2153 {
2155  x_Init();
2156  return *this;
2157 }
2158 
2160 {
2162  // check if handles point to the same bioseq
2163  return (*m_SeqIter == *seq_it);
2164 }
2165 
2166 
2167 
2168 /////////////////////////////////////////////////////////////////
2169 /// CMacroBioData_SeqSetIter- iterates over all types of sets
2170 ///
2172  : IMacroBioDataIter(entry), m_SeqSetIter(entry, CSeq_entry_CI::fRecursive | CSeq_entry_CI::fIncludeGivenEntry, CSeq_entry::e_Set)
2173 {
2174 }
2175 
2177 {
2179  m_SeqSetIter = local_iter;
2180  x_Init();
2181  return *this;
2182 }
2183 
2185 {
2186  ++m_SeqSetIter;
2187  x_Init();
2188  return *this;
2189 }
2190 
2192 {
2193  return (!m_SeqSetIter);
2194 }
2195 
2197 {
2199  return (m_SeqSetIter->GetCompleteSeq_entry().GetPointerOrNull() == set_iter->GetCompleteSeq_entry().GetPointerOrNull());
2200 }
2201 
2203 {
2204  SConstScopedObject sobject;
2205 
2206  CConstRef<CSeq_entry> entry = m_SeqSetIter->GetCompleteSeq_entry();
2207  _ASSERT(entry->IsSet());
2208  const CBioseq_set& set = entry->GetSet();
2209  sobject.object.Reset(&set);
2210 
2211  CRef<CScope> pscope(&(m_SeqSetIter->GetScope()));
2212  sobject.scope = pscope;
2213 
2214  return sobject;
2215 }
2216 
2218 {
2219  string label = kEmptyStr;
2220  m_SeqSetIter->GetCompleteSeq_entry()->GetLabel(&label, CSeq_entry::eType);
2221  return label;
2222 }
2223 
2225 {
2226  CConstRef<CSeq_entry> entry = m_SeqSetIter->GetCompleteSeq_entry();
2227  _ASSERT(entry->IsSet());
2228  m_OrigSeqSet.Reset(&entry->GetSet());
2230  m_EditedSeqSet->Assign(*m_OrigSeqSet);
2231 
2232  CObjectInfo objInfo(m_EditedSeqSet, m_EditedSeqSet->GetThisTypeInfo());
2233  m_CurIterOI = objInfo;
2234 }
2235 
2237 {
2238  CConstRef<CSeq_entry> entry = m_SeqSetIter->GetCompleteSeq_entry();
2239  _ASSERT(entry->IsSet());
2240  CBioseq_set_Handle bssh = (*m_SeqSetIter).GetScope().GetBioseq_setHandle(entry->GetSet());
2242  chg_cmd->Execute();
2243  cmd_composite->AddCommand(*chg_cmd);
2244 }
2245 
2247 {
2248  CConstRef<CSeq_entry> entry = m_SeqSetIter->GetCompleteSeq_entry();
2249  _ASSERT(entry->IsSet());
2250  CBioseq_set_Handle bssh = (*m_SeqSetIter).GetScope().GetBioseq_setHandle(entry->GetSet());
2251  CRef<CCmdDelBioseqSet> del_cmd(new CCmdDelBioseqSet(bssh));
2252  del_cmd->Execute();
2253  cmd_composite->AddCommand(*del_cmd);
2254 
2255  Next();
2256 }
2257 
2259 {
2260  CConstRef<CSeq_entry> entry = m_SeqSetIter->GetCompleteSeq_entry();
2261  _ASSERT(entry->IsSet());
2262  const CBioseq_set& c_set = entry->GetSet();
2263  CBioseq_set& set = const_cast<CBioseq_set&>(c_set);
2264  CObjectInfo oi(&set, set.GetThisTypeInfo());
2265  m_CurIterOI = oi;
2266 }
2267 
2268 /////////////////////////////////////////////////////////////////
2269 /// CMacroBioData_TSEntryIter
2270 ///
2272  : IMacroBioDataIter(entry), m_EntryIter(entry, CSeq_entry_CI::fIncludeGivenEntry)
2273 {
2274 }
2275 
2276 
2278 {
2280  m_EntryIter = local_iter;
2281  x_Init();
2282  return *this;
2283 }
2284 
2286 {
2287  ++m_EntryIter;
2288  x_Init();
2289  return *this;
2290 }
2291 
2293 {
2294  if (m_EntryIter && m_EntryIter.GetDepth() == 0) {
2295  return false;
2296  }
2297  return true;
2298 }
2299 
2301 {
2303  if (m_EntryIter->GetCompleteSeq_entry().GetPointerOrNull() ==
2304  entry_iter->GetCompleteSeq_entry().GetPointerOrNull()) {
2305  return true;
2306  }
2307  return false;
2308 }
2309 
2311 {
2312  SConstScopedObject sobject;
2313 
2314  CConstRef<CSeq_entry> entry = m_EntryIter->GetCompleteSeq_entry();
2315  sobject.object.Reset(&(*entry));
2316 
2317  CRef<CScope> pscope(&(m_EntryIter->GetScope()));
2318  sobject.scope = pscope;
2319 
2320  return sobject;
2321 }
2322 
2324 {
2325  return kEmptyStr;
2326 }
2327 
2329 {
2330  CConstRef<CSeq_entry> orig_entry = m_EntryIter->GetCompleteSeq_entry();
2331  m_OrigTSE.Reset(&(*orig_entry));
2332 
2333  m_EditedTSE.Reset(new CSeq_entry());
2334  m_EditedTSE->Assign(*orig_entry);
2335 
2336  CObjectInfo objInfo(m_EditedTSE, m_EditedTSE->GetThisTypeInfo());
2337  m_CurIterOI = objInfo;
2338 }
2339 
2341 {
2343  chg_cmd->Execute();
2344  cmd_composite->AddCommand(*chg_cmd);
2345 }
2346 
2348 {
2349  // do nothing
2350 }
2351 
2352 
2354 {
2355  CConstRef<CSeq_entry> c_entry = m_EntryIter->GetCompleteSeq_entry();
2356  CSeq_entry& entry = const_cast<CSeq_entry&>(*c_entry);
2357  CObjectInfo oi(&entry, entry.GetThisTypeInfo());
2358  m_CurIterOI = oi;
2359 }
2360 
2361 END_SCOPE(macro)
2363 
2364 /* @} */
User-defined methods of the data storage class.
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
static CSeq_entry_Handle GetSeq_entry_Handle(TTypeInfo type, TConstObjectPtr ptr, CScope &scope)
bool IsGeneralIdProtPresent(objects::CSeq_entry_Handle tse)
CAlign_CI –.
Definition: align_ci.hpp:63
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
CBioseq_set_Handle –.
void AddCommand(IEditCommand &command)
virtual void Execute()
Do the editing action.
static bool IsStructuredComment(const CUser_object &user)
CFeat_CI –.
Definition: feat_ci.hpp:64
CMacroBioData_SeqIter- iterates over sequences (na and aa)
CMacroBioData_SeqdescIter- iterates over all types of sequence descriptors.
CMacroBioData_UserObjectIter - iterates over all user objects in the seq-entry.
implements special composite command, which does not call to its internal commands when run the very ...
class CMacroExecException
Definition: macro_ex.hpp:146
CObjectInfo –.
Definition: objectinfo.hpp:597
CObjectTypeInfoCV –.
Definition: objectiter.hpp:477
CObject –.
Definition: ncbiobj.hpp:180
@Pubdesc.hpp User-defined methods of the data storage class.
Definition: Pubdesc.hpp:54
CScope –.
Definition: scope.hpp:92
static CTempString SubtypeValueToName(ESubtype eSubtype)
Turns a ESubtype into its string value which is NOT necessarily related to the identifier of the enum...
CSeq_entry_CI –.
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
@ eType
Definition: Seq_entry.hpp:92
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
CSubmit_block –.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
Definition: tse_handle.cpp:205
static bool GetBestId(CSeq_id_Handle, CScope &, string &)
Definition: write_util.cpp:675
IMacroBioDataIter - common interface of all iterators used in the editing macros The type of the iter...
void clear()
Definition: map.hpp:169
Definition: set.hpp:45
const char * file_name[]
CChangeUnindexedObjectCommand< objects::CSubmit_block > CChangeSubmitBlockCommand
static auto & FindOrgNames
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define true
Definition: bool.h:35
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:46
string
Definition: cgiapp.hpp:687
#define DIAG_COMPILE_INFO
Make compile time diagnostic information object to use in CNcbiDiag and CException.
Definition: ncbidiag.hpp:170
#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
#define NCBI_USER_THROW(message)
Throw a quick-and-dirty runtime exception of type 'CException' with the given error message and error...
Definition: ncbiexpt.hpp:715
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
#define NCBI_RETHROW2(prev_exception, exception_class, err_code, message, extra)
Re-throw exception with extra parameter.
Definition: ncbiexpt.hpp:1761
@ eUnknown
Unknown exception.
Definition: ncbiexpt.hpp:887
const objects::CUser_object * x_GetAutodefOptions()
virtual string GetBestDescr() const
Used for logging.
CMacroBioData_SeqSetIter(const objects::CSeq_entry_Handle &entry)
CMacroBioData_TSEntryIter(const objects::CSeq_entry_Handle &entry)
bool m_Completed
flag to be used by actions that need to be completed only once
virtual void x_SetDefaultObjectInfo()
Initializes member variable m_CurIterOI.
CConstRef< objects::CBioseq_set > m_OrigSeqSet
CConstRef< objects::CSeqdesc > m_FirstSeqdesc
virtual bool IsEnd(void) const =0
CConstRef< objects::CSeq_align > m_OrigSeqalign
virtual IMacroBioDataIter & Begin(void)
virtual string GetBestDescr() const
Used for logging.
virtual bool IsEnd(void) const
bool SetTableToApply(const string &file_name, size_t match_col)
virtual void SetToDelete(bool intent)
virtual SConstScopedObject GetScopedObject() const
Dereferences the underlying iterator.
virtual void x_SetDefaultObjectInfo()
Initializes member variable m_CurIterOI.
virtual string GetBestDescr() const
Used for logging.
CMacroBioData_SeqNAIter(const objects::CSeq_entry_Handle &entry)
virtual size_t GetCount() const
bool m_MultipleSpaceOnly
when true, single space character are not considered delimiters
CRef< objects::CPubdesc > m_EditedPubdesc
void ConvertMultiSpaces(string &line, const string &delimiter)
replace any instance of 2 or more spaces with a single instance of 'delimiter'
Definition: macro_util.cpp:833
virtual IMacroBioDataIter & Next(void)
virtual SConstScopedObject GetScopedObject() const
Dereferences the underlying iterator.
virtual void x_SetDefaultObjectInfo()
Initializes member variable m_CurIterOI.
virtual void BuildEditedObject()
Creates a copy of the object that will be edited.
const objects::CMolInfo * x_GetMolInfo()
void ThrowCMacroExecException(const CDiagCompileInfo &info, CMacroExecException::EErrCode code, const string &message, const CQueryParseTree::TNode *treeNode, const CException *previous=nullptr)
Throws CMacroExecException with the specified message and error location from the TNode.
Definition: macro_ex.hpp:279
virtual const vector< string > & GetTaxnames() const
virtual IMacroBioDataIter & Begin(void)
virtual string GetBestDescr() const
Used for logging.
virtual SConstScopedObject GetScopedObject() const
Dereferences the underlying iterator.
virtual bool IsEnd(void) const
virtual void BuildEditedObject()
Creates a copy of the object that will be edited.
virtual IMacroBioDataIter & Next(void)
virtual void RunDeleteCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the delete command.
objects::CSeq_entry_CI m_SeqSetIter
bool FindInTable(const CMQueryNodeValue::TObs &objs, bool case_sensitive=true)
virtual IMacroBioDataIter & Begin(void)
virtual void RunEditCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the editing command.
virtual void RunDeleteCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the delete command.
objects::CSeqdesc_CI m_DescIter
objects::CBioseq_CI m_SeqIter
bool m_MergeFirstCols
when true, merges first two columns to form the seq-id match field
virtual string GetBestDescr() const
Used for logging.
bool GetValueFromTable(size_t col, string &value)
CRef< objects::CSeq_feat > m_EditedFeat
virtual void RunDeleteCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the delete command.
virtual void x_SetDefaultObjectInfo()
Initializes member variable m_CurIterOI.
virtual void x_SetDefaultObjectInfo()
Initializes member variable m_CurIterOI.
virtual bool IsEnd(void) const
virtual void BuildEditedObject()
Creates a copy of the object that will be edited.
CConstRef< objects::CSeq_entry > m_OrigTSE
objects::CSeq_entry_CI m_SeqSetIter
> provides context information
virtual void BuildEditedObject()
Creates a copy of the object that will be edited.
list< SResolvedField > TObs
Definition: macro_exec.hpp:92
virtual IMacroBioDataIter & Next(void)
const objects::CBioSource * x_GetBioSource()
CConstRef< objects::CSubmit_block > m_OrigSubmitBlock
CMacroBioData_FeatIterBase(const objects::CSeq_entry_Handle &entry, const objects::SAnnotSelector &sel)
CMacroBioData_AutodefOptsIter(const objects::CSeq_entry_Handle &entry)
virtual bool IsDescriptor() const
string GetValueFromTable(size_t col)
void SetTableToApply(const string &file_name, size_t match_col, const string &delimiter, bool merge_de, bool split_firstcol, bool convert_multi, bool merge_firstcols, bool multiple_sp_only)
static CMacroBioData_SeqIter * s_MakeSeqIterator(const objects::CSeq_entry_Handle &entry, objects::CSeq_inst::EMol mol_type)
virtual SConstScopedObject GetScopedObject() const
Dereferences the underlying iterator.
virtual string GetBestDescr() const
Used for logging.
CConstRef< objects::CSeq_feat > m_FirstFeat
virtual void BuildEditedObject()
Creates a copy of the object that will be edited.
virtual void RunEditCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the editing command.
virtual string GetBestDescr() const
Used for logging.
virtual string GetBestDescr() const
Used for logging.
virtual void RunDeleteCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the delete command.
virtual SConstScopedObject GetScopedObject() const
Dereferences the underlying iterator.
virtual IMacroBioDataIter & Next(void)
virtual void RunEditCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the editing command.
virtual void x_SetDefaultObjectInfo()
Initializes member variable m_CurIterOI.
virtual objects::CBioseq_Handle GetBioseqHandle(void) const
CSubmitblockIter(CConstRef< objects::CSeq_submit > seqsubmit)
virtual void x_SetDefaultObjectInfo()
Initializes member variable m_CurIterOI.
virtual IMacroBioDataIter & Begin(void)
CConstRef< objects::CSeq_feat > m_FirstFeat
virtual void BuildEditedObject()
Creates a copy of the object that will be edited.
virtual IMacroBioDataIter & Begin(void)
CRef< objects::CSeq_entry > m_EditedTSE
virtual string GetBestDescr() const
Used for logging.
virtual IMacroBioDataIter & Next(void)
virtual IMacroBioDataIter & Begin(void)
virtual IMacroBioDataIter & Begin(void)
CMacroBioData_SeqAlignIter(const objects::CSeq_entry_Handle &entry)
CRef< objects::CBioseq > m_EditedSeq
virtual IMacroBioDataIter & Begin(void)
CRef< objects::CMolInfo > m_EditedMolinfo
virtual IMacroBioDataIter & Begin(void)
virtual string GetBestDescr() const
Used for logging.
bool m_HugeData
indicates that the data is large and some macros should take that into account (for example: taxlooku...
CConstRef< objects::CSeq_feat > m_OrigFeat
void GetPrimitiveObjectInfos(CMQueryNodeValue::TObs &objs, const CMQueryNodeValue::SResolvedField &info)
Definition: macro_util.cpp:212
virtual string GetBestDescr() const
Used for logging.
const string & GetTableName() const
virtual IMacroBioDataIter & Begin(void)
objects::CObject_id::TId & MaxFeatureId()
void RunCommand(CRef< CCmdComposite > cmd, CMacroCmdComposite *cmd_composite)
Method for executing a specific command.
CMacroBioData_MolInfoIter(const objects::CSeq_entry_Handle &entry)
CConstRef< objects::CSeqdesc > m_OrigSeqdesc
CMacroBioData_BioSourceIter(const objects::CSeq_entry_Handle &entry)
virtual bool IsEnd(void) const
bool GetFieldsByName(CMQueryNodeValue::TObs *results, const CObjectInfo &oi_i, const string &field_name)
Resolve existing dot qualified ASN.1 name (field_name) starting from the object information instance ...
virtual IMacroBioDataIter & Next(void)
CMacroBioData_SeqdescIter(const objects::CSeq_entry_Handle &entry)
CRef< objects::CSeqdesc > m_EditedSeqdesc
CConstRef< objects::CMolInfo > m_OrigMolinfo
virtual void RunEditCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the editing command.
CRef< objects::CSeq_entry > m_EditedEntry
objects::CSeqdesc_CI m_PubDescrIter
CConstRef< objects::CMolInfo > m_FirstMolinfo
CRef< CSubmitblockIter > m_SubmitBlockIter
virtual SConstScopedObject GetScopedObject() const
Dereferences the underlying iterator.
CConstRef< objects::CBioSource > m_OrigSource
> provides context information
virtual void x_SetDefaultObjectInfo()
Initializes member variable m_CurIterOI.
virtual void RunEditCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the editing command.
virtual IMacroBioDataIter & Next(void)
shared_ptr< CHugeMacroContext > m_MacroContext
virtual IMacroBioDataIter & Next(void)
CMacroBioData_DBLinkIter(const objects::CSeq_entry_Handle &entry)
bool GetChoiceType(const string &field_name, string &choice_type) const
returns choice type string for a given identifier field_name
virtual bool IsDescriptor() const
objects::CSeq_entry_CI m_SeqSetIter
> provides context information
objects::CSeq_entry_CI m_EntryIter
virtual void RunDeleteCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the delete command.
virtual IMacroBioDataIter & Next(void)
map< objects::CBioseq_Handle, set< objects::CSeq_feat_Handle > > m_ProductToCDS
virtual string GetBestDescr() const
Used for logging.
virtual SConstScopedObject GetScopedObject() const
Dereferences the underlying iterator.
virtual void x_SetDefaultObjectInfo()=0
Initializes member variable m_CurIterOI.
virtual bool IsEnd(void) const
CRef< objects::CSubmit_block > BuildEditedObject()
bool m_Modified
indicates whether the edited object has been modified. When it's TRUE, call RunEditCommand()
virtual void BuildEditedObject()
Creates a copy of the object that will be edited.
virtual void BuildEditedObject()
Creates a copy of the object that will be edited.
virtual SConstScopedObject GetScopedObject() const
Dereferences the underlying iterator.
virtual bool IsBegin(void)
const objects::CUser_object * x_GetDBLink()
virtual IMacroBioDataIter & Begin(void)
virtual bool IsEnd(void) const
TPresent m_State
to report values of the matching field that are present in the table, but not present in the data
CConstRef< objects::CUser_object > m_FirstUserObj
string m_Delimiter
< number of actual columns in the table
virtual void x_SetDefaultObjectInfo()
Initializes member variable m_CurIterOI.
virtual void x_SetDefaultObjectInfo()
Initializes member variable m_CurIterOI.
virtual objects::CBioseq_Handle GetBioseqHandle(void) const
virtual void BuildEditedObject()
Creates a copy of the object that will be edited.
virtual void BuildEditedObject()
Creates a copy of the object that will be edited.
virtual void RunDeleteCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the delete command.
virtual void RunDeleteCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the delete command.
CRef< objects::CSeq_feat > m_EditedFeat
virtual IMacroBioDataIter & Next(void)
virtual SConstScopedObject GetScopedObject() const
Dereferences the underlying iterator.
virtual objects::CBioseq_Handle GetBioseqHandle(void) const
CMacroBioData_SeqIter(const objects::CSeq_entry_Handle &entry)
virtual void RunEditCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the editing command.
CConstRef< objects::CSeq_submit > m_SeqSubmit
virtual IMacroBioDataIter & Begin(void)
virtual SConstScopedObject GetScopedObject() const
Dereferences the underlying iterator.
virtual objects::CBioseq_Handle GetBioseqHandle(void) const
virtual objects::CBioseq_Handle GetBioseqHandle(void) const
virtual bool IsFeature() const
virtual string GetBestDescr() const
Used for logging.
virtual void RunDeleteCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the delete command.
virtual bool IsEnd(void) const
virtual bool IsEnd(void) const
virtual IMacroBioDataIter & Begin(void)
CConstRef< objects::CPubdesc > m_OrigPubdesc
virtual IMacroBioDataIter & Next(void)
CMacroBioData_SeqAAIter(const objects::CSeq_entry_Handle &entry)
CMacroBioData_PubdescIter(const objects::CSeq_entry_Handle &entry)
void SetHugeContext(const shared_ptr< CHugeMacroContext > &context)
virtual void BuildEditedObject()
Creates a copy of the object that will be edited.
CConstRef< objects::CBioseq > m_OrigSeq
string GetUnMatchedTableEntries(int &count)
objects::CSeqdesc_CI m_SrcDescrIter
virtual bool IsEnd(void) const
CRef< objects::CBioSource > m_EditedSource
CRef< objects::CSeq_align > m_EditedSeqalign
CConstRef< objects::CBioSource > m_FirstSource
CRef< objects::CBioseq_set > m_EditedSeqSet
virtual void RunEditCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the editing command.
STableToApply m_TableToApply
virtual void RunEditCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the editing command.
virtual IMacroBioDataIter & Begin(void)
virtual IMacroBioDataIter & Next(void)
virtual void RunEditCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the editing command.
CConstRef< objects::CPubdesc > m_FirstPubdesc
virtual IMacroBioDataIter & Begin(void)
virtual void RunDeleteCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the delete command.
virtual void RunDeleteCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the delete command.
CMacroBioData_UserObjectIter(const objects::CSeq_entry_Handle &entry)
CMacroBioData_FeatIntervalIter(const objects::CBioseq_Handle &bsh, const objects::SAnnotSelector &sel, const SFeatInterval &feat_interval)
CConstRef< objects::CSeq_feat > m_OrigFeat
TIndex m_Index
stores the match_field value and the row number where that value appears in the table
virtual string GetBestDescr() const
Used for logging.
virtual objects::CBioseq_Handle GetBioseqHandle(void) const
virtual bool IsEnd(void) const
virtual bool IsEnd(void) const
virtual IMacroBioDataIter & Next(void)
virtual SConstScopedObject GetScopedObject() const
Dereferences the underlying iterator.
CConstRef< objects::CUser_object > m_OrigUserObj
virtual void RunEditCommand(CMacroCmdComposite *cmd_composite)
Constructs and executes the editing command.
string x_GetDescription(const string &descr_name) const
void x_InitAndCheck(const string &file_name, size_t col)
bool m_DeleteObject
indicates the intention to delete the underlying object
virtual IMacroBioDataIter & Begin(void)
virtual void x_SetDefaultObjectInfo()
Initializes member variable m_CurIterOI.
virtual IMacroBioDataIter & Next(void)
vector< string > m_Taxnames
CMacroBioData_StructCommentIter(const objects::CSeq_entry_Handle &entry)
objects::CSeq_entry_Handle m_Seh
objects::CBioseq_Handle GetBioseqForSeqFeat(const objects::CSeq_feat &f, objects::CScope &scope)
CRef< objects::CScope > scope
Definition: objects.hpp:53
CConstRef< CObject > object
Definition: objects.hpp:52
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
virtual const CTypeInfo * GetThisTypeInfo(void) const =0
@ ePrimitiveValueString
string|char*|const char*
Definition: serialdef.hpp:153
@ ePrimitiveValueInteger
(signed|unsigned) (char|short|int|long)
Definition: serialdef.hpp:151
@ ePrimitiveValueEnum
enum
Definition: serialdef.hpp:154
@ eTypeFamilyChoice
Definition: serialdef.hpp:141
@ eTypeFamilyPointer
Definition: serialdef.hpp:143
CTempString GetCurrentLine(void) const
static CRef< ILineReader > New(const string &filename)
Return a new ILineReader object corresponding to the given filename, taking "-" (but not "....
Definition: line_reader.cpp:49
void ReadLine(void)
Definition: line_reader.hpp:88
virtual Uint8 GetLineNumber(void) const =0
Returns the current line number (counting from 1, not 0).
virtual bool AtEOF(void) const =0
Indicates (negatively) whether there is any more input.
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Override Assign() to incorporate cache invalidation.
Definition: Seq_loc.cpp:337
void GetLabel(string *label) const
Appends a label suitable for display (e.g., error messages) label must point to an existing string ob...
Definition: Seq_loc.cpp:3467
const string & GetAlias(void) const
CObjectInfo GetPointedObject(void) const
Get data and type information of object to which this type refers.
Definition: objectinfo.cpp:102
CChoiceVariant GetCurrentChoiceVariant(void) const
Get data and type information of selected choice variant.
ETypeFamily GetTypeFamily(void) const
Get data type family.
void GetPrimitiveValueString(string &value) const
Get string data.
Definition: objectinfo.cpp:199
Int4 GetPrimitiveValueInt4(void) const
Get data as Int4.
Definition: objectinfo.cpp:174
EPrimitiveValueType GetPrimitiveValueType(void) const
Get type of primitive value.
Definition: objectinfo.cpp:109
Int8 GetPrimitiveValueInt8(void) const
Get data as Int8.
Definition: objectinfo.cpp:184
void ChangeSeqLocId(CSeq_loc *loc, bool best, CScope *scope)
Change each of the CSeq_ids embedded in a CSeq_loc to the best or worst CSeq_id accoring to the value...
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CBioseq_set_Handle GetBioseq_setHandle(const CBioseq_set &seqset, EMissing action=eMissing_Default)
Definition: scope.cpp:176
vector< CSeq_entry_Handle > TTSE_Handles
Definition: scope.hpp:645
@ eAllTSEs
Definition: scope.hpp:643
const CTSE_Handle & GetTSE_Handle(void) const
Get CTSE_Handle of containing TSE.
CSeq_id_Handle GetAccessSeq_id_Handle(void) const
Get any CSeq_id_Handle handle that can be used to access this bioseq Use GetSeq_id_Handle() if it's n...
CScope & GetScope(void) const
Get scope this handle belongs to.
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
CConstRef< CSeq_entry > GetCompleteSeq_entry(void) const
Complete and get const reference to the seq-entry.
CScope & GetScope(void) const
Get scope this handle belongs to.
CRef< CSeq_loc > GetRangeSeq_loc(TSeqPos start, TSeqPos stop, ENa_strand strand=eNa_strand_unknown) const
Return CSeq_loc referencing the given range and strand on the bioseq If start == 0,...
void Rewind(void)
Move to the first object in iterated sequence.
Definition: align_ci.cpp:195
@ fIncludeGivenEntry
Include the top (given) entry.
@ fRecursive
Iterate recursively.
TObjectType * GetNCPointerOrNull(void) const THROWS_NONE
Get pointer value.
Definition: ncbiobj.hpp:1162
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:1684
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:1401
CConstRef< C > ConstRef(const C *object)
Template function for conversion of const object pointer to CConstRef.
Definition: ncbiobj.hpp:2024
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
TObjectType * GetPointerOrNull(void) const THROWS_NONE
Get pointer value.
Definition: ncbiobj.hpp:1672
TObjectType & GetNCObject(void) const
Get object.
Definition: ncbiobj.hpp:1187
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
Definition: ncbiobj.hpp:719
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define USING_SCOPE(ns)
Use the specified namespace.
Definition: ncbistl.hpp:78
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
static list< string > & SplitByPattern(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Variation of Split() with fSplit_ByPattern flag applied by default.
Definition: ncbistr.cpp:3507
static string Int8ToString(Int8 value, TNumToStringFlags flags=0, int base=10)
Convert Int8 to string.
Definition: ncbistr.hpp:5159
#define kEmptyStr
Definition: ncbistr.hpp:123
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 bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
Definition: ncbistr.cpp:3554
static 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 string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3405
@ fSplit_MergeDelimiters
Merge adjacent delimiters.
Definition: ncbistr.hpp:2498
static const char label[]
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
const TSet & GetSet(void) const
Get the variant data.
Definition: Seq_entry_.cpp:124
bool IsSet(void) const
Check if variant Set is selected.
Definition: Seq_entry_.hpp:263
TPub & SetPub(void)
Select the variant.
Definition: Seqdesc_.cpp:362
const TPub & GetPub(void) const
Get the variant data.
Definition: Seqdesc_.cpp:356
TSource & SetSource(void)
Select the variant.
Definition: Seqdesc_.cpp:572
TUser & SetUser(void)
Select the variant.
Definition: Seqdesc_.cpp:390
TMolinfo & SetMolinfo(void)
Select the variant.
Definition: Seqdesc_.cpp:594
@ e_User
user defined object
Definition: Seqdesc_.hpp:124
@ e_Pub
a reference to the publication
Definition: Seqdesc_.hpp:122
@ e_Molinfo
info on the molecule and techniques
Definition: Seqdesc_.hpp:134
@ e_Source
source of materials, includes Org-ref
Definition: Seqdesc_.hpp:133
@ eMol_na
just a nucleic acid
Definition: Seq_inst_.hpp:113
const TSub & GetSub(void) const
Get the Sub member data.
bool IsSetCit(void) const
citation for this submission Check if a value has been assigned to Cit data member.
Lightweight interface for getting lines of data with minimal memory copying.
Biodata iterators for macro execution.
Macro exceptions.
Functions that resolve field names described in asn format.
range(_Ty, _Ty) -> range< _Ty >
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Miscellaneous common-use basic types and functionality.
static const char delimiter[]
Utility macros and typedefs for exploring NCBI objects from seq.asn.
Utility macros and typedefs for exploring NCBI objects from seqset.asn.
SAnnotSelector –.
#define _ASSERT
CScope & GetScope()
void GetProductToCDSMap(objects::CScope &scope, map< objects::CBioseq_Handle, set< objects::CSeq_feat_Handle > > &product_to_cds)
CRef< CCmdComposite > GetDeleteFeatureCommand(const objects::CSeq_feat_Handle &fh, bool remove_proteins=true)
static CS_CONTEXT * context
Definition: will_convert.c:21
Modified on Wed Apr 17 13:10:59 2024 by modify_doxy.py rev. 669887