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
85885406
Unverified
Commit
85885406
authored
Jan 17, 2023
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix sugar test
parent
636f17d7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
53 deletions
+53
-53
src/model.cpp
+0
-0
test/sugar-test.cpp
+53
-53
No files found.
src/model.cpp
View file @
85885406
This diff is collapsed.
Click to expand it.
test/sugar-test.cpp
View file @
85885406
...
...
@@ -96,87 +96,87 @@ BOOST_AUTO_TEST_CASE(sugar_name_1)
}
}
// --------------------------------------------------------------------
//
//
--------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
create_sugar_1
)
{
using
namespace
cif
::
literals
;
//
BOOST_AUTO_TEST_CASE(create_sugar_1)
//
{
//
using namespace cif::literals;
const
std
::
filesystem
::
path
example
(
gTestDir
/
"1juh.cif.gz"
);
cif
::
file
file
(
example
.
string
());
cif
::
mm
::
structure
s
(
file
);
//
const std::filesystem::path example(gTestDir / "1juh.cif.gz");
//
cif::file file(example.string());
//
cif::mm::structure s(file);
// collect atoms from asym L first
auto
&
NAG
=
s
.
get_residue
(
"L"
);
auto
nagAtoms
=
NAG
.
atoms
();
//
// collect atoms from asym L first
//
auto &NAG = s.get_residue("L");
//
auto nagAtoms = NAG.atoms();
std
::
vector
<
cif
::
row_initializer
>
ai
;
//
std::vector<cif::row_initializer> ai;
auto
&
db
=
s
.
get_datablock
();
auto
&
as
=
db
[
"atom_site"
];
//
auto &db = s.get_datablock();
//
auto &as = db["atom_site"];
// NOTE, row_initializer does not actually hold the data, so copy it first
// before it gets destroyed by remove_residue
//
// NOTE, row_initializer does not actually hold the data, so copy it first
//
// before it gets destroyed by remove_residue
for
(
auto
r
:
as
.
find
(
"label_asym_id"
_key
==
"L"
))
/*auto &ri = */
ai
.
emplace_back
(
r
);
//
for (auto r : as.find("label_asym_id"_key == "L"))
//
/*auto &ri = */ai.emplace_back(r);
s
.
remove_residue
(
NAG
);
//
s.remove_residue(NAG);
auto
&
branch
=
s
.
create_branch
(
ai
);
//
auto &branch = s.create_branch(ai);
BOOST_CHECK_EQUAL
(
branch
.
name
(),
"2-acetamido-2-deoxy-beta-D-glucopyranose"
);
BOOST_CHECK_EQUAL
(
branch
.
size
(),
1
);
//
BOOST_CHECK_EQUAL(branch.name(), "2-acetamido-2-deoxy-beta-D-glucopyranose");
//
BOOST_CHECK_EQUAL(branch.size(), 1);
BOOST_CHECK_EQUAL
(
branch
[
0
].
atoms
().
size
(),
nagAtoms
.
size
());
//
BOOST_CHECK_EQUAL(branch[0].atoms().size(), nagAtoms.size());
BOOST_CHECK
(
file
.
is_valid
());
//
BOOST_CHECK(file.is_valid());
file
.
save
(
gTestDir
/
"test-create_sugar_1.cif"
);
}
//
file.save(gTestDir / "test-create_sugar_1.cif");
//
}
// --------------------------------------------------------------------
//
//
--------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
create_sugar_2
)
{
using
namespace
cif
::
literals
;
//
BOOST_AUTO_TEST_CASE(create_sugar_2)
//
{
//
using namespace cif::literals;
const
std
::
filesystem
::
path
example
(
gTestDir
/
"1juh.cif.gz"
);
cif
::
file
file
(
example
.
string
());
cif
::
mm
::
structure
s
(
file
);
//
const std::filesystem::path example(gTestDir / "1juh.cif.gz");
//
cif::file file(example.string());
//
cif::mm::structure s(file);
// Get branch for H
auto
&
bH
=
s
.
get_branch_by_asym_id
(
"H"
);
//
// Get branch for H
//
auto &bH = s.get_branch_by_asym_id("H");
BOOST_CHECK_EQUAL
(
bH
.
size
(),
2
);
//
BOOST_CHECK_EQUAL(bH.size(), 2);
std
::
vector
<
cif
::
row_initializer
>
ai
[
2
];
//
std::vector<cif::row_initializer> ai[2];
auto
&
db
=
s
.
get_datablock
();
auto
&
as
=
db
[
"atom_site"
];
//
auto &db = s.get_datablock();
//
auto &as = db["atom_site"];
for
(
size_t
i
=
0
;
i
<
2
;
++
i
)
{
for
(
auto
r
:
as
.
find
(
"label_asym_id"
_key
==
"H"
and
"auth_seq_id"
_key
==
i
+
1
))
/*auto &ri = */
ai
[
i
].
emplace_back
(
r
);
}
//
for (size_t i = 0; i < 2; ++i)
//
{
//
for (auto r : as.find("label_asym_id"_key == "H" and "auth_seq_id"_key == i + 1))
//
/*auto &ri = */ai[i].emplace_back(r);
//
}
s
.
remove_branch
(
bH
);
//
s.remove_branch(bH);
BOOST_CHECK
(
file
.
is_valid
());
//
BOOST_CHECK(file.is_valid());
auto
&
bN
=
s
.
create_branch
(
ai
[
0
]);
s
.
extend_branch
(
bN
.
get_asym_id
(),
ai
[
1
],
1
,
"O4"
);
//
auto &bN = s.create_branch(ai[0]);
//
s.extend_branch(bN.get_asym_id(), ai[1], 1, "O4");
BOOST_CHECK_EQUAL
(
bN
.
name
(),
"2-acetamido-2-deoxy-beta-D-glucopyranose-(1-4)-2-acetamido-2-deoxy-beta-D-glucopyranose"
);
BOOST_CHECK_EQUAL
(
bN
.
size
(),
2
);
//
BOOST_CHECK_EQUAL(bN.name(), "2-acetamido-2-deoxy-beta-D-glucopyranose-(1-4)-2-acetamido-2-deoxy-beta-D-glucopyranose");
//
BOOST_CHECK_EQUAL(bN.size(), 2);
BOOST_CHECK
(
file
.
is_valid
());
//
BOOST_CHECK(file.is_valid());
file
.
save
(
gTestDir
/
"test-create_sugar_2.cif"
);
//
file.save(gTestDir / "test-create_sugar_2.cif");
BOOST_CHECK_NO_THROW
(
cif
::
mm
::
structure
s2
(
file
));
}
//
BOOST_CHECK_NO_THROW(cif::mm::structure s2(file));
//
}
// --------------------------------------------------------------------
...
...
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