Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
851a43ba
Unverified
Commit
851a43ba
authored
Apr 26, 2021
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alternative layering of compound factory object implementations
parent
47ae50f7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
13 deletions
+43
-13
include/cif++/Cif++.hpp
+21
-0
include/cif++/Compound.hpp
+15
-6
src/BondMap.cpp
+2
-2
src/Compound.cpp
+0
-0
src/PDB2Cif.cpp
+5
-5
src/Structure.cpp
+0
-0
No files found.
include/cif++/Cif++.hpp
View file @
851a43ba
...
@@ -1404,6 +1404,7 @@ class iterator_proxy
...
@@ -1404,6 +1404,7 @@ class iterator_proxy
using
row_iterator
=
iterator_impl
<
RowType
>
;
using
row_iterator
=
iterator_impl
<
RowType
>
;
iterator_proxy
(
Category
&
cat
,
row_iterator
pos
,
char
const
*
const
columns
[
N
]);
iterator_proxy
(
Category
&
cat
,
row_iterator
pos
,
char
const
*
const
columns
[
N
]);
iterator_proxy
(
Category
&
cat
,
row_iterator
pos
,
std
::
initializer_list
<
char
const
*>
columns
);
iterator_proxy
(
iterator_proxy
&&
p
);
iterator_proxy
(
iterator_proxy
&&
p
);
iterator_proxy
&
operator
=
(
iterator_proxy
&&
p
);
iterator_proxy
&
operator
=
(
iterator_proxy
&&
p
);
...
@@ -1767,6 +1768,13 @@ class Category
...
@@ -1767,6 +1768,13 @@ class Category
return
iterator_proxy
<
Row
,
Ts
...
>
(
*
this
,
begin
(),
columns
);
return
iterator_proxy
<
Row
,
Ts
...
>
(
*
this
,
begin
(),
columns
);
}
}
template
<
typename
...
Ts
,
typename
...
Ns
>
iterator_proxy
<
Row
,
Ts
...
>
rows
(
Ns
...
names
)
{
static_assert
(
sizeof
...(
Ts
)
==
sizeof
...(
Ns
),
"The number of column titles should be equal to the number of types to return"
);
return
iterator_proxy
<
Row
,
Ts
...
>
(
*
this
,
begin
(),
{
names
...
});
}
conditional_iterator_proxy
<
Row
>
find
(
Condition
&&
cond
)
conditional_iterator_proxy
<
Row
>
find
(
Condition
&&
cond
)
{
{
return
find
(
cbegin
(),
std
::
forward
<
Condition
>
(
cond
));
return
find
(
cbegin
(),
std
::
forward
<
Condition
>
(
cond
));
...
@@ -2126,6 +2134,19 @@ iterator_proxy<RowType, Ts...>::iterator_proxy(Category& cat, row_iterator pos,
...
@@ -2126,6 +2134,19 @@ iterator_proxy<RowType, Ts...>::iterator_proxy(Category& cat, row_iterator pos,
mCix
[
i
]
=
mCat
->
getColumnIndex
(
columns
[
i
]);
mCix
[
i
]
=
mCat
->
getColumnIndex
(
columns
[
i
]);
}
}
template
<
typename
RowType
,
typename
...
Ts
>
iterator_proxy
<
RowType
,
Ts
...
>::
iterator_proxy
(
Category
&
cat
,
row_iterator
pos
,
std
::
initializer_list
<
char
const
*>
columns
)
:
mCat
(
&
cat
)
,
mCBegin
(
pos
)
,
mCEnd
(
cat
.
end
())
{
// static_assert(columns.size() == N, "The list of column names should be exactly the same as the list of requested columns");
std
::
size_t
i
=
0
;
for
(
auto
column
:
columns
)
mCix
[
i
++
]
=
mCat
->
getColumnIndex
(
column
);
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
template
<
typename
RowType
,
typename
...
Ts
>
template
<
typename
RowType
,
typename
...
Ts
>
...
...
include/cif++/Compound.hpp
View file @
851a43ba
...
@@ -97,11 +97,6 @@ struct CompoundBond
...
@@ -97,11 +97,6 @@ struct CompoundBond
class
Compound
class
Compound
{
{
public
:
public
:
/// \brief factory method, create a Compound based on the three letter code
/// (for amino acids) or the one-letter code (for bases) or the
/// code as it is known in the CCD.
static
const
Compound
*
create
(
const
std
::
string
&
id
);
// accessors
// accessors
...
@@ -131,6 +126,7 @@ class Compound
...
@@ -131,6 +126,7 @@ class Compound
friend
class
CompoundFactoryImpl
;
friend
class
CompoundFactoryImpl
;
friend
class
CCDCompoundFactoryImpl
;
friend
class
CCDCompoundFactoryImpl
;
friend
class
CCP4CompoundFactoryImpl
;
Compound
(
cif
::
Datablock
&
db
);
Compound
(
cif
::
Datablock
&
db
);
Compound
(
cif
::
Datablock
&
db
,
const
std
::
string
&
id
,
const
std
::
string
&
name
,
const
std
::
string
&
type
);
Compound
(
cif
::
Datablock
&
db
,
const
std
::
string
&
id
,
const
std
::
string
&
name
,
const
std
::
string
&
type
);
...
@@ -153,6 +149,14 @@ extern const std::map<std::string, char> kAAMap, kBaseMap;
...
@@ -153,6 +149,14 @@ extern const std::map<std::string, char> kAAMap, kBaseMap;
class
CompoundFactory
class
CompoundFactory
{
{
public
:
public
:
/// \brief Initialise a singleton instance.
///
/// If you have a multithreaded application and want to have different
/// compounds in each thread (e.g. a web service processing user requests
/// with different sets of compounds) you can set the \a useThreadLocalInstanceOnly
/// flag to true.
static
void
init
(
bool
useThreadLocalInstanceOnly
);
static
void
init
(
bool
useThreadLocalInstanceOnly
);
static
CompoundFactory
&
instance
();
static
CompoundFactory
&
instance
();
static
void
clear
();
static
void
clear
();
...
@@ -163,7 +167,12 @@ class CompoundFactory
...
@@ -163,7 +167,12 @@ class CompoundFactory
bool
isKnownPeptide
(
const
std
::
string
&
res_name
)
const
;
bool
isKnownPeptide
(
const
std
::
string
&
res_name
)
const
;
bool
isKnownBase
(
const
std
::
string
&
res_name
)
const
;
bool
isKnownBase
(
const
std
::
string
&
res_name
)
const
;
const
Compound
*
get
(
std
::
string
id
);
/// \brief Create the Compound object for \a id
///
/// This will create the Compound instance for \a id if it doesn't exist already.
/// The result is owned by this factory and should not be deleted by the user.
/// \param id The Compound ID, a three letter code usually
/// \result The compound, or nullptr if it could not be created (missing info)
const
Compound
*
create
(
std
::
string
id
);
const
Compound
*
create
(
std
::
string
id
);
~
CompoundFactory
();
~
CompoundFactory
();
...
...
src/BondMap.cpp
View file @
851a43ba
...
@@ -328,7 +328,7 @@ bool CompoundBondMap::bonded(const std::string &compoundID, const std::string& a
...
@@ -328,7 +328,7 @@ bool CompoundBondMap::bonded(const std::string &compoundID, const std::string& a
}
}
// not found in our cache, calculate
// not found in our cache, calculate
auto
compound
=
CompoundFactory
::
instance
().
create
(
compoundID
);
auto
compound
=
mmcif
::
CompoundFactory
::
instance
().
create
(
compoundID
);
if
(
not
compound
)
if
(
not
compound
)
throw
BondMapException
(
"Missing compound bond info for "
+
compoundID
);
throw
BondMapException
(
"Missing compound bond info for "
+
compoundID
);
...
@@ -621,7 +621,7 @@ std::vector<std::string> BondMap::atomIDsForCompound(const std::string& compound
...
@@ -621,7 +621,7 @@ std::vector<std::string> BondMap::atomIDsForCompound(const std::string& compound
{
{
std
::
vector
<
std
::
string
>
result
;
std
::
vector
<
std
::
string
>
result
;
auto
*
compound
=
mmcif
::
Compound
::
create
(
compoundID
);
auto
*
compound
=
mmcif
::
Compound
Factory
::
instance
().
create
(
compoundID
);
if
(
compound
==
nullptr
)
if
(
compound
==
nullptr
)
throw
BondMapException
(
"Missing bond information for compound "
+
compoundID
);
throw
BondMapException
(
"Missing bond information for compound "
+
compoundID
);
...
...
src/Compound.cpp
View file @
851a43ba
This diff is collapsed.
Click to expand it.
src/PDB2Cif.cpp
View file @
851a43ba
...
@@ -2575,7 +2575,7 @@ void PDBFileParser::ParseRemarks()
...
@@ -2575,7 +2575,7 @@ void PDBFileParser::ParseRemarks()
int
seq
=
vI
(
22
,
25
);
int
seq
=
vI
(
22
,
25
);
char
iCode
=
vC
(
26
);
char
iCode
=
vC
(
26
);
auto
compound
=
mmcif
::
Compound
::
create
(
res
);
auto
compound
=
mmcif
::
Compound
Factory
::
instance
().
create
(
res
);
if
(
compound
==
nullptr
)
if
(
compound
==
nullptr
)
continue
;
continue
;
...
@@ -4037,7 +4037,7 @@ void PDBFileParser::ConstructEntities()
...
@@ -4037,7 +4037,7 @@ void PDBFileParser::ConstructEntities()
letter
=
'('
+
res
.
mMonID
+
')'
;
letter
=
'('
+
res
.
mMonID
+
')'
;
// sja...
// sja...
auto
compound
=
mmcif
::
Compound
::
create
(
stdRes
.
empty
()
?
res
.
mMonID
:
stdRes
);
auto
compound
=
mmcif
::
Compound
Factory
::
instance
().
create
(
stdRes
.
empty
()
?
res
.
mMonID
:
stdRes
);
if
(
compound
!=
nullptr
and
if
(
compound
!=
nullptr
and
not
iequals
(
compound
->
type
(),
"L-peptide linking"
)
and
not
iequals
(
compound
->
type
(),
"L-peptide linking"
)
and
not
iequals
(
compound
->
type
(),
"RNA linking"
))
not
iequals
(
compound
->
type
(),
"RNA linking"
))
...
@@ -4193,7 +4193,7 @@ void PDBFileParser::ConstructEntities()
...
@@ -4193,7 +4193,7 @@ void PDBFileParser::ConstructEntities()
{
{
if
(
mHetnams
[
hetID
].
empty
())
if
(
mHetnams
[
hetID
].
empty
())
{
{
auto
compound
=
mmcif
::
Compound
::
create
(
hetID
);
auto
compound
=
mmcif
::
Compound
Factory
::
instance
().
create
(
hetID
);
if
(
compound
!=
nullptr
)
if
(
compound
!=
nullptr
)
mHetnams
[
hetID
]
=
compound
->
name
();
mHetnams
[
hetID
]
=
compound
->
name
();
}
}
...
@@ -4330,7 +4330,7 @@ void PDBFileParser::ConstructEntities()
...
@@ -4330,7 +4330,7 @@ void PDBFileParser::ConstructEntities()
for
(
auto
cc
:
mChemComp
)
for
(
auto
cc
:
mChemComp
)
{
{
auto
compound
=
mmcif
::
Compound
::
create
(
auto
compound
=
mmcif
::
Compound
Factory
::
instance
().
create
(
mMod2parent
.
count
(
cc
)
?
mMod2parent
[
cc
]
:
cc
mMod2parent
.
count
(
cc
)
?
mMod2parent
[
cc
]
:
cc
);
);
...
@@ -4872,7 +4872,7 @@ static bool IsMetal(const std::string& resName, const std::string& atomID)
...
@@ -4872,7 +4872,7 @@ static bool IsMetal(const std::string& resName, const std::string& atomID)
try
try
{
{
auto
compound
=
mmcif
::
Compound
::
create
(
resName
);
auto
compound
=
mmcif
::
Compound
Factory
::
instance
().
create
(
resName
);
if
(
compound
!=
nullptr
)
if
(
compound
!=
nullptr
)
{
{
auto
at
=
mmcif
::
AtomTypeTraits
(
compound
->
getAtomByID
(
atomID
).
typeSymbol
);
auto
at
=
mmcif
::
AtomTypeTraits
(
compound
->
getAtomByID
(
atomID
).
typeSymbol
);
...
...
src/Structure.cpp
View file @
851a43ba
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment