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
4a82a8d5
Unverified
Commit
4a82a8d5
authored
May 02, 2022
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed all tests
parent
11019a26
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
16 deletions
+28
-16
include/cif++/Structure.hpp
+0
-3
src/Structure.cpp
+26
-11
test/sugar-test.cpp
+2
-2
No files found.
include/cif++/Structure.hpp
View file @
4a82a8d5
...
@@ -725,9 +725,6 @@ class Structure
...
@@ -725,9 +725,6 @@ class Structure
removeResidue
(
getResidue
(
asym_id
,
seq_id
,
auth_seq_id
));
removeResidue
(
getResidue
(
asym_id
,
seq_id
,
auth_seq_id
));
}
}
/// \brief Remove residue \a res, can be monomer or nonpoly
void
removeResidue
(
Residue
&
res
);
/// \brief Create a new non-polymer entity, returns new ID
/// \brief Create a new non-polymer entity, returns new ID
/// \param mon_id The mon_id for the new nonpoly, must be an existing and known compound from CCD
/// \param mon_id The mon_id for the new nonpoly, must be an existing and known compound from CCD
/// \return The ID of the created entity
/// \return The ID of the created entity
...
...
src/Structure.cpp
View file @
4a82a8d5
...
@@ -412,7 +412,19 @@ Residue::~Residue()
...
@@ -412,7 +412,19 @@ Residue::~Residue()
std
::
string
Residue
::
entityID
()
const
std
::
string
Residue
::
entityID
()
const
{
{
return
mAtoms
.
empty
()
?
""
:
mAtoms
.
front
().
labelEntityID
();
std
::
string
result
;
if
(
not
mAtoms
.
empty
())
result
=
mAtoms
.
front
().
labelEntityID
();
else
if
(
mStructure
!=
nullptr
and
not
mAsymID
.
empty
())
{
using
namespace
cif
::
literals
;
auto
&
db
=
mStructure
->
datablock
();
result
=
db
[
"struct_asym"
].
find1
<
std
::
string
>
(
"id"
_key
==
mAsymID
,
"entity_id"
);
}
return
result
;
}
}
EntityType
Residue
::
entityType
()
const
EntityType
Residue
::
entityType
()
const
...
@@ -487,6 +499,7 @@ void Residue::addAtom(Atom &atom)
...
@@ -487,6 +499,7 @@ void Residue::addAtom(Atom &atom)
{
{
atom
.
set_property
(
"label_comp_id"
,
mCompoundID
);
atom
.
set_property
(
"label_comp_id"
,
mCompoundID
);
atom
.
set_property
(
"label_asym_id"
,
mAsymID
);
atom
.
set_property
(
"label_asym_id"
,
mAsymID
);
if
(
mSeqID
!=
0
)
atom
.
set_property
(
"label_seq_id"
,
std
::
to_string
(
mSeqID
));
atom
.
set_property
(
"label_seq_id"
,
std
::
to_string
(
mSeqID
));
atom
.
set_property
(
"auth_seq_id"
,
mAuthSeqID
);
atom
.
set_property
(
"auth_seq_id"
,
mAuthSeqID
);
...
@@ -1882,10 +1895,10 @@ void Structure::removeAtom(Atom &a)
...
@@ -1882,10 +1895,10 @@ void Structure::removeAtom(Atom &a)
auto
&
res
=
getResidue
(
a
);
auto
&
res
=
getResidue
(
a
);
res
.
mAtoms
.
erase
(
std
::
remove
(
res
.
mAtoms
.
begin
(),
res
.
mAtoms
.
end
(),
a
),
res
.
mAtoms
.
end
());
res
.
mAtoms
.
erase
(
std
::
remove
(
res
.
mAtoms
.
begin
(),
res
.
mAtoms
.
end
(),
a
),
res
.
mAtoms
.
end
());
}
}
catch
(
const
std
::
exception
&
e
)
catch
(
const
std
::
exception
&
ex
)
{
{
if
(
cif
::
VERBOSE
>
0
)
if
(
cif
::
VERBOSE
>
0
)
std
::
cerr
<<
"Error removing atom from residue: "
<<
e
.
what
()
<<
std
::
endl
;
std
::
cerr
<<
"Error removing atom from residue: "
<<
e
x
.
what
()
<<
std
::
endl
;
}
}
assert
(
mAtomIndex
.
size
()
==
mAtoms
.
size
());
assert
(
mAtomIndex
.
size
()
==
mAtoms
.
size
());
...
@@ -2071,6 +2084,10 @@ void Structure::removeResidue(Residue &res)
...
@@ -2071,6 +2084,10 @@ void Structure::removeResidue(Residue &res)
cif
::
Datablock
&
db
=
datablock
();
cif
::
Datablock
&
db
=
datablock
();
auto
atoms
=
res
.
atoms
();
for
(
auto
atom
:
atoms
)
removeAtom
(
atom
);
switch
(
res
.
entityType
())
switch
(
res
.
entityType
())
{
{
case
EntityType
:
:
Polymer
:
case
EntityType
:
:
Polymer
:
...
@@ -2105,9 +2122,6 @@ void Structure::removeResidue(Residue &res)
...
@@ -2105,9 +2122,6 @@ void Structure::removeResidue(Residue &res)
// TODO: Fix this?
// TODO: Fix this?
throw
std
::
runtime_error
(
"no support for macrolides yet"
);
throw
std
::
runtime_error
(
"no support for macrolides yet"
);
}
}
for
(
auto
atom
:
res
.
atoms
())
removeAtom
(
atom
);
}
}
void
Structure
::
removeBranch
(
Branch
&
branch
)
void
Structure
::
removeBranch
(
Branch
&
branch
)
...
@@ -2121,7 +2135,8 @@ void Structure::removeBranch(Branch &branch)
...
@@ -2121,7 +2135,8 @@ void Structure::removeBranch(Branch &branch)
for
(
auto
&
sugar
:
branch
)
for
(
auto
&
sugar
:
branch
)
{
{
for
(
auto
atom
:
sugar
.
atoms
())
auto
atoms
=
sugar
.
atoms
();
for
(
auto
atom
:
atoms
)
removeAtom
(
atom
);
removeAtom
(
atom
);
}
}
...
@@ -2644,7 +2659,7 @@ void Structure::validateAtoms() const
...
@@ -2644,7 +2659,7 @@ void Structure::validateAtoms() const
std
::
vector
<
Atom
>
atoms
=
mAtoms
;
std
::
vector
<
Atom
>
atoms
=
mAtoms
;
auto
removeAtom
=
[
&
atoms
](
const
Atom
&
a
)
auto
removeAtom
FromList
=
[
&
atoms
](
const
Atom
&
a
)
{
{
auto
i
=
std
::
find
(
atoms
.
begin
(),
atoms
.
end
(),
a
);
auto
i
=
std
::
find
(
atoms
.
begin
(),
atoms
.
end
(),
a
);
assert
(
i
!=
atoms
.
end
());
assert
(
i
!=
atoms
.
end
());
...
@@ -2656,7 +2671,7 @@ void Structure::validateAtoms() const
...
@@ -2656,7 +2671,7 @@ void Structure::validateAtoms() const
for
(
auto
&
monomer
:
poly
)
for
(
auto
&
monomer
:
poly
)
{
{
for
(
auto
&
atom
:
monomer
.
atoms
())
for
(
auto
&
atom
:
monomer
.
atoms
())
removeAtom
(
atom
);
removeAtom
FromList
(
atom
);
}
}
}
}
...
@@ -2665,14 +2680,14 @@ void Structure::validateAtoms() const
...
@@ -2665,14 +2680,14 @@ void Structure::validateAtoms() const
for
(
auto
&
sugar
:
branch
)
for
(
auto
&
sugar
:
branch
)
{
{
for
(
auto
&
atom
:
sugar
.
atoms
())
for
(
auto
&
atom
:
sugar
.
atoms
())
removeAtom
(
atom
);
removeAtom
FromList
(
atom
);
}
}
}
}
for
(
auto
&
res
:
mNonPolymers
)
for
(
auto
&
res
:
mNonPolymers
)
{
{
for
(
auto
&
atom
:
res
.
atoms
())
for
(
auto
&
atom
:
res
.
atoms
())
removeAtom
(
atom
);
removeAtom
FromList
(
atom
);
}
}
assert
(
atoms
.
empty
());
assert
(
atoms
.
empty
());
...
...
test/sugar-test.cpp
View file @
4a82a8d5
...
@@ -112,8 +112,6 @@ BOOST_AUTO_TEST_CASE(create_sugar_1)
...
@@ -112,8 +112,6 @@ BOOST_AUTO_TEST_CASE(create_sugar_1)
auto
&
NAG
=
s
.
getResidue
(
"L"
);
auto
&
NAG
=
s
.
getResidue
(
"L"
);
auto
nagAtoms
=
NAG
.
atoms
();
auto
nagAtoms
=
NAG
.
atoms
();
s
.
removeResidue
(
NAG
);
std
::
vector
<
std
::
vector
<
cif
::
Item
>>
ai
;
std
::
vector
<
std
::
vector
<
cif
::
Item
>>
ai
;
auto
&
db
=
s
.
datablock
();
auto
&
db
=
s
.
datablock
();
...
@@ -122,6 +120,8 @@ BOOST_AUTO_TEST_CASE(create_sugar_1)
...
@@ -122,6 +120,8 @@ BOOST_AUTO_TEST_CASE(create_sugar_1)
for
(
auto
r
:
as
.
find
(
"label_asym_id"
_key
==
"L"
))
for
(
auto
r
:
as
.
find
(
"label_asym_id"
_key
==
"L"
))
ai
.
emplace_back
(
r
.
begin
(),
r
.
end
());
ai
.
emplace_back
(
r
.
begin
(),
r
.
end
());
s
.
removeResidue
(
NAG
);
auto
&
branch
=
s
.
createBranch
(
ai
);
auto
&
branch
=
s
.
createBranch
(
ai
);
BOOST_CHECK_EQUAL
(
branch
.
name
(),
"2-acetamido-2-deoxy-beta-D-glucopyranose"
);
BOOST_CHECK_EQUAL
(
branch
.
name
(),
"2-acetamido-2-deoxy-beta-D-glucopyranose"
);
...
...
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