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
82e73a95
Unverified
Commit
82e73a95
authored
Oct 05, 2022
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All tests pass
parent
adc316d6
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
60 additions
and
20 deletions
+60
-20
.gitignore
+3
-1
include/cif++/condition.hpp
+3
-0
include/cif++/model.hpp
+4
-1
include/cif++/row.hpp
+5
-0
src/category.cpp
+8
-4
src/file.cpp
+6
-0
src/model.cpp
+12
-12
test/rename-compound-test.cpp
+5
-0
test/sugar-test.cpp
+12
-0
test/unit-v2-test.cpp
+2
-2
No files found.
.gitignore
View file @
82e73a95
...
@@ -12,4 +12,6 @@ CMakeSettings.json
...
@@ -12,4 +12,6 @@ CMakeSettings.json
msvc/
msvc/
Testing/
Testing/
rsrc/feature-request.txt
rsrc/feature-request.txt
test/test-create_sugar_2.cif
test/test-create_sugar_?.cif
test/oprofile_data/abi
test/oprofile_data/samples/operf.log
include/cif++/condition.hpp
View file @
82e73a95
...
@@ -358,6 +358,9 @@ namespace detail
...
@@ -358,6 +358,9 @@ namespace detail
std
::
regex
mRx
;
std
::
regex
mRx
;
};
};
// TODO: Optimize and_condition by having a list of sub items.
// That way you can also collapse multiple _is_ conditions in
// case they make up an indexed tuple.
struct
and_condition_impl
:
public
condition_impl
struct
and_condition_impl
:
public
condition_impl
{
{
and_condition_impl
(
condition
&&
a
,
condition
&&
b
)
and_condition_impl
(
condition
&&
a
,
condition
&&
b
)
...
...
include/cif++/model.hpp
View file @
82e73a95
...
@@ -609,7 +609,10 @@ class sugar : public residue
...
@@ -609,7 +609,10 @@ class sugar : public residue
size_t
get_link_nr
()
const
size_t
get_link_nr
()
const
{
{
return
m_link
?
std
::
stoi
(
m_link
.
get_auth_seq_id
())
:
0
;
size_t
result
=
0
;
if
(
m_link
)
result
=
m_link
.
get_property_int
(
"auth_seq_id"
);
return
result
;
}
}
private
:
private
:
...
...
include/cif++/row.hpp
View file @
82e73a95
...
@@ -307,6 +307,11 @@ class row_initializer : public std::vector<item>
...
@@ -307,6 +307,11 @@ class row_initializer : public std::vector<item>
row_initializer
(
row_handle
rh
);
row_initializer
(
row_handle
rh
);
void
set_value
(
std
::
string_view
name
,
std
::
string_view
value
);
void
set_value
(
std
::
string_view
name
,
std
::
string_view
value
);
void
set_value
(
item
&&
i
)
{
set_value
(
i
.
name
(),
i
.
value
());
}
void
set_value_if_empty
(
std
::
string_view
name
,
std
::
string_view
value
);
void
set_value_if_empty
(
std
::
string_view
name
,
std
::
string_view
value
);
void
set_value_if_empty
(
item
&&
i
)
void
set_value_if_empty
(
item
&&
i
)
{
{
...
...
src/category.cpp
View file @
82e73a95
...
@@ -986,6 +986,11 @@ condition category::get_children_condition(row_handle rh, const category &childC
...
@@ -986,6 +986,11 @@ condition category::get_children_condition(row_handle rh, const category &childC
condition
result
;
condition
result
;
iset
mandatoryChildFields
;
auto
childCatValidator
=
m_validator
->
get_validator_for_category
(
childCat
.
name
());
if
(
childCatValidator
!=
nullptr
)
mandatoryChildFields
=
childCatValidator
->
m_mandatory_fields
;
for
(
auto
&
link
:
m_validator
->
get_links_for_parent
(
m_name
))
for
(
auto
&
link
:
m_validator
->
get_links_for_parent
(
m_name
))
{
{
if
(
link
->
m_child_category
!=
childCat
.
m_name
)
if
(
link
->
m_child_category
!=
childCat
.
m_name
)
...
@@ -1002,14 +1007,13 @@ condition category::get_children_condition(row_handle rh, const category &childC
...
@@ -1002,14 +1007,13 @@ condition category::get_children_condition(row_handle rh, const category &childC
if
(
parentValue
.
empty
())
if
(
parentValue
.
empty
())
cond
=
std
::
move
(
cond
)
and
key
(
childKey
)
==
null
;
cond
=
std
::
move
(
cond
)
and
key
(
childKey
)
==
null
;
else
if
(
link
->
m_parent_keys
.
size
()
>
1
and
not
mandatoryChildFields
.
contains
(
childKey
))
cond
=
std
::
move
(
cond
)
and
(
key
(
childKey
)
==
parentValue
.
text
()
or
key
(
childKey
)
==
null
);
else
else
cond
=
std
::
move
(
cond
)
and
key
(
childKey
)
==
parentValue
.
text
();
cond
=
std
::
move
(
cond
)
and
key
(
childKey
)
==
parentValue
.
text
();
}
}
if
(
result
)
result
=
std
::
move
(
result
)
or
std
::
move
(
cond
);
result
=
std
::
move
(
result
)
or
std
::
move
(
cond
);
else
result
=
std
::
move
(
cond
);
}
}
return
result
;
return
result
;
...
...
src/file.cpp
View file @
82e73a95
...
@@ -48,6 +48,9 @@ bool file::is_valid() const
...
@@ -48,6 +48,9 @@ bool file::is_valid() const
for
(
auto
&
d
:
*
this
)
for
(
auto
&
d
:
*
this
)
result
=
d
.
is_valid
()
and
result
;
result
=
d
.
is_valid
()
and
result
;
if
(
result
)
result
=
validate_links
();
return
result
;
return
result
;
}
}
...
@@ -203,6 +206,9 @@ void file::save(const std::filesystem::path &p) const
...
@@ -203,6 +206,9 @@ void file::save(const std::filesystem::path &p) const
void
file
::
save
(
std
::
ostream
&
os
)
const
void
file
::
save
(
std
::
ostream
&
os
)
const
{
{
if
(
not
is_valid
())
std
::
cout
<<
"File is not valid!"
<<
std
::
endl
;
for
(
auto
&
db
:
*
this
)
for
(
auto
&
db
:
*
this
)
db
.
write
(
os
);
db
.
write
(
os
);
}
}
...
...
src/model.cpp
View file @
82e73a95
...
@@ -1859,11 +1859,9 @@ void structure::change_residue(residue &res, const std::string &newCompound,
...
@@ -1859,11 +1859,9 @@ void structure::change_residue(residue &res, const std::string &newCompound,
// create a copy of the entity first
// create a copy of the entity first
auto
&
entity
=
m_db
[
"entity"
];
auto
&
entity
=
m_db
[
"entity"
];
try
entityID
=
entity
.
find1
<
std
::
string
>
(
"type"
_key
==
"non-polymer"
and
"pdbx_description"
_key
==
compound
->
name
(),
"id"
);
{
entityID
=
entity
.
find1
<
std
::
string
>
(
"type"
_key
==
"non-polymer"
and
"pdbx_description"
_key
==
compound
->
name
(),
"id"
);
if
(
entityID
.
empty
())
}
catch
(
const
std
::
exception
&
ex
)
{
{
entityID
=
entity
.
get_unique_id
(
""
);
entityID
=
entity
.
get_unique_id
(
""
);
entity
.
emplace
({{
"id"
,
entityID
},
entity
.
emplace
({{
"id"
,
entityID
},
...
@@ -1881,6 +1879,7 @@ void structure::change_residue(residue &res, const std::string &newCompound,
...
@@ -1881,6 +1879,7 @@ void structure::change_residue(residue &res, const std::string &newCompound,
for
(
auto
nps
:
pdbxNonPolyScheme
.
find
(
"asym_id"
_key
==
asym_id
))
for
(
auto
nps
:
pdbxNonPolyScheme
.
find
(
"asym_id"
_key
==
asym_id
))
{
{
nps
.
assign
(
"mon_id"
,
newCompound
,
true
);
nps
.
assign
(
"mon_id"
,
newCompound
,
true
);
nps
.
assign
(
"pdb_mon_id"
,
newCompound
,
true
);
nps
.
assign
(
"auth_mon_id"
,
newCompound
,
true
);
nps
.
assign
(
"auth_mon_id"
,
newCompound
,
true
);
nps
.
assign
(
"entity_id"
,
entityID
,
true
);
nps
.
assign
(
"entity_id"
,
entityID
,
true
);
}
}
...
@@ -2192,13 +2191,13 @@ std::string structure::create_non_poly(const std::string &entity_id, std::vector
...
@@ -2192,13 +2191,13 @@ std::string structure::create_non_poly(const std::string &entity_id, std::vector
atom
.
set_value
(
"name"
,
atom_id
);
atom
.
set_value
(
"name"
,
atom_id
);
atom
.
set_value
(
"label_asym_id"
,
asym_id
);
atom
.
set_value
(
"label_asym_id"
,
asym_id
);
atom
.
set_value
(
"auth_asym_id"
,
asym_id
);
atom
.
set_value
(
"label_entity_id"
,
entity_id
);
atom
.
set_value_if_empty
({
"group_PDB"
,
"HETATM"
});
atom
.
set_value_if_empty
({
"group_PDB"
,
"HETATM"
});
atom
.
set_value_if_empty
({
"label_comp_id"
,
comp_id
});
atom
.
set_value_if_empty
({
"label_comp_id"
,
comp_id
});
atom
.
set_value_if_empty
({
"label_seq_id"
,
""
});
atom
.
set_value_if_empty
({
"label_seq_id"
,
""
});
atom
.
set_value_if_empty
({
"label_entity_id"
,
entity_id
});
atom
.
set_value_if_empty
({
"auth_comp_id"
,
comp_id
});
atom
.
set_value_if_empty
({
"auth_comp_id"
,
comp_id
});
atom
.
set_value_if_empty
({
"auth_asym_id"
,
asym_id
});
atom
.
set_value_if_empty
({
"auth_seq_id"
,
1
});
atom
.
set_value_if_empty
({
"auth_seq_id"
,
1
});
atom
.
set_value_if_empty
({
"pdbx_PDB_model_num"
,
1
});
atom
.
set_value_if_empty
({
"pdbx_PDB_model_num"
,
1
});
atom
.
set_value_if_empty
({
"label_alt_id"
,
""
});
atom
.
set_value_if_empty
({
"label_alt_id"
,
""
});
...
@@ -2256,14 +2255,14 @@ branch &structure::create_branch(std::vector<row_initializer> atoms)
...
@@ -2256,14 +2255,14 @@ branch &structure::create_branch(std::vector<row_initializer> atoms)
atom
.
set_value
(
"id"
,
atom_id
);
atom
.
set_value
(
"id"
,
atom_id
);
atom
.
set_value
(
"label_asym_id"
,
asym_id
);
atom
.
set_value
(
"label_asym_id"
,
asym_id
);
atom
.
set_value
(
"auth_asym_id"
,
asym_id
);
atom
.
set_value
(
"label_entity_id"
,
tmp_entity_id
);
atom
.
set_value
({
"auth_seq_id"
,
1
});
atom
.
set_value_if_empty
({
"group_PDB"
,
"HETATM"
});
atom
.
set_value_if_empty
({
"group_PDB"
,
"HETATM"
});
atom
.
set_value_if_empty
({
"label_comp_id"
,
"NAG"
});
atom
.
set_value_if_empty
({
"label_comp_id"
,
"NAG"
});
atom
.
set_value_if_empty
({
"label_seq_id"
,
"."
});
atom
.
set_value_if_empty
({
"label_seq_id"
,
"."
});
atom
.
set_value_if_empty
({
"label_entity_id"
,
tmp_entity_id
});
atom
.
set_value_if_empty
({
"auth_comp_id"
,
"NAG"
});
atom
.
set_value_if_empty
({
"auth_comp_id"
,
"NAG"
});
atom
.
set_value_if_empty
({
"auth_asym_id"
,
asym_id
});
atom
.
set_value_if_empty
({
"auth_seq_id"
,
1
});
atom
.
set_value_if_empty
({
"pdbx_PDB_model_num"
,
1
});
atom
.
set_value_if_empty
({
"pdbx_PDB_model_num"
,
1
});
atom
.
set_value_if_empty
({
"label_alt_id"
,
""
});
atom
.
set_value_if_empty
({
"label_alt_id"
,
""
});
...
@@ -2353,12 +2352,13 @@ branch &structure::extend_branch(const std::string &asym_id, std::vector<row_ini
...
@@ -2353,12 +2352,13 @@ branch &structure::extend_branch(const std::string &asym_id, std::vector<row_ini
atom
.
set_value
(
"id"
,
atom_id
);
atom
.
set_value
(
"id"
,
atom_id
);
atom
.
set_value
(
"label_asym_id"
,
asym_id
);
atom
.
set_value
(
"label_asym_id"
,
asym_id
);
atom
.
set_value
(
"auth_asym_id"
,
asym_id
);
atom
.
set_value
(
"label_entity_id"
,
tmp_entity_id
);
atom
.
set_value
({
"auth_seq_id"
,
sugarNum
});
atom
.
set_value_if_empty
({
"group_PDB"
,
"HETATM"
});
atom
.
set_value_if_empty
({
"group_PDB"
,
"HETATM"
});
atom
.
set_value_if_empty
({
"label_comp_id"
,
compoundID
});
atom
.
set_value_if_empty
({
"label_comp_id"
,
compoundID
});
atom
.
set_value_if_empty
({
"label_entity_id"
,
tmp_entity_id
});
atom
.
set_value_if_empty
({
"auth_comp_id"
,
compoundID
});
atom
.
set_value_if_empty
({
"auth_comp_id"
,
compoundID
});
atom
.
set_value_if_empty
({
"auth_asym_id"
,
asym_id
});
atom
.
set_value_if_empty
({
"pdbx_PDB_model_num"
,
1
});
atom
.
set_value_if_empty
({
"pdbx_PDB_model_num"
,
1
});
atom
.
set_value_if_empty
({
"label_alt_id"
,
""
});
atom
.
set_value_if_empty
({
"label_alt_id"
,
""
});
...
...
test/rename-compound-test.cpp
View file @
82e73a95
...
@@ -58,6 +58,11 @@ int main(int argc, char* argv[])
...
@@ -58,6 +58,11 @@ int main(int argc, char* argv[])
structure
.
cleanup_empty_categories
();
structure
.
cleanup_empty_categories
();
f
.
save
(
std
::
cout
);
f
.
save
(
std
::
cout
);
if
(
not
f
.
is_valid
())
throw
std
::
runtime_error
(
"Invalid"
);
f
.
save
(
std
::
cout
);
}
}
catch
(
const
std
::
exception
&
e
)
catch
(
const
std
::
exception
&
e
)
{
{
...
...
test/sugar-test.cpp
View file @
82e73a95
...
@@ -135,6 +135,10 @@ BOOST_AUTO_TEST_CASE(create_sugar_1)
...
@@ -135,6 +135,10 @@ BOOST_AUTO_TEST_CASE(create_sugar_1)
BOOST_CHECK_EQUAL
(
branch
.
size
(),
1
);
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
());
file
.
save
(
gTestDir
/
"test-create_sugar_1.cif"
);
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
...
@@ -170,12 +174,18 @@ BOOST_AUTO_TEST_CASE(create_sugar_2)
...
@@ -170,12 +174,18 @@ BOOST_AUTO_TEST_CASE(create_sugar_2)
s
.
remove_branch
(
bH
);
s
.
remove_branch
(
bH
);
file
.
save
(
gTestDir
/
"test-create_sugar_2-0.cif"
);
BOOST_CHECK
(
file
.
is_valid
());
auto
&
bN
=
s
.
create_branch
(
ai
[
0
]);
auto
&
bN
=
s
.
create_branch
(
ai
[
0
]);
s
.
extend_branch
(
bN
.
get_asym_id
(),
ai
[
1
],
1
,
"O4"
);
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
.
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
.
size
(),
2
);
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
));
...
@@ -205,6 +215,8 @@ BOOST_AUTO_TEST_CASE(delete_sugar_1)
...
@@ -205,6 +215,8 @@ BOOST_AUTO_TEST_CASE(delete_sugar_1)
BOOST_CHECK_EQUAL
(
bN
.
name
(),
"2-acetamido-2-deoxy-beta-D-glucopyranose"
);
BOOST_CHECK_EQUAL
(
bN
.
name
(),
"2-acetamido-2-deoxy-beta-D-glucopyranose"
);
BOOST_CHECK_EQUAL
(
bN
.
size
(),
1
);
BOOST_CHECK_EQUAL
(
bN
.
size
(),
1
);
BOOST_CHECK
(
file
.
is_valid
());
file
.
save
(
gTestDir
/
"test-create_sugar_3.cif"
);
file
.
save
(
gTestDir
/
"test-create_sugar_3.cif"
);
BOOST_CHECK_NO_THROW
(
cif
::
mm
::
structure
s2
(
file
));
BOOST_CHECK_NO_THROW
(
cif
::
mm
::
structure
s2
(
file
));
...
...
test/unit-v2-test.cpp
View file @
82e73a95
...
@@ -1037,12 +1037,12 @@ _cat_2.desc
...
@@ -1037,12 +1037,12 @@ _cat_2.desc
cat1
.
erase
(
cif
::
key
(
"id"
)
==
10
);
cat1
.
erase
(
cif
::
key
(
"id"
)
==
10
);
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
2
);
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
2
);
BOOST_CHECK_EQUAL
(
cat2
.
size
(),
3
);
// TODO: Is this really what we want?
BOOST_CHECK_EQUAL
(
cat2
.
size
(),
2
);
// TODO: Is this really what we want?
cat1
.
erase
(
cif
::
key
(
"id"
)
==
20
);
cat1
.
erase
(
cif
::
key
(
"id"
)
==
20
);
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
1
);
BOOST_CHECK_EQUAL
(
cat1
.
size
(),
1
);
BOOST_CHECK_EQUAL
(
cat2
.
size
(),
2
);
// TODO: Is this really what we want?
BOOST_CHECK_EQUAL
(
cat2
.
size
(),
1
);
// TODO: Is this really what we want?
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
...
...
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