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
d5134000
Commit
d5134000
authored
Nov 10, 2020
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- fix new row iterators
- Residue constructor for sugars
parent
6f93fa37
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
61 deletions
+82
-61
.gitignore
+2
-2
include/cif++/Cif++.hpp
+0
-0
include/cif++/Structure.hpp
+2
-53
src/Cif++.cpp
+12
-2
src/Structure.cpp
+31
-4
test/unit-test.cpp
+35
-0
No files found.
.gitignore
View file @
d5134000
...
...
@@ -15,4 +15,5 @@ config.log
libtool
rsrc/lib-version.txt
version-info*.txt
src/revision.hpp
\ No newline at end of file
src/revision.hpp
test/pdb2cif-test
include/cif++/Cif++.hpp
View file @
d5134000
This diff is collapsed.
Click to expand it.
include/cif++/Structure.hpp
View file @
d5134000
...
...
@@ -484,59 +484,8 @@ class Structure
/// Will asssign new atom_id's to all atoms. Be carefull
void
sortAtoms
();
// // iterator for all residues
// class residue_iterator : public std::iterator<std::forward_iterator_tag, const Residue>
// {
// public:
// typedef std::iterator<std::forward_iterator_tag, const Residue> baseType;
// typedef typename baseType::pointer pointer;
// typedef typename baseType::reference reference;
// typedef std::list<Polymer>::const_iterator poly_iterator;
// residue_iterator(const Structure* s, poly_iterator polyIter, size_t polyResIndex, size_t nonPolyIndex);
// reference operator*();
// pointer operator->();
// residue_iterator& operator++();
// residue_iterator operator++(int);
// bool operator==(const residue_iterator& rhs) const;
// bool operator!=(const residue_iterator& rhs) const;
// private:
// const Structure& mStructure;
// poly_iterator mPolyIter;
// size_t mPolyResIndex;
// size_t mNonPolyIndex;
// };
// class residue_view
// {
// public:
// residue_view(const Structure* s) : mStructure(s) {}
// residue_view(const residue_view& rhs) : mStructure(rhs.mStructure) {}
// residue_view& operator=(residue_view& rhs)
// {
// mStructure = rhs.mStructure;
// return *this;
// }
// residue_iterator begin() const { return residue_iterator(mStructure, mStructure->mPolymers.begin(), 0, 0); }
// residue_iterator end() const { return residue_iterator(mStructure, mStructure->mPolymers.end(), 0, mStructure->mNonPolymers.size()); }
// size_t size() const
// {
// size_t ps = std::accumulate(mStructure->mPolymers.begin(), mStructure->mPolymers.end(), 0UL, [](size_t s, auto& p) { return s + p.size(); });
// return ps + mStructure->mNonPolymers.size();
// }
// private:
// const Structure* mStructure;
// };
// residue_view residues() const { return residue_view(this); }
const
std
::
vector
<
Residue
>&
getNonPolymers
()
const
{
return
mNonPolymers
;
}
const
std
::
vector
<
Residue
>&
getBranchResidues
()
const
{
return
mBranchResidues
;
}
private
:
friend
Polymer
;
...
...
src/Cif++.cpp
View file @
d5134000
...
...
@@ -1741,7 +1741,17 @@ Category::iterator Category::begin()
Category
::
iterator
Category
::
end
()
{
return
iterator
(
nullptr
);
return
iterator
();
}
Category
::
const_iterator
Category
::
cbegin
()
const
{
return
const_iterator
(
mHead
);
}
Category
::
const_iterator
Category
::
cend
()
const
{
return
const_iterator
();
}
Category
::
const_iterator
Category
::
begin
()
const
...
...
@@ -1751,7 +1761,7 @@ Category::const_iterator Category::begin() const
Category
::
const_iterator
Category
::
end
()
const
{
return
const_iterator
(
nullptr
);
return
const_iterator
();
}
bool
Category
::
hasParent
(
Row
r
,
const
Category
&
parentCat
,
const
ValidateLink
&
link
)
const
...
...
src/Structure.cpp
View file @
d5134000
...
...
@@ -716,21 +716,29 @@ std::ostream& operator<<(std::ostream& os, const Atom& atom)
// --------------------------------------------------------------------
// residue
// First constructor used to be for waters only, but now accepts sugars as well.
Residue
::
Residue
(
const
Structure
&
structure
,
const
std
::
string
&
compoundID
,
const
std
::
string
&
asymID
,
const
std
::
string
&
authSeqID
)
:
mStructure
(
&
structure
),
mCompoundID
(
compoundID
)
,
mAsymID
(
asymID
),
mAuthSeqID
(
authSeqID
)
{
assert
(
mCompoundID
==
"HOH"
);
for
(
auto
&
a
:
mStructure
->
atoms
())
{
if
(
a
.
labelAsymID
()
!=
mAsymID
or
a
.
labelCompID
()
!=
mCompoundID
)
continue
;
if
(
not
mAuthSeqID
.
empty
()
and
a
.
authSeqID
()
!=
mAuthSeqID
)
// water!
continue
;
if
(
compoundID
==
"HOH"
)
{
if
(
not
mAuthSeqID
.
empty
()
and
a
.
authSeqID
()
!=
mAuthSeqID
)
continue
;
}
else
{
if
(
mSeqID
>
0
and
a
.
labelSeqID
()
!=
mSeqID
)
continue
;
}
mAtoms
.
push_back
(
a
);
}
...
...
@@ -1842,6 +1850,25 @@ const Residue& Structure::getResidue(const std::string& asymID, const std::strin
}
}
if
(
seqID
==
0
)
{
for
(
auto
&
res
:
mNonPolymers
)
{
if
(
res
.
asymID
()
!=
asymID
or
res
.
compoundID
()
!=
compID
)
continue
;
return
res
;
}
}
for
(
auto
&
res
:
mBranchResidues
)
{
if
(
res
.
asymID
()
!=
asymID
or
res
.
compoundID
()
!=
compID
or
res
.
seqID
()
!=
seqID
)
continue
;
return
res
;
}
throw
std
::
out_of_range
(
"Could not find residue "
+
asymID
+
'/'
+
std
::
to_string
(
seqID
));
}
...
...
test/unit-test.cpp
View file @
d5134000
...
...
@@ -1154,6 +1154,41 @@ _test.name
// query tests
for
(
const
auto
&
[
id
,
name
]
:
db
[
"test"
].
rows
<
int
,
std
::
optional
<
std
::
string
>>
({
"id"
,
"name"
}))
{
switch
(
id
)
{
case
1
:
BOOST_CHECK
(
name
==
"aap"
);
break
;
case
2
:
BOOST_CHECK
(
name
==
"noot"
);
break
;
case
3
:
BOOST_CHECK
(
name
==
"mies"
);
break
;
case
4
:
case
5
:
BOOST_CHECK
(
not
name
);
break
;
default
:
BOOST_CHECK
(
false
);
}
}
}
BOOST_AUTO_TEST_CASE
(
c3
)
{
cif
::
VERBOSE
=
1
;
auto
f
=
R"(data_TEST
#
loop_
_test.id
_test.name
1 aap
2 noot
3 mies
4 .
5 ?
)"
_cf
;
auto
&
db
=
f
.
firstDatablock
();
// query tests
for
(
const
auto
&
[
id
,
name
]
:
db
[
"test"
].
find
<
int
,
std
::
optional
<
std
::
string
>>
(
cif
::
All
(),
{
"id"
,
"name"
}))
{
switch
(
id
)
...
...
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