Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
812e856c
Verified
Commit
812e856c
authored
1 year ago
by
Xavier Robin
Browse files
Options
Downloads
Patches
Plain Diff
refactor: explicitly drop pre-1.5.0 compound libs
parent
ee7f24e8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/conop/doc/compoundlib.rst
+6
-6
6 additions, 6 deletions
modules/conop/doc/compoundlib.rst
modules/conop/src/compound_lib.cc
+25
-58
25 additions, 58 deletions
modules/conop/src/compound_lib.cc
modules/conop/src/compound_lib.hh
+2
-5
2 additions, 5 deletions
modules/conop/src/compound_lib.hh
with
33 additions
and
69 deletions
modules/conop/doc/compoundlib.rst
+
6
−
6
View file @
812e856c
...
...
@@ -11,13 +11,13 @@ information for the :class:`rule-based processor <RuleBasedBuilder>`.
The compound definitions for standard PDB files are taken from the
components.cif dictionary provided by the PDB. The dictionary is updated with
every PDB release and augmented with the compound definitions of newly
crystallized compounds.
If you downloaded the bundle, a recent version of the compound library is
already included. If you are compiling from source or want to incorporate the
latest compound definitions, follow :ref:`these instructions <mmcif-convert>` to
build the compound library manually.
crystallized compounds. Follow :ref:`these instructions <mmcif-convert>` to
build the compound library.
In general, compound libraries built with older versions of OST are compatible
with newer version of OST, so it may not be necessary to rebuild a new one.
However, some functionality may not be available. Currently, compound libraries
built with OST 1.5.0 or later can be loaded.
.. function:: GetDefaultLib()
...
...
This diff is collapsed.
Click to expand it.
modules/conop/src/compound_lib.cc
+
25
−
58
View file @
812e856c
...
...
@@ -36,6 +36,11 @@ namespace ost { namespace conop {
namespace
{
/*
This is the oldest version (GetCreationDate) of compound libraries we support.
*/
const
String
COMPAT_VERSION
=
"1.5.0"
;
/*
COMMENT ON CREATE_CMD
...
...
@@ -390,27 +395,9 @@ CompoundLibPtr CompoundLib::Load(const String& database, bool readonly)
LOG_ERROR
(
sqlite3_errmsg
(
lib
->
db_
->
ptr
));
return
CompoundLibPtr
();
}
// check if column chem_type exists in database
String
aq
=
"SELECT chem_type FROM chem_compounds LIMIT 1"
;
String
aq
;
sqlite3_stmt
*
stmt
;
retval
=
sqlite3_prepare_v2
(
lib
->
db_
->
ptr
,
aq
.
c_str
(),
static_cast
<
int
>
(
aq
.
length
()),
&
stmt
,
NULL
);
lib
->
chem_type_available_
=
retval
==
SQLITE_OK
;
sqlite3_finalize
(
stmt
);
aq
=
"SELECT name FROM chem_compounds LIMIT 1"
;
retval
=
sqlite3_prepare_v2
(
lib
->
db_
->
ptr
,
aq
.
c_str
(),
static_cast
<
int
>
(
aq
.
length
()),
&
stmt
,
NULL
);
lib
->
name_available_
=
retval
==
SQLITE_OK
;
sqlite3_finalize
(
stmt
);
// check if InChIs are available
aq
=
"SELECT inchi_code FROM chem_compounds LIMIT 1"
;
retval
=
sqlite3_prepare_v2
(
lib
->
db_
->
ptr
,
aq
.
c_str
(),
static_cast
<
int
>
(
aq
.
length
()),
&
stmt
,
NULL
);
lib
->
inchi_available_
=
retval
==
SQLITE_OK
;
sqlite3_finalize
(
stmt
);
std
::
stringstream
ss
;
// check if SMILES are available
aq
=
"SELECT smiles FROM chem_compounds LIMIT 1"
;
retval
=
sqlite3_prepare_v2
(
lib
->
db_
->
ptr
,
aq
.
c_str
(),
...
...
@@ -429,6 +416,13 @@ CompoundLibPtr CompoundLib::Load(const String& database, bool readonly)
lib
->
creation_date_
=
lib
->
GetCreationDate
();
lib
->
ost_version_used_
=
lib
->
GetOSTVersionUsed
();
if
(
lib
->
ost_version_used_
.
compare
(
COMPAT_VERSION
)
<
0
)
{
ss
<<
"Compound lib was created with an unsupported version of OST: "
<<
lib
->
ost_version_used_
<<
". Please update your compound library."
;
throw
ost
::
Error
(
ss
.
str
());
}
return
lib
;
}
...
...
@@ -498,23 +492,7 @@ CompoundPtr CompoundLib::FindCompound(const String& id,
if
(
i
!=
compound_cache_
.
end
())
{
return
i
->
second
;
}
String
query
=
"SELECT id, tlc, olc, chem_class, dialect, formula"
;
int
col_offset_inchi
=
0
;
int
col_offset_smiles
=
0
;
if
(
chem_type_available_
)
{
query
+=
", chem_type"
;
col_offset_inchi
+=
1
;
col_offset_smiles
+=
1
;
if
(
name_available_
)
{
query
+=
", name"
;
col_offset_inchi
+=
1
;
col_offset_smiles
+=
1
;
}
}
if
(
inchi_available_
)
{
query
+=
", inchi_code, inchi_key"
;
col_offset_smiles
+=
2
;
}
String
query
=
"SELECT id, tlc, olc, chem_class, dialect, formula, chem_type, name, inchi_code, inchi_key"
;
if
(
smiles_available_
)
{
query
+=
", smiles"
;
}
...
...
@@ -540,27 +518,19 @@ CompoundPtr CompoundLib::FindCompound(const String& id,
compound
->
SetDialect
(
Compound
::
Dialect
(
sqlite3_column_text
(
stmt
,
4
)[
0
]));
const
char
*
f
=
reinterpret_cast
<
const
char
*>
(
sqlite3_column_text
(
stmt
,
5
));
compound
->
SetFormula
(
f
);
if
(
chem_type_available_
)
{
compound
->
SetChemType
(
mol
::
ChemType
(
sqlite3_column_text
(
stmt
,
6
)[
0
]));
}
if
(
name_available_
)
{
const
char
*
name
=
reinterpret_cast
<
const
char
*>
(
sqlite3_column_text
(
stmt
,
7
));
if
(
name
)
{
compound
->
SetName
(
name
);
}
compound
->
SetChemType
(
mol
::
ChemType
(
sqlite3_column_text
(
stmt
,
6
)[
0
]));
const
char
*
name
=
reinterpret_cast
<
const
char
*>
(
sqlite3_column_text
(
stmt
,
7
));
compound
->
SetName
(
name
);
const
char
*
inchi_code
=
reinterpret_cast
<
const
char
*>
(
sqlite3_column_text
(
stmt
,
8
));
if
(
inchi_code
)
{
compound
->
SetInchi
(
inchi_code
);
}
if
(
inchi_available_
)
{
const
char
*
inchi_code
=
reinterpret_cast
<
const
char
*>
(
sqlite3_column_text
(
stmt
,
6
+
col_offset_inchi
));
if
(
inchi_code
)
{
compound
->
SetInchi
(
inchi_code
);
}
const
char
*
inchi_key
=
reinterpret_cast
<
const
char
*>
(
sqlite3_column_text
(
stmt
,
6
+
col_offset_inchi
+
1
));
if
(
inchi_key
)
{
compound
->
SetInchiKey
(
inchi_key
);
}
const
char
*
inchi_key
=
reinterpret_cast
<
const
char
*>
(
sqlite3_column_text
(
stmt
,
9
));
if
(
inchi_key
)
{
compound
->
SetInchiKey
(
inchi_key
);
}
if
(
smiles_available_
)
{
const
char
*
smiles
=
reinterpret_cast
<
const
char
*>
(
sqlite3_column_text
(
stmt
,
6
+
col_offset_smiles
));
const
char
*
smiles
=
reinterpret_cast
<
const
char
*>
(
sqlite3_column_text
(
stmt
,
10
));
if
(
smiles
)
{
compound
->
SetSMILES
(
smiles
);
}
...
...
@@ -587,9 +557,6 @@ CompoundLib::CompoundLib():
CompoundLibBase
(),
db_
(
new
Database
),
compound_cache_
(),
chem_type_available_
(
false
),
name_available_
(),
inchi_available_
(),
smiles_available_
(),
charges_available_
(),
creation_date_
(),
...
...
This diff is collapsed.
Click to expand it.
modules/conop/src/compound_lib.hh
+
2
−
5
View file @
812e856c
...
...
@@ -55,11 +55,8 @@ private:
struct
Database
;
Database
*
db_
;
mutable
CompoundMap
compound_cache_
;
bool
chem_type_available_
;
// wether pdbx_type is available in db
bool
name_available_
;
// wether name is available in db
bool
inchi_available_
;
//whether inchi is available in db
bool
smiles_available_
;
//whether smiles are available in db
bool
charges_available_
;
//whether atom charges are available in db
bool
smiles_available_
;
//whether smiles are available in db - introduced in 2.6.0
bool
charges_available_
;
//whether atom charges are available in db - introduced in 2.6.0
Date
creation_date_
;
String
ost_version_used_
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment