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

Go to the SVN repository for this file.

1 /* $Id: util_cmds.cpp 47378 2023-02-27 20:09:44Z 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: Colleen Bollin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
34 
36 #include <objmgr/scope.hpp>
38 #include <objmgr/bioseq_ci.hpp>
39 #include <objmgr/seqdesc_ci.hpp>
40 #include <objmgr/util/sequence.hpp>
41 
46 
60 
63 
64 // Returns true if there are multiple coding regions pointing to the same protein
66 {
68  const CSeq_loc& product_loc = fh.GetProduct();
69 
72  ITERATE(CScope::TTSE_Handles, handle, tses) {
73  for (CBioseq_CI b_iter(*handle, CSeq_inst::eMol_na); b_iter; ++b_iter) {
74  for (CFeat_CI feat_it(*b_iter, SAnnotSelector(CSeqFeatData::eSubtype_cdregion)); feat_it; ++feat_it) {
75  if (feat_it->IsSetProduct()
76  && feat_it->GetProduct().Equals(product_loc)
77  && feat_it->GetOriginalSeq_feat().GetPointer() != orig_feat.GetPointer()) {
78  return true;
79  }
80  }
81  }
82  }
83  return false;
84 }
85 
87 {
88  for (CSeq_loc_CI loc_iter(fh.GetLocation(), CSeq_loc_CI::eEmpty_Skip); loc_iter; ++loc_iter) {
89  CBioseq_Handle bsh;
90  try {
91  bsh = fh.GetScope().GetBioseqHandle(loc_iter.GetSeq_id());
92  } catch (const CObjMgrException&) {}
93 
94  if (!bsh)
95  return true;
96 
98  if (!parent)
99  return true;
100 
101  if (validator::IsFarLocation(fh.GetProduct(), parent))
102  return true;
103  }
104  return false;
105 }
106 
108 {
109  CRef<CCmdComposite> cmd(new CCmdComposite("Delete Feature"));
110 
111  const CSeqFeatData& data = fh.GetData();
112  if (data.IsPub()) {
114  CSeq_entry_Handle top_parent = this_seq.GetSeq_entry_Handle();
115  CBioseq_set_Handle parent_set = top_parent.GetParentBioseq_set();
116  while (parent_set) {
117  top_parent = parent_set.GetParentEntry();
118  parent_set = top_parent.GetParentBioseq_set();
119  }
120  CIRef<IEditCommand> cit_cmd = CCmdFactory::RemoveCitations(top_parent, data.GetPub().GetPub());
121  if (cit_cmd) {
122  cmd->AddCommand(*cit_cmd);
123  }
124  }
125 
126  CRef<CCmdDelSeq_feat> del_feat(new CCmdDelSeq_feat(fh));
127  cmd->AddCommand(*del_feat);
128 
129  // do not delete the protein if
130  // - the protein is not local
131  // - there is at least another coding region pointing to this protein
132  if (fh.IsSetProduct() && remove_proteins && !s_AreThereOtherCDSForThisProduct(fh)) {
133  if (!s_IsFarLocation(fh) && fh.GetProductId()) {
134  CBioseq_Handle product = fh.GetScope().GetBioseqHandle(*(fh.GetProductId().GetSeqId()));
135  if (product && product.IsProtein()) {
136  CRef<CCmdDelBioseqInst> del_product(new CCmdDelBioseqInst(product));
137  cmd->AddCommand(*del_product);
138  }
139  }
140  }
141 
142  return cmd;
143 }
144 
146 {
147  product_to_cds.clear();
149  scope.GetAllTSEs(tses, CScope::eAllTSEs);
150  for (auto tse : tses)
151  {
152  for (CFeat_CI feat_it(tse, SAnnotSelector(CSeqFeatData::eSubtype_cdregion)); feat_it; ++feat_it)
153  {
154  if (feat_it->IsSetProduct())
155  {
156  CSeq_feat_Handle fh = feat_it->GetSeq_feat_Handle();
157  CBioseq_Handle product = scope.GetBioseqHandle(*(fh.GetProductId().GetSeqId()));
158  product_to_cds[product].insert(fh);
159  }
160  }
161  }
162 }
163 
165 {
166  CRef<CCmdComposite> cmd(new CCmdComposite("Delete Feature"));
167 
168  const CSeqFeatData& data = fh.GetData();
169  if (data.IsPub()) {
171  CSeq_entry_Handle top_parent = this_seq.GetSeq_entry_Handle();
172  CBioseq_set_Handle parent_set = top_parent.GetParentBioseq_set();
173  while (parent_set) {
174  top_parent = parent_set.GetParentEntry();
175  parent_set = top_parent.GetParentBioseq_set();
176  }
177  CIRef<IEditCommand> cit_cmd = CCmdFactory::RemoveCitations(top_parent, data.GetPub().GetPub());
178  if (cit_cmd) {
179  cmd->AddCommand(*cit_cmd);
180  }
181  }
182 
183  CRef<CCmdDelSeq_feat> del_feat(new CCmdDelSeq_feat(fh));
184  cmd->AddCommand(*del_feat);
185 
186  // do not delete the protein if
187  // - the protein is not local
188  // - there is at least another coding region pointing to this protein
189  if (fh.IsSetProduct() && remove_proteins) {
190  if (!s_IsFarLocation(fh) && fh.GetProductId()) {
191  CBioseq_Handle product = fh.GetScope().GetBioseqHandle(*(fh.GetProductId().GetSeqId()));
192  product_to_cds[product].erase(fh);
193  if (product && product.IsProtein() && product_to_cds[product].empty()) {
194  CRef<CCmdDelBioseqInst> del_product(new CCmdDelBioseqInst(product));
195  cmd->AddCommand(*del_product);
196  }
197  }
198  }
199 
200  return cmd;
201 }
202 
203 
205 {
206  CRef<CCmdComposite> cmd(new CCmdComposite("Delete Sequence"));
207 
208  CBioseq_set_Handle nuc_parent = bsh.GetParentBioseq_set();
209  if (nuc_parent && nuc_parent.IsSetClass() && nuc_parent.GetClass() == CBioseq_set::eClass_nuc_prot
210  && bsh.IsNa()) {
211  if (nuc_parent.GetTopLevelEntry() == nuc_parent.GetParentEntry()) {
212  NCBI_THROW(CException, eUnknown, "Cannot delete last sequence");
213  } else {
214  CRef<CCmdDelBioseqSet> delSet(new CCmdDelBioseqSet(nuc_parent));
215  cmd->AddCommand(*delSet);
216  }
217  } else if (bsh.GetTopLevelEntry() == bsh.GetSeq_entry_Handle()) {
218  NCBI_THROW(CException, eUnknown, "Cannot delete last sequence");
219  } else {
221  cmd->AddCommand(*scmd);
222  }
223  return cmd;
224 }
225 
227 {
228  for (CSeq_loc_CI loc_iter(fh.GetLocation(), CSeq_loc_CI::eEmpty_Skip); loc_iter; ++loc_iter) {
229  CBioseq_Handle bsh;
230  try {
231  bsh = fh.GetScope().GetBioseqHandle(loc_iter.GetSeq_id());
232  } catch (const CObjMgrException&) {}
233 
234  if (!bsh || !bsh.IsNa())
235  return false;
236  }
237  return true;
238 }
239 
240 CRef<CCmdComposite> GetDeleteAllFeaturesCommand(CSeq_entry_Handle seh, size_t& count, bool remove_proteins)
241 {
242  //CLogPerformance perfLog("GetDeleteAllFeaturesCommand");
244  GetProductToCDSMap(seh.GetScope(), product_to_cds);
245  CRef<CCmdComposite> delete_features_cmd(new CCmdComposite("Remove All Features"));
246  count = 0;
247  // only delete features on nucleotide sequences, protein features are automatically removed with the coding region
248  for (CFeat_CI it(seh); it; ++it)
249  {
250  CSeq_feat_Handle fh = it->GetSeq_feat_Handle();
251  if (!s_IsNucLocation(fh))
252  continue;
253 
254  CRef<CCmdComposite> cmd = GetDeleteFeatureCommand(fh, remove_proteins, product_to_cds);
255  delete_features_cmd->AddCommand(*cmd);
256  count++;
257  }
258  //perfLog.Post(CRequestStatus::e200_Ok);
259  return delete_features_cmd;
260 }
261 
262 
263 static void s_GetSourceDescriptors(const CSeq_entry& se, vector<pair<const CSeqdesc*, const CSeq_entry*>>& src_descs)
264 {
265  if (se.IsSetDescr()) {
267  if ((*it)->IsSource() && (*it)->GetSource().IsSetOrg()) {
268  src_descs.emplace_back(*it, &se);
269  }
270  }
271  }
272 
273  if (se.IsSet() && se.GetSet().IsSetSeq_set()) {
275  s_GetSourceDescriptors(**it, src_descs);
276  }
277  }
278 }
279 
280 CRef<CCmdComposite> CleanupCommand(CSeq_entry_Handle orig_seh, bool extended, bool do_tax)
281 {
282  CConstRef<CSeq_entry> entry = orig_seh.GetCompleteSeq_entry();
284  copy->Assign(*entry);
285 
287  CScope scope2(*objmgr);
288  scope2.AddDefaults();
289  CSeq_entry_Handle new_seh = scope2.AddTopLevelSeqEntry(*copy);
290 
291  if (do_tax) {
293  if (tax) {
294  tax->Execute();
295  }
296  }
297 
299  cleanup.SetScope(&scope2);
300 
301  // perform BasicCleanup and ExtendedCleanup
302  try {
304  if (extended) {
305  // basic cleanup is intrinsically part of ExtendedCleanup
306  changes = cleanup.ExtendedCleanup(new_seh, CCleanup::eClean_SyncGenCodes|CCleanup::eClean_KeepTopSet);
307  } else {
308  changes = cleanup.BasicCleanup(const_cast<CSeq_entry&>(*copy), CCleanup::eClean_SyncGenCodes);
309  }
310  } catch (CException& e) {
311  LOG_POST(Error << "error in cleanup: " << e.GetMsg());
312  }
313 
314  CRef<CCmdComposite> cmd(new CCmdComposite("Cleanup"));
315  CRef<CCmdChangeSeqEntry> clean(new CCmdChangeSeqEntry(orig_seh, copy));
316  cmd->AddCommand(*clean);
317 
318  return cmd;
319 }
320 
321 CRef<CCmdComposite> CleanupHugeFileCommand(CSeq_entry_Handle orig_seh, bool extended, bool do_tax, objects::taxupdate_func_t& updater, bool rmv_user_object)
322 {
323  CConstRef<CSeq_entry> entry = orig_seh.GetCompleteSeq_entry();
325  copy->Assign(*entry);
326 
328  CScope scope2(*objmgr);
329  scope2.AddDefaults();
330  CSeq_entry_Handle new_seh = scope2.AddTopLevelSeqEntry(*copy);
331 
332  if (do_tax) {
333  CRef<CCmdComposite> tax = CachedTaxonomyLookupCommand(new_seh, updater);
334  if (tax) {
335  tax->Execute();
336  }
337  }
338 
340  cleanup.SetScope(&scope2);
341 
342  Uint4 cleanup_flags = CCleanup::eClean_SyncGenCodes;
343  if (extended) {
344  cleanup_flags |= CCleanup::eClean_KeepTopSet;
345  }
346  if (rmv_user_object) {
347  cleanup_flags |= CCleanup::eClean_NoNcbiUserObjects;
348  }
349 
350  // perform BasicCleanup and ExtendedCleanup
351  try {
353  if (extended) {
354  // basic cleanup is intrinsically part of ExtendedCleanup
355  changes = cleanup.ExtendedCleanup(new_seh, cleanup_flags);
356  }
357  else {
358  changes = cleanup.BasicCleanup(const_cast<CSeq_entry&>(*copy), cleanup_flags);
359  }
360  } catch (CException& e) {
361  LOG_POST(Error << "error in cleanup: " << e.GetMsg());
362  }
363 
364  CRef<CCmdComposite> cmd(new CCmdComposite("Cleanup"));
365  CRef<CCmdChangeSeqEntry> clean(new CCmdChangeSeqEntry(orig_seh, copy));
366  cmd->AddCommand(*clean);
367 
368  return cmd;
369 }
370 
371 
373 {
374  CRef<CCmdComposite> cmd(new CCmdComposite("Tax lookup"));
375 
376  validator::CTaxValidationAndCleanup tval;
377  tval.Init(*(seh.GetCompleteSeq_entry()));
378 
379  vector<CRef<COrg_ref> > original_orgs = tval.GetTaxonomyLookupRequest();
380  if (original_orgs.empty())
381  {
382  return cmd;
383  }
384  size_t chunk_size = 250;
385  vector< CRef<COrg_ref> > edited_orgs;
386 
387  CTaxon3 taxon3;
388  taxon3.Init();
389  size_t i = 0;
390  while (i < original_orgs.size())
391  {
392  size_t len = min(chunk_size, original_orgs.size() - i);
393  vector< CRef<COrg_ref> > tmp_original_orgs(original_orgs.begin() + i, original_orgs.begin() + i + len);
394  vector< CRef<COrg_ref> > tmp_edited_orgs;
395  ITERATE(vector<CRef<COrg_ref> >, it, tmp_original_orgs)
396  {
397  CRef<COrg_ref> cpy(new COrg_ref());
398  cpy->Assign(**it);
399  tmp_edited_orgs.push_back(cpy);
400  }
401  CRef<CTaxon3_reply> tmp_lookup_reply = taxon3.SendOrgRefList(tmp_original_orgs);
402  if (tmp_lookup_reply) {
403  string error_message;
404  tval.AdjustOrgRefsWithTaxLookupReply(*tmp_lookup_reply, tmp_edited_orgs, error_message);
405  if (!NStr::IsBlank(error_message))
406  {
407  // post error message
408  LOG_POST(Error << error_message);
409  return CRef<CCmdComposite>(NULL);
410  }
411  edited_orgs.insert(edited_orgs.end(), tmp_edited_orgs.begin(), tmp_edited_orgs.end());
412  i += len;
413  } else if (chunk_size > 20) {
414  // try a smaller chunk size and try again.
415  chunk_size = chunk_size / 2;
416  } else {
417  // post error message
418  LOG_POST(Error << "Unable to contact taxonomy server");
419  return CRef<CCmdComposite>(NULL);
420  }
421  }
422 
423  vector< CRef<COrg_ref> > spec_host_rq = tval.GetSpecificHostLookupRequest(true);
424  i = 0;
425  while (i < spec_host_rq.size())
426  {
427  size_t len = min(chunk_size, spec_host_rq.size() - i);
428  vector< CRef<COrg_ref> > tmp_spec_host_rq(spec_host_rq.begin() + i, spec_host_rq.begin() + i + len);
429  CRef<CTaxon3_reply> tmp_spec_host_reply = taxon3.SendOrgRefList(tmp_spec_host_rq);
430  string error_message = tval.IncrementalSpecificHostMapUpdate(tmp_spec_host_rq, *tmp_spec_host_reply);
431  if (!NStr::IsBlank(error_message))
432  {
433  // post error message
434  LOG_POST(Error << error_message);
435  return CRef<CCmdComposite>(NULL);
436  }
437  i += len;
438  }
439 
440  tval.AdjustOrgRefsForSpecificHosts(edited_orgs);
441 
442  // update descriptors
443  size_t num_descs = tval.NumDescs();
444  size_t num_updated_descs = 0;
445  for (size_t n = 0; n < num_descs; n++) {
446  if (!original_orgs[n]->Equals(*(edited_orgs[n]))) {
447  CConstRef<CSeqdesc> original_desc = tval.GetDesc(n);
448  CConstRef<CSeq_entry> orig_entry = tval.GetSeqContext(n);
449  if (original_desc && orig_entry) {
450  CRef<CSeqdesc> new_desc(new CSeqdesc());
451  new_desc->Assign(*original_desc);
452  new_desc->SetSource().SetOrg().Assign(*(edited_orgs[n]));
453  CSeq_entry_Handle orig_seh = seh.GetScope().GetSeq_entryHandle(*orig_entry);
454  CRef<CCmdChangeSeqdesc> subcmd(new CCmdChangeSeqdesc(orig_seh, *original_desc, *new_desc));
455  cmd->AddCommand(*subcmd);
456  num_updated_descs++;
457  }
458  }
459  }
460 
461  // now update features
462  size_t num_updated_feats = 0;
463  for (size_t n = 0; n < tval.NumFeats(); n++) {
464  if (!original_orgs[n + num_descs]->Equals(*edited_orgs[n + num_descs])) {
465  CConstRef<CSeq_feat> feat = tval.GetFeat(n);
466  CRef<CSeq_feat> new_feat(new CSeq_feat());
467  new_feat->Assign(*feat);
468  new_feat->SetData().SetBiosrc().SetOrg().Assign(*(edited_orgs[n + num_descs]));
469 
470  CSeq_feat_Handle fh = seh.GetScope().GetSeq_featHandle(*feat);
471  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(fh, *new_feat));
472  cmd->AddCommand(*chgFeat);
473 
474  num_updated_feats++;
475  }
476  }
477 
478  return cmd;
479 }
480 
482 {
483  CRef<CCmdComposite> cmd(new CCmdComposite("Tax lookup using Remote Updater"));
484 
485  validator::CTaxValidationAndCleanup tval;
486  tval.Init(*(seh.GetCompleteSeq_entry()));
487 
488  vector<CRef<COrg_ref> > original_orgs = tval.GetTaxonomyLookupRequest();
489  if (original_orgs.empty()) {
490  return cmd;
491  }
492 
493  size_t chunk_size = 250;
494  vector< CRef<COrg_ref> > edited_orgs;
495 
496  size_t i = 0;
497  while (i < original_orgs.size())
498  {
499  size_t len = min(chunk_size, original_orgs.size() - i);
500  vector< CRef<COrg_ref> > tmp_original_orgs(original_orgs.begin() + i, original_orgs.begin() + i + len);
501 
502  vector< CRef<COrg_ref> > tmp_edited_orgs;
503  ITERATE(vector<CRef<COrg_ref> >, it, tmp_original_orgs)
504  {
505  CRef<COrg_ref> cpy(new COrg_ref());
506  cpy->Assign(**it);
507  tmp_edited_orgs.push_back(cpy);
508  }
509 
510  CRef<CTaxon3_reply> tmp_lookup_reply = updater(tmp_original_orgs);
511  if (tmp_lookup_reply) {
512  string error_message;
513  tval.AdjustOrgRefsWithTaxLookupReply(*tmp_lookup_reply, tmp_edited_orgs, error_message);
514  if (!NStr::IsBlank(error_message))
515  {
516  // post error message
517  LOG_POST(Error << error_message);
518  return CRef<CCmdComposite>(NULL);
519  }
520  edited_orgs.insert(edited_orgs.end(), tmp_edited_orgs.begin(), tmp_edited_orgs.end());
521  i += len;
522  }
523  else if (chunk_size > 20) {
524  // try a smaller chunk size and try again.
525  chunk_size = chunk_size / 2;
526  }
527  else {
528  // post error message
529  LOG_POST(Error << "Unable to contact taxonomy server");
530  return CRef<CCmdComposite>(NULL);
531  }
532  }
533 
534  vector< CRef<COrg_ref> > spec_host_rq = tval.GetSpecificHostLookupRequest(true);
535  i = 0;
536  while (i < spec_host_rq.size()) {
537  size_t len = min(chunk_size, spec_host_rq.size() - i);
538  vector< CRef<COrg_ref> > tmp_spec_host_rq(spec_host_rq.begin() + i, spec_host_rq.begin() + i + len);
539 
540  CRef<CTaxon3_reply> tmp_spec_host_reply = updater(tmp_spec_host_rq);
541  string error_message = tval.IncrementalSpecificHostMapUpdate(tmp_spec_host_rq, *tmp_spec_host_reply);
542  if (!NStr::IsBlank(error_message))
543  {
544  // post error message
545  LOG_POST(Error << error_message);
546  return CRef<CCmdComposite>(NULL);
547  }
548  i += len;
549  }
550 
551  tval.AdjustOrgRefsForSpecificHosts(edited_orgs);
552 
553  // update descriptors
554  size_t num_descs = tval.NumDescs();
555  size_t num_updated_descs = 0;
556  for (size_t n = 0; n < num_descs; n++) {
557  if (!original_orgs[n]->Equals(*(edited_orgs[n]))) {
558  CConstRef<CSeqdesc> original_desc = tval.GetDesc(n);
559  CConstRef<CSeq_entry> orig_entry = tval.GetSeqContext(n);
560  if (original_desc && orig_entry) {
561  CRef<CSeqdesc> new_desc(new CSeqdesc());
562  new_desc->Assign(*original_desc);
563  new_desc->SetSource().SetOrg().Assign(*(edited_orgs[n]));
564  CSeq_entry_Handle orig_seh = seh.GetScope().GetSeq_entryHandle(*orig_entry);
565  CRef<CCmdChangeSeqdesc> subcmd(new CCmdChangeSeqdesc(orig_seh, *original_desc, *new_desc));
566  cmd->AddCommand(*subcmd);
567  num_updated_descs++;
568  }
569  }
570  }
571 
572  // now update features
573  size_t num_updated_feats = 0;
574  for (size_t n = 0; n < tval.NumFeats(); n++) {
575  if (!original_orgs[n + num_descs]->Equals(*edited_orgs[n + num_descs])) {
576  CConstRef<CSeq_feat> feat = tval.GetFeat(n);
577  CRef<CSeq_feat> new_feat(new CSeq_feat());
578  new_feat->Assign(*feat);
579  new_feat->SetData().SetBiosrc().SetOrg().Assign(*(edited_orgs[n + num_descs]));
580 
581  CSeq_feat_Handle fh = seh.GetScope().GetSeq_featHandle(*feat);
582  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(fh, *new_feat));
583  cmd->AddCommand(*chgFeat);
584 
585  num_updated_feats++;
586  }
587  }
588 
589  return cmd;
590 }
591 
592 
594 {
595  CRef<CCmdComposite> cmd(new CCmdComposite("Tax lookup"));
596 
597  validator::CTaxValidationAndCleanup tval;
598  tval.Init(*(seh.GetCompleteSeq_entry()));
599 
600  vector<CRef<COrg_ref> > original_orgs = tval.GetTaxonomyLookupRequest();
601  if (original_orgs.empty())
602  {
603  return cmd;
604  }
605  const size_t chunk_size = 1000;
606  vector< CRef<COrg_ref> > edited_orgs;
607 
608  CTaxon3 taxon3;
609  taxon3.Init();
610  size_t i = 0;
611  while (i < original_orgs.size())
612  {
613  size_t len = min(chunk_size, original_orgs.size() - i);
614  vector< CRef<COrg_ref> > tmp_original_orgs(original_orgs.begin() + i, original_orgs.begin() + i + len);
615  vector< CRef<COrg_ref> > tmp_edited_orgs;
616  ITERATE(vector<CRef<COrg_ref> >, it, tmp_original_orgs)
617  {
618  CRef<COrg_ref> cpy(new COrg_ref());
619  cpy->Assign(**it);
620  tmp_edited_orgs.push_back(cpy);
621  }
622 #if 0
623  CRef<CTaxon3_reply> tmp_lookup_reply = taxon3.SendOrgRefList(tmp_original_orgs);
624  string error_message;
625  tval.AdjustOrgRefsWithTaxLookupReply(*tmp_lookup_reply, tmp_edited_orgs, error_message);
626  if (!NStr::IsBlank(error_message))
627  {
628  // post error message
629  LOG_POST(Error << error_message);
630  return CRef<CCmdComposite>(NULL);
631  }
632 #endif
633  edited_orgs.insert(edited_orgs.end(), tmp_edited_orgs.begin(), tmp_edited_orgs.end());
634  i += len;
635  }
636 
637  vector< CRef<COrg_ref> > spec_host_rq = tval.GetSpecificHostLookupRequest(true);
638  i = 0;
639  while (i < spec_host_rq.size())
640  {
641  size_t len = min(chunk_size, spec_host_rq.size() - i);
642  vector< CRef<COrg_ref> > tmp_spec_host_rq(spec_host_rq.begin() + i, spec_host_rq.begin() + i + len);
643  CRef<CTaxon3_reply> tmp_spec_host_reply = taxon3.SendOrgRefList(tmp_spec_host_rq);
644  string error_message = tval.IncrementalSpecificHostMapUpdate(tmp_spec_host_rq, *tmp_spec_host_reply);
645  if (!NStr::IsBlank(error_message))
646  {
647  // post error message
648  LOG_POST(Error << error_message);
649  return CRef<CCmdComposite>(NULL);
650  }
651  i += len;
652  }
653 
654  tval.AdjustOrgRefsForSpecificHosts(edited_orgs);
655 
656  // update descriptors
657  size_t num_descs = tval.NumDescs();
658  size_t num_updated_descs = 0;
659  for (size_t n = 0; n < num_descs; n++) {
660  if (!original_orgs[n]->Equals(*(edited_orgs[n]))) {
661  CConstRef<CSeqdesc> original_desc = tval.GetDesc(n);
662  CConstRef<CSeq_entry> orig_entry = tval.GetSeqContext(n);
663  if (original_desc && orig_entry) {
664  CRef<CSeqdesc> new_desc(new CSeqdesc());
665  new_desc->Assign(*original_desc);
666  new_desc->SetSource().SetOrg().Assign(*(edited_orgs[n]));
667  CSeq_entry_Handle orig_seh = seh.GetScope().GetSeq_entryHandle(*orig_entry);
668  CRef<CCmdChangeSeqdesc> subcmd(new CCmdChangeSeqdesc(orig_seh, *original_desc, *new_desc));
669  cmd->AddCommand(*subcmd);
670  num_updated_descs++;
671  }
672  }
673  }
674 
675  // now update features
676  size_t num_updated_feats = 0;
677  for (size_t n = 0; n < tval.NumFeats(); n++) {
678  if (!original_orgs[n + num_descs]->Equals(*edited_orgs[n + num_descs])) {
679  CConstRef<CSeq_feat> feat = tval.GetFeat(n);
680  CRef<CSeq_feat> new_feat(new CSeq_feat());
681  new_feat->Assign(*feat);
682  new_feat->SetData().SetBiosrc().SetOrg().Assign(*(edited_orgs[n + num_descs]));
683 
684  CSeq_feat_Handle fh = seh.GetScope().GetSeq_featHandle(*feat);
685  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(fh, *new_feat));
686  cmd->AddCommand(*chgFeat);
687 
688  num_updated_feats++;
689  }
690  }
691 
692  return cmd;
693 }
694 
695 
697 {
698  CRef<CCmdComposite> cmd(new CCmdComposite("Disable Strain Forwarding"));
699 
700  vector<pair<const CSeqdesc*, const CSeq_entry*>> src_descs;
701  vector<CConstRef<CSeq_feat> > src_feats;
702 
703  CScope& scope = seh.GetScope();
704  s_GetSourceDescriptors(*(seh.GetCompleteSeq_entry()), src_descs);
705  for (auto&& desc_it : src_descs) {
706  const CSeqdesc& old_desc = *desc_it.first;
707  CRef<CSeqdesc> new_desc(new CSeqdesc());
708  new_desc->Assign(old_desc);
709  new_desc->SetSource().SetDisableStrainForwarding(disable);
710  CRef<CCmdChangeSeqdesc> subcmd(new CCmdChangeSeqdesc(scope.GetSeq_entryHandle(*desc_it.second), old_desc, *new_desc));
711  cmd->AddCommand(*subcmd);
712  }
713 
715  while (feat_it) {
716  CConstRef<CSeq_feat> old_feat = feat_it->GetSeq_feat();
717  CRef<CSeq_feat> new_feat(new CSeq_feat());
718  new_feat->Assign(*old_feat);
719  new_feat->SetData().SetBiosrc().SetDisableStrainForwarding(disable);
720  CSeq_feat_Handle fh = seh.GetScope().GetSeq_featHandle(*old_feat);
721  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(fh, *new_feat));
722  cmd->AddCommand(*chgFeat);
723  ++feat_it;
724  }
725 
726  return cmd;
727 }
728 
730 {
731  return GetChangeStrainForwardingCommand(seh, true);
732 }
733 
735 {
736  return GetChangeStrainForwardingCommand(seh, false);
737 }
738 
739 
740 bool s_IsSpeciesLevel(const COrg_ref& org)
741 {
742  bool rval = false;
743  CRef<CT3Request> rq(new CT3Request());
744  rq->SetOrg().Assign(org);
745  CTaxon3_request request;
746  request.SetRequest().push_back(rq);
747  CTaxon3 taxon3;
748  taxon3.Init();
749  CRef<CTaxon3_reply> reply = taxon3.SendRequest(request);
750  if (reply) {
751  CTaxon3_reply::TReply::const_iterator reply_it = reply->GetReply().begin();
752  while (reply_it != reply->GetReply().end()) {
753  if ((*reply_it)->IsData()
754  && (*reply_it)->GetData().GetOrg().IsSetTaxname()) {
755  bool is_species_level = false, force_consult = false, has_nucleomorphs = false;
756  (*reply_it)->GetData().GetTaxFlags (is_species_level, force_consult, has_nucleomorphs);
757  if (is_species_level) {
758  rval = true;
759  }
760  break;
761  }
762  ++reply_it;
763  }
764  }
765  return rval;
766 }
767 
768 
770 {
771  CRef<CCmdComposite> cmd(new CCmdComposite("Rm Culture Notes"));
772 
773  vector<pair<const CSeqdesc*, const CSeq_entry*>> src_descs;
774  vector<bool> is_species_level;
775 
776  s_GetSourceDescriptors(*(seh.GetCompleteSeq_entry()), src_descs);
777 
778  CTaxon3_request request;
779  for (auto&& desc_it : src_descs) {
780  const CSeqdesc& desc = *desc_it.first;
781  CRef<CT3Request> rq(new CT3Request());
782  rq->SetOrg().Assign(desc.GetSource().GetOrg());
783  request.SetRequest().push_back(rq);
784  is_species_level.push_back(false);
785  }
786 
788  while (feat_it) {
789  CRef<CT3Request> rq(new CT3Request());
790  rq->SetOrg().Assign(feat_it->GetData().GetBiosrc().GetOrg());
791  request.SetRequest().push_back(rq);
792  is_species_level.push_back(false);
793  ++feat_it;
794  }
795 
796  CTaxon3 taxon3;
797  taxon3.Init();
798  CRef<CTaxon3_reply> reply = taxon3.SendRequest(request);
799  if (reply) {
800  CTaxon3_reply::TReply::const_iterator reply_it = reply->GetReply().begin();
801  size_t pos = 0;
802  while (reply_it != reply->GetReply().end()) {
803  if ((*reply_it)->IsData()
804  && (*reply_it)->GetData().GetOrg().IsSetTaxname()) {
805  bool species_level = false, force_consult = false, has_nucleomorphs = false;
806  (*reply_it)->GetData().GetTaxFlags (species_level, force_consult, has_nucleomorphs);
807  if (species_level) {
808  is_species_level[pos] = true;
809  }
810  }
811  ++reply_it;
812  ++pos;
813  }
814  }
815 
816  CScope& scope = seh.GetScope();
817  size_t pos = 0;
818  for (auto&& desc_it : src_descs) {
819  const CSeqdesc& old_desc = *desc_it.first;
820  CRef<CSeqdesc> new_desc(new CSeqdesc());
821  new_desc->Assign(old_desc);
822  new_desc->SetSource().RemoveCultureNotes(is_species_level[pos]);
823  CRef<CCmdChangeSeqdesc> subcmd(new CCmdChangeSeqdesc(scope.GetSeq_entryHandle(*desc_it.second), old_desc, *new_desc));
824  cmd->AddCommand(*subcmd);
825  ++pos;
826  }
827 
828  feat_it.Rewind();
829  while (feat_it) {
830  CConstRef<CSeq_feat> old_feat = feat_it->GetSeq_feat();
831  CRef<CSeq_feat> new_feat(new CSeq_feat());
832  new_feat->Assign(*old_feat);
833  new_feat->SetData().SetBiosrc().RemoveCultureNotes(is_species_level[pos]);
834  CSeq_feat_Handle fh = seh.GetScope().GetSeq_featHandle(*old_feat);
835  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(fh, *new_feat));
836  cmd->AddCommand(*chgFeat);
837  ++pos;
838  ++feat_it;
839  }
840 
841  return cmd;
842 }
843 
844 
846 {
847  if (!cds.IsSetData() || !cds.GetData().IsCdregion() || !cds.IsSetProduct()) {
848  return CRef<CCmdComposite>(NULL);
849  }
850 
851  CBioseq_Handle product = scope.GetBioseqHandle(cds.GetProduct());
852  if (!product || (product && product.IsNa())) {
853  return CRef<CCmdComposite>(NULL);
854  }
855 
856  // change molinfo on bioseq
857  CRef<CSeqdesc> new_molinfo_desc( new CSeqdesc );
858  CMolInfo & molinfo = new_molinfo_desc->SetMolinfo();
859  bool molinfo_changed = false;
860  CSeqdesc_CI desc_ci( product, CSeqdesc::e_Molinfo);
861  if (desc_ci) {
862  molinfo.Assign(desc_ci->GetMolinfo());
863  } else {
865  molinfo_changed = true;
866  }
867 
868  molinfo_changed |= feature::AdjustProteinMolInfoToMatchCDS(molinfo, cds);
869 
870  if (molinfo_changed) {
871  CRef<CCmdComposite> cmd(new CCmdComposite("Create molinfo"));
872  if (desc_ci) {
873  CRef<CCmdChangeSeqdesc> ecmd(new CCmdChangeSeqdesc(desc_ci.GetSeq_entry_Handle(), *desc_ci, *new_molinfo_desc));
874  cmd->AddCommand(*ecmd);
875  } else {
876  CRef<CCmdCreateDesc> ecmd(new CCmdCreateDesc(product.GetParentEntry(), *new_molinfo_desc));
877  cmd->AddCommand(*ecmd);
878  }
879  return cmd;
880  }
881  return CRef<CCmdComposite>(NULL);
882 }
883 
884 
886 {
887  if (!cds.IsSetData() || !cds.GetData().IsCdregion() || !cds.IsSetProduct()) {
888  return CRef<CCmdComposite>(NULL);
889  }
890 
891  CBioseq_Handle product = scope.GetBioseqHandle(cds.GetProduct());
892  if (!product) {
893  return CRef<CCmdComposite>(NULL);
894  }
895 
896  CRef<CCmdComposite> cmd(new CCmdComposite("Synchronize Partials"));
897  bool any_cmd = false;
898 
899  // change molinfo on bioseq
900  CRef<CCmdComposite> synch_molinfo = GetSynchronizeProductMolInfoCommand(scope, cds);
901  if (synch_molinfo) {
902  cmd->AddCommand(*synch_molinfo);
903  any_cmd = true;
904  }
905 
906  // change partials for protein feature
908  if (f) {
909  CRef<CSeq_feat> new_prot(new CSeq_feat());
910  new_prot->Assign(*(f->GetSeq_feat()));
911  if (edit::AdjustProteinFeaturePartialsToMatchCDS(*new_prot, cds)) {
912  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(f->GetSeq_feat_Handle(), *new_prot)));
913  any_cmd = true;
914  }
915  }
916 
917  if (!any_cmd) {
918  cmd.Reset(NULL);
919  }
920  return cmd;
921 }
922 
923 void SetProteinFeature(CSeq_feat& prot, CBioseq_Handle product, const CSeq_feat& cds)
924 {
925  bool partial5 = cds.GetLocation().IsPartialStart(eExtreme_Biological);
926  bool partial3 = cds.GetLocation().IsPartialStop(eExtreme_Biological);
927 
928  prot.SetData().SetProt();
929  CRef<CSeq_id> id(new CSeq_id());
930  id->Assign(*(product.GetId().front().GetSeqId()));
931  prot.SetLocation().SetInt().SetId(*id);
932  prot.SetLocation().SetInt().SetFrom(0);
933  prot.SetLocation().SetInt().SetTo(product.GetInst_Length() - 1);
934  prot.SetLocation().SetPartialStart(partial5, eExtreme_Biological);
935  prot.SetLocation().SetPartialStop(partial3, eExtreme_Biological);
936  prot.SetPartial(partial5 || partial3);
937 }
938 
939 void AdjustProteinFeature(CSeq_feat& prot, CBioseq_Handle product, CSeq_feat& cds, bool& cds_change)
940 {
941  SetProteinFeature(prot, product, cds);
942 
943  if (cds.IsSetXref()) {
945  if ((*it)->IsSetData() && (*it)->GetData().IsProt()) {
946  prot.SetData().SetProt().Assign((*it)->GetData().GetProt());
947  cds.SetXref().erase(it);
948  cds_change = true;
949  break;
950  }
951  }
952  if (cds.GetXref().size() == 0) {
953  cds.ResetXref();
954  cds_change = true;
955  }
956  }
957 }
958 
959 
961 {
962  CRef<CCmdComposite> cmd(new CCmdComposite("Create or Adjust Protein Feature"));
964  CFeat_CI existing(product, CSeqFeatData::eSubtype_prot);
965  if (existing) {
966  prot->Assign(*((*existing).GetSeq_feat()));
967  AdjustProteinFeature(*prot, product, cds, cds_change);
968  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(*existing, *prot)));
969  } else {
970  AdjustProteinFeature(*prot, product, cds, cds_change);
971  CSeq_entry_Handle psh = product.GetSeq_entry_Handle();
972  cmd->AddCommand(*CRef<CCmdCreateFeat>(new CCmdCreateFeat(psh, *prot)));
973  }
975  cleanup.BasicCleanup(*prot);
976 
977  return cmd;
978 }
979 
980 
981 CRef<CCmdComposite> TranslateCDSCommand(CScope& scope, CSeq_feat& cds, bool& cds_change, int& offset, bool create_general_only)
982 {
983  CRef<CBioseq> new_product = CSeqTranslator::TranslateToProtein(cds, scope);
984  if (!new_product) {
985  return CRef<CCmdComposite>(NULL);
986  }
987  cds_change = false; // set to true if we need a command to change the coding region
988  if (!new_product->IsSetId()) {
989  CBioseq_Handle bsh = scope.GetBioseqHandle(cds.GetLocation());
991  CRef<CSeq_id> product_id;
992  if (cds.IsSetProduct()) {
993  product_id.Reset(new CSeq_id());
994  product_id->Assign(*(cds.GetProduct().GetId()));
995  } else {
996  string id_label;
997  product_id = edit::GetNewProtId(bsh, offset, id_label, create_general_only);
998  cds.SetProduct().SetWhole().Assign(*product_id);
999  cds_change = true;
1000  }
1001 
1002  new_product->SetId().push_back(product_id);
1003  }
1004 
1005  CRef<CSeq_entry> prot_entry (new CSeq_entry());
1006  prot_entry->SetSeq(*new_product);
1007  bool partial5 = cds.GetLocation().IsPartialStart(eExtreme_Biological);
1008  bool partial3 = cds.GetLocation().IsPartialStop(eExtreme_Biological);
1009  SetMolinfoForProtein (prot_entry, partial5, partial3);
1010  CRef<CSeq_feat> prot = AddEmptyProteinFeatureToProtein(prot_entry, partial5, partial3);
1011  if (cds.IsSetXref()) {
1013  if ((*it)->IsSetData() && (*it)->GetData().IsProt()) {
1014  prot->SetData().SetProt().Assign((*it)->GetData().GetProt());
1015  cds.SetXref().erase(it);
1016  cds_change = true;
1017  break;
1018  }
1019  }
1020  if (cds.GetXref().size() == 0) {
1021  cds.ResetXref();
1022  cds_change = true;
1023  }
1024  }
1025 
1026 
1027  CRef<CCmdComposite> cmd(new CCmdComposite("Translate CDS"));
1028 
1029  CRef<CCmdAddSeqEntry> subcmd(new CCmdAddSeqEntry(prot_entry,
1030  scope.GetBioseqHandle(cds.GetLocation()).GetParentEntry()));
1031  cmd->AddCommand(*subcmd);
1032  return cmd;
1033 }
1034 
1035 
1036 CRef<CCmdComposite> GetRetranslateCDSCommand(CScope& scope, CSeq_feat& cds, bool& cds_change, bool create_general_only)
1037 {
1038  int offset = 1;
1039  return GetRetranslateCDSCommand(scope, cds, cds_change, offset, create_general_only);
1040 }
1041 
1042 
1043 CRef<CCmdComposite> GetRetranslateCDSCommand(CScope& scope, CSeq_feat& cds, bool& cds_change, int& offset, bool create_general_only)
1044 {
1045  // feature must be cds
1046  if (!cds.IsSetData() && !cds.GetData().IsCdregion()) {
1048  return empty;
1049  }
1050  cds_change = false;
1051 
1052  if (!cds.IsSetProduct()) {
1053  return TranslateCDSCommand(scope, cds, cds_change, offset, create_general_only);
1054  }
1055 
1056  // Use Cdregion.Product to get handle to protein bioseq
1057  CBioseq_Handle prot_bsh = scope.GetBioseqHandle(cds.GetProduct());
1058 
1059  if (!prot_bsh) {
1060  return TranslateCDSCommand(scope, cds, cds_change, offset, create_general_only);
1061  }
1062 
1063  // Should be a protein!
1064  if (!prot_bsh.IsProtein())
1065  {
1067  return empty;
1068  }
1069 
1070 
1071  // Make a copy of existing CSeq_inst
1072  CRef<CSeq_inst> new_inst(new CSeq_inst());
1073  new_inst->Assign(prot_bsh.GetInst());
1074 
1075  // Make edits to the CSeq_inst copy
1076  CRef<CBioseq> new_protein_bioseq;
1077  if (new_inst->IsSetSeq_data())
1078  {
1079  // Generate new protein sequence data and length
1080  new_protein_bioseq = CSeqTranslator::TranslateToProtein(cds, scope);
1081  if (new_protein_bioseq && new_protein_bioseq->IsSetInst())
1082  new_inst->Assign(new_protein_bioseq->GetInst());
1083  }
1084  if ( !new_protein_bioseq ) {
1085  string prot_seq;
1086  try
1087  {
1088  CSeqTranslator::Translate(cds, scope, prot_seq);
1089  }
1090  catch (CSeqMapException&) {}
1091 
1092  if (prot_seq.empty()) {
1094  return empty;
1095  }
1096  else {
1097  new_protein_bioseq.Reset(new CBioseq);
1098  new_protein_bioseq->Assign(*(prot_bsh.GetCompleteBioseq()));
1099  if (NStr::EndsWith(prot_seq, "*")) {
1100  prot_seq = prot_seq.substr(0, prot_seq.length() - 1);
1101  }
1102  new_protein_bioseq->ResetInst();
1103  new_protein_bioseq->SetInst().SetRepr(CSeq_inst::eRepr_raw);
1104  new_protein_bioseq->SetInst().SetSeq_data().SetNcbieaa().Set(prot_seq);
1105  new_protein_bioseq->SetInst().SetLength(TSeqPos(prot_seq.length()));
1106  new_protein_bioseq->SetInst().SetMol(CSeq_inst::eMol_aa);
1107  new_inst->Assign(new_protein_bioseq->GetInst());
1108  }
1109  }
1110  CRef<CCmdComposite> cmd(new CCmdComposite("Retranslate CDS"));
1111 
1112  // Update protein sequence data and length
1113  CRef<CCmdChangeBioseqInst> chgInst (new CCmdChangeBioseqInst(prot_bsh,
1114  *new_inst));
1115  cmd->AddCommand(*chgInst);
1116 
1117  // change molinfo on bioseq
1118  CRef<CCmdComposite> synch_molinfo = GetSynchronizeProductMolInfoCommand(scope, cds);
1119  if (synch_molinfo) {
1120  cmd->AddCommand(*synch_molinfo);
1121  }
1122 
1123  // If protein feature exists, update it
1124  for (CFeat_CI prot_feat_ci(prot_bsh, CSeqFeatData::e_Prot); prot_feat_ci; ++prot_feat_ci )
1125  {
1126  CRef<CSeq_feat> new_feat(new CSeq_feat());
1127  new_feat->Assign(prot_feat_ci->GetOriginalFeature());
1128 
1129  if (prot_feat_ci->GetFeatSubtype() != CSeqFeatData::eSubtype_prot)
1130  {
1131  if (new_feat->IsSetLocation() && new_feat->GetLocation().GetStop(eExtreme_Positional) >= new_inst->GetLength())
1132  {
1133  CRef<CSeq_loc> sub(new CSeq_loc);
1134  sub->SetInt().SetFrom(new_inst->GetLength());
1135  sub->SetInt().SetTo(new_feat->GetLocation().GetStop(eExtreme_Positional));
1136  CRef<CSeq_id> id(new CSeq_id);
1137  id->Assign(*prot_bsh.GetSeqId());
1138  sub->SetId(*id);
1139  CRef<CSeq_loc> new_loc = new_feat->SetLocation().Subtract(*sub, 0, nullptr, nullptr); // TODO delete feature if location is removed completely
1140  new_feat->SetLocation(*new_loc);
1141 
1142  }
1143  }
1144  else
1145  {
1146  if ( new_feat->CanGetLocation() &&
1147  new_feat->GetLocation().IsInt() &&
1148  new_feat->GetLocation().GetInt().CanGetTo() )
1149  {
1150  new_feat->SetLocation().SetInt().SetTo(new_protein_bioseq->GetLength() - 1);
1151  }
1153  }
1154 
1155 
1156  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(*prot_feat_ci,
1157  *new_feat));
1158  cmd->AddCommand(*chgFeat);
1159  }
1160 
1161  return cmd;
1162 }
1163 
1164 
1165 CRef<CCmdComposite> GetRetranslateCDSCommand(CScope& scope, const CSeq_feat& cds, bool create_general_only)
1166 {
1167  int offset = 1;
1168  return GetRetranslateCDSCommand(scope, cds, offset, create_general_only);
1169 }
1170 
1171 
1172 CRef<CCmdComposite> GetRetranslateCDSCommand(CScope& scope, const CSeq_feat& cds, int& offset, bool create_general_only)
1173 {
1174  // feature must be cds
1175  if (!cds.IsSetData() && !cds.GetData().IsCdregion()) {
1177  return empty;
1178  }
1179 
1180  bool cds_change = false;
1181  CRef<CSeq_feat> new_cds(new CSeq_feat());
1182  new_cds->Assign(cds);
1183  CRef<CCmdComposite> cmd = GetRetranslateCDSCommand(scope, *new_cds, cds_change, offset, create_general_only);
1184  if (cds_change) {
1185  CSeq_feat_Handle fh;
1186  try {
1187  fh = scope.GetSeq_featHandle(cds);
1188  } catch (CException&) {
1189  }
1190 
1191  if (fh) {
1192  // if feature handle doesn't exist, feature can't be adjusted
1193  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(fh, *new_cds));
1194  cmd->AddCommand(*chgFeat);
1195  }
1196  }
1197  return cmd;
1198 }
1199 
1200 
1201 /// SetTranslExcept
1202 /// A function to set a code break at the 3' end of coding regions in a Seq-entry
1203 /// to indicate that the stop codon is formed by the addition of a poly-A tail.
1204 /// @param seh The Seq-entry to search for coding regions to adjust
1205 /// @param comment The string to place in the note on cds if a code break is added
1206 /// @param strict Only add code break if last partial codon consists of "TA" or just "T".
1207 /// If strict is false, add code break if first NT of last partial codon
1208 /// is T or N.
1209 /// @param extend If true, extend coding region to cover partial stop codon
1210 /// @param adjust_gene If true, adjust gene location to match coding region after adjustment
1211 CRef<CCmdComposite> SetTranslExcept(CSeq_entry_Handle seh, const string& comment, bool strict, bool extend, bool adjust_gene)
1212 {
1213  CRef<CCmdComposite> cmd(new CCmdComposite("Set Transl Except"));
1214  CScope& scope = seh.GetScope();
1216  bool any = false;
1217 
1218  while (feat_ci) {
1219  // TODO: first, get gene before location changes
1220  CConstRef<CSeq_feat> gene(NULL);
1221  if (adjust_gene) {
1222  gene = sequence::GetOverlappingGene(feat_ci->GetLocation(), scope);
1223  }
1224  CRef<CSeq_feat> new_feat(new CSeq_feat());
1225  new_feat->Assign(feat_ci->GetOriginalFeature());
1226  if (edit::SetTranslExcept(*new_feat, comment, strict, extend, scope)) {
1227  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(*feat_ci,
1228  *new_feat));
1229  cmd->AddCommand(*chgFeat);
1230  // if extending feature, also extend gene
1231  if (adjust_gene && gene) {
1232  TSeqPos cds_stop = new_feat->GetLocation().GetStop(eExtreme_Biological);
1233  TSeqPos gene_stop = gene->GetLocation().GetStop(eExtreme_Biological);
1234  TSeqPos diff = 0;
1235  if (gene->GetLocation().GetStrand() == eNa_strand_minus) {
1236  if (gene_stop > cds_stop) {
1237  diff = gene_stop - cds_stop;
1238  }
1239  } else {
1240  if (gene_stop < cds_stop) {
1241  diff = cds_stop - gene_stop;
1242  }
1243  }
1244  if (diff > 0) {
1245  CRef<CSeq_feat> new_gene(new CSeq_feat());
1246  new_gene->Assign(*gene);
1247  edit::ExtendStop(new_gene->SetLocation(), diff, scope);
1248  CSeq_feat_Handle gh = scope.GetSeq_featHandle(*gene);
1249  CIRef<IEditCommand> chgGene(new CCmdChangeSeq_feat(gh, *new_gene));
1250  cmd->AddCommand(*chgGene);
1251  }
1252  }
1253  any = true;
1254  }
1255  ++feat_ci;
1256  }
1257 
1258  if (!any) {
1259  cmd.Reset(NULL);
1260  }
1261  return cmd;
1262 }
1263 
1264 
1266 {
1267  if (!bsh)
1268  return CRef<CCmdComposite>(NULL);
1269 
1270  CRef<CCmdComposite> cmd(new CCmdComposite("Reverse Compliment Bioseq"));
1271  CScope &scope = bsh.GetScope();
1272 
1273  // Change Inst
1274  CRef<CSeq_inst> inst(new CSeq_inst());
1275  inst->Assign(bsh.GetInst());
1276  ReverseComplement(*inst, &scope);
1277  CRef<CCmdChangeBioseqInst> flip(new CCmdChangeBioseqInst(bsh, *inst));
1278  cmd->AddCommand(*flip);
1279 
1280  // Change feature locations
1281  CFeat_CI fit(bsh);
1282  while (fit) {
1284  CSeq_feat_Handle fh = scope.GetSeq_featHandle(*f);
1285  CRef<CSeq_feat> new_feat(new CSeq_feat());
1286  new_feat->Assign(*f);
1287  edit::ReverseComplementFeature(*new_feat, scope);
1288  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(fh, *new_feat)));
1289  ++fit;
1290  }
1291 
1292  return cmd;
1293 }
1294 
1295 //////////////////////////////////////////////////////////////////
1296 /// TrimStopsFromCompleteCDS
1297 /// If the CDS is 3' complete and the protein sequence ends with a stop codon,
1298 /// the function removes the stop codon, shortens the protein length and
1299 /// adjusts the features on the protein sequence so that they do not extend past the
1300 /// "new" end of the sequence. The function does not modify either the CDS location or
1301 /// the nucleotide sequence.
1302 /// @param cds Coding region feature which product will be examined
1303 /// @param scope The scope in which adjustments are to be made (if necessary)
1304 ///
1305 /// @return True if stop codon was found, removed and features on the protein sequence
1306 /// were adjusted, false otherwise
1308 {
1310 
1311  if (!cds.GetData().IsCdregion() || !cds.IsSetProduct()) {
1312  return empty;
1313  }
1314  // check if cds is 3' complete
1316  return empty;
1317  }
1318  CBioseq_Handle product = scope.GetBioseqHandle(cds.GetProduct());
1319  if (!product || !product.IsProtein()) {
1320  return empty;
1321  }
1322  // check if protein sequence ends with a stop residue
1324  prot_vec.SetCoding(CSeq_data::e_Ncbieaa);
1325  string prot_seq;
1326  prot_vec.GetSeqData(0, prot_vec.size(), prot_seq);
1327  if (!NStr::EndsWith(prot_seq, '*')) {
1328  return empty;
1329  }
1330 
1331  CRef<CCmdComposite> cmd(new CCmdComposite("Remove trailing * from complete CDS"));
1332 
1333  CRef<CSeq_inst> new_inst(new CSeq_inst());
1334  new_inst->Assign(product.GetInst());
1335 
1336  // Make edits to the CSeq_inst copy - shorten length by one
1337  bool modified = false;
1338  if (new_inst->IsSetSeq_data()) {
1339  prot_seq.erase(prot_seq.end() - 1);
1340  if (product.GetInst_Seq_data().IsIupacaa()) {
1341  new_inst->SetSeq_data().SetIupacaa().Set(prot_seq);
1342  new_inst->SetLength((TSeqPos)prot_seq.size());
1343  modified = true;
1344  } else if (product.GetInst_Seq_data().IsNcbieaa()) {
1345  new_inst->SetSeq_data().SetNcbieaa().Set(prot_seq);
1346  new_inst->SetLength((TSeqPos)prot_seq.size());
1347  modified = true;
1348  }
1349  }
1350 
1351  if (modified) {
1352  CRef<CCmdChangeBioseqInst> chgInst (new CCmdChangeBioseqInst(product, *new_inst));
1353  cmd->AddCommand(*chgInst);
1354 
1355  // If features exist, adjust them to the new sequence end
1357  CFeat_CI feat_ci(product);
1358  for ( ; feat_ci; ++feat_ci ) {
1359  CRef<CSeq_feat> new_feat(new CSeq_feat());
1360  new_feat->Assign(feat_ci->GetOriginalFeature());
1361  if (new_feat->CanGetLocation() &&
1362  new_feat->GetLocation().IsInt() && // only single intervals are tested
1363  new_feat->GetLocation().GetInt().GetTo()) {
1364 
1365  TSeqPos feat_stop = new_feat->GetLocation().GetStop(eExtreme_Biological);
1366  if (feat_stop > new_inst->GetLength() -1 ) {
1367  new_feat->SetLocation().SetInt().SetTo(new_inst->GetLength() - 1);
1368  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(*feat_ci, *new_feat));
1369  cmd->AddCommand(*chgFeat);
1370  }
1371  }
1372  }
1373  return cmd;
1374  }
1375  return empty;
1376 }
1377 
1378 static const char* kDiscrepancyEdit = "Dialogs.Edit.Discrepancy";
1379 
1380 static string s_GetProductRules()
1381 {
1384  string fname = reg_view.GetString("ProductRules");
1385  CFile file(fname);
1386  return file.Exists() ? fname : kEmptyStr;
1387 }
1388 
1389 #ifdef NEW_DISCREPANCY_API
1390 CRef<CCmdComposite> AutofixCommand(CSeq_entry_Handle orig_seh, const string& str_test_name, string* output, const string& suspect_rules)
1391 {
1392  CConstRef<CSeq_entry> entry = orig_seh.GetCompleteSeq_entry();
1394  copy->Assign(*entry);
1396  CScope scope2(*objmgr);
1397  scope2.AddDefaults();
1398  CSeq_entry_Handle new_seh = scope2.AddTopLevelSeqEntry(*copy);
1399 
1400 
1401  CRef<NDiscrepancy::CDiscrepancySet> discrSet = NDiscrepancy::CDiscrepancySet::New(scope2);
1402  if (suspect_rules.empty()) {
1403  discrSet->SetSuspectRules(s_GetProductRules());
1404  }
1405  else {
1406  discrSet->SetSuspectRules(suspect_rules);
1407  }
1408 
1409  auto test_name = NDiscrepancy::GetDiscrepancyCaseName(str_test_name);
1410  auto product = discrSet->RunTests({test_name}, *copy, "");
1411  product->Summarize();
1412  auto report = discrSet->Autofix();
1413  if (report.empty()) {
1414  return CRef<CCmdComposite>();
1415  } else {
1416  if (output) {
1417  for (auto J : report) {
1418  *output += NDiscrepancy::CDiscrepancySet::Format(J.first, (unsigned)J.second) + "\n";
1419  }
1420  }
1421  }
1422 
1423  CRef<CCmdComposite> cmd(new CCmdComposite("Perform Autofix for " + str_test_name + " discrepancy test"));
1424  CRef<CCmdChangeSeqEntry> clean(new CCmdChangeSeqEntry(orig_seh, copy));
1425  cmd->AddCommand(*clean);
1426 
1427  return cmd;
1428 }
1429 #else
1430 CRef<CCmdComposite> AutofixCommand(CSeq_entry_Handle orig_seh, const string& test_name, string* output, const string& suspect_rules)
1431 {
1432  CConstRef<CSeq_entry> entry = orig_seh.GetCompleteSeq_entry();
1434  copy->Assign(*entry);
1436  CScope scope2(*objmgr);
1437  scope2.AddDefaults();
1438  CSeq_entry_Handle new_seh = scope2.AddTopLevelSeqEntry(*copy);
1439 
1440 
1441  CRef<NDiscrepancy::CDiscrepancySet> discrSet = NDiscrepancy::CDiscrepancySet::New(scope2);
1442  discrSet->AddTest(test_name);
1443  if (suspect_rules.empty()) {
1444  discrSet->SetSuspectRules(s_GetProductRules());
1445  }
1446  else {
1447  discrSet->SetSuspectRules(suspect_rules);
1448  }
1449  discrSet->Parse(*copy.GetNCPointer());
1450  discrSet->Summarize();
1451 
1452  const map<string, CRef<NDiscrepancy::CDiscrepancyCase> >& tests = discrSet->GetTests();
1453  if (tests.size() != 1) {
1454  return CRef<CCmdComposite>();
1455  }
1456 
1458  NDiscrepancy::TReportItemList reports = tests.at(test_name)->GetReport();
1459  for (auto it : reports) {
1460  for (auto obj : it->GetDetails()) {
1461  if (obj->CanAutofix()) {
1462  tofix.push_back(CRef<NDiscrepancy::CReportObj>(&*obj));
1463  }
1464  }
1465  }
1466  if (tofix.empty()) {
1467  return CRef<CCmdComposite>();
1468  }
1469 
1471  discrSet->Autofix(tofix, result);
1472 
1473  if (output && result.size()) {
1474  for (auto J : result) {
1475  *output += NDiscrepancy::CDiscrepancySet::Format(J.first, (unsigned)J.second) + "\n";
1476  }
1477  }
1478 
1479  CRef<CCmdComposite> cmd(new CCmdComposite("Perform Autofix for " + test_name + " discrepancy test"));
1480  CRef<CCmdChangeSeqEntry> clean(new CCmdChangeSeqEntry(orig_seh, copy));
1481  cmd->AddCommand(*clean);
1482 
1483  return cmd;
1484 }
1485 #endif
1486 
1487 CRef<CCmdComposite> AutofixCommandHugeMode(CSeq_entry_Handle orig_seh, const string& str_test_name,
1488  map<string, size_t>& report, const string& suspect_rules)
1489 {
1490  CConstRef<CSeq_entry> entry = orig_seh.GetCompleteSeq_entry();
1492  copy->Assign(*entry);
1494  CScope scope2(*objmgr);
1495  scope2.AddDefaults();
1496  CSeq_entry_Handle new_seh = scope2.AddTopLevelSeqEntry(*copy);
1497 
1498  CRef<NDiscrepancy::CDiscrepancySet> discrSet = NDiscrepancy::CDiscrepancySet::New(scope2);
1499  if (suspect_rules.empty()) {
1500  discrSet->SetSuspectRules(s_GetProductRules());
1501  }
1502  else {
1503  discrSet->SetSuspectRules(suspect_rules);
1504  }
1505 
1506  auto test_name = NDiscrepancy::GetDiscrepancyCaseName(str_test_name);
1507  auto lcl_product = discrSet->RunTests({ test_name }, *copy, "");
1508  lcl_product->Summarize();
1509  auto lcl_report = discrSet->Autofix();
1510  if (lcl_report.empty()) {
1511  return CRef<CCmdComposite>();
1512  }
1513  else {
1514  report = lcl_report;
1515  }
1516 
1517  CRef<CCmdComposite> cmd(new CCmdComposite("Perform Autofix for " + str_test_name + " discrepancy test"));
1518  CRef<CCmdChangeSeqEntry> clean(new CCmdChangeSeqEntry(orig_seh, copy));
1519  cmd->AddCommand(*clean);
1520 
1521  return cmd;
1522 }
1523 
1524 //////////////////////////////////////////////////////////////////
1525 /// GetEditLocationCommand
1526 /// Changes the location properties of a feature according to a location policy
1527 ///
1528 CRef<CCmdComposite> GetEditLocationCommand(const edit::CLocationEditPolicy& policy,
1529  bool retranslate, bool adjust_gene, const CSeq_feat& orig_feat, CScope& scope,
1530  int& offset, bool create_general_only)
1531 {
1532  CRef<CCmdComposite> cmd(new CCmdComposite("Edit Location"));
1533  CRef<CSeq_feat> new_feat(new CSeq_feat());
1534  new_feat->Assign(orig_feat);
1535 
1536  bool any_change = policy.ApplyPolicyToFeature(*new_feat, scope);
1537 
1538  if (any_change) {
1539  // adjust gene feature
1540  if (adjust_gene) {
1541  CRef<CCmdChangeSeq_feat> adjust_gene_cmd = AdjustGene(orig_feat, *new_feat, scope);
1542  if (adjust_gene_cmd) {
1543  cmd->AddCommand(*adjust_gene_cmd);
1544  }
1545  }
1546 
1547  // set partial flag
1549 
1550  // command to change feature
1551  cmd->AddCommand(*CRef<CCmdChangeSeq_feat>(new CCmdChangeSeq_feat(scope.GetSeq_featHandle(orig_feat), *new_feat)));
1552 
1553  // retranslate or resynch if coding region
1554  if (new_feat->IsSetProduct() && new_feat->GetData().IsCdregion()) {
1555  if (retranslate) {
1556  CRef<CCmdComposite> retranslate_cmd = GetRetranslateCDSCommand(scope, *new_feat, offset, create_general_only);
1557  if (retranslate_cmd) {
1558  cmd->AddCommand(*retranslate_cmd);
1559  }
1560  }
1561  else {
1563  if (synch) {
1564  cmd->AddCommand(*synch);
1565  }
1566  }
1567  }
1568 
1569  }
1570  else {
1571  cmd.Reset(NULL);
1572  }
1573  return cmd;
1574 }
1575 
1576 CRef<CCmdChangeSeq_feat> AdjustGene(const CSeq_feat& orig_feat, const CSeq_feat& new_feat, CScope& scope)
1577 {
1578  CConstRef<CSeq_feat> old_gene = sequence::GetOverlappingGene(orig_feat.GetLocation(), scope);
1579  if (!old_gene) {
1580  return CRef<CCmdChangeSeq_feat>();
1581  }
1582 
1583  size_t feat_start = new_feat.GetLocation().GetStart(eExtreme_Biological);
1584  size_t feat_stop = new_feat.GetLocation().GetStop(eExtreme_Biological);
1585  CRef<CSeq_feat> new_gene(new CSeq_feat());
1586  new_gene->Assign(*old_gene);
1587 
1588  bool gene_change = false;
1589  // adjust ends of gene to match ends of feature
1590  CRef<CSeq_loc> new_loc = edit::SeqLocExtend(new_gene->GetLocation(), feat_start, &scope);
1591  if (new_loc) {
1592  new_gene->SetLocation().Assign(*new_loc);
1593  gene_change = true;
1594  }
1595  new_loc = edit::SeqLocExtend(new_gene->GetLocation(), feat_stop, &scope);
1596  if (new_loc) {
1597  new_gene->SetLocation().Assign(*new_loc);
1598  gene_change = true;
1599  }
1600  // adjust partial ends and the partial flag
1601  new_gene->SetLocation().SetPartialStart(new_feat.GetLocation().IsPartialStart(eExtreme_Biological), eExtreme_Biological);
1602  new_gene->SetLocation().SetPartialStop(new_feat.GetLocation().IsPartialStop(eExtreme_Biological), eExtreme_Biological);
1606 
1607  gene_change = true;
1608  }
1609 
1610  if (gene_change) {
1611  return Ref(new CCmdChangeSeq_feat(scope.GetSeq_featHandle(*old_gene), *new_gene));
1612  }
1613  return CRef<CCmdChangeSeq_feat>();
1614 }
1615 
1616 
1618 {
1619  bool any_change = false;
1620 
1621  vector<CCleanup::TFeatGenePair> cds_gene_pairs = CCleanup::GetNormalizableGeneQualPairs(bsh);
1622  for (auto copy_pair : cds_gene_pairs) {
1623  CRef<CSeq_feat> new_cds(new CSeq_feat());
1624  new_cds->Assign(*(copy_pair.first.GetOriginalSeq_feat()));
1625  CRef<CSeq_feat> new_gene(new CSeq_feat());
1626  new_gene->Assign(*(copy_pair.second.GetOriginalSeq_feat()));
1627  if (CCleanup::NormalizeGeneQuals(*new_cds, *new_gene)) {
1628  CIRef<IEditCommand> chgGene(new CCmdChangeSeq_feat(copy_pair.second, *new_gene));
1629  cmd->AddCommand(*chgGene);
1630  CIRef<IEditCommand> chgCDS(new CCmdChangeSeq_feat(copy_pair.first, *new_cds));
1631  cmd->AddCommand(*chgCDS);
1632  any_change = true;
1633  }
1634  }
1635  return any_change;
1636 }
1637 
1638 
1640 {
1641  CBioseq_CI bi(seh, CSeq_inst::eMol_na);
1642  CRef<CCmdComposite> cmd(new CCmdComposite("Normalize Gene Quals"));
1643 
1644  bool any = false;
1645  while (bi) {
1646  any |= GetNormalizeGeneQualsCommand(*bi, cmd);
1647  ++bi;
1648  }
1649  if (!any) {
1650  cmd.Reset(NULL);
1651  }
1652  return cmd;
1653 }
1654 
1655 
1657 {
1658  bool any_change = false;
1659 
1660  CFeat_CI f(bsh);
1661  while (f) {
1662  CRef<CSeq_feat> cp(new CSeq_feat());
1663  cp->Assign(*(f->GetSeq_feat()));
1665  CSeq_feat_Handle fh = f->GetSeq_feat_Handle();
1666  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(fh, *cp));
1667  cmd->AddCommand(*chgFeat);
1668  any_change = true;
1669  }
1670  ++f;
1671  }
1672  return any_change;
1673 }
1674 
1675 
1677 {
1678  CBioseq_CI bi(seh, CSeq_inst::eMol_na);
1679  CRef<CCmdComposite> cmd(new CCmdComposite("Remove Duplicate GO Terms"));
1680 
1681  bool any = false;
1682  while (bi) {
1684  ++bi;
1685  }
1686  if (!any) {
1687  cmd.Reset(NULL);
1688  }
1689  return cmd;
1690 }
1691 
1692 
1693 CRef<CCmdComposite> UpdatemRNAProduct(const CSeq_feat& protein, CScope& scope, string& message)
1694 {
1695  if (!protein.IsSetData() ||
1696  (protein.IsSetData() && protein.GetData().GetSubtype() != CSeqFeatData::eSubtype_prot)) {
1697  return CRef<CCmdComposite>(nullptr);
1698  }
1700  const string& product = (protein.GetData().GetProt().IsSetName()) ? protein.GetData().GetProt().GetName().front() : kEmptyStr;
1701  CBioseq_Handle prot_bsh = scope.GetBioseqHandle(protein.GetLocation());
1702  const CSeq_feat* cds = sequence::GetCDSForProduct(*prot_bsh.GetCompleteBioseq(), &scope);
1703  if (cds) {
1704  CConstRef<CSeq_feat> mrna = sequence::GetmRNAforCDS(*cds, scope);
1705  if (mrna) {
1706  CRef<CSeq_feat> new_mrna(new CSeq_feat());
1707  new_mrna->Assign(*mrna);
1708 
1709  bool modified = false;
1710  if (mrna->GetData().IsRna() && mrna->GetData().GetRna().GetType() == CRNA_ref::eType_mRNA) {
1711  CRNA_ref& rna = new_mrna->SetData().SetRna();
1712  if (product.empty()) {
1713  rna.ResetExt();
1714  message += "reset the mRNA product name ";
1715  modified = true;
1716  }
1717  else if (!rna.IsSetExt() || (rna.IsSetExt() && !NStr::Equal(rna.GetExt().GetName(), product))) {
1718  rna.SetExt().SetName(product);
1719  message = "applied " + product + " to mRNA product name ";
1720  modified = true;
1721  }
1722  }
1723 
1724  if (modified) {
1725  CSeq_feat_Handle fh = scope.GetSeq_featHandle(*mrna);
1726  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(fh, *new_mrna));
1727  cmd.Reset(new CCmdComposite("Update mRNA product to match CDS product name"));
1728  cmd->AddCommand(*chgFeat);
1729  }
1730  }
1731  }
1732  return cmd;
1733 }
1734 
1735 
1736 CRef<CCmdComposite> UpdatemRNAProduct(const string& prot_product, CConstRef<CObject> object, CScope& scope)
1737 {
1738  const CSeq_feat* seq_feat = dynamic_cast<const CSeq_feat*>(object.GetPointer());
1739  // at this point, only handle protein features
1740  // TO DO: extend it to other features as well
1741  if (!seq_feat) {
1743  return empty;
1744  }
1745 
1746  CConstRef<CSeq_feat> orig_mrna;
1747  CSeqFeatData::ESubtype subtype = seq_feat->GetData().GetSubtype();
1748 
1749  switch (subtype) {
1751  // for proteins: find first the CDS and then find the original overlapping mRNA
1752  CBioseq_Handle prot_bsh = scope.GetBioseqHandle(seq_feat->GetLocation());
1753  const CSeq_feat* cds = sequence::GetCDSForProduct(prot_bsh);
1754  if (cds) {
1755  orig_mrna.Reset(sequence::GetmRNAforCDS(*cds, scope));
1756  }
1757  break;
1758  }
1759  default:
1760  break;
1761  }
1762 
1763  if (orig_mrna) {
1764  CRef<CCmdComposite> cmd(new CCmdComposite("Update mRNA product name to match CDS protein name"));
1765  CRef<CSeq_feat> new_mrna(new CSeq_feat());
1766  new_mrna->Assign(*orig_mrna);
1767 
1768  bool modified = false;
1769  if (orig_mrna->GetData().IsRna()) {
1770  string remainder;
1771  new_mrna->SetData().SetRna().SetRnaProductName(prot_product, remainder);
1772  modified = true;
1773  }
1774 
1775  if (modified) {
1776  CSeq_feat_Handle fh = scope.GetSeq_featHandle(*orig_mrna);
1777  CIRef<IEditCommand> chgFeat(new CCmdChangeSeq_feat(fh, *new_mrna));
1778  cmd->AddCommand(*chgFeat);
1779  return cmd;
1780  }
1781  }
1783  return empty;
1784 }
1785 
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
@ eExtreme_Biological
5' and 3'
Definition: Na_strand.hpp:62
void ExtendStop(CSeq_loc &loc, TSeqPos len, CScope &scope)
Definition: cds_fix.cpp:197
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
CRef< objects::CSeq_id > GetNewProtId(objects::CBioseq_Handle bsh, int &offset, string &id_label, bool general_only)
void RemoveCultureNotes(bool is_species_level=true)
Definition: BioSource.cpp:1428
void SetDisableStrainForwarding(bool val)
Definition: BioSource.cpp:621
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
CBioseq_set_Handle –.
TSeqPos GetLength(void) const
Definition: Bioseq.cpp:360
static vector< TFeatGenePair > GetNormalizableGeneQualPairs(CBioseq_Handle bsh)
@ eClean_NoNcbiUserObjects
Definition: cleanup.hpp:75
@ eClean_KeepTopSet
Definition: cleanup.hpp:78
@ eClean_SyncGenCodes
Definition: cleanup.hpp:76
static bool NormalizeGeneQuals(CSeq_feat &cds, CSeq_feat &gene)
void AddCommand(IEditCommand &command)
virtual void Execute()
Do the editing action.
static CIRef< IEditCommand > RemoveCitations(objects::CSeq_entry_Handle &seh, const objects::CPub_equiv &pubs)
Definition: cmd_factory.cpp:80
CFeat_CI –.
Definition: feat_ci.hpp:64
CFile –.
Definition: ncbifile.hpp:1604
static CGuiRegistry & GetInstance()
access the application-wide singleton
Definition: registry.cpp:400
CRegistryReadView GetReadView(const string &section) const
get a read-only view at a particular level.
Definition: registry.cpp:428
Base class for all object manager exceptions.
@RNA_ref.hpp User-defined methods of the data storage class.
Definition: RNA_ref.hpp:54
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
string GetString(const string &key, const string &default_val=kEmptyStr) const
Definition: reg_view.cpp:246
CScope –.
Definition: scope.hpp:92
ESubtype GetSubtype(void) const
SeqMap related exceptions.
CSeqVector –.
Definition: seq_vector.hpp:65
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
const CSeq_descr & GetDescr(void) const
Definition: Seq_entry.cpp:120
bool IsSetDescr(void) const
Definition: Seq_entry.cpp:106
CSeq_feat_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Seq-loc iterator class – iterates all intervals from a seq-loc in the correct order.
Definition: Seq_loc.hpp:453
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
CT3Request –.
Definition: T3Request.hpp:66
CTaxon3_request –.
virtual CRef< CTaxon3_reply > SendRequest(const CTaxon3_request &request)
Definition: taxon3.cpp:115
virtual CRef< CTaxon3_reply > SendOrgRefList(const vector< CRef< COrg_ref > > &list, COrg_ref::fOrgref_parts result_parts=COrg_ref::eOrgref_default, fT3reply_parts t3result_parts=eT3reply_default)
Definition: taxon3.cpp:190
virtual void Init()
Definition: taxon3.cpp:74
Definition: map.hpp:338
Definition: set.hpp:45
void SetMolinfoForProtein(CRef< objects::CSeq_entry > protein, bool partial5, bool partial3)
CRef< objects::CSeq_feat > AddEmptyProteinFeatureToProtein(CRef< objects::CSeq_entry > protein, bool partial5, bool partial3)
static const int chunk_size
vector< CRef< CReportItem > > TReportItemList
vector< CRef< CReportObj > > TReportObjectList
eTestNames GetDiscrepancyCaseName(string_view)
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
static void cleanup(void)
Definition: ct_dynamic.c:30
static SQLCHAR output[256]
Definition: print.c:5
static DbTestEntry * tests
Definition: testodbc.c:388
int offset
Definition: replacements.h:160
static char test_name[128]
Definition: utf8_2.c:34
char data[12]
Definition: iconv.c:80
void ReverseComplement(const BidirectionalIterator &first, const BidirectionalIterator &last)
bool RemoveDuplicateGoTerms(CSeq_feat &feat)
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
@ eUnknown
Definition: app_popup.hpp:72
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Optimized implementation of CSerialObject::Assign, which is not so efficient.
Definition: Seq_id.cpp:318
CConstRef< CSeq_id > GetSeqId(void) const
bool IsPartialStart(ESeqLocExtremes ext) const
check start or stop of location for e_Lim fuzz
Definition: Seq_loc.cpp:3222
ENa_strand GetStrand(void) const
Get the location's strand.
Definition: Seq_loc.cpp:882
void SetId(CSeq_id &id)
set the 'id' field in all parts of this location
Definition: Seq_loc.cpp:3474
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
Definition: Seq_loc.cpp:915
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
Definition: Seq_loc.hpp:941
bool IsPartialStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:3251
TSeqPos GetStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:963
bool AdjustProteinMolInfoToMatchCDS(CMolInfo &molinfo, const CSeq_feat &cds)
AdjustProteinMolInfoToMatchCDS A function to change an existing MolInfo to match a coding region.
Definition: feature.cpp:4024
const CSeq_feat * GetCDSForProduct(const CBioseq &product, CScope *scope)
Get the encoding CDS feature of a given protein sequence.
Definition: sequence.cpp:2549
static CRef< CBioseq > TranslateToProtein(const CSeq_feat &cds, CScope &scope)
Definition: sequence.cpp:3839
CConstRef< CSeq_feat > GetOverlappingGene(const CSeq_loc &loc, CScope &scope, ETransSplicing eTransSplicing=eTransSplicing_Auto)
Definition: sequence.cpp:1366
CConstRef< CSeq_feat > GetmRNAforCDS(const CSeq_feat &cds, CScope &scope)
GetmRNAforCDS A function to find a CSeq_feat representing the appropriate mRNA for a given CDS.
Definition: sequence.cpp:1261
static void Translate(const string &seq, string &prot, const CGenetic_code *code, bool include_stop=true, bool remove_trailing_X=false, bool *alt_start=NULL, bool is_5prime_complete=true, bool is_3prime_complete=true)
Translate a string using a specified genetic code.
Definition: sequence.cpp:4095
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
CSeq_entry_Handle AddTopLevelSeqEntry(CSeq_entry &top_entry, TPriority pri=kPriority_Default, EExist action=eExist_Default)
Add seq_entry, default priority is higher than for defaults or loaders Add object to the score with p...
Definition: scope.cpp:522
CSeq_entry_Handle GetSeq_entryHandle(CDataLoader *loader, const TBlobId &blob_id, EMissing action=eMissing_Default)
Get Seq-entry handle by its blob-id, with possible loading.
Definition: scope.cpp:113
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
void AddDefaults(TPriority pri=kPriority_Default)
Add default data loaders from object manager.
Definition: scope.cpp:504
void GetAllTSEs(TTSE_Handles &tses, enum ETSEKind kind=eManualTSEs)
Definition: scope.cpp:295
CSeq_feat_Handle GetSeq_featHandle(const CSeq_feat &feat, EMissing action=eMissing_Default)
Definition: scope.cpp:200
vector< CSeq_entry_Handle > TTSE_Handles
Definition: scope.hpp:645
@ eAllTSEs
Definition: scope.hpp:643
virtual CSeq_id_Handle GetLocationId(void) const
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
TClass GetClass(void) const
CBioseq_set_Handle GetParentBioseq_set(void) const
Return a handle for the parent Bioseq-set, or null handle.
CSeq_entry_Handle GetParentEntry(void) const
Get parent Seq-entry handle.
const CSeqFeatData & GetData(void) const
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
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_set_Handle GetParentBioseq_set(void) const
Get parent bioseq-set handle.
bool IsProtein(void) const
CSeq_entry_Handle GetParentEntry(void) const
Return a handle for the parent seq-entry of the bioseq.
TInst_Length GetInst_Length(void) const
bool IsSetClass(void) const
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.
CScope & GetScope(void) const
Get scope this handle belongs to.
const TInst_Seq_data & GetInst_Seq_data(void) const
CScope & GetScope(void) const
Get scope this handle belongs to.
CConstRef< CSeq_feat > GetOriginalSeq_feat(void) const
bool IsNa(void) const
CSeq_entry_Handle GetTopLevelEntry(void) const
Return a handle for the top-level seq-entry.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
const TId & GetId(void) const
virtual CSeq_id_Handle GetProductId(void) const
CSeqVector GetSeqVector(EVectorCoding coding, ENa_strand strand=eNa_strand_plus) const
Get sequence: Iupacna or Iupacaa if use_iupac_coding is true.
const TInst & GetInst(void) const
@ eCoding_Ncbi
Set coding to binary coding (Ncbi4na or Ncbistdaa)
const CSeq_loc & GetLocation(void) const
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
CConstRef< CSeq_feat > GetSeq_feat(void) const
Get current seq-feat.
void Rewind(void)
Definition: feat_ci.hpp:239
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Definition: seqdesc_ci.cpp:326
void GetSeqData(TSeqPos start, TSeqPos stop, string &buffer) const
Fill the buffer string with the sequence data for the interval [start, stop).
Definition: seq_vector.cpp:304
TSeqPos size(void) const
Definition: seq_vector.hpp:291
void SetCoding(TCoding coding)
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:1684
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
Definition: ncbiobj.hpp:2015
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
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
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
const TOrg & GetOrg(void) const
Get the Org member data.
Definition: BioSource_.hpp:509
void SetOrg(TOrg &value)
Assign a value to Org data member.
Definition: BioSource_.cpp:108
const TName & GetName(void) const
Get the Name member data.
Definition: Prot_ref_.hpp:378
bool IsSetName(void) const
protein name Check if a value has been assigned to Name data member.
Definition: Prot_ref_.hpp:366
TType GetType(void) const
Get the Type member data.
Definition: RNA_ref_.hpp:529
TXref & SetXref(void)
Assign a value to Xref data member.
Definition: Seq_feat_.hpp:1314
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
Definition: Seq_feat_.hpp:913
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.
void SetPartial(TPartial value)
Assign a value to Partial data member.
Definition: Seq_feat_.hpp:971
void SetProduct(TProduct &value)
Assign a value to Product data member.
Definition: Seq_feat_.cpp:110
bool 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
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
bool CanGetLocation(void) const
Check if it is safe to call GetLocation method.
Definition: Seq_feat_.hpp:1111
const TBiosrc & GetBiosrc(void) const
Get the variant data.
const TProduct & GetProduct(void) const
Get the Product member data.
Definition: Seq_feat_.hpp:1096
const TProt & GetProt(void) const
Get the variant data.
const TXref & GetXref(void) const
Get the Xref member data.
Definition: Seq_feat_.hpp:1308
vector< CRef< CSeqFeatXref > > TXref
Definition: Seq_feat_.hpp:122
void ResetXref(void)
Reset Xref data member.
Definition: Seq_feat_.cpp:182
const TRna & GetRna(void) const
Get the variant data.
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
Definition: Seq_feat_.hpp:1084
bool IsRna(void) const
Check if variant Rna is selected.
bool IsSetLocation(void) const
feature made from Check if a value has been assigned to Location data member.
Definition: Seq_feat_.hpp:1105
bool CanGetTo(void) const
Check if it is safe to call GetTo method.
TTo GetTo(void) const
Get the To 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
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
const TSet & GetSet(void) const
Get the variant data.
Definition: Seq_entry_.cpp:124
bool IsSetSeq_set(void) const
Check if a value has been assigned to Seq_set data member.
bool IsSet(void) const
Check if variant Set is selected.
Definition: Seq_entry_.hpp:263
const TSeq_set & GetSeq_set(void) const
Get the Seq_set member data.
list< CRef< CSeq_entry > > TSeq_set
TSeq & SetSeq(void)
Select the variant.
Definition: Seq_entry_.cpp:108
@ eClass_nuc_prot
nuc acid and coded proteins
Definition: Bioseq_set_.hpp:99
list< CRef< CSeqdesc > > Tdata
Definition: Seq_descr_.hpp:91
TId & SetId(void)
Assign a value to Id data member.
Definition: Bioseq_.hpp:296
bool IsSetSeq_data(void) const
the sequence Check if a value has been assigned to Seq_data data member.
Definition: Seq_inst_.hpp:805
bool IsNcbieaa(void) const
Check if variant Ncbieaa is selected.
Definition: Seq_data_.hpp:644
const TInst & GetInst(void) const
Get the Inst member data.
Definition: Bioseq_.hpp:336
bool IsIupacaa(void) const
Check if variant Iupacaa is selected.
Definition: Seq_data_.hpp:524
const TSource & GetSource(void) const
Get the variant data.
Definition: Seqdesc_.cpp:566
const Tdata & Get(void) const
Get the member data.
Definition: Seq_descr_.hpp:166
bool IsSetInst(void) const
the sequence data Check if a value has been assigned to Inst data member.
Definition: Bioseq_.hpp:324
TLength GetLength(void) const
Get the Length member data.
Definition: Seq_inst_.hpp:659
void SetInst(TInst &value)
Assign a value to Inst data member.
Definition: Bioseq_.cpp:86
TSource & SetSource(void)
Select the variant.
Definition: Seqdesc_.cpp:572
void SetBiomol(TBiomol value)
Assign a value to Biomol data member.
Definition: MolInfo_.hpp:453
bool IsSetId(void) const
equivalent identifiers Check if a value has been assigned to Id data member.
Definition: Bioseq_.hpp:278
void SetLength(TLength value)
Assign a value to Length data member.
Definition: Seq_inst_.hpp:668
void ResetInst(void)
Reset Inst data member.
Definition: Bioseq_.cpp:77
void SetSeq_data(TSeq_data &value)
Assign a value to Seq_data data member.
Definition: Seq_inst_.cpp:130
const TMolinfo & GetMolinfo(void) const
Get the variant data.
Definition: Seqdesc_.cpp:588
TMolinfo & SetMolinfo(void)
Select the variant.
Definition: Seqdesc_.cpp:594
@ eRepr_raw
continuous sequence
Definition: Seq_inst_.hpp:94
@ e_Ncbieaa
extended ASCII 1 letter aa codes
Definition: Seq_data_.hpp:111
@ e_Molinfo
info on the molecule and techniques
Definition: Seqdesc_.hpp:134
@ eMol_na
just a nucleic acid
Definition: Seq_inst_.hpp:113
TRequest & SetRequest(void)
Assign a value to Request data member.
function< CRef< CTaxon3_reply >(const vector< CRef< COrg_ref > > &list)> taxupdate_func_t
Definition: itaxon3.hpp:60
FILE * file
int i
yy_size_t n
int len
void ReverseComplementFeature(CSeq_feat &feat, CScope &scope)
Definition: loc_edit.cpp:1068
CRef< CSeq_loc > SeqLocExtend(const CSeq_loc &loc, size_t pos, CScope *scope)
Definition: loc_edit.cpp:546
constexpr bool empty(list< Ts... >) noexcept
static bool Equals(const CVariation::TPlacements &p1, const CVariation::TPlacements &p2)
T min(T x_, T y_)
Format
Definition: njn_ioutil.hpp:52
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Definition: njn_matrix.hpp:613
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
The Object manager core.
bool IsFarLocation(const CSeq_loc &loc, const CSeq_entry_Handle &seh)
Definition: utilities.cpp:159
SAnnotSelector –.
else result
Definition: token2.c:20
CRef< CCmdComposite > GetDeleteAllFeaturesCommand(CSeq_entry_Handle seh, size_t &count, bool remove_proteins)
Definition: util_cmds.cpp:240
CRef< CCmdComposite > TrimStopsFromCompleteCDS(const CSeq_feat &cds, CScope &scope)
TrimStopsFromCompleteCDS If the CDS is 3' complete and the protein sequence ends with a stop codon,...
Definition: util_cmds.cpp:1307
USING_SCOPE(objects)
static bool s_IsNucLocation(CSeq_feat_Handle fh)
Definition: util_cmds.cpp:226
void SetProteinFeature(CSeq_feat &prot, CBioseq_Handle product, const CSeq_feat &cds)
Definition: util_cmds.cpp:923
CRef< CCmdComposite > TranslateCDSCommand(CScope &scope, CSeq_feat &cds, bool &cds_change, int &offset, bool create_general_only)
Definition: util_cmds.cpp:981
bool GetRemoveDuplicateGOTermsCommand(CBioseq_Handle bsh, CRef< CCmdComposite > cmd)
Definition: util_cmds.cpp:1656
CRef< CCmdComposite > CleanupCommand(CSeq_entry_Handle orig_seh, bool extended, bool do_tax)
Definition: util_cmds.cpp:280
static bool s_IsFarLocation(CSeq_feat_Handle fh)
Definition: util_cmds.cpp:86
CRef< CCmdComposite > GetDeleteFeatureCommand(const CSeq_feat_Handle &fh, bool remove_proteins)
Definition: util_cmds.cpp:107
static const char * kDiscrepancyEdit
Definition: util_cmds.cpp:1378
CRef< CCmdComposite > GetEditLocationCommand(const edit::CLocationEditPolicy &policy, bool retranslate, bool adjust_gene, const CSeq_feat &orig_feat, CScope &scope, int &offset, bool create_general_only)
GetEditLocationCommand Changes the location properties of a feature according to a location policy.
Definition: util_cmds.cpp:1528
static bool s_AreThereOtherCDSForThisProduct(const CSeq_feat_Handle &fh)
Definition: util_cmds.cpp:65
CRef< CCmdComposite > GetSynchronizeProductMolInfoCommand(CScope &scope, const CSeq_feat &cds)
Definition: util_cmds.cpp:845
CRef< CCmdComposite > TaxonomyLookupCommand(CSeq_entry_Handle seh)
Definition: util_cmds.cpp:372
bool s_IsSpeciesLevel(const COrg_ref &org)
Definition: util_cmds.cpp:740
CRef< CCmdComposite > GetEnableStrainForwardingCommand(CSeq_entry_Handle seh)
Definition: util_cmds.cpp:734
CRef< CCmdComposite > GetRetranslateCDSCommand(CScope &scope, CSeq_feat &cds, bool &cds_change, bool create_general_only)
Definition: util_cmds.cpp:1036
CRef< CCmdComposite > GetSynchronizeProteinPartialsCommand(CScope &scope, const CSeq_feat &cds)
Definition: util_cmds.cpp:885
CRef< CCmdComposite > GetChangeStrainForwardingCommand(CSeq_entry_Handle seh, bool disable)
Definition: util_cmds.cpp:696
CRef< CCmdComposite > CreateOrAdjustProteinFeature(CBioseq_Handle product, CSeq_feat &cds, bool &cds_change)
Definition: util_cmds.cpp:960
CRef< CCmdComposite > GetDeleteSequenceCommand(CBioseq_Handle bsh)
Definition: util_cmds.cpp:204
CRef< CCmdChangeSeq_feat > AdjustGene(const CSeq_feat &orig_feat, const CSeq_feat &new_feat, CScope &scope)
Definition: util_cmds.cpp:1576
CRef< CCmdComposite > SpecificHostCleanupCommand(CSeq_entry_Handle seh)
Definition: util_cmds.cpp:593
bool GetNormalizeGeneQualsCommand(CBioseq_Handle bsh, CRef< CCmdComposite > cmd)
Definition: util_cmds.cpp:1617
void GetProductToCDSMap(CScope &scope, map< CBioseq_Handle, set< CSeq_feat_Handle > > &product_to_cds)
Definition: util_cmds.cpp:145
CRef< CCmdComposite > AutofixCommand(CSeq_entry_Handle orig_seh, const string &test_name, string *output, const string &suspect_rules)
Definition: util_cmds.cpp:1430
CRef< CCmdComposite > GetRmCultureNotesCommand(CSeq_entry_Handle seh)
Definition: util_cmds.cpp:769
static void s_GetSourceDescriptors(const CSeq_entry &se, vector< pair< const CSeqdesc *, const CSeq_entry * >> &src_descs)
Definition: util_cmds.cpp:263
CRef< CCmdComposite > CleanupHugeFileCommand(CSeq_entry_Handle orig_seh, bool extended, bool do_tax, objects::taxupdate_func_t &updater, bool rmv_user_object)
Definition: util_cmds.cpp:321
CRef< CCmdComposite > GetDisableStrainForwardingCommand(CSeq_entry_Handle seh)
Definition: util_cmds.cpp:729
CRef< CCmdComposite > SetTranslExcept(CSeq_entry_Handle seh, const string &comment, bool strict, bool extend, bool adjust_gene)
SetTranslExcept A function to set a code break at the 3' end of coding regions in a Seq-entry to indi...
Definition: util_cmds.cpp:1211
CRef< CCmdComposite > AutofixCommandHugeMode(CSeq_entry_Handle orig_seh, const string &str_test_name, map< string, size_t > &report, const string &suspect_rules)
Definition: util_cmds.cpp:1487
CRef< CCmdComposite > GetReverseComplimentSequenceCommand(CBioseq_Handle bsh)
Definition: util_cmds.cpp:1265
CRef< CCmdComposite > UpdatemRNAProduct(const CSeq_feat &protein, CScope &scope, string &message)
Definition: util_cmds.cpp:1693
void AdjustProteinFeature(CSeq_feat &prot, CBioseq_Handle product, CSeq_feat &cds, bool &cds_change)
Definition: util_cmds.cpp:939
static string s_GetProductRules()
Definition: util_cmds.cpp:1380
CRef< CCmdComposite > CachedTaxonomyLookupCommand(CSeq_entry_Handle seh, objects::taxupdate_func_t &updater)
Definition: util_cmds.cpp:481
Modified on Tue Apr 23 07:39:02 2024 by modify_doxy.py rev. 669887