A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/lds2__db_8cpp_source.html below:

NCBI C++ ToolKit: src/objtools/lds2/lds2_db.cpp Source File

43 #define NCBI_USE_ERRCODE_X Objtools_LDS2 79  "file_id integer primary key on conflict abort autoincrement," 80  "file_name text not null unique on conflict abort," 81  "file_format integer not null," 83  "file_size integer(8)," 84  "file_time integer(8)," 85  "file_crc integer(4));"

,

88  "create table chunk (" 89  "file_id integer(8) not null," 90  "raw_pos integer(8) not null," 91  "stream_pos integer(8) not null," 92  "data_size inteter not null," 93  "data blob default null);"

,

96  "create table seq_id (" 97  "lds_id integer primary key on conflict abort autoincrement," 98  "txt_id text not null," 99  "int_id integer(8) default null," 101  "blob_size integer(8)," 102  "blob_data blob not null);"

,

106  "create unique index if not exists idx_int_id on seq_id (int_id);"

,

107  "create unique index if not exists idx_txt_id on seq_id (txt_id);"

,

110  "create table bioseq (" 111  "bioseq_id integer primary key on conflict abort autoincrement," 112  "blob_id integer(8) not null);"

,

115  "create table bioseq_id (" 116  "bioseq_id integer(8) not null," 117  "lds_id integer(8) not null);"

,

120  "create table blob (" 121  "blob_id integer primary key on conflict abort autoincrement," 122  "blob_type integer not null," 123  "file_id integer(8) not null," 124  "file_pos integer(8));"

,

127  "create table annot (" 128  "annot_id integer primary key on conflict abort autoincrement," 129  "annot_type integer not null," 130  "blob_id integer(8) not null," 131  "annot_name text);"

,

134  "create table annot_id (" 135  "annot_id integer(8) not null," 136  "lds_id integer(8) not null," 138  "rg_from integer(8) not null," 139  "rg_to integer(8) not null);"

,

142  "create trigger delete_file before delete on file begin " 143  "delete from blob where blob.file_id=old.file_id;" 144  "delete from chunk where chunk.file_id=old.file_id;" 147  "create trigger delete_bioseq before delete on bioseq begin " 148  "delete from bioseq_id where bioseq_id.bioseq_id=old.bioseq_id;" 151  "create trigger delete_blob before delete on blob begin " 152  "delete from bioseq where bioseq.blob_id=old.blob_id;" 153  "delete from annot where annot.blob_id=old.blob_id;" 156  "create trigger delete_annot before delete on annot begin " 157  "delete from annot_id where annot_id.annot_id=old.annot_id;" 166  "create unique index if not exists idx_filename on file (file_name);"

,

170  "create index if not exists idx_stream_pos on chunk (stream_pos);"

,

174  "create index if not exists idx_blob_id on bioseq (blob_id);"

,

178  "create index if not exists idx_bioseq_id on bioseq_id (bioseq_id);"

,

180  "create index if not exists idx_bioseq_lds_id on bioseq_id (lds_id);"

,

183  "create index if not exists idx_orig_id on seq_id (orig);"

,

187  "create index if not exists idx_blob_file_id on blob (file_id);"

,

191  "create index if not exists idx_annot_blob_id on annot (blob_id);"

,

193  "create index if not exists idx_annot_name on annot (annot_name);"

,

197  "create index if not exists idx_annot_id on annot_id (annot_id);"

,

199  "create index if not exists idx_annot_lds_id on annot_id (lds_id);"

,

201  "create index if not exists idx_external on annot_id (external);" 203  "create index if not exists idx_annot_rg_from on annot_id (rg_from);" 204  "create index if not exists idx_annot_rg_to on annot_id (rg_to);" 210  "drop index if exists idx_filename;"

,

211  "drop index if exists idx_stream_pos;"

,

212  "drop index if exists idx_blob_id;"

,

213  "drop index if exists idx_bioseq_id;"

,

214  "drop index if exists idx_bioseq_lds_id;"

,

215  "drop index if exists idx_orig_id;"

,

216  "drop index if exists idx_blob_file_id;"

,

217  "drop index if exists idx_annot_blob_id;"

,

218  "drop index if exists idx_annot_name;"

,

219  "drop index if exists idx_annot_id;"

,

220  "drop index if exists idx_annot_lds_id;"

,

221  "drop index if exists idx_external;"

,

222  "drop index if exists idx_annot_rg_from;"

,

223  "drop index if exists idx_annot_rg_to;" 229  "select file_name from file;"

,

231  "select file_id, file_format, file_handler, file_size, " 232  "file_time, file_crc from file where file_name=?1;"

,

234  "select file_name, file_format, file_handler, file_size, " 235  "file_time, file_crc from file where file_id=?1;"

,

237  "select lds_id from seq_id where int_id=?1;"

,

239  "select lds_id from seq_id where txt_id=?1;"

,

241  "select bioseq_id.bioseq_id from seq_id " 242  "inner join bioseq_id using(lds_id) where seq_id.int_id=?1;"

,

244  "select bioseq_id.bioseq_id from seq_id " 245  "inner join bioseq_id using(lds_id) where seq_id.txt_id=?1;"

,

247  "select distinct lds_id from bioseq_id where bioseq_id=?1;"

,

249  "select blob_id, blob_type, file_id, file_pos " 250  "from blob where blob_id=?1;"

,

252  "select blob_id, blob_type, file_id, file_pos " 253  "from blob inner join bioseq using(blob_id) " 254  "inner join bioseq_id using(bioseq_id) " 255  "inner join seq_id using(lds_id) where seq_id.int_id=?1;"

,

257  "select blob_id, blob_type, file_id, file_pos " 258  "from blob inner join bioseq using(blob_id) " 259  "inner join bioseq_id using(bioseq_id) " 260  "inner join seq_id using(lds_id) where seq_id.txt_id=?1;"

,

262  "select blob_id, blob_type, file_id, file_pos " 263  "from blob inner join annot using(blob_id) " 264  "inner join annot_id using(annot_id) " 265  "inner join seq_id using(lds_id) where " 266  "annot_id.external=?2 and seq_id.int_id=?1;"

,

268  "select blob_id, blob_type, file_id, file_pos " 269  "from blob inner join annot using(blob_id) " 270  "inner join annot_id using(annot_id) " 271  "inner join seq_id using(lds_id) where " 272  "seq_id.int_id=?1;"

,

274  "select blob_id, blob_type, file_id, file_pos " 275  "from blob inner join annot using(blob_id) " 276  "inner join annot_id using(annot_id) " 277  "inner join seq_id using(lds_id) where " 278  "annot_id.external=?2 and seq_id.txt_id=?1;"

,

280  "select blob_id, blob_type, file_id, file_pos " 281  "from blob inner join annot using(blob_id) " 282  "inner join annot_id using(annot_id) " 283  "inner join seq_id using(lds_id) where " 284  "seq_id.txt_id=?1;"

,

286  "select count(annot_id) from annot where blob_id=?1;"

,

288  "select annot.annot_id, annot_type, annot_name not null as is_named, " 289  " annot_name, lds_id, external, rg_from, rg_to, blob_size, blob_data " 290  "from annot inner join annot_id using (annot_id) " 291  "inner join seq_id using(lds_id) where " 292  "annot.blob_id=?1;"

,

296  "(file_name, file_format, file_handler, file_size, " 297  "file_time, file_crc) values (?1, ?2, ?3, ?4, ?5, ?6);"

,

299  "insert into seq_id (txt_id, int_id, orig, blob_size, blob_data) " 300  "values (?1, ?2, ?3, ?4, ?5);"

,

302  "insert into blob (blob_type, file_id, file_pos) " 303  "values (?1, ?2, ?3);"

,

305  "insert into bioseq (blob_id) values (?1);"

,

307  "insert into bioseq_id (bioseq_id, lds_id) values (?1, ?2);"

,

309  "insert into annot (annot_type, blob_id, annot_name) " 310  "values (?1, ?2, ?3);"

,

312  "insert into annot_id (annot_id, lds_id, external, rg_from, rg_to) " 313  "values (?1, ?2, ?3, ?4, ?5);"

,

315  "delete from file where file_name=?1;"

,

317  "delete from file where file_id=?1;"

,

321  "(file_id, raw_pos, stream_pos, data_size, data) " 322  "values (?1, ?2, ?3, ?4, ?5);"

,

324  "select raw_pos, stream_pos, data_size, data from chunk " 325  "where file_id=?1 and stream_pos<=?2 order by stream_pos desc " 329  "select blob_size, blob_data from seq_id where lds_id=?1;"

,

331  "select blob_size, blob_data from seq_id inner join bioseq_id " 332  "using(lds_id) where orig=?1 and bioseq_id=?2;" 356

db_conn = conn_ptr.get();

357

tls->SetValue(conn_ptr.release(), CTlsBase::DefaultCleanup<SLDS2_DbConnection>);

372

LDS2_SQLITE_CACHE_SIZE);

381  LDS2_THROW

(eInvalidDbFile,

"Empty database file name."

);

395  unsigned int

cache_size = (

unsigned int

)TSQLiteCacheSize::GetDefault();

396

db_conn.

Connection

->SetCacheSize(cache_size);

407  if

( !ptr.

get

() ) {

422  for

(

size_t i

= 0;

i

<

len

;

i

++) {

423  conn

.ExecuteSql(sqls[

i

]);

475  while

(

st

.Step() ) {

487  st

.Bind(2,

info

.format);

488  st

.Bind(3,

info

.handler);

493  info

.id =

st

.GetLastInsertedRowid();

520  st

.Bind(1, file_id);

538  st

->Bind(1,

id

.AsString());

541  Int8

ret =

st

->GetInt8(0);

548  st

->Bind(1,

id

.AsString());

554  st

->Bind(2, (

void

*)

NULL

, 0);

561  st

->Bind(4,

buf

.size());

562  st

->Bind(5,

buf

.data(),

buf

.size());

565  Int8

ret =

st

->GetLastInsertedRowid();

576  st

.Bind(1, blob_type);

577  st

.Bind(2, file_id);

578  st

.Bind(3, file_pos);

580  Int8

blob_id =

st

.GetLastInsertedRowid();

595  id

->GetSeqId()->GetMatchingIds(matches);

604

st1.

Bind

(1, blob_id);

612

st2.

Bind

(1, bioseq_id);

613

st2.

Bind

(2, *lds_id);

643

st2.

Bind

(1, annot.

id

);

644

st2.

Bind

(2, lds_id);

645

st2.

Bind

(3, ref_id->second.external);

646

st2.

Bind

(4, ref_id->second.range.GetFrom());

647

st2.

Bind

(5, ref_id->second.range.GetToOpen());

659  if

( idh.

IsGi

() ) {

673

bioseq_id =

st

->GetInt8(0);

686  if

(bioseq_id <= 0) {

691  st

.Bind(1, bioseq_id);

692  while

(

st

.Step() ) {

702  if

(bioseq_id <= 0) {

708  st

.Bind(2, bioseq_id);

709  while

(

st

.Step() ) {

723  if

( idh.

IsGi

() ) {

739  if

( !

st

.Step() ) {

744  info

.id =

st

.GetInt8(0);

746  info

.file_id =

st

.GetInt8(2);

747  info

.file_pos =

st

.GetInt8(3);

765  st

.Bind(1, blob_id);

766  if

( !

st

.Step() ) {

769  info

.id =

st

.GetInt8(0);

771  info

.file_id =

st

.GetInt8(2);

772  info

.file_pos =

st

.GetInt8(3);

786  info

.id =

st

.GetInt8(0);

788  info

.handler =

st

.GetString(2);

789  info

.size =

st

.GetInt8(3);

790  info

.time =

st

.GetInt8(4);

791  info

.crc =

st

.GetInt(5);

805  st

.Bind(1, file_id);

808  info

.name =

st

.GetString(0);

810  info

.handler =

st

.GetString(2);

811  info

.size =

st

.GetInt8(3);

812  info

.time =

st

.GetInt8(4);

813  info

.crc =

st

.GetInt(5);

824  while

(

st

.Step() ) {

826  info

.id =

st

.GetInt8(0);

828  info

.file_id =

st

.GetInt8(2);

829  info

.file_pos =

st

.GetInt8(3);

830

blobs.push_back(

info

);

841  if

( idh.

IsGi

() ) {

856  while

(

st

->Step() ) {

858  info

.id =

st

->GetInt8(0);

860  info

.file_id =

st

->GetInt8(2);

861  info

.file_pos =

st

->GetInt8(3);

862

blobs.push_back(

info

);

874  st

.Bind(1, blob_id);

875  if

( !

st

.Step() ) {

895  st

.Bind(1, blob_id);

896

unique_ptr<SLDS2_Annot> annot;

897  while

(

st

.Step() ) {

898  Int8

annot_id =

st

.GetInt8(0);

899  if

(!annot.get() || annot_id != annot->id) {

902

infos.push_back(annot.release());

905

annot->id = annot_id;

906

annot->blob_id = blob_id;

908

annot->is_named =

st

.GetInt(2) != 0;

909

annot->name =

st

.GetString(3);

913  Int8

lds_id =

st

.GetInt8(4);

916  if

(found != ids.

end

()) {

929  _ASSERT

(annot->ref_ids.find(idh) == annot->ref_ids.end());

930

annot->ref_ids[idh] = id_info;

933

infos.push_back(annot.release());

943  st

.Bind(1, file_info.

id

);

958  st

.Bind(1, file_info.

id

);

959  st

.Bind(2, stream_pos);

960  if

( !

st

.Step() ) {

983  size_t

sz =

st

.GetInt(size_idx);

987  st

.GetBlob(data_idx,

data

.get(), sz);

988  string

sdata(

data

.get(), sz);

1001  st

.Bind(1, lds_id);

1013  conn

.ExecuteSql(

"begin transaction;"

);

1024  conn

.ExecuteSql(

"end transaction;"

);

1035  conn

.ExecuteSql(

"analyze;"

);

1056  "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'"

;

1062

vector<string> tables;

1065  while

(

st

.Step() ) {

1066

tables.push_back(

st

.GetString(0));

1070

tables.push_back(

table

);

1073  if

(

table

.empty() ) {

1075  out

<<

"LDS2 table names:"

<< endl;

1076  ITERATE

(vector<string>, it, tables) {

1083  ITERATE

(vector<string>, it, tables) {

1086  for

(

int i

= 0;

i

<

st

.GetColumnsCount();

i

++) {

1090  out

<<

st

.GetColumnName(

i

);

1093  while

(

st

.Step() ) {

1094  for

(

int i

= 0;

i

<

st

.GetColumnsCount();

i

++) {

Int8 AddAnnot(SLDS2_Annot &annot)

Add annotation, return the new annot id.

void Analyze(void)

Analyze the DB.

Int8 AddBlob(Int8 file_id, SLDS2_Blob::EBlobType blob_type, Int8 file_pos)

Add blob, return the new blob id.

void GetAnnots(Int8 blob_id, TLDS2Annots &infos)

Get details about all annotations from a blob.

void SetAccessMode(EAccessMode mode)

Set new access mode, re-open the database.

void SetSQLiteFlags(int flags)

Set SQLite flags. This funtion resets the db connection.

void GetAnnotBlobs(const CSeq_id_Handle &idh, TAnnotChoice choice, TBlobSet &blobs)

Get all blobs, containing annotations for the seq-id.

void x_ExecuteSqls(const char *sqls[], size_t len)

void GetFileNames(TStringSet &files) const

Get all known file names.

void Dump(const string &table, CNcbiOstream &out)

Dump the selected table (use empty string to dump table names or * to dump all tables.

void Open(EAccessMode mode=eWrite)

Open LDS2 database. If the database does not exist, throws exception.

vector< CSeq_id_Handle > TSeqIds

List of seq-ids.

CRef< CSeq_id > GetSeq_idForLdsSeqId(int lds_id)

Get seq-id for the given lds-id.

vector< SLDS2_Blob > TBlobSet

A set of ids (file_id, blob_id etc.).

void GetBioseqBlobs(const CSeq_id_Handle &idh, TBlobSet &blobs)

Get all blobs, containing bioseqs with the seq-id.

Int8 x_GetLdsSeqId(const CSeq_id_Handle &id, EIdType id_type)

void AddFile(SLDS2_File &info)

Add new file record. On success file_info.id is not zero.

void BeginRead(void)

Start reading transaction, lock the db.

CSQLITE_Statement & x_GetStatement(EStatement st) const

void EndRead(void)

End reading transaction, release the lock.

@ fAnnot_External

Annots from blobs not containing the bioseq.

Int8 GetAnnotCountForBlob(Int8 blob_id)

Get number of annotations grouped into a single blob.

void x_ResetDbConnection(void)

SLDS2_DbConnection & x_GetDbConnection(void) const

SLDS2_Blob GetBlobInfo(const CSeq_id_Handle &idh)

Find blob containing the requested bioseq.

@ eSt_GetLdsSeqIdForIntId

@ eSt_GetAnnotBlobsAllByTxtId

@ eSt_GetLdsSeqIdForTxtId

@ eSt_GetAnnotBlobsByIntId

@ eSt_GetSeq_idForLdsSeqId

@ eSt_GetAnnotInfosForBlob

@ eSt_GetBioseqIdForIntId

@ eSt_GetBioseqIdForTxtId

@ eSt_GetAnnotBlobsByTxtId

@ eSt_GetAnnotCountForBlob

@ eSt_GetAnnotBlobsAllByIntId

CSQLITE_Connection & x_GetConn(void) const

CSQLITE_Statement & x_InitGetBioseqsSql(const CSeq_id_Handle &idh) const

void BeginUpdate(void)

Start update transaction.

EAccessMode

Database access mode flags.

@ eWrite

Read/write access.

@ eRead

Read-only access.

@ eMemory

Copy db to memory and open read-only.

void GetSynonyms(const CSeq_id_Handle &idh, TLdsIdSet &ids)

Get all lds-id synonyms for the seq-id (including lds-id for the seq-id itself).

vector< AutoPtr< SLDS2_Annot > > TLDS2Annots

CRef< CSeq_id > x_BlobToSeq_id(CSQLITE_Statement &st, int size_idx, int data_idx) const

void DeleteFile(const string &file_name)

Delete file and all related entries from the database.

CRef< TDbConnectionsTls > m_DbConn

void UpdateFile(SLDS2_File &info)

Update info for the known file. The 'id' of the info will change.

Int8 GetBioseqId(const CSeq_id_Handle &idh) const

Check if the db contains a bioseq with the given id.

void AddChunk(const SLDS2_File &file_info, const SLDS2_Chunk &chunk_info)

Store the chunk info in the database.

void Create(void)

Create the database.

void EndUpdate(void)

End update transaction, commit the changes.

SLDS2_File GetFileInfo(const string &file_name) const

Get complete file info.

Int8 AddBioseq(Int8 blob_id, const TSeqIdSet &ids)

Add bioseq, return the new bioseq id.

bool FindChunk(const SLDS2_File &file_info, SLDS2_Chunk &chunk_info, Int8 stream_pos)

Load chunk containing the required stream position.

CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:

Connection to SQLite database.

@ fReadOnly

The DB is read-only. Also forces fVacuumOff flag.

static CSQLITE_Connection * CreateInMemoryDatabase(CTempString file_name, bool shared=false)

Create a read-only copy of the database in memory.

void ExecuteSql(CTempString sql)

Execute sql statement without returning any results.

SQL statement executing on SQLite database.

void Bind(int index, int val)

Bind integer value to parameter index.

void Reset(void)

Reset the statement to release all locks and to be ready to execute again.

Int8 GetLastInsertedRowid(void) const

Get rowid of the row inserted in last statement execution.

void BindNull(int index)

Bind null value to parameter index.

void Execute(void)

Execute statement without returning any result.

container_type::iterator iterator

const_iterator end() const

const_iterator find(const key_type &key) const

iterator_bool insert(const value_type &val)

std::ofstream out("events_result.xml")

main entry point for tests

static CS_CONNECTION * conn

void reset(element_type *p=0, EOwnership ownership=eTakeOwnership)

Reset will delete the old pointer (if owned), set content to the new value, and assume the ownership ...

#define ITERATE(Type, Var, Cont)

ITERATE macro to sequence through container elements.

element_type * get(void) const

Get pointer.

#define NON_CONST_ITERATE(Type, Var, Cont)

Non constant version of ITERATE macro.

#define LOG_POST_X(err_subcode, message)

void Info(CExceptionArgs_Base &args)

virtual bool Remove(TRemoveFlags flags=eRecursive) const

Remove a directory entry.

virtual bool Exists(void) const

Check existence of file.

#define MSerial_AsnBinary

static CSeq_id_Handle GetHandle(const CSeq_id &id)

Normal way of getting a handle, works for any seq-id.

string AsString(void) const

void Reset(void)

Reset reference object.

@ eParam_NoThread

Do not use per-thread values.

int64_t Int8

8-byte (64-bit) signed integer

TThisType & SetOpen(position_type from, position_type toOpen)

#define END_NCBI_SCOPE

End previously defined NCBI scope.

#define END_SCOPE(ns)

End the previously defined scope.

#define BEGIN_NCBI_SCOPE

Define ncbi namespace.

#define BEGIN_SCOPE(ns)

Define a new scope.

IO_PREFIX::ostream CNcbiOstream

Portable alias for ostream.

static string PrintableString(const CTempString str, TPrintableMode mode=fNewLine_Quote|fNonAscii_Passthru)

Get a printable version of the specified string.

unsigned int

A callback function used to compare two keys in a database.

<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table

static const char * s_LDS2_SQL[]

const char * kLDS2_CreateDBIdx[]

NCBI_PARAM_DEF_EX(int, LDS2, SQLiteCacheSize, 2000, eParam_NoThread, LDS2_SQLITE_CACHE_SIZE)

NCBI_PARAM_DECL(int, LDS2, SQLiteCacheSize)

const char * kLDS2_ListTables

const CSQLITE_Connection::TOperationFlags kDefaultLDS2DBFlags

const char * kLDS2_DumpTable

const char * kLDS2_CreateDB[]

typedef NCBI_PARAM_TYPE(LDS2, SQLiteCacheSize) TSQLiteCacheSize

const char * kLDS2_DropDBIdx[]

#define LDS2_THROW(errcode, message)

Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...

NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.

std::istream & in(std::istream &in_, double &x_)

static int match(PCRE2_SPTR start_eptr, PCRE2_SPTR start_ecode, uint16_t top_bracket, PCRE2_SIZE frame_size, pcre2_match_data *match_data, match_block *mb)

static SLJIT_INLINE sljit_ins st(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)

unique_ptr< CSQLITE_Connection > Connection

Info about seq-id used in an annotation.

EBlobType

Top-level object types.

Int8 stream_pos

Chunk position in the processed (e.g. unzipped) stream.

size_t data_size

Extra data size.

void * data

Extra data required to load the chunk.

Int8 raw_pos

Chunk position in the raw file.

CFormatGuess::EFormat TFormat


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4