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
e09913a9
Unverified
Commit
e09913a9
authored
Jan 22, 2024
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- checking and optionally dropping ndb_poly_seq_scheme
- fix in iterator_proxy
parent
b4d1c4cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
15 deletions
+97
-15
include/cif++/iterator.hpp
+20
-15
src/pdb/reconstruct.cpp
+77
-0
No files found.
include/cif++/iterator.hpp
View file @
e09913a9
...
...
@@ -562,22 +562,23 @@ class conditional_iterator_proxy
reference
operator
*
()
{
return
*
m
B
egin
;
return
*
m
_b
egin
;
}
pointer
operator
->
()
{
return
&*
mBegin
;
m_current
=
*
m_begin
;
return
&
m_current
;
}
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
;
if
(
m_condition
->
operator
()(
m
B
egin
))
if
(
m_condition
->
operator
()(
m
_b
egin
))
break
;
}
...
...
@@ -591,18 +592,22 @@ class conditional_iterator_proxy
return
result
;
}
bool
operator
==
(
const
conditional_iterator_impl
&
rhs
)
const
{
return
mBegin
==
rhs
.
mBegin
;
}
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
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
>
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
>
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
:
CategoryType
*
mCat
;
base_iterator
mBegin
,
mEnd
;
CategoryType
*
m_cat
;
base_iterator
m_begin
,
m_end
;
value_type
m_current
;
const
condition
*
m_condition
;
};
...
...
@@ -673,13 +678,13 @@ iterator_proxy<Category, Ts...>::iterator_proxy(Category &cat, row_iterator pos,
template
<
typename
Category
,
typename
...
Ts
>
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
)
:
m
C
at
(
&
cat
)
,
m
B
egin
(
pos
,
cix
)
,
m
E
nd
(
cat
.
end
(),
cix
)
:
m
_c
at
(
&
cat
)
,
m
_b
egin
(
pos
,
cix
)
,
m
_e
nd
(
cat
.
end
(),
cix
)
,
m_condition
(
&
cond
)
{
if
(
m_condition
==
nullptr
or
m_condition
->
empty
())
m
Begin
=
mE
nd
;
m
_begin
=
m_e
nd
;
}
template
<
typename
Category
,
typename
...
Ts
>
...
...
src/pdb/reconstruct.cpp
View file @
e09913a9
...
...
@@ -563,6 +563,80 @@ void createPdbxPolySeqScheme(datablock &db)
}
}
// Some programs write out a ndb_poly_seq_scheme, which has been replaced by pdbx_poly_seq_scheme
void
comparePolySeqSchemes
(
datablock
&
db
)
{
auto
&
ndb_poly_seq_scheme
=
db
[
"ndb_poly_seq_scheme"
];
auto
&
pdbx_poly_seq_scheme
=
db
[
"pdbx_poly_seq_scheme"
];
// Since often ndb_poly_seq_scheme only contains an id and mon_id field
// we assume that it should match the accompanying pdbx_poly_seq
std
::
vector
<
std
::
string
>
asym_ids_ndb
,
asym_ids_pdbx
;
for
(
auto
asym_id
:
ndb_poly_seq_scheme
.
rows
<
std
::
string
>
(
"id"
))
{
auto
i
=
std
::
lower_bound
(
asym_ids_ndb
.
begin
(),
asym_ids_ndb
.
end
(),
asym_id
);
if
(
i
==
asym_ids_ndb
.
end
()
or
*
i
!=
asym_id
)
asym_ids_ndb
.
insert
(
i
,
asym_id
);
}
for
(
auto
asym_id
:
pdbx_poly_seq_scheme
.
rows
<
std
::
string
>
(
"asym_id"
))
{
auto
i
=
std
::
lower_bound
(
asym_ids_pdbx
.
begin
(),
asym_ids_pdbx
.
end
(),
asym_id
);
if
(
i
==
asym_ids_pdbx
.
end
()
or
*
i
!=
asym_id
)
asym_ids_pdbx
.
insert
(
i
,
asym_id
);
}
// If we have different Asym ID's assume the ndb is invalid.
if
(
asym_ids_ndb
!=
asym_ids_pdbx
)
{
if
(
cif
::
VERBOSE
>
0
)
std
::
clog
<<
"The asym ID's of ndb_poly_seq_scheme and pdbx_poly_seq_scheme are not equal, dropping ndb_poly_seq_scheme
\n
"
;
ndb_poly_seq_scheme
.
clear
();
}
else
{
for
(
const
auto
&
asym_id
:
asym_ids_ndb
)
{
bool
valid
=
true
;
auto
ndb_range
=
ndb_poly_seq_scheme
.
find
(
key
(
"id"
)
==
asym_id
);
auto
pdbx_range
=
pdbx_poly_seq_scheme
.
find
(
key
(
"asym_id"
)
==
asym_id
);
for
(
auto
ndb_i
=
ndb_range
.
begin
(),
pdbx_i
=
pdbx_range
.
begin
();
ndb_i
!=
ndb_range
.
end
()
or
pdbx_i
!=
pdbx_range
.
end
();
++
ndb_i
,
++
pdbx_i
)
{
if
(
ndb_i
==
ndb_range
.
end
()
or
pdbx_i
==
pdbx_range
.
end
())
{
if
(
cif
::
VERBOSE
>
0
)
std
::
clog
<<
"The sequences in ndb_poly_seq_scheme and pdbx_poly_seq_scheme are unequal in size for asym ID "
<<
asym_id
<<
'\n'
;
valid
=
false
;
break
;
}
auto
ndb_mon_id
=
ndb_i
->
get
<
std
::
string
>
(
"mon_id"
);
auto
pdbx_mon_id
=
pdbx_i
->
get
<
std
::
string
>
(
"mon_id"
);
if
(
ndb_mon_id
!=
pdbx_mon_id
)
{
if
(
cif
::
VERBOSE
>
0
)
std
::
clog
<<
"The sequences in ndb_poly_seq_scheme and pdbx_poly_seq_scheme contain different mon ID's for asym ID "
<<
asym_id
<<
'\n'
;
valid
=
false
;
break
;
}
}
if
(
not
valid
)
{
if
(
cif
::
VERBOSE
>
0
)
std
::
clog
<<
"Dropping asym ID "
<<
asym_id
<<
" from ndb_poly_seq_scheme
\n
"
;
ndb_poly_seq_scheme
.
erase
(
key
(
"id"
)
==
asym_id
);
}
}
}
}
void
reconstruct_pdbx
(
file
&
file
,
std
::
string_view
dictionary
)
{
if
(
file
.
empty
())
...
...
@@ -765,6 +839,9 @@ void reconstruct_pdbx(file &file, std::string_view dictionary)
if
(
db
.
get
(
"pdbx_poly_seq_scheme"
)
==
nullptr
)
createPdbxPolySeqScheme
(
db
);
if
(
db
.
get
(
"ndb_poly_seq_scheme"
)
!=
nullptr
)
comparePolySeqSchemes
(
db
);
}
}
// namespace cif::pdb
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