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

Go to the SVN repository for this file.

1 /* $Id: edits_db_saver.cpp 74559 2016-09-13 11:58:16Z ivanov $
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  * Author: Maxim Didenko
27  *
28  *
29  */
30 
31 #include <ncbi_pch.hpp>
32 #include <corelib/ncbistre.hpp>
33 
36 #include <objmgr/blob_id.hpp>
37 #include <objmgr/bio_object_id.hpp>
38 
39 #include <objmgr/bioseq_handle.hpp>
46 
48 #include <objects/seq/Seqdesc.hpp>
50 #include <objects/seq/Bioseq.hpp>
53 
56 
80 
81 #include <algorithm>
82 #include <functional>
83 
86 
88 {
90  switch( id.GetType() ) {
92  {
93  CSeq_id& seq_id = const_cast<CSeq_id&>(*id.GetSeqId().GetSeqId());
94  ret->SetBioseq_id(seq_id);
95  }
96  break;
99  break;
101  ret->SetUnique_num((CSeqEdit_Id_Base::TUnique_num)id.GetUniqNumber());
102  break;
103  default:
104  _ASSERT(0);
105  }
106  return ret;
107 }
108 
110  : m_Engine(&engine)
111 {
112 }
113 
115 {
116 }
117 
119 {
121 }
123 {
125 }
127 {
129 }
130 
131 template<int type>
133 
134 #define DEFCHOOSER(type, name) \
135 template<> \
136 struct STypeChooser<CSeqEdit_Cmd::e_##type> { \
137  typedef CSeqEdit_Cmd_##name TCommand; \
138  static inline TCommand& GetCommand(CSeqEdit_Cmd& cmd) \
139  { return cmd.Set##type(); } \
140 }
141 
142 DEFCHOOSER(Add_descr, AddDescr);
143 DEFCHOOSER(Set_descr, SetDescr);
144 DEFCHOOSER(Reset_descr, ResetDescr);
145 DEFCHOOSER(Add_desc, AddDesc);
146 DEFCHOOSER(Remove_desc, RemoveDesc);
147 DEFCHOOSER(Add_id, AddId);
148 DEFCHOOSER(Remove_id, RemoveId);
149 DEFCHOOSER(Reset_ids, ResetIds);
150 DEFCHOOSER(Change_seqattr, ChangeSeqAttr);
151 DEFCHOOSER(Reset_seqattr, ResetSeqAttr);
152 DEFCHOOSER(Change_setattr, ChangeSetAttr);
153 DEFCHOOSER(Reset_setattr, ResetSetAttr);
154 DEFCHOOSER(Attach_seq, AttachSeq);
155 DEFCHOOSER(Attach_set, AttachSet);
156 DEFCHOOSER(Reset_seqentry, ResetSeqEntry);
157 DEFCHOOSER(Attach_seqentry, AttachSeqEntry);
158 DEFCHOOSER(Remove_seqentry, RemoveSeqEntry);
159 DEFCHOOSER(Attach_annot, AttachAnnot);
160 DEFCHOOSER(Remove_annot, RemoveAnnot);
161 DEFCHOOSER(Add_annot, AddAnnot);
162 DEFCHOOSER(Replace_annot, ReplaceAnnot);
163 
164 #undef DEFCHOOSER
165 
166 
167 template<int type>
168 struct SCmdCreator
169 {
171  typedef typename TTypeChooser::TCommand TCommand;
172 
173  template<typename THandle>
174  static inline TCommand& CreateCmd(const THandle& handle,
175  CRef<CSeqEdit_Cmd>& holder)
176  {
177  holder.Reset(new CSeqEdit_Cmd(handle.GetTSE_Handle().
178  GetBlobId().ToString()));
179  TCommand& cmd = TTypeChooser::GetCommand(*holder);
180  cmd.SetId(*objects::s_Convert(handle.GetBioObjectId()));
181  return cmd;
182  }
183  template<typename THandle>
184  static inline TCommand& CreateCmd(const THandle& handle,
185  const CBioObjectId& id,
186  CRef<CSeqEdit_Cmd>& holder)
187  {
188  holder.Reset(new CSeqEdit_Cmd(handle.GetTSE_Handle().
189  GetBlobId().ToString()));
190  TCommand& cmd = TTypeChooser::GetCommand(*holder);
191  cmd.SetId(*objects::s_Convert(id));
192  return cmd;
193  }
194 
195 };
196 
197 
198 
199 template<typename THandle>
200 static inline void s_AddDescr(const THandle& handle, const CSeq_descr& descr,
201  IEditsDBEngine& engine)
202 {
205  .SetAdd_descr(const_cast<CSeq_descr&>(descr));
206  engine.SaveCommand(*cmd);
207 }
208 
210  const CSeq_descr& descr, ECallMode)
211 {
212  s_AddDescr(handle, descr, GetDBEngine());
213 }
214 
216  const CSeq_descr& descr, ECallMode)
217 {
218  s_AddDescr(handle, descr, GetDBEngine());
219 }
220 
221 
222 
223 template<typename THandle>
224 static inline void s_SetDescr(const THandle& handle, const CSeq_descr& descr,
225  IEditsDBEngine& engine)
226 {
229  .SetSet_descr(const_cast<CSeq_descr&>(descr));
230  engine.SaveCommand(*cmd);
231 }
232 
234  const CSeq_descr& descr, ECallMode)
235 {
236  s_SetDescr(handle, descr, GetDBEngine());
237 }
238 
240  const CSeq_descr& descr, ECallMode)
241 {
242  s_SetDescr(handle, descr, GetDBEngine());
243 }
244 
245 
246 
247 template<typename THandle>
248 static inline void s_ResetDescr(const THandle& handle,
249  IEditsDBEngine& engine)
250 {
253  engine.SaveCommand(*cmd);
254 }
255 
257 {
258  s_ResetDescr(handle, GetDBEngine());
259 }
260 
262 {
263  s_ResetDescr(handle, GetDBEngine());
264 }
265 
266 
267 
268 template<typename THandle>
269 static inline void s_AddDesc(const THandle& handle,
270  const CSeqdesc& desc,
271  IEditsDBEngine& engine)
272 {
275  SetAdd_desc(const_cast<CSeqdesc&>(desc));
276  engine.SaveCommand(*cmd);
277 }
278 
280  const CSeqdesc& desc, ECallMode)
281 {
282  s_AddDesc(handle, desc, GetDBEngine());
283 }
284 
286  const CSeqdesc& desc, ECallMode)
287 {
288  s_AddDesc(handle, desc, GetDBEngine());
289 }
290 
291 template<typename THandle>
292 static inline void s_RemoveDesc(const THandle& handle,
293  const CSeqdesc& desc,
294  IEditsDBEngine& engine)
295 {
298  SetRemove_desc(const_cast<CSeqdesc&>(desc));
299  engine.SaveCommand(*cmd);
300 }
301 
303  const CSeqdesc& desc, ECallMode)
304 {
305  s_RemoveDesc(handle, desc, GetDBEngine());
306 }
307 
309  const CSeqdesc& desc, ECallMode)
310 {
311  s_RemoveDesc(handle, desc, GetDBEngine());
312 }
313 
314 
315 //------------------------------------------------------------------
316 
317 template<int>
319 
320 #define DEFINSTCH(type) \
321 template<> \
322 struct SSeqAttrChanger<CSeqEdit_Cmd_ChangeSeqAttr::TData::e_##type> { \
323  typedef CSeqEdit_Cmd_ChangeSeqAttr::TData::T##type TParam; \
324  static inline void CreateCmd(const CBioseq_Handle& handle, \
325  const TParam& value, \
326  IEditsDBEngine& engine) \
327  { \
328  CRef<CSeqEdit_Cmd> cmd; \
329  CSeqEdit_Cmd_ChangeSeqAttr& c = \
330  SCmdCreator<CSeqEdit_Cmd::e_Change_seqattr>::CreateCmd(handle,cmd); \
331  c.SetData().Set##type(const_cast<TParam&>(value)); \
332  engine.SaveCommand(*cmd); \
333  } \
334 }
335 
336 DEFINSTCH(Inst);
337 DEFINSTCH(Repr);
339 DEFINSTCH(Length);
340 DEFINSTCH(Topology);
341 DEFINSTCH(Strand);
342 DEFINSTCH(Fuzz);
344 DEFINSTCH(Hist);
345 DEFINSTCH(Seq_data);
346 
347 #undef DEFINSTCH
348 
350  const CSeq_inst& value,
351  ECallMode)
352 {
354  CreateCmd(handle,value,GetDBEngine());
355 }
356 
359  ECallMode)
360 {
362  CreateCmd(handle,value,GetDBEngine());
363 }
364 
367  ECallMode)
368 {
370  CreateCmd(handle,value,GetDBEngine());
371 }
372 
375  ECallMode)
376 {
378  CreateCmd(handle,value,GetDBEngine());
379 }
380 
382  const CSeq_inst::TFuzz& value,
383  ECallMode)
384 {
386  CreateCmd(handle,value,GetDBEngine());
387 }
388 
391  ECallMode)
392 {
394  CreateCmd(handle,value,GetDBEngine());
395 }
396 
399  ECallMode)
400 {
402  CreateCmd(handle,value,GetDBEngine());
403 }
404 
406  const CSeq_inst::TExt& value,
407  ECallMode)
408 {
410  CreateCmd(handle,value,GetDBEngine());
411 }
412 
414  const CSeq_inst::THist& value,
415  ECallMode)
416 {
418  CreateCmd(handle,value,GetDBEngine());
419 }
420 
422  const CSeq_inst::TSeq_data& value,
423  ECallMode)
424 {
426  CreateCmd(handle,value,GetDBEngine());
427 }
428 
429 
430 static inline
431 void s_ResetSeqAttr(const CBioseq_Handle& handle,
433  IEditsDBEngine& engine)
434 {
437  SetWhat(what);
438  engine.SaveCommand(*cmd);
439 }
440 
442 {
444 }
445 
447 {
449 }
450 
452 {
454 }
455 
457 {
459 }
460 
462 {
464 }
465 
467 {
469 }
470 
472 {
474 }
475 
477 {
479 }
480 
482 {
484 }
485 
487 {
489 
490 }
491 
492 
493 //----------------------------------------------------------------
494 
495 void CEditsSaver::AddId(const CBioseq_Handle& handle,
496  const CSeq_id_Handle& id,
497  ECallMode)
498 {
499 
502  SetAdd_id(const_cast<CSeq_id&>(*id.GetSeqId()));
503  GetDBEngine().SaveCommand(*cmd);
504  GetDBEngine().NotifyIdChanged(id, cmd->GetBlobId());
505 }
506 
508  const CSeq_id_Handle& id,
509  ECallMode)
510 {
513  CBioObjectId(id),
514  cmd).
515  SetRemove_id(const_cast<CSeq_id&>(*id.GetSeqId()));
516  GetDBEngine().SaveCommand(*cmd);
517  GetDBEngine().NotifyIdChanged(id,"");
518 }
519 
520 static inline CRef<CSeq_id> s_ConvertId(const CSeq_id_Handle& handle)
521 {
522  return CRef<CSeq_id>(const_cast<CSeq_id*>(&*handle.GetSeqId()));
523 }
524 
526  const TIds& ids,
527  ECallMode)
528 {
529  if (ids.empty())
530  return;
533  TList& id_list =
535  CBioObjectId(*ids.begin()),
536  cmd)
537  .SetRemove_ids();
538  transform(ids.begin(), ids.end(), back_inserter(id_list), s_ConvertId);
539  GetDBEngine().SaveCommand(*cmd);
540  ITERATE(TIds, id, ids) {
541  GetDBEngine().NotifyIdChanged(*id,"");
542 ;
543  }
544 }
545 
546 
547 //-------------------------------------------------------
548 
549 template<int>
551 
552 #define DEFINSTCH(type) \
553 template<> \
554 struct SSetAttrChanger<CSeqEdit_Cmd_ChangeSetAttr::TData::e_##type> { \
555  typedef CSeqEdit_Cmd_ChangeSetAttr::TData::T##type TParam; \
556  static inline void CreateCmd(const CBioseq_set_Handle& handle, \
557  const TParam& value, \
558  IEditsDBEngine& engine) \
559  { \
560  CRef<CSeqEdit_Cmd> cmd; \
561  CSeqEdit_Cmd_ChangeSetAttr& c = \
562  SCmdCreator<CSeqEdit_Cmd::e_Change_setattr>::CreateCmd(handle,cmd); \
563  c.SetData().Set##type(const_cast<TParam&>(value)); \
564  engine.SaveCommand(*cmd); \
565  } \
566 }
567 
569 DEFINSTCH(Coll);
570 DEFINSTCH(Level);
571 DEFINSTCH(Class);
572 DEFINSTCH(Release);
574 
575 #undef DEFINSTCH
576 
578  const CBioseq_set::TId& value,
579  ECallMode)
580 {
582  CreateCmd(handle,value,GetDBEngine());
583 }
584 
586  const CBioseq_set::TColl& value,
587  ECallMode)
588 {
590  CreateCmd(handle,value,GetDBEngine());
591 }
592 
595  ECallMode)
596 {
598  CreateCmd(handle,value,GetDBEngine());
599 }
600 
603  ECallMode)
604 {
606  CreateCmd(handle,value,GetDBEngine());
607 }
608 
611  ECallMode)
612 {
614  CreateCmd(handle,value,GetDBEngine());
615 }
616 
618  const CBioseq_set::TDate& value,
619  ECallMode)
620 {
622  CreateCmd(handle,value,GetDBEngine());
623 }
624 
625 
626 static inline
627 void s_ResetSetAttr(const CBioseq_set_Handle& handle,
629  IEditsDBEngine& engine)
630 {
633  engine.SaveCommand(*cmd);
634 }
635 
637 {
639 }
640 
642 {
644 }
645 
647 {
649 }
650 
652 {
654 }
655 
657 {
659 }
660 
662 {
664 }
665 
666 
667 //-----------------------------------------------------------------
668 
670  const CSeq_entry_Handle& handle,
671  const CBioseq_Handle& bioseq,
672  ECallMode)
673 {
676  SetSeq(const_cast<CBioseq&>(*bioseq.GetCompleteBioseq()));
677  GetDBEngine().SaveCommand(*cmd);
678  ITERATE(CBioseq_Handle::TId, id, bioseq.GetId()) {
679  GetDBEngine().NotifyIdChanged(*id,cmd->GetBlobId());
680  }
681 }
682 
683 static void s_CollectSeqIds(const CSeq_entry& entry, IEditSaver::TIds& ids);
684 static void s_CollectSeqIds(const CBioseq_set& bset, IEditSaver::TIds& ids)
685 {
686  if (bset.IsSetSeq_set()) {
687  const CBioseq_set::TSeq_set& sset = bset.GetSeq_set();
688  ITERATE(CBioseq_set::TSeq_set, entry, sset) {
689  s_CollectSeqIds(**entry, ids);
690  }
691  }
692 }
693 
694 static void s_CollectSeqIds(const CSeq_entry& entry, IEditSaver::TIds& ids)
695 {
696  if (entry.IsSet())
697  s_CollectSeqIds(entry.GetSet(),ids);
698  else if (entry.IsSeq()) {
699  const CBioseq::TId& bids = entry.GetSeq().GetId();
700  ITERATE(CBioseq::TId, id, bids) {
702  }
703  }
704 }
705 
707  const CSeq_entry_Handle& handle,
708  const CBioseq_set_Handle& bioseq_set,
709  ECallMode)
710 {
712  const CBioseq_set& bset = *bioseq_set.GetCompleteBioseq_set();
714  SetSet(const_cast<CBioseq_set&>(bset));
715  GetDBEngine().SaveCommand(*cmd);
716  IEditSaver::TIds ids;
717  s_CollectSeqIds(bset,ids);
718  ITERATE(IEditSaver::TIds, id, ids) {
719  GetDBEngine().NotifyIdChanged(*id,cmd->GetBlobId());
720  }
721 
722 }
723 
725  const CBioseq_Handle& handle, ECallMode)
726 {
729  ::CreateCmd(entry, handle.GetBioObjectId(),cmd);
730  GetDBEngine().SaveCommand(*cmd);
731  ITERATE(CBioseq_Handle::TId, id, handle.GetId()) {
732  GetDBEngine().NotifyIdChanged(*id, "");
733  }
734 
735 }
736 
738  const CBioseq_set_Handle& handle, ECallMode)
739 {
741  const CBioseq_set& bset = *handle.GetCompleteBioseq_set();
743  ::CreateCmd(entry, handle.GetBioObjectId(),cmd);
744  GetDBEngine().SaveCommand(*cmd);
745  IEditSaver::TIds ids;
746  s_CollectSeqIds(bset,ids);
747  ITERATE(IEditSaver::TIds, id, ids) {
748  GetDBEngine().NotifyIdChanged(*id,"");
749  }
750 }
751 
753  const CSeq_annot_Handle& annot, ECallMode)
754 {
757  SetAnnot(const_cast<CSeq_annot&>(*annot.GetCompleteSeq_annot()));
758  GetDBEngine().SaveCommand(*cmd);
759 }
760 
762  const CSeq_entry_Handle& entry,
763  int index, ECallMode)
764 {
766  const CSeq_entry& sentry = *entry.GetCompleteSeq_entry();
769  if (entry.Which() != CSeq_entry::e_not_set)
770  c.SetSeq_entry(const_cast<CSeq_entry&>(sentry));
771  c.SetIndex(index);
772  GetDBEngine().SaveCommand(*cmd);
773  IEditSaver::TIds ids;
774  s_CollectSeqIds(sentry,ids);
775  ITERATE(IEditSaver::TIds, id, ids) {
776  GetDBEngine().NotifyIdChanged(*id,cmd->GetBlobId());
777  }
778 }
779 
781  const CSeq_entry_Handle& entry,
782  int, ECallMode)
783 {
785  const CSeq_entry& sentry = *entry.GetCompleteSeq_entry();
787  SetEntry_id(*s_Convert(entry.GetBioObjectId()));
788  GetDBEngine().SaveCommand(*cmd);
789  IEditSaver::TIds ids;
790  s_CollectSeqIds(sentry,ids);
791  ITERATE(IEditSaver::TIds, id, ids) {
792  GetDBEngine().NotifyIdChanged(*id,"");
793  }
794 }
795 /*
796 void CEditsSaver::RemoveTSE(const CTSE_Handle& handle,
797  ECallMode mode)
798 {
799  NCBI_THROW(CUnsupportedEditSaverException,
800  eUnsupported,
801  "RemoveTSE(const CTSE_Handle&, ECallMode)");
802 }
803 */
804 
805 
806 //-----------------------------------------------------------------
807 
808 template<int type>
811  typedef typename TCmdCreator::TCommand TCommand;
812 
813  static inline
814  TCommand& PrepareCmd(const CSeq_annot_Handle& annot,
816  {
817  const CSeq_entry_Handle& entry = annot.GetParentEntry();
818  return PrepareCmd(annot, entry, cmd);
819  }
820  static inline
821  TCommand& PrepareCmd(const CSeq_annot_Handle& annot,
822  const CSeq_entry_Handle& entry,
824  {
825  TCommand& c = TCmdCreator::CreateCmd(entry, entry.GetBioObjectId(), cmd);
826  if (annot.IsNamed()) {
827  c.SetNamed(true);
828  c.SetName(annot.GetName());
829  } else {
830  c.SetNamed(false);
831  }
832  return c;
833  }
834 };
835 
837  const CSeq_feat& old_value,
838  ECallMode)
839 {
840  const CSeq_annot_Handle& annot = handle.GetAnnot();
844  c.SetData().SetFeat().SetOvalue(const_cast<CSeq_feat&>(old_value));
845  c.SetData().SetFeat().SetNvalue(const_cast<CSeq_feat&>(*handle.GetSeq_feat()));
846  GetDBEngine().SaveCommand(*cmd);
847 
848 }
849 
851  const CSeq_align& old_value,
852  ECallMode)
853 {
854  const CSeq_annot_Handle& annot = handle.GetAnnot();
858  c.SetData().SetAlign().SetOvalue(const_cast<CSeq_align&>(old_value));
859  c.SetData().SetAlign().SetNvalue(const_cast<CSeq_align&>(*handle.GetSeq_align()));
860  GetDBEngine().SaveCommand(*cmd);
861 }
862 
864  const CSeq_graph& old_value,
865  ECallMode)
866 {
867  const CSeq_annot_Handle& annot = handle.GetAnnot();
871  c.SetData().SetGraph().SetOvalue(const_cast<CSeq_graph&>(old_value));
872  c.SetData().SetGraph().SetNvalue(const_cast<CSeq_graph&>(*handle.GetSeq_graph()));
873  GetDBEngine().SaveCommand(*cmd);
874 }
875 
876 
877 template<typename T>
879 
880 template<>
883  static const TCont& GetCont(const CSeq_annot& annot)
884  {
885  _ASSERT(annot.IsSetData() &&
887  return annot.GetData().GetFtable();
888  }
889  template<typename Holder>
890  static void Set(Holder& holder, CSeq_feat& feat) { holder.SetFeat(feat); }
891 };
892 
893 
894 template<>
897  static const TCont& GetCont(const CSeq_annot& annot)
898  {
899  _ASSERT(annot.IsSetData() &&
901  return annot.GetData().GetAlign();
902  }
903  template<typename Holder>
904  static void Set(Holder& holder, CSeq_align& align) { holder.SetAlign(align); }
905 };
906 
907 template<>
910  static const TCont& GetCont(const CSeq_annot& annot)
911  {
912  _ASSERT(annot.IsSetData() &&
914  return annot.GetData().GetGraph();
915  }
916  template<typename Holder>
917  static void Set(Holder& holder, CSeq_graph& graph) { holder.SetGraph(graph); }
918 };
919 
920 template<typename T> static inline
922  const CSeq_annot_Handle& handle)
923 {
924  typedef AnnotObjTrait<T> TAnnotObjTrait;
925  typedef typename TAnnotObjTrait::TCont TCont;
927  if (annot->IsSetData()) {
928  const TCont& cont = TAnnotObjTrait::GetCont(*annot);
929  if( cont.size() > 1 ) {
930  ITERATE(typename TCont, it, cont) {
931  if ( !(*it)->Equals(new_obj) ) {
932  T& obj = const_cast<T&>(**it);
933  TAnnotObjTrait::Set(cmd.SetSearch_param().SetObj(), obj);
934  return;
935  }
936  }
937  }
938  }
939  if (annot->IsSetDesc()) {
940  cmd.SetSearch_param()
941  .SetDescr(const_cast<CSeq_annot::TDesc&>(annot->GetDesc()));
942  }
943 }
944 
945 
946 template<typename T> static inline
947 void s_AddAnnot(const CSeq_annot_Handle& handle, const T& value,
948  IEditsDBEngine& engine)
949 {
953 
954  objects::s_SetSearchParam(c, value, handle);
955 
956  T& nc_value = const_cast<T&>(value);
957  AnnotObjTrait<T>::Set(c.SetData(), nc_value);
958 
959  engine.SaveCommand(*cmd);
960 }
961 
963  const CSeq_feat& value,
964  ECallMode)
965 {
966  s_AddAnnot(handle, value, GetDBEngine());
967 }
968 
970  const CSeq_align& value,
971  ECallMode)
972 {
973  s_AddAnnot(handle, value, GetDBEngine());
974 }
975 
977  const CSeq_graph& value,
978  ECallMode)
979 {
980  s_AddAnnot(handle, value, GetDBEngine());
981 }
982 
983 
984 template<typename T> static inline
986  const CSeq_annot_Handle& annot,
987  const T& old_value,
988  IEditsDBEngine& engine)
989 {
993 
994  T& nc_value = const_cast<T&>(old_value);
995  AnnotObjTrait<T>::Set(c.SetData(), nc_value);
996 
997  engine.SaveCommand(*cmd);
998 
999 
1000 }
1001 
1003  const CSeq_feat& old_value,
1004  ECallMode)
1005 {
1006  s_RemoveAnnot(handle.GetParentEntry(), handle, old_value, GetDBEngine());
1007 }
1008 
1010  const CSeq_align& old_value,
1011  ECallMode)
1012 {
1013  s_RemoveAnnot(handle.GetParentEntry(), handle, old_value, GetDBEngine());
1014 }
1015 
1017  const CSeq_graph& old_value,
1018  ECallMode)
1019 {
1020  s_RemoveAnnot(handle.GetParentEntry(), handle, old_value, GetDBEngine());
1021 }
1022 
1023 
1025  const CSeq_annot_Handle& annot,
1026  ECallMode)
1027 {
1029  switch (annots->GetData().Which()) {
1031  {
1032  const CSeq_annot::TData::TFtable& cont = annots->GetData().GetFtable();
1033  ITERATE(CSeq_annot::TData::TFtable, it, cont) {
1034  s_RemoveAnnot(entry, annot, **it, GetDBEngine());
1035  }
1036  }
1037  break;
1039  {
1040  const CSeq_annot::TData::TAlign& cont = annots->GetData().GetAlign();
1041  ITERATE(CSeq_annot::TData::TAlign, it, cont) {
1042  s_RemoveAnnot(entry, annot, **it, GetDBEngine());
1043  }
1044  }
1045  break;
1047  {
1048  const CSeq_annot::TData::TGraph& cont = annots->GetData().GetGraph();
1049  ITERATE(CSeq_annot::TData::TGraph, it, cont) {
1050  s_RemoveAnnot(entry, annot, **it, GetDBEngine());
1051  }
1052  break;
1053  }
1054  default:
1055  return;
1056  }
1057 }
1058 
1059 
virtual void AddId(const CBioseq_Handle &, const CSeq_id_Handle &, ECallMode)
ID operation.
void transform(Container &c, UnaryFunction *op)
Definition: chainer.hpp:85
virtual void ResetSeqInstSeq_data(const CBioseq_Handle &, ECallMode)
Definition: Date.hpp:52
bool IsNamed(void) const
CBioseq_Handle –.
virtual void ResetSeqInstTopology(const CBioseq_Handle &, ECallMode)
static void Set(Holder &holder, CSeq_align &align)
virtual void Detach(const CSeq_entry_Handle &entry, const CBioseq_Handle &what, ECallMode)
const CBioObjectId & GetBioObjectId(void) const
Get unique object id.
virtual void ResetSeqInstMol(const CBioseq_Handle &, ECallMode)
virtual void ResetBioseqSetRelease(const CBioseq_set_Handle &, ECallMode)
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
virtual void SetSeqInstTopology(const CBioseq_Handle &info, CSeq_inst::TTopology topology, ECallMode)
#define T(s)
Definition: common.h:225
CConstRef< CSeq_align > GetSeq_align(void) const
Get const reference to current seq-align.
virtual void Remove(const CSeq_entry_Handle &entry, const CSeq_annot_Handle &what, ECallMode)
User-defined methods of the data storage class.
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:73
CConstRef< CSeq_graph > GetSeq_graph(void) const
Get constant reference to the current seq-graph.
static const TCont & GetCont(const CSeq_annot &annot)
ECallMode
This flag can be used for optimization purpose.
Definition: edit_saver.hpp:76
virtual void RemoveDesc(const CBioseq_Handle &, const CSeqdesc &, ECallMode)
virtual void AddDesc(const CBioseq_Handle &, const CSeqdesc &, ECallMode)
IEditsDBEngine & GetDBEngine()
CConstRef< CBioseq_set > GetCompleteBioseq_set(void) const
Return the complete bioseq-set object.
static void s_RemoveDesc(const THandle &handle, const CSeqdesc &desc, IEditsDBEngine &engine)
static void Set(Holder &holder, CSeq_graph &graph)
virtual void ResetSeqInstFuzz(const CBioseq_Handle &, ECallMode)
User-defined methods of the data storage class.
SCmdCreator< type > TCmdCreator
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
CConstRef< CSeq_entry > GetCompleteSeq_entry(void) const
Complete and get const reference to the seq-entry.
virtual void NotifyIdChanged(const CSeq_id_Handle &id, const string &newblobid)=0
const CBioObjectId & GetBioObjectId(void) const
Get unique object id.
ERepr
representation class
Definition: Seq_inst_.hpp:91
static CRef< CSeq_id > s_ConvertId(const CSeq_id_Handle &handle)
CSeq_annot::TData::TFtable TCont
static void s_AddAnnot(const CSeq_annot_Handle &handle, const T &value, IEditsDBEngine &engine)
list< CRef< CSeq_graph > > TGraph
Definition: Seq_annot_.hpp:195
void SetData(TData &value)
Assign a value to Data data member.
CSeqEdit_Cmd_AddAnnot –.
const_iterator end() const
Definition: set.hpp:136
virtual void SetSeqInstRepr(const CBioseq_Handle &, CSeq_inst::TRepr, ECallMode)
list< CRef< CSeq_align > > TAlign
Definition: Seq_annot_.hpp:194
.hpp User-defined methods of the data storage class.
Definition: Seq_descr.hpp:54
static TCommand & PrepareCmd(const CSeq_annot_Handle &annot, CRef< CSeqEdit_Cmd > &cmd)
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_annot_.hpp:574
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:776
const TId & GetId(void) const
Get the Id member data.
Definition: Bioseq_.hpp:280
static void s_SetDescr(const THandle &handle, const CSeq_descr &descr, IEditsDBEngine &engine)
static CRef< CSeqEdit_Id > s_Convert(const CBioObjectId &id)
CEditsSaver(IEditsDBEngine &)
bool empty() const
Definition: set.hpp:133
User-defined methods of the data storage class.
static void s_AddDesc(const THandle &handle, const CSeqdesc &desc, IEditsDBEngine &engine)
bool IsSetSeq_set(void) const
Check if a value has been assigned to Seq_set data member.
CSeq_annot::TData::TGraph TCont
const TId & GetId(void) const
User-defined methods of the data storage class.
list< CRef< CSeq_entry > > TSeq_set
static const TCont & GetCont(const CSeq_annot &annot)
virtual void ResetSeqInst(const CBioseq_Handle &, ECallMode)
void SetIndex(TIndex value)
Assign a value to Index data member.
virtual void ResetSeqInstHist(const CBioseq_Handle &, ECallMode)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
virtual void SetBioseqSetColl(const CBioseq_set_Handle &, const CBioseq_set::TColl &, ECallMode)
User-defined methods of the data storage class.
static void s_SetSearchParam(CSeqEdit_Cmd_AddAnnot &cmd, const T &new_obj, const CSeq_annot_Handle &handle)
STypeChooser< type > TTypeChooser
const TSeq_set & GetSeq_set(void) const
Get the Seq_set member data.
User-defined methods of the data storage class.
const_iterator begin() const
Definition: set.hpp:135
virtual ~CEditsSaver()
User-defined methods of the data storage class.
const TSeq & GetSeq(void) const
Get the variant data.
Definition: Seq_entry_.cpp:102
CBioseq_set_Handle –.
static void Set(Holder &holder, CSeq_feat &feat)
virtual void ResetIds(const CBioseq_Handle &, const TIds &, ECallMode)
const TGraph & GetGraph(void) const
Get the variant data.
Definition: Seq_annot_.hpp:649
void SetSeq_entry(TSeq_entry &value)
Assign a value to Seq_entry data member.
User-defined methods of the data storage class.
virtual void SetSeqInstFuzz(const CBioseq_Handle &info, const CSeq_inst::TFuzz &fuzz, ECallMode)
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
Definition: Seq_annot_.hpp:842
virtual void SaveCommand(const CSeqEdit_Cmd &cmd)=0
static void s_CollectSeqIds(const CSeq_entry &entry, IEditSaver::TIds &ids)
static void s_ResetSetAttr(const CBioseq_set_Handle &handle, CSeqEdit_Cmd_ResetSetAttr::TWhat what, IEditsDBEngine &engine)
CSeq_annot::TData::TAlign TCont
static PyObject * Date(PyObject *self, PyObject *args)
const TDesc & GetDesc(void) const
Get the Desc member data.
Definition: Seq_annot_.hpp:833
virtual void SetBioseqSetDate(const CBioseq_set_Handle &, const CBioseq_set::TDate &, ECallMode)
virtual void BeginTransaction()
Called when a transaction has just been started.
virtual void ResetSeqInstStrand(const CBioseq_Handle &, ECallMode)
virtual void Attach(const CBioObjectId &old_id, const CSeq_entry_Handle &entry, const CBioseq_Handle &what, ECallMode)
virtual void ResetSeqInstExt(const CBioseq_Handle &, ECallMode)
User-defined methods of the data storage class.
User-defined methods of the data storage class.
ETopology
topology of molecule
Definition: Seq_inst_.hpp:121
CConstRef< CSeq_annot > GetCompleteSeq_annot(void) const
Complete and return const reference to the current seq-annot.
virtual void RollbackTransaction()=0
virtual void ResetSeqInstRepr(const CBioseq_Handle &, ECallMode)
virtual void SetBioseqSetLevel(const CBioseq_set_Handle &, CBioseq_set::TLevel, ECallMode)
CSeqEdit_Cmd_ReplaceAnnot –.
bool IsSet(void) const
Check if variant Set is selected.
Definition: Seq_entry_.hpp:263
virtual void SetBioseqSetId(const CBioseq_set_Handle &, const CBioseq_set::TId &, ECallMode)
#define DEFINSTCH(type)
TSeqPos TLength
Definition: Seq_inst_.hpp:147
TUnique_num & SetUnique_num(void)
Select the variant.
CSeq_annot_Handle –.
CSeq_ext –.
Definition: Seq_ext.hpp:65
CSeq_entry_Handle –.
EStrand
strandedness in living organism
Definition: Seq_inst_.hpp:133
User-defined methods of the data storage class.
virtual void ResetDescr(const CBioseq_Handle &, ECallMode)
static TCommand & PrepareCmd(const CSeq_annot_Handle &annot, const CSeq_entry_Handle &entry, CRef< CSeqEdit_Cmd > &cmd)
bool IsSeq(void) const
Check if variant Seq is selected.
Definition: Seq_entry_.hpp:257
virtual void ResetBioseqSetId(const CBioseq_set_Handle &, ECallMode)
list< CRef< CSeq_feat > > TFtable
Definition: Seq_annot_.hpp:193
const CSeq_annot_Handle & GetAnnot(void) const
Get handle to the seq-annot.
virtual void CommitTransaction()=0
EMol
molecule class in living organism
Definition: Seq_inst_.hpp:108
virtual void BeginTransaction()=0
const TFtable & GetFtable(void) const
Get the variant data.
Definition: Seq_annot_.hpp:609
virtual void SetSeqInstLength(const CBioseq_Handle &, CSeq_inst::TLength, ECallMode)
User-defined methods of the data storage class.
virtual void SetDescr(const CBioseq_Handle &, const CSeq_descr &, ECallMode)
char value[7]
Definition: config.c:428
virtual void SetBioseqSetClass(const CBioseq_set_Handle &, CBioseq_set::TClass, ECallMode)
TBioseqset_id & SetBioseqset_id(void)
Select the variant.
static const TCont & GetCont(const CSeq_annot &annot)
list< CRef< CSeq_id > > TRemove_ids
E_Choice Which(void) const
User-defined methods of the data storage class.
CConstRef< CSeq_id > GetSeqId(void) const
virtual void ResetBioseqSetClass(const CBioseq_set_Handle &, ECallMode)
#define DEFCHOOSER(type, name)
const TAlign & GetAlign(void) const
Get the variant data.
Definition: Seq_annot_.hpp:629
virtual void ResetBioseqSetColl(const CBioseq_set_Handle &, ECallMode)
static void s_AddDescr(const THandle &handle, const CSeq_descr &descr, IEditsDBEngine &engine)
virtual void SetSeqInstExt(const CBioseq_Handle &info, const CSeq_inst::TExt &ext, ECallMode)
User-defined methods of the data storage class.
CSeqEdit_Id –.
Definition: SeqEdit_Id.hpp:65
User-defined methods of the data storage class.
CSeq_entry_Handle GetParentEntry(void) const
Get parent Seq-entry handle.
CSeqEdit_Cmd_RemoveAnnot –.
CRef –.
Definition: ncbiobj.hpp:616
No variant selected.
Definition: Seq_entry_.hpp:88
static TCommand & CreateCmd(const THandle &handle, const CBioObjectId &id, CRef< CSeqEdit_Cmd > &holder)
virtual void ResetBioseqSetLevel(const CBioseq_set_Handle &, ECallMode)
Definition: Seq_entry.hpp:55
const TSet & GetSet(void) const
Get the variant data.
Definition: Seq_entry_.cpp:124
User-defined methods of the data storage class.
void SetData(TData &value)
Assign a value to Data data member.
virtual void SetBioseqSetRelease(const CBioseq_set_Handle &, const CBioseq_set::TRelease &, ECallMode)
static void s_ResetSeqAttr(const CBioseq_Handle &handle, CSeqEdit_Cmd_ResetSeqAttr::TWhat what, IEditsDBEngine &engine)
const CSeq_annot_Handle & GetAnnot(void) const
Get handle to seq-annot for this feature.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
virtual void ResetBioseqSetDate(const CBioseq_set_Handle &, ECallMode)
list< CRef< CSeq_id > > TId
Definition: Bioseq_.hpp:94
virtual void CommitTransaction()
Called when a transaction is finished.
CSeqEdit_Cmd_AttachSeqEntry –.
CSeq_hist –.
Definition: Seq_hist.hpp:65
virtual void Replace(const CSeq_feat_Handle &handle, const CSeq_feat &old_value, ECallMode)
#define _ASSERT
virtual void SetSeqInstMol(const CBioseq_Handle &, CSeq_inst::TMol, ECallMode)
virtual void SetSeqInstStrand(const CBioseq_Handle &info, CSeq_inst::TStrand strand, ECallMode)
User-defined methods of the data storage class.
virtual void SetSeqInstSeq_data(const CBioseq_Handle &info, const CSeq_inst::TSeq_data &data, ECallMode)
virtual void SetSeqInst(const CBioseq_Handle &, const CSeq_inst &, ECallMode)
CSeq_inst operatoions.
namespace ncbi::objects::
Definition: Seq_feat.hpp:56
bool IsSetDesc(void) const
used only for stand alone Seq-annots Check if a value has been assigned to Desc data member...
Definition: Seq_annot_.hpp:821
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:70
User-defined methods of the data storage class.
User-defined methods of the data storage class.
const string & GetBlobId() const
Definition: SeqEdit_Cmd.hpp:89
TTypeChooser::TCommand TCommand
TBioseq_id & SetBioseq_id(void)
Select the variant.
const CSeq_annot_Handle & GetAnnot(void) const
Get an annotation handle for the current seq-graph.
#define const
Definition: zconf.h:217
CSeq_feat_Handle –.
virtual void ResetSeqInstLength(const CBioseq_Handle &, ECallMode)
User-defined methods of the data storage class.
TCmdCreator::TCommand TCommand
User-defined methods of the data storage class.
virtual void AddDescr(const CBioseq_Handle &, const CSeq_descr &, ECallMode)
Description operations.
static void s_RemoveAnnot(const CSeq_entry_Handle &entry, const CSeq_annot_Handle &annot, const T &old_value, IEditsDBEngine &engine)
virtual void SetSeqInstHist(const CBioseq_Handle &info, const CSeq_inst::THist &hist, ECallMode)
virtual CConstRef< CSeq_feat > GetSeq_feat(void) const
virtual void RemoveId(const CBioseq_Handle &, const CSeq_id_Handle &, ECallMode)
const string & GetName(void) const
void SetSearch_param(TSearch_param &value)
Assign a value to Search_param data member.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_annot_.hpp:854
vector< CSeq_id_Handle > TId
Definition: Dbtag.hpp:52
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
virtual void RollbackTransaction()
Called when a transaction should be undone.
User-defined methods of the data storage class.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
virtual void Add(const CSeq_annot_Handle &handle, const CSeq_feat &obj, ECallMode)
void SetData(TData &value)
Assign a value to Data data member.
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:756
static TCommand & CreateCmd(const THandle &handle, CRef< CSeqEdit_Cmd > &holder)
const CBioObjectId & GetBioObjectId(void) const
Get unique object id.
static void s_ResetDescr(const THandle &handle, IEditsDBEngine &engine)
static char cmd[512]
Definition: bcp.c:20
Modified on Sun Jun 25 17:53:24 2017 by modify_doxy.py rev. 533848