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
ebb27638
Unverified
Commit
ebb27638
authored
Apr 21, 2021
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renaming compound code...
parent
3eb7e4c5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
20 deletions
+79
-20
.gitignore
+2
-0
examples/pdb1cbs.ent
+0
-0
include/cif++/Structure.hpp
+2
-0
src/Cif++.cpp
+10
-2
src/Structure.cpp
+65
-18
No files found.
.gitignore
View file @
ebb27638
...
...
@@ -23,3 +23,5 @@ msvc/.vs/
msvc/**/Debug
msvc/**/x64
.vs/
data/
test/rename-compound-test
examples/pdb1cbs.ent
0 → 100644
View file @
ebb27638
This source diff could not be displayed because it is too large. You can
view the blob
instead.
include/cif++/Structure.hpp
View file @
ebb27638
...
...
@@ -116,6 +116,7 @@ class Atom
std
::
string
labelAtomID
()
const
;
std
::
string
labelCompID
()
const
;
std
::
string
labelAsymID
()
const
;
std
::
string
labelEntityID
()
const
;
int
labelSeqID
()
const
;
std
::
string
labelAltID
()
const
;
bool
isAlternate
()
const
;
...
...
@@ -224,6 +225,7 @@ class Residue
const
std
::
string
&
compoundID
()
const
{
return
mCompoundID
;
}
const
std
::
string
&
asymID
()
const
{
return
mAsymID
;
}
int
seqID
()
const
{
return
mSeqID
;
}
std
::
string
entityID
()
const
;
std
::
string
authAsymID
()
const
;
std
::
string
authSeqID
()
const
;
...
...
src/Cif++.cpp
View file @
ebb27638
...
...
@@ -2502,6 +2502,8 @@ void Category::update_value(RowSet &&rows, const std::string &tag, const std::st
// we cannot simply rename the child but will have to create a new child. Unless that new
// child already exists of course.
RowSet
process
(
*
childCat
);
for
(
auto
child
:
children
)
{
Condition
cond
;
...
...
@@ -2518,7 +2520,10 @@ void Category::update_value(RowSet &&rows, const std::string &tag, const std::st
auto
parents
=
find
(
std
::
move
(
cond
));
if
(
parents
.
empty
())
{
process
.
push_back
(
child
);
continue
;
}
// oops, we need to split this child, unless a row already exists for the new value
Condition
check
;
...
...
@@ -2540,11 +2545,14 @@ void Category::update_value(RowSet &&rows, const std::string &tag, const std::st
continue
;
// create the actual copy
childCat
->
copyRow
(
child
);
auto
copy
=
childCat
->
copyRow
(
child
);
if
(
copy
!=
child
)
process
.
push_back
(
child
);
}
// finally, update the children
childCat
->
update_value
(
std
::
move
(
children
),
childTag
,
value
);
if
(
not
process
.
empty
())
childCat
->
update_value
(
std
::
move
(
process
),
childTag
,
value
);
}
}
}
...
...
src/Structure.cpp
View file @
ebb27638
...
...
@@ -605,6 +605,11 @@ std::string Atom::labelAsymID() const
return
impl
()
->
mAsymID
;
}
std
::
string
Atom
::
labelEntityID
()
const
{
return
property
<
std
::
string
>
(
"label_entity_id"
);
}
std
::
string
Atom
::
labelAltID
()
const
{
return
impl
()
->
mAltID
;
...
...
@@ -841,6 +846,11 @@ Residue::~Residue()
//std::cerr << "~Residue" << std::endl;
}
std
::
string
Residue
::
entityID
()
const
{
return
mAtoms
.
empty
()
?
""
:
mAtoms
.
front
().
labelEntityID
();
}
std
::
string
Residue
::
authInsCode
()
const
{
assert
(
mStructure
);
...
...
@@ -2096,7 +2106,7 @@ void Structure::insertCompound(const std::string& compoundID, bool isEntity)
if
(
isEntity
)
{
auto
&
pdbxEntityNonpoly
=
db
[
"pdbx_entity_nonpoly"
];
if
(
pdbxEntityNonpoly
.
find
(
cif
::
Key
(
"comp_id"
)
==
compoundID
).
empty
(
))
if
(
not
pdbxEntityNonpoly
.
exists
(
cif
::
Key
(
"comp_id"
)
==
compoundID
))
{
auto
&
entity
=
db
[
"entity"
];
std
::
string
entityID
=
std
::
to_string
(
entity
.
size
()
+
1
);
...
...
@@ -2239,19 +2249,66 @@ void Structure::changeResidue(const Residue& res, const std::string& newCompound
{
using
namespace
cif
::
literals
;
cif
::
Datablock
&
db
=
*
mFile
.
impl
().
mDb
;
std
::
string
asymID
=
res
.
asymID
();
const
auto
compound
=
Compound
::
create
(
newCompound
);
if
(
not
compound
)
throw
std
::
runtime_error
(
"Unknown compound "
+
newCompound
);
cif
::
Datablock
&
db
=
*
mFile
.
impl
().
mDb
;
// First make sure the compound is already known or insert it.
// And if the residue is an entity, we must make sure it exists
std
::
string
asymID
=
res
.
asymID
();
std
::
string
entityID
;
std
::
tie
(
entityID
)
=
db
[
"struct_asym"
].
find1
<
std
::
string
>
(
"id"
_key
==
asymID
,
{
"entity_id"
});
if
(
res
.
isEntity
())
{
// create a copy of the entity first
auto
&
entity
=
db
[
"entity"
];
try
{
std
::
tie
(
entityID
)
=
entity
.
find1
<
std
::
string
>
(
"type"
_key
==
"non-polymer"
and
"pdbx_description"
_key
==
compound
->
name
(),
{
"id"
});
}
catch
(
const
std
::
exception
&
ex
)
{
entityID
=
entity
.
getUniqueID
(
""
);
entity
.
emplace
({
{
"id"
,
entityID
},
{
"type"
,
"non-polymer"
},
{
"pdbx_description"
,
compound
->
name
()
},
{
"formula_weight"
,
compound
->
formulaWeight
()
}
});
}
auto
&
pdbxEntityNonpoly
=
db
[
"pdbx_entity_nonpoly"
];
pdbxEntityNonpoly
.
emplace
({
{
"entity_id"
,
entityID
},
{
"name"
,
compound
->
name
()
},
{
"comp_id"
,
newCompound
}
});
auto
&
pdbxNonPolyScheme
=
db
[
"pdbx_nonpoly_scheme"
];
for
(
auto
&
nps
:
pdbxNonPolyScheme
.
find
(
"asym_id"
_key
==
asymID
))
nps
.
assign
(
"entity_id"
,
entityID
,
true
);
// create rest
auto
&
chemComp
=
db
[
"chem_comp"
];
if
(
not
chemComp
.
exists
(
cif
::
Key
(
"id"
)
==
newCompound
))
{
chemComp
.
emplace
({
{
"id"
,
newCompound
},
{
"name"
,
compound
->
name
()
},
{
"formula"
,
compound
->
formula
()
},
{
"formula_weight"
,
compound
->
formulaWeight
()
},
{
"type"
,
compound
->
type
()
}
});
}
// // First make sure the compound is already known or insert it.
// // And if the residue is an entity, we must make sure it exists
// insertCompound(newCompound, res.isEntity());
// update the struct_asym for the new entity
db
[
"struct_asym"
].
update_value
(
"id"
_key
==
asymID
,
"entity_id"
,
entityID
);
}
else
insertCompound
(
newCompound
,
false
);
auto
&
atomSites
=
db
[
"atom_site"
];
auto
atoms
=
res
.
atoms
();
...
...
@@ -2278,17 +2335,7 @@ void Structure::changeResidue(const Residue& res, const std::string& newCompound
}
for
(
auto
a
:
atoms
)
{
auto
r
=
atomSites
.
find
(
cif
::
Key
(
"id"
)
==
a
.
id
());
assert
(
r
.
size
()
==
1
);
if
(
r
.
size
()
!=
1
)
continue
;
r
.
front
().
assign
(
"label_comp_id"
,
newCompound
,
false
);
if
(
not
entityID
.
empty
())
r
.
front
().
assign
(
"label_entity_id"
,
entityID
,
false
);
}
atomSites
.
update_value
(
cif
::
Key
(
"id"
)
==
a
.
id
(),
"label_comp_id"
,
newCompound
);
}
}
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