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

Go to the SVN repository for this file.

1 /* $Id: sample_saver.cpp 90055 2020-05-06 18:48:03Z ivanov@NCBI.NLM.NIH.GOV $
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 #include <corelib/ncbifile.hpp>
34 
38 #include <objmgr/data_loader.hpp>
39 
40 #include <serial/objostr.hpp>
41 #include <serial/serial.hpp>
42 
43 
44 #include "sample_saver.hpp"
45 
46 //#include <fstream>
47 
50 
52  : m_AsnDBGuard(new CAsnDB(db_path)), m_AsnDB(*m_AsnDBGuard)
53 {
54 }
56  : m_AsnDB(db)
57 
58 {
59 }
60 
62 {
63 }
64 
65 
67 {
68  x_CleanUp();
69 }
71 {
73  for (it = m_Blobs.begin(); it != m_Blobs.end(); ++it) {
74  const CBlobIdKey& id = it->first;
75  const TBioseqCont& cont = it->second;
77  for (bit = cont.begin(); bit != cont.end(); ++bit) {
78  const CBioseq_Handle& bh = *bit;
80  m_AsnDB.Save(id.ToString(), *bioseq);
81  }
82  }
84  for( itt = m_TSEs.begin(); itt != m_TSEs.end(); ++itt) {
85  const CSeq_entry_Handle& sh = *itt;
88  m_AsnDB.SaveTSE(id.ToString(), *entry);
89  }
90 
91  x_CleanUp();
92 }
94 {
95  x_CleanUp();
96 }
97 
100 {
101  CSeq_entry_Handle entry = handle.GetParentEntry();
102  CBlobIdKey id = entry.GetTSE_Handle().GetBlobId();
103  TBioseqCont& bioseqs = m_Blobs[id];
104  bioseqs.insert(handle);
105 }
106 
107 
110 {
111  m_TSEs.insert(handle);
112 }
113 
114 
116 {
117  m_Blobs.clear();
118  m_TSEs.clear();
119 }
120 
121 
CBioseq_Handle –.
virtual void UpdateTSE(const CSeq_entry_Handle &handle, IEditSaver::ECallMode mode)
CSampleEditSaver(const string &dbpath)
virtual void CommitTransaction()
virtual void UpdateSeq(const CBioseq_Handle &handle, IEditSaver::ECallMode mode)
virtual void BeginTransaction()
virtual ~CSampleEditSaver()
virtual void RollbackTransaction()
CSeq_entry_Handle –.
TBlobId GetBlobId(void) const
Definition: tse_handle.cpp:122
ECallMode
This flag can be used for optimization purpose.
Definition: edit_saver.hpp:76
const_iterator begin() const
Definition: map.hpp:151
const_iterator end() const
Definition: map.hpp:152
void clear()
Definition: map.hpp:169
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator begin() const
Definition: set.hpp:135
void clear()
Definition: set.hpp:153
const_iterator end() const
Definition: set.hpp:136
parent_type::const_iterator const_iterator
Definition: set.hpp:79
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
CSeq_entry_Handle GetParentEntry(void) const
Get parent Seq-entry handle.
const CTSE_Handle & GetTSE_Handle(void) const
CConstRef< CSeq_entry > GetCompleteSeq_entry(void) const
Complete and get const reference to the seq-entry.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
mdb_mode_t mode
Definition: lmdb++.h:38
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
string ToString(const wxRect &rc)
Definition: wx_utils.cpp:773
#define const
Definition: zconf.h:230
Modified on Fri Dec 01 04:43:38 2023 by modify_doxy.py rev. 669887