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
6e3b85f4
Unverified
Commit
6e3b85f4
authored
Apr 11, 2022
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getResidue, again
parent
58f1b626
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
85 deletions
+80
-85
include/cif++/Structure.hpp
+5
-2
src/Structure.cpp
+75
-83
No files found.
include/cif++/Structure.hpp
View file @
6e3b85f4
...
...
@@ -650,12 +650,15 @@ class Structure
}
/// \brief Get a the residue for atom \a atom
Residue
&
getResidue
(
const
mmcif
::
Atom
&
atom
);
Residue
&
getResidue
(
const
mmcif
::
Atom
&
atom
)
{
return
getResidue
(
atom
.
labelAsymID
(),
atom
.
labelCompID
(),
atom
.
labelSeqID
(),
atom
.
authSeqID
());
}
/// \brief Get a the residue for atom \a atom
const
Residue
&
getResidue
(
const
mmcif
::
Atom
&
atom
)
const
{
return
const_cast
<
Structure
*>
(
this
)
->
getResidue
(
atom
);
return
getResidue
(
atom
.
labelAsymID
(),
atom
.
labelCompID
(),
atom
.
labelSeqID
(),
atom
.
authSeqID
()
);
}
// map between auth and label locations
...
...
src/Structure.cpp
View file @
6e3b85f4
...
...
@@ -1460,43 +1460,35 @@ void Structure::loadData()
// place atoms in residues
using
key_type
=
std
::
tuple
<
std
::
string
,
int
>
;
using
map_type
=
std
::
map
<
key_type
,
Residue
*>
;
map_type
resMap
;
using
key_type
=
std
::
tuple
<
std
::
string
,
int
,
std
::
string
>
;
std
::
map
<
key_type
,
Residue
*>
resMap
;
for
(
auto
&
poly
:
mPolymers
)
{
for
(
auto
&
res
:
poly
)
resMap
[{
res
.
asymID
(),
res
.
seqID
()}]
=
&
res
;
resMap
[{
res
.
asymID
(),
res
.
seqID
()
,
res
.
authSeqID
()
}]
=
&
res
;
}
for
(
auto
&
res
:
mNonPolymers
)
resMap
[{
res
.
asymID
(),
(
res
.
isWater
()
?
std
::
stoi
(
res
.
mAuthSeqID
)
:
res
.
seqID
())
}]
=
&
res
;
resMap
[{
res
.
asymID
(),
res
.
seqID
(),
res
.
mAuthSeqID
}]
=
&
res
;
std
::
set
<
std
::
string
>
sugars
;
for
(
auto
&
branch
:
mBranches
)
{
for
(
auto
&
sugar
:
branch
)
{
resMap
[{
sugar
.
asymID
(),
sugar
.
num
()}]
=
&
sugar
;
resMap
[{
sugar
.
asymID
(),
sugar
.
seqID
(),
sugar
.
authSeqID
()}]
=
&
sugar
;
sugars
.
insert
(
sugar
.
compoundID
());
}
}
for
(
auto
&
atom
:
mAtoms
)
{
key_type
k
(
atom
.
labelAsymID
(),
atom
.
isWater
()
?
std
::
stoi
(
atom
.
authSeqID
())
:
atom
.
label
SeqID
());
key_type
k
(
atom
.
labelAsymID
(),
atom
.
labelSeqID
(),
atom
.
auth
SeqID
());
auto
ri
=
resMap
.
find
(
k
);
if
(
ri
==
resMap
.
end
()
and
sugars
.
count
(
atom
.
labelCompID
()))
{
k
=
{
atom
.
labelAsymID
(),
std
::
stoi
(
atom
.
authSeqID
())
};
ri
=
resMap
.
find
(
k
);
}
if
(
ri
==
resMap
.
end
())
{
if
(
cif
::
VERBOSE
>
0
)
std
::
cerr
<<
"Missing residue for atom "
<<
atom
<<
std
::
endl
;
...
...
@@ -1747,75 +1739,75 @@ Residue &Structure::getResidue(const std::string &asymID, const std::string &com
throw
std
::
out_of_range
(
"Could not find residue "
+
asymID
+
'/'
+
std
::
to_string
(
seqID
)
+
'-'
+
authSeqID
);
}
Residue
&
Structure
::
getResidue
(
const
mmcif
::
Atom
&
atom
)
{
using
namespace
cif
::
literals
;
auto
asymID
=
atom
.
labelAsymID
();
auto
entityID
=
atom
.
labelEntityID
();
auto
type
=
mDb
[
"entity"
].
find1
<
std
::
string
>
(
"id"
_key
==
entityID
,
"type"
);
if
(
type
==
"water"
)
{
auto
authSeqID
=
atom
.
authSeqID
();
for
(
auto
&
res
:
mNonPolymers
)
{
if
(
res
.
asymID
()
!=
asymID
or
res
.
authSeqID
()
!=
authSeqID
)
continue
;
return
res
;
}
throw
std
::
out_of_range
(
"Could not find water "
+
asymID
+
'/'
+
authSeqID
);
}
else
if
(
type
==
"branched"
)
{
auto
authSeqID
=
std
::
stoi
(
atom
.
authSeqID
());
for
(
auto
&
branch
:
mBranches
)
{
if
(
branch
.
asymID
()
!=
asymID
)
continue
;
for
(
auto
&
sugar
:
branch
)
{
if
(
sugar
.
asymID
()
==
asymID
and
sugar
.
num
()
==
authSeqID
)
return
sugar
;
}
}
throw
std
::
out_of_range
(
"Could not find sugar residue "
+
asymID
+
'/'
+
std
::
to_string
(
authSeqID
));
}
else
if
(
type
==
"polymer"
)
{
auto
seqID
=
atom
.
labelSeqID
();
for
(
auto
&
poly
:
mPolymers
)
{
if
(
poly
.
asymID
()
!=
asymID
)
continue
;
for
(
auto
&
res
:
poly
)
{
if
(
res
.
seqID
()
==
seqID
)
return
res
;
}
}
throw
std
::
out_of_range
(
"Could not find residue "
+
asymID
+
'/'
+
std
::
to_string
(
seqID
));
}
for
(
auto
&
res
:
mNonPolymers
)
{
if
(
res
.
asymID
()
!=
asymID
)
continue
;
return
res
;
}
throw
std
::
out_of_range
(
"Could not find residue "
+
asymID
);
}
//
Residue &Structure::getResidue(const mmcif::Atom &atom)
//
{
//
using namespace cif::literals;
//
auto asymID = atom.labelAsymID();
//
auto entityID = atom.labelEntityID();
//
auto type = mDb["entity"].find1<std::string>("id"_key == entityID, "type");
//
if (type == "water")
//
{
//
auto authSeqID = atom.authSeqID();
//
for (auto &res : mNonPolymers)
//
{
//
if (res.asymID() != asymID or res.authSeqID() != authSeqID)
//
continue;
//
return res;
//
}
//
throw std::out_of_range("Could not find water " + asymID + '/' + authSeqID);
//
}
//
else if (type == "branched")
//
{
//
auto authSeqID = std::stoi(atom.authSeqID());
//
for (auto &branch : mBranches)
//
{
//
if (branch.asymID() != asymID)
//
continue;
//
for (auto &sugar : branch)
//
{
//
if (sugar.asymID() == asymID and sugar.num() == authSeqID)
//
return sugar;
//
}
//
}
//
throw std::out_of_range("Could not find sugar residue " + asymID + '/' + std::to_string(authSeqID));
//
}
//
else if (type == "polymer")
//
{
//
auto seqID = atom.labelSeqID();
//
for (auto &poly : mPolymers)
//
{
//
if (poly.asymID() != asymID)
//
continue;
//
for (auto &res : poly)
//
{
//
if (res.seqID() == seqID)
//
return res;
//
}
//
}
//
throw std::out_of_range("Could not find residue " + asymID + '/' + std::to_string(seqID));
//
}
//
for (auto &res : mNonPolymers)
//
{
//
if (res.asymID() != asymID)
//
continue;
//
return res;
//
}
//
throw std::out_of_range("Could not find residue " + asymID);
//
}
std
::
tuple
<
char
,
int
,
char
>
Structure
::
MapLabelToAuth
(
const
std
::
string
&
asymID
,
int
seqID
)
const
...
...
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