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
afc541b9
Unverified
Commit
afc541b9
authored
Jan 22, 2024
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'github/develop-cif2fasta' into develop
parents
22537c0e
7e4d2ffb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
122 additions
and
43 deletions
+122
-43
include/cif++/category.hpp
+43
-9
include/cif++/condition.hpp
+10
-0
include/cif++/item.hpp
+1
-1
include/cif++/iterator.hpp
+20
-15
include/cif++/validate.hpp
+1
-1
src/category.cpp
+39
-9
src/dictionary_parser.cpp
+1
-1
src/model.cpp
+4
-4
src/pdb/reconstruct.cpp
+0
-0
src/pdb/validate-pdbx.cpp
+1
-1
src/validate.cpp
+1
-1
test/unit-v2-test.cpp
+1
-1
No files found.
include/cif++/category.hpp
View file @
afc541b9
...
@@ -70,6 +70,26 @@ class duplicate_key_error : public std::runtime_error
...
@@ -70,6 +70,26 @@ class duplicate_key_error : public std::runtime_error
}
}
};
};
/// @brief A missing_key_error is thrown when an attempt is made
/// to create an index when one of the key fields is missing.
class
missing_key_error
:
public
std
::
runtime_error
{
public
:
/**
* @brief Construct a new duplicate key error object
*/
missing_key_error
(
const
std
::
string
&
msg
,
const
std
::
string
&
key
)
:
std
::
runtime_error
(
msg
)
,
m_key
(
key
)
{
}
const
std
::
string
&
get_key
()
const
noexcept
{
return
m_key
;
}
private
:
std
::
string
m_key
;
};
/// @brief A multiple_results_error is throw when you request a single
/// @brief A multiple_results_error is throw when you request a single
/// row using a query but the query contains more than exactly one row.
/// row using a query but the query contains more than exactly one row.
class
multiple_results_error
:
public
std
::
runtime_error
class
multiple_results_error
:
public
std
::
runtime_error
...
@@ -516,7 +536,7 @@ class category
...
@@ -516,7 +536,7 @@ class category
/// @param column The name of the column to return the value for
/// @param column The name of the column to return the value for
/// @return The value found
/// @return The value found
template
<
typename
T
>
template
<
typename
T
>
T
find1
(
condition
&&
cond
,
const
char
*
column
)
const
T
find1
(
condition
&&
cond
,
std
::
string_view
column
)
const
{
{
return
find1
<
T
>
(
cbegin
(),
std
::
move
(
cond
),
column
);
return
find1
<
T
>
(
cbegin
(),
std
::
move
(
cond
),
column
);
}
}
...
@@ -530,7 +550,7 @@ class category
...
@@ -530,7 +550,7 @@ class category
/// @param column The name of the column to return the value for
/// @param column The name of the column to return the value for
/// @return The value found
/// @return The value found
template
<
typename
T
,
std
::
enable_if_t
<
not
is_optional_v
<
T
>
,
int
>
=
0
>
template
<
typename
T
,
std
::
enable_if_t
<
not
is_optional_v
<
T
>
,
int
>
=
0
>
T
find1
(
const_iterator
pos
,
condition
&&
cond
,
const
char
*
column
)
const
T
find1
(
const_iterator
pos
,
condition
&&
cond
,
std
::
string_view
column
)
const
{
{
auto
h
=
find
<
T
>
(
pos
,
std
::
move
(
cond
),
column
);
auto
h
=
find
<
T
>
(
pos
,
std
::
move
(
cond
),
column
);
...
@@ -549,7 +569,7 @@ class category
...
@@ -549,7 +569,7 @@ class category
/// @param column The name of the column to return the value for
/// @param column The name of the column to return the value for
/// @return The value found, can be empty if no row matches the condition
/// @return The value found, can be empty if no row matches the condition
template
<
typename
T
,
std
::
enable_if_t
<
is_optional_v
<
T
>
,
int
>
=
0
>
template
<
typename
T
,
std
::
enable_if_t
<
is_optional_v
<
T
>
,
int
>
=
0
>
T
find1
(
const_iterator
pos
,
condition
&&
cond
,
const
char
*
column
)
const
T
find1
(
const_iterator
pos
,
condition
&&
cond
,
std
::
string_view
column
)
const
{
{
auto
h
=
find
<
typename
T
::
value_type
>
(
pos
,
std
::
move
(
cond
),
column
);
auto
h
=
find
<
typename
T
::
value_type
>
(
pos
,
std
::
move
(
cond
),
column
);
...
@@ -644,7 +664,7 @@ class category
...
@@ -644,7 +664,7 @@ class category
/// @param column The column for which the value should be returned
/// @param column The column for which the value should be returned
/// @return The value found or a default constructed value if not found
/// @return The value found or a default constructed value if not found
template
<
typename
T
>
template
<
typename
T
>
T
find_first
(
condition
&&
cond
,
const
char
*
column
)
const
T
find_first
(
condition
&&
cond
,
std
::
string_view
column
)
const
{
{
return
find_first
<
T
>
(
cbegin
(),
std
::
move
(
cond
),
column
);
return
find_first
<
T
>
(
cbegin
(),
std
::
move
(
cond
),
column
);
}
}
...
@@ -657,7 +677,7 @@ class category
...
@@ -657,7 +677,7 @@ class category
/// @param column The column for which the value should be returned
/// @param column The column for which the value should be returned
/// @return The value found or a default constructed value if not found
/// @return The value found or a default constructed value if not found
template
<
typename
T
>
template
<
typename
T
>
T
find_first
(
const_iterator
pos
,
condition
&&
cond
,
const
char
*
column
)
const
T
find_first
(
const_iterator
pos
,
condition
&&
cond
,
std
::
string_view
column
)
const
{
{
auto
h
=
find
<
T
>
(
pos
,
std
::
move
(
cond
),
column
);
auto
h
=
find
<
T
>
(
pos
,
std
::
move
(
cond
),
column
);
...
@@ -701,7 +721,7 @@ class category
...
@@ -701,7 +721,7 @@ class category
/// @param cond The condition to search for
/// @param cond The condition to search for
/// @return The value found or the minimal value for the type
/// @return The value found or the minimal value for the type
template
<
typename
T
,
std
::
enable_if_t
<
std
::
is_arithmetic_v
<
T
>
,
int
>
=
0
>
template
<
typename
T
,
std
::
enable_if_t
<
std
::
is_arithmetic_v
<
T
>
,
int
>
=
0
>
T
find_max
(
const
char
*
column
,
condition
&&
cond
)
const
T
find_max
(
std
::
string_view
column
,
condition
&&
cond
)
const
{
{
T
result
=
std
::
numeric_limits
<
T
>::
min
();
T
result
=
std
::
numeric_limits
<
T
>::
min
();
...
@@ -719,7 +739,7 @@ class category
...
@@ -719,7 +739,7 @@ class category
/// @param column The column to use for the value
/// @param column The column to use for the value
/// @return The value found or the minimal value for the type
/// @return The value found or the minimal value for the type
template
<
typename
T
,
std
::
enable_if_t
<
std
::
is_arithmetic_v
<
T
>
,
int
>
=
0
>
template
<
typename
T
,
std
::
enable_if_t
<
std
::
is_arithmetic_v
<
T
>
,
int
>
=
0
>
T
find_max
(
const
char
*
column
)
const
T
find_max
(
std
::
string_view
column
)
const
{
{
return
find_max
<
T
>
(
column
,
all
());
return
find_max
<
T
>
(
column
,
all
());
}
}
...
@@ -730,7 +750,7 @@ class category
...
@@ -730,7 +750,7 @@ class category
/// @param cond The condition to search for
/// @param cond The condition to search for
/// @return The value found or the maximum value for the type
/// @return The value found or the maximum value for the type
template
<
typename
T
,
std
::
enable_if_t
<
std
::
is_arithmetic_v
<
T
>
,
int
>
=
0
>
template
<
typename
T
,
std
::
enable_if_t
<
std
::
is_arithmetic_v
<
T
>
,
int
>
=
0
>
T
find_min
(
const
char
*
column
,
condition
&&
cond
)
const
T
find_min
(
std
::
string_view
column
,
condition
&&
cond
)
const
{
{
T
result
=
std
::
numeric_limits
<
T
>::
max
();
T
result
=
std
::
numeric_limits
<
T
>::
max
();
...
@@ -748,7 +768,7 @@ class category
...
@@ -748,7 +768,7 @@ class category
/// @param column The column to use for the value
/// @param column The column to use for the value
/// @return The value found or the maximum value for the type
/// @return The value found or the maximum value for the type
template
<
typename
T
,
std
::
enable_if_t
<
std
::
is_arithmetic_v
<
T
>
,
int
>
=
0
>
template
<
typename
T
,
std
::
enable_if_t
<
std
::
is_arithmetic_v
<
T
>
,
int
>
=
0
>
T
find_min
(
const
char
*
column
)
const
T
find_min
(
std
::
string_view
column
)
const
{
{
return
find_min
<
T
>
(
column
,
all
());
return
find_min
<
T
>
(
column
,
all
());
}
}
...
@@ -756,8 +776,17 @@ class category
...
@@ -756,8 +776,17 @@ class category
/// @brief Return whether a row exists that matches condition @a cond
/// @brief Return whether a row exists that matches condition @a cond
/// @param cond The condition to match
/// @param cond The condition to match
/// @return True if a row exists
/// @return True if a row exists
[[
deprecated
(
"Use contains instead"
)]]
bool
exists
(
condition
&&
cond
)
const
bool
exists
(
condition
&&
cond
)
const
{
{
return
contains
(
std
::
move
(
cond
));
}
/// @brief Return whether a row exists that matches condition @a cond
/// @param cond The condition to match
/// @return True if a row exists
bool
contains
(
condition
&&
cond
)
const
{
bool
result
=
false
;
bool
result
=
false
;
if
(
cond
)
if
(
cond
)
...
@@ -922,6 +951,11 @@ class category
...
@@ -922,6 +951,11 @@ class category
{
return
prefix
+
std
::
to_string
(
nr
+
1
);
});
{
return
prefix
+
std
::
to_string
(
nr
+
1
);
});
}
}
/// @brief Generate a new, unique value for a item named @a tag
/// @param tag The name of the item
/// @return a new unique value
std
::
string
get_unique_value
(
std
::
string_view
tag
);
// --------------------------------------------------------------------
// --------------------------------------------------------------------
/// \brief Update a single column named @a tag in the rows that match \a cond to value \a value
/// \brief Update a single column named @a tag in the rows that match \a cond to value \a value
...
...
include/cif++/condition.hpp
View file @
afc541b9
...
@@ -934,6 +934,16 @@ struct key
...
@@ -934,6 +934,16 @@ struct key
{
{
}
}
/**
* @brief Construct a new key object using @a itemTag as name
*
* @param itemTag
*/
explicit
key
(
std
::
string_view
itemTag
)
:
m_item_tag
(
itemTag
)
{
}
key
(
const
key
&
)
=
delete
;
key
(
const
key
&
)
=
delete
;
key
&
operator
=
(
const
key
&
)
=
delete
;
key
&
operator
=
(
const
key
&
)
=
delete
;
...
...
include/cif++/item.hpp
View file @
afc541b9
...
@@ -556,7 +556,7 @@ struct item_handle::item_value_as<T, std::enable_if_t<std::is_arithmetic_v<T> an
...
@@ -556,7 +556,7 @@ struct item_handle::item_value_as<T, std::enable_if_t<std::is_arithmetic_v<T> an
auto
txt
=
ref
.
text
();
auto
txt
=
ref
.
text
();
if
(
txt
.
empty
())
if
(
ref
.
empty
())
result
=
1
;
result
=
1
;
else
else
{
{
...
...
include/cif++/iterator.hpp
View file @
afc541b9
...
@@ -562,22 +562,23 @@ class conditional_iterator_proxy
...
@@ -562,22 +562,23 @@ class conditional_iterator_proxy
reference
operator
*
()
reference
operator
*
()
{
{
return
*
m
B
egin
;
return
*
m
_b
egin
;
}
}
pointer
operator
->
()
pointer
operator
->
()
{
{
return
&*
mBegin
;
m_current
=
*
m_begin
;
return
&
m_current
;
}
}
conditional_iterator_impl
&
operator
++
()
conditional_iterator_impl
&
operator
++
()
{
{
while
(
m
Begin
!=
mE
nd
)
while
(
m
_begin
!=
m_e
nd
)
{
{
if
(
++
m
Begin
==
mE
nd
)
if
(
++
m
_begin
==
m_e
nd
)
break
;
break
;
if
(
m_condition
->
operator
()(
m
B
egin
))
if
(
m_condition
->
operator
()(
m
_b
egin
))
break
;
break
;
}
}
...
@@ -591,18 +592,22 @@ class conditional_iterator_proxy
...
@@ -591,18 +592,22 @@ class conditional_iterator_proxy
return
result
;
return
result
;
}
}
bool
operator
==
(
const
conditional_iterator_impl
&
rhs
)
const
{
return
mBegin
==
rhs
.
mBegin
;
}
bool
operator
==
(
const
conditional_iterator_impl
&
rhs
)
const
{
return
m_begin
==
rhs
.
m_begin
;
}
bool
operator
!=
(
const
conditional_iterator_impl
&
rhs
)
const
{
return
mBegin
!=
rhs
.
mBegin
;
}
bool
operator
!=
(
const
conditional_iterator_impl
&
rhs
)
const
{
return
m_begin
!=
rhs
.
m_begin
;
}
bool
operator
==
(
const
row_iterator
&
rhs
)
const
{
return
m_begin
==
rhs
;
}
bool
operator
!=
(
const
row_iterator
&
rhs
)
const
{
return
m_begin
!=
rhs
;
}
template
<
typename
IRowType
,
typename
...
ITs
>
template
<
typename
IRowType
,
typename
...
ITs
>
bool
operator
==
(
const
iterator_impl
<
IRowType
,
ITs
...
>
&
rhs
)
const
{
return
m
B
egin
==
rhs
;
}
bool
operator
==
(
const
iterator_impl
<
IRowType
,
ITs
...
>
&
rhs
)
const
{
return
m
_b
egin
==
rhs
;
}
template
<
typename
IRowType
,
typename
...
ITs
>
template
<
typename
IRowType
,
typename
...
ITs
>
bool
operator
!=
(
const
iterator_impl
<
IRowType
,
ITs
...
>
&
rhs
)
const
{
return
m
B
egin
!=
rhs
;
}
bool
operator
!=
(
const
iterator_impl
<
IRowType
,
ITs
...
>
&
rhs
)
const
{
return
m
_b
egin
!=
rhs
;
}
private
:
private
:
CategoryType
*
mCat
;
CategoryType
*
m_cat
;
base_iterator
mBegin
,
mEnd
;
base_iterator
m_begin
,
m_end
;
value_type
m_current
;
const
condition
*
m_condition
;
const
condition
*
m_condition
;
};
};
...
@@ -673,13 +678,13 @@ iterator_proxy<Category, Ts...>::iterator_proxy(Category &cat, row_iterator pos,
...
@@ -673,13 +678,13 @@ iterator_proxy<Category, Ts...>::iterator_proxy(Category &cat, row_iterator pos,
template
<
typename
Category
,
typename
...
Ts
>
template
<
typename
Category
,
typename
...
Ts
>
conditional_iterator_proxy
<
Category
,
Ts
...
>::
conditional_iterator_impl
::
conditional_iterator_impl
(
conditional_iterator_proxy
<
Category
,
Ts
...
>::
conditional_iterator_impl
::
conditional_iterator_impl
(
Category
&
cat
,
row_iterator
pos
,
const
condition
&
cond
,
const
std
::
array
<
uint16_t
,
N
>
&
cix
)
Category
&
cat
,
row_iterator
pos
,
const
condition
&
cond
,
const
std
::
array
<
uint16_t
,
N
>
&
cix
)
:
m
C
at
(
&
cat
)
:
m
_c
at
(
&
cat
)
,
m
B
egin
(
pos
,
cix
)
,
m
_b
egin
(
pos
,
cix
)
,
m
E
nd
(
cat
.
end
(),
cix
)
,
m
_e
nd
(
cat
.
end
(),
cix
)
,
m_condition
(
&
cond
)
,
m_condition
(
&
cond
)
{
{
if
(
m_condition
==
nullptr
or
m_condition
->
empty
())
if
(
m_condition
==
nullptr
or
m_condition
->
empty
())
m
Begin
=
mE
nd
;
m
_begin
=
m_e
nd
;
}
}
template
<
typename
Category
,
typename
...
Ts
>
template
<
typename
Category
,
typename
...
Ts
>
...
...
include/cif++/validate.hpp
View file @
afc541b9
...
@@ -202,7 +202,7 @@ struct category_validator
...
@@ -202,7 +202,7 @@ struct category_validator
}
}
/// @brief Add item_validator @a v to the list of item validators
/// @brief Add item_validator @a v to the list of item validators
void
add
ItemV
alidator
(
item_validator
&&
v
);
void
add
_item_v
alidator
(
item_validator
&&
v
);
/// @brief Return the item_validator for item @a tag, may return nullptr
/// @brief Return the item_validator for item @a tag, may return nullptr
const
item_validator
*
get_validator_for_item
(
std
::
string_view
tag
)
const
;
const
item_validator
*
get_validator_for_item
(
std
::
string_view
tag
)
const
;
...
...
src/category.cpp
View file @
afc541b9
...
@@ -672,7 +672,7 @@ void category::set_validator(const validator *v, datablock &db)
...
@@ -672,7 +672,7 @@ void category::set_validator(const validator *v, datablock &db)
std
::
ostringstream
msg
;
std
::
ostringstream
msg
;
msg
<<
"Cannot construct index since the key field"
<<
(
missing
.
size
()
>
1
?
"s"
:
""
)
<<
" "
msg
<<
"Cannot construct index since the key field"
<<
(
missing
.
size
()
>
1
?
"s"
:
""
)
<<
" "
<<
cif
::
join
(
missing
,
", "
)
<<
" in "
<<
m_name
<<
" "
<<
(
missing
.
size
()
==
1
?
"is"
:
"are"
)
<<
" missing
\n
"
;
<<
cif
::
join
(
missing
,
", "
)
<<
" in "
<<
m_name
<<
" "
<<
(
missing
.
size
()
==
1
?
"is"
:
"are"
)
<<
" missing
\n
"
;
throw
std
::
runtime_error
(
msg
.
str
());
throw
missing_key_error
(
msg
.
str
(),
*
missing
.
begin
());
}
}
}
}
}
}
...
@@ -860,7 +860,7 @@ bool category::validate_links() const
...
@@ -860,7 +860,7 @@ bool category::validate_links() const
auto
cond
=
get_parents_condition
(
r
,
*
parent
);
auto
cond
=
get_parents_condition
(
r
,
*
parent
);
if
(
not
cond
)
if
(
not
cond
)
continue
;
continue
;
if
(
not
parent
->
exist
s
(
std
::
move
(
cond
)))
if
(
not
parent
->
contain
s
(
std
::
move
(
cond
)))
{
{
++
missing
;
++
missing
;
if
(
VERBOSE
and
first_missing_rows
.
size
()
<
5
)
if
(
VERBOSE
and
first_missing_rows
.
size
()
<
5
)
...
@@ -997,7 +997,7 @@ bool category::has_children(row_handle r) const
...
@@ -997,7 +997,7 @@ bool category::has_children(row_handle r) const
for
(
auto
&&
[
childCat
,
link
]
:
m_child_links
)
for
(
auto
&&
[
childCat
,
link
]
:
m_child_links
)
{
{
if
(
not
childCat
->
exist
s
(
get_children_condition
(
r
,
*
childCat
)))
if
(
not
childCat
->
contain
s
(
get_children_condition
(
r
,
*
childCat
)))
continue
;
continue
;
result
=
true
;
result
=
true
;
...
@@ -1013,7 +1013,7 @@ bool category::has_parents(row_handle r) const
...
@@ -1013,7 +1013,7 @@ bool category::has_parents(row_handle r) const
for
(
auto
&&
[
parentCat
,
link
]
:
m_parent_links
)
for
(
auto
&&
[
parentCat
,
link
]
:
m_parent_links
)
{
{
if
(
not
parentCat
->
exist
s
(
get_parents_condition
(
r
,
*
parentCat
)))
if
(
not
parentCat
->
contain
s
(
get_parents_condition
(
r
,
*
parentCat
)))
continue
;
continue
;
result
=
true
;
result
=
true
;
...
@@ -1214,7 +1214,7 @@ void category::erase_orphans(condition &&cond, category &parent)
...
@@ -1214,7 +1214,7 @@ void category::erase_orphans(condition &&cond, category &parent)
if
(
not
cond
(
r
))
if
(
not
cond
(
r
))
continue
;
continue
;
if
(
parent
.
exist
s
(
get_parents_condition
(
r
,
parent
)))
if
(
parent
.
contain
s
(
get_parents_condition
(
r
,
parent
)))
continue
;
continue
;
if
(
VERBOSE
>
1
)
if
(
VERBOSE
>
1
)
...
@@ -1263,7 +1263,7 @@ std::string category::get_unique_id(std::function<std::string(int)> generator)
...
@@ -1263,7 +1263,7 @@ std::string category::get_unique_id(std::function<std::string(int)> generator)
{
{
for
(;;)
for
(;;)
{
{
if
(
not
exist
s
(
key
(
id_tag
)
==
result
))
if
(
not
contain
s
(
key
(
id_tag
)
==
result
))
break
;
break
;
result
=
generator
(
static_cast
<
int
>
(
m_last_unique_num
++
));
result
=
generator
(
static_cast
<
int
>
(
m_last_unique_num
++
));
...
@@ -1273,6 +1273,36 @@ std::string category::get_unique_id(std::function<std::string(int)> generator)
...
@@ -1273,6 +1273,36 @@ std::string category::get_unique_id(std::function<std::string(int)> generator)
return
result
;
return
result
;
}
}
std
::
string
category
::
get_unique_value
(
std
::
string_view
tag
)
{
std
::
string
result
;
if
(
m_validator
and
m_cat_validator
)
{
auto
iv
=
m_cat_validator
->
get_validator_for_item
(
tag
);
if
(
iv
and
iv
->
m_type
and
iv
->
m_type
->
m_primitive_type
==
DDL_PrimitiveType
::
Numb
)
{
uint64_t
v
=
find_max
<
uint64_t
>
(
tag
);
result
=
std
::
to_string
(
v
+
1
);
}
}
if
(
result
.
empty
())
{
// brain-dead implementation
for
(
size_t
ix
=
0
;
ix
<
size
();
++
ix
)
{
// result = m_name + "-" + std::to_string(ix);
result
=
cif_id_for_number
(
ix
);
if
(
not
contains
(
key
(
tag
)
==
result
))
break
;
}
}
return
result
;
}
void
category
::
update_value
(
const
std
::
vector
<
row_handle
>
&
rows
,
std
::
string_view
tag
,
std
::
string_view
value
)
void
category
::
update_value
(
const
std
::
vector
<
row_handle
>
&
rows
,
std
::
string_view
tag
,
std
::
string_view
value
)
{
{
using
namespace
std
::
literals
;
using
namespace
std
::
literals
;
...
@@ -1376,7 +1406,7 @@ void category::update_value(const std::vector<row_handle> &rows, std::string_vie
...
@@ -1376,7 +1406,7 @@ void category::update_value(const std::vector<row_handle> &rows, std::string_vie
check
=
std
::
move
(
check
)
&&
key
(
ck
)
==
parent
[
pk
].
text
();
check
=
std
::
move
(
check
)
&&
key
(
ck
)
==
parent
[
pk
].
text
();
}
}
if
(
childCat
->
exist
s
(
std
::
move
(
check
)))
// phew..., narrow escape
if
(
childCat
->
contain
s
(
std
::
move
(
check
)))
// phew..., narrow escape
continue
;
continue
;
// create the actual copy, if we can...
// create the actual copy, if we can...
...
@@ -1405,7 +1435,7 @@ void category::update_value(const std::vector<row_handle> &rows, std::string_vie
...
@@ -1405,7 +1435,7 @@ void category::update_value(const std::vector<row_handle> &rows, std::string_vie
void
category
::
update_value
(
row
*
row
,
uint16_t
column
,
std
::
string_view
value
,
bool
updateLinked
,
bool
validate
)
void
category
::
update_value
(
row
*
row
,
uint16_t
column
,
std
::
string_view
value
,
bool
updateLinked
,
bool
validate
)
{
{
// make sure we have an index, if possible
// make sure we have an index, if possible
if
(
m_index
==
nullptr
and
m_cat_validator
!=
nullptr
)
if
(
(
updateLinked
or
validate
)
and
m_index
==
nullptr
and
m_cat_validator
!=
nullptr
)
m_index
=
new
category_index
(
*
this
);
m_index
=
new
category_index
(
*
this
);
auto
&
col
=
m_columns
[
column
];
auto
&
col
=
m_columns
[
column
];
...
@@ -1444,7 +1474,7 @@ void category::update_value(row *row, uint16_t column, std::string_view value, b
...
@@ -1444,7 +1474,7 @@ void category::update_value(row *row, uint16_t column, std::string_view value, b
if
(
not
value
.
empty
())
if
(
not
value
.
empty
())
row
->
append
(
column
,
{
value
});
row
->
append
(
column
,
{
value
});
if
(
reinsert
)
if
(
reinsert
and
m_index
!=
nullptr
)
m_index
->
insert
(
*
this
,
row
);
m_index
->
insert
(
*
this
,
row
);
// see if we need to update any child categories that depend on this value
// see if we need to update any child categories that depend on this value
...
...
src/dictionary_parser.cpp
View file @
afc541b9
...
@@ -87,7 +87,7 @@ class dictionary_parser : public parser
...
@@ -87,7 +87,7 @@ class dictionary_parser : public parser
error
(
"Undefined category '"
+
iv
.
first
);
error
(
"Undefined category '"
+
iv
.
first
);
for
(
auto
&
v
:
iv
.
second
)
for
(
auto
&
v
:
iv
.
second
)
const_cast
<
category_validator
*>
(
cv
)
->
add
ItemV
alidator
(
std
::
move
(
v
));
const_cast
<
category_validator
*>
(
cv
)
->
add
_item_v
alidator
(
std
::
move
(
v
));
}
}
// check all item validators for having a typeValidator
// check all item validators for having a typeValidator
...
...
src/model.cpp
View file @
afc541b9
...
@@ -1783,7 +1783,7 @@ atom &structure::emplace_atom(atom &&atom)
...
@@ -1783,7 +1783,7 @@ atom &structure::emplace_atom(atom &&atom)
std
::
string
symbol
=
atom
.
get_property
(
"type_symbol"
);
std
::
string
symbol
=
atom
.
get_property
(
"type_symbol"
);
using
namespace
cif
::
literals
;
using
namespace
cif
::
literals
;
if
(
not
atom_type
.
exist
s
(
"symbol"
_key
==
symbol
))
if
(
not
atom_type
.
contain
s
(
"symbol"
_key
==
symbol
))
atom_type
.
emplace
({
{
"symbol"
,
symbol
}
});
atom_type
.
emplace
({
{
"symbol"
,
symbol
}
});
return
m_atoms
.
emplace_back
(
std
::
move
(
atom
));
return
m_atoms
.
emplace_back
(
std
::
move
(
atom
));
...
@@ -1969,7 +1969,7 @@ void structure::change_residue(residue &res, const std::string &newCompound,
...
@@ -1969,7 +1969,7 @@ void structure::change_residue(residue &res, const std::string &newCompound,
// create rest
// create rest
auto
&
chemComp
=
m_db
[
"chem_comp"
];
auto
&
chemComp
=
m_db
[
"chem_comp"
];
if
(
not
chemComp
.
exist
s
(
key
(
"id"
)
==
newCompound
))
if
(
not
chemComp
.
contain
s
(
key
(
"id"
)
==
newCompound
))
{
{
chemComp
.
emplace
({{
"id"
,
newCompound
},
chemComp
.
emplace
({{
"id"
,
newCompound
},
{
"name"
,
compound
->
name
()},
{
"name"
,
compound
->
name
()},
...
@@ -2702,7 +2702,7 @@ void structure::cleanup_empty_categories()
...
@@ -2702,7 +2702,7 @@ void structure::cleanup_empty_categories()
for
(
auto
chemComp
:
chem_comp
)
for
(
auto
chemComp
:
chem_comp
)
{
{
std
::
string
compID
=
chemComp
[
"id"
].
as
<
std
::
string
>
();
std
::
string
compID
=
chemComp
[
"id"
].
as
<
std
::
string
>
();
if
(
atomSite
.
exist
s
(
"label_comp_id"
_key
==
compID
or
"auth_comp_id"
_key
==
compID
))
if
(
atomSite
.
contain
s
(
"label_comp_id"
_key
==
compID
or
"auth_comp_id"
_key
==
compID
))
continue
;
continue
;
obsoleteChemComps
.
push_back
(
chemComp
);
obsoleteChemComps
.
push_back
(
chemComp
);
...
@@ -2719,7 +2719,7 @@ void structure::cleanup_empty_categories()
...
@@ -2719,7 +2719,7 @@ void structure::cleanup_empty_categories()
for
(
auto
entity
:
entities
)
for
(
auto
entity
:
entities
)
{
{
std
::
string
entityID
=
entity
[
"id"
].
as
<
std
::
string
>
();
std
::
string
entityID
=
entity
[
"id"
].
as
<
std
::
string
>
();
if
(
atomSite
.
exist
s
(
"label_entity_id"
_key
==
entityID
))
if
(
atomSite
.
contain
s
(
"label_entity_id"
_key
==
entityID
))
continue
;
continue
;
obsoleteEntities
.
push_back
(
entity
);
obsoleteEntities
.
push_back
(
entity
);
...
...
src/pdb/reconstruct.cpp
View file @
afc541b9
This diff is collapsed.
Click to expand it.
src/pdb/validate-pdbx.cpp
View file @
afc541b9
...
@@ -183,7 +183,7 @@ bool is_valid_pdbx_file(const file &file, std::string_view dictionary)
...
@@ -183,7 +183,7 @@ bool is_valid_pdbx_file(const file &file, std::string_view dictionary)
"label_asym_id"
_key
==
asym_id
and
"label_asym_id"
_key
==
asym_id
and
"label_seq_id"
_key
==
seq_id
and
not
std
::
move
(
cond
);
"label_seq_id"
_key
==
seq_id
and
not
std
::
move
(
cond
);
if
(
atom_site
.
exist
s
(
std
::
move
(
cond
)))
if
(
atom_site
.
contain
s
(
std
::
move
(
cond
)))
throw
validation_error
(
"An atom_site record exists that has no parent in the poly seq scheme categories"
);
throw
validation_error
(
"An atom_site record exists that has no parent in the poly seq scheme categories"
);
}
}
}
}
...
...
src/validate.cpp
View file @
afc541b9
...
@@ -233,7 +233,7 @@ void item_validator::operator()(std::string_view value) const
...
@@ -233,7 +233,7 @@ void item_validator::operator()(std::string_view value) const
// --------------------------------------------------------------------
// --------------------------------------------------------------------
void
category_validator
::
add
ItemV
alidator
(
item_validator
&&
v
)
void
category_validator
::
add
_item_v
alidator
(
item_validator
&&
v
)
{
{
if
(
v
.
m_mandatory
)
if
(
v
.
m_mandatory
)
m_mandatory_fields
.
insert
(
v
.
m_tag
);
m_mandatory_fields
.
insert
(
v
.
m_tag
);
...
...
test/unit-v2-test.cpp
View file @
afc541b9
...
@@ -568,7 +568,7 @@ _test.value
...
@@ -568,7 +568,7 @@ _test.value
auto
&
test
=
db
[
"test"
];
auto
&
test
=
db
[
"test"
];
REQUIRE
(
test
.
size
()
==
5
);
REQUIRE
(
test
.
size
()
==
5
);
REQUIRE
(
test
.
exist
s
(
"value"
_key
==
cif
::
null
));
REQUIRE
(
test
.
contain
s
(
"value"
_key
==
cif
::
null
));
REQUIRE
(
test
.
find
(
"value"
_key
==
cif
::
null
).
size
()
==
2
);
REQUIRE
(
test
.
find
(
"value"
_key
==
cif
::
null
).
size
()
==
2
);
}
}
...
...
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