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
f7b98c05
Unverified
Commit
f7b98c05
authored
Jan 05, 2022
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored AtomImpl
parent
c4f3b1cd
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
76 deletions
+127
-76
include/cif++/Structure.hpp
+127
-76
src/Structure.cpp
+0
-0
No files found.
include/cif++/Structure.hpp
View file @
f7b98c05
...
...
@@ -60,30 +60,101 @@ class File;
class
Atom
{
private
:
struct
AtomImpl
:
public
std
::
enable_shared_from_this
<
AtomImpl
>
{
AtomImpl
(
cif
::
Datablock
&
db
,
const
std
::
string
&
id
,
cif
::
Row
row
);
// constructor for a symmetry copy of an atom
AtomImpl
(
const
AtomImpl
&
impl
,
const
Point
&
loc
,
const
std
::
string
&
sym_op
);
AtomImpl
(
const
AtomImpl
&
i
)
=
default
;
void
prefetch
();
int
compare
(
const
AtomImpl
&
b
)
const
;
bool
getAnisoU
(
float
anisou
[
6
])
const
;
void
moveTo
(
const
Point
&
p
);
const
Compound
&
comp
()
const
;
const
std
::
string
get_property
(
const
std
::
string_view
name
)
const
;
void
set_property
(
const
std
::
string_view
name
,
const
std
::
string
&
value
);
const
cif
::
Datablock
&
mDb
;
std
::
string
mID
;
AtomType
mType
;
std
::
string
mAtomID
;
std
::
string
mCompID
;
std
::
string
mAsymID
;
int
mSeqID
;
std
::
string
mAltID
;
std
::
string
mAuthSeqID
;
Point
mLocation
;
int
mRefcount
;
cif
::
Row
mRow
;
mutable
std
::
vector
<
std
::
tuple
<
std
::
string
,
cif
::
detail
::
ItemReference
>>
mCachedRefs
;
mutable
const
Compound
*
mCompound
=
nullptr
;
bool
mSymmetryCopy
=
false
;
bool
mClone
=
false
;
std
::
string
mSymmetryOperator
=
"1_555"
;
};
public
:
Atom
();
Atom
(
struct
AtomImpl
*
impl
);
Atom
(
const
Atom
&
rhs
);
Atom
()
{}
Atom
(
std
::
shared_ptr
<
AtomImpl
>
impl
)
:
mImpl
(
impl
)
{}
Atom
(
const
Atom
&
rhs
)
:
mImpl
(
rhs
.
mImpl
)
{}
Atom
(
cif
::
Datablock
&
db
,
cif
::
Row
&
row
);
// a special constructor to create symmetry copies
Atom
(
const
Atom
&
rhs
,
const
Point
&
symmmetry_location
,
const
std
::
string
&
symmetry_operation
);
~
Atom
();
explicit
operator
bool
()
const
{
return
mImpl_
!=
nullptr
;
}
explicit
operator
bool
()
const
{
return
(
bool
)
mImpl
;
}
// return a copy of this atom, with data copied instead of referenced
Atom
clone
()
const
;
Atom
clone
()
const
{
auto
copy
=
std
::
make_shared
<
AtomImpl
>
(
*
mImpl
);
copy
->
mClone
=
true
;
return
Atom
(
copy
);
}
Atom
&
operator
=
(
const
Atom
&
rhs
)
=
default
;
template
<
typename
T
>
T
get_property
(
const
std
::
string_view
name
)
const
;
void
set_property
(
const
std
::
string_view
name
,
const
std
::
string
&
value
)
{
mImpl
->
set_property
(
name
,
value
);
}
Atom
&
operator
=
(
const
Atom
&
rhs
);
template
<
typename
T
,
std
::
enable_if_t
<
std
::
is_arithmetic_v
<
T
>
,
int
>
=
0
>
void
property
(
const
std
::
string_view
name
,
const
T
&
value
)
{
set_property
(
name
,
std
::
to_string
(
value
));
}
const
std
::
string
&
id
()
const
;
AtomType
type
()
const
;
const
std
::
string
&
id
()
const
{
return
mImpl
->
mID
;
}
AtomType
type
()
const
{
return
mImpl
->
mType
;
}
Point
location
()
const
;
void
location
(
Point
p
)
;
Point
location
()
const
{
return
mImpl
->
mLocation
;
}
void
location
(
Point
p
)
{
mImpl
->
moveTo
(
p
);
}
/// \brief Translate the position of this atom by \a t
void
translate
(
Point
t
);
...
...
@@ -92,46 +163,33 @@ class Atom
void
rotate
(
Quaternion
q
);
// for direct access to underlying data, be careful!
const
cif
::
Row
getRow
()
const
;
const
cif
::
Row
getRow
()
const
{
return
mImpl
->
mRow
;
}
const
cif
::
Row
getRowAniso
()
const
;
// Atom symmetryCopy(const Point& d, const clipper::RTop_orth& rt);
bool
isSymmetryCopy
()
const
;
std
::
string
symmetry
()
const
;
// const clipper::RTop_orth& symop() const;
bool
isSymmetryCopy
()
const
{
return
mImpl
->
mSymmetryCopy
;
}
std
::
string
symmetry
()
const
{
return
mImpl
->
mSymmetryOperator
;
}
const
Compound
&
comp
()
const
;
bool
isWater
()
const
;
const
Compound
&
comp
()
const
{
return
mImpl
->
comp
();
}
bool
isWater
()
const
{
return
mImpl
->
mCompID
==
"HOH"
or
mImpl
->
mCompID
==
"H2O"
or
mImpl
->
mCompID
==
"WAT"
;
}
int
charge
()
const
;
float
uIso
()
const
;
bool
getAnisoU
(
float
anisou
[
6
])
const
;
bool
getAnisoU
(
float
anisou
[
6
])
const
{
return
mImpl
->
getAnisoU
(
anisou
);
}
float
occupancy
()
const
;
template
<
typename
T
>
T
property
(
const
std
::
string_view
name
)
const
;
void
property
(
const
std
::
string_view
name
,
const
std
::
string
&
value
);
template
<
typename
T
,
std
::
enable_if_t
<
std
::
is_arithmetic_v
<
T
>
,
int
>
=
0
>
void
property
(
const
std
::
string_view
name
,
const
T
&
value
)
{
property
(
name
,
std
::
to_string
(
value
));
}
// specifications
const
std
::
string
&
labelAtomID
()
const
{
return
mAtomID
;
}
const
std
::
string
&
labelCompID
()
const
{
return
mCompID
;
}
const
std
::
string
&
labelAsymID
()
const
{
return
mAsymID
;
}
const
std
::
string
&
labelAtomID
()
const
{
return
m
Impl
->
m
AtomID
;
}
const
std
::
string
&
labelCompID
()
const
{
return
m
Impl
->
m
CompID
;
}
const
std
::
string
&
labelAsymID
()
const
{
return
m
Impl
->
m
AsymID
;
}
std
::
string
labelEntityID
()
const
;
int
labelSeqID
()
const
{
return
mSeqID
;
}
const
std
::
string
&
labelAltID
()
const
{
return
mAltID
;
}
bool
isAlternate
()
const
{
return
not
mAltID
.
empty
();
}
int
labelSeqID
()
const
{
return
m
Impl
->
m
SeqID
;
}
const
std
::
string
&
labelAltID
()
const
{
return
m
Impl
->
m
AltID
;
}
bool
isAlternate
()
const
{
return
not
m
Impl
->
m
AltID
.
empty
();
}
std
::
string
authAtomID
()
const
;
std
::
string
authCompID
()
const
;
std
::
string
authAsymID
()
const
;
const
std
::
string
&
authSeqID
()
const
{
return
mAuthSeqID
;
}
const
std
::
string
&
authSeqID
()
const
{
return
m
Impl
->
m
AuthSeqID
;
}
std
::
string
pdbxAuthInsCode
()
const
;
std
::
string
pdbxAuthAltID
()
const
;
...
...
@@ -140,13 +198,6 @@ class Atom
bool
operator
==
(
const
Atom
&
rhs
)
const
;
// // get clipper format Atom
// clipper::Atom toClipper() const;
// Radius calculation based on integrating the density until perc of electrons is found
void
calculateRadius
(
float
resHigh
,
float
resLow
,
float
perc
);
float
radius
()
const
;
// access data in compound for this atom
// convenience routine
...
...
@@ -158,16 +209,10 @@ class Atom
void
swap
(
Atom
&
b
)
{
std
::
swap
(
mImpl_
,
b
.
mImpl_
);
std
::
swap
(
mAtomID
,
b
.
mAtomID
);
std
::
swap
(
mCompID
,
b
.
mCompID
);
std
::
swap
(
mAsymID
,
b
.
mAsymID
);
std
::
swap
(
mSeqID
,
b
.
mSeqID
);
std
::
swap
(
mAltID
,
b
.
mAltID
);
std
::
swap
(
mAuthSeqID
,
b
.
mAuthSeqID
);
std
::
swap
(
mImpl
,
b
.
mImpl
);
}
int
compare
(
const
Atom
&
b
)
const
;
int
compare
(
const
Atom
&
b
)
const
{
return
mImpl
->
compare
(
*
b
.
mImpl
);
}
bool
operator
<
(
const
Atom
&
rhs
)
const
{
...
...
@@ -178,21 +223,30 @@ class Atom
private
:
friend
class
Structure
;
void
setID
(
int
id
);
AtomImpl
*
impl
()
;
const
AtomImpl
*
impl
()
const
;
std
::
shared_ptr
<
AtomImpl
>
mImpl
;
}
;
struct
AtomImpl
*
mImpl_
;
template
<>
inline
std
::
string
Atom
::
get_property
<
std
::
string
>
(
const
std
::
string_view
name
)
const
{
return
mImpl
->
get_property
(
name
);
}
// cached values
std
::
string
mAtomID
;
std
::
string
mCompID
;
std
::
string
mAsymID
;
int
mSeqID
;
std
::
string
mAltID
;
std
::
string
mAuthSeqID
;
};
template
<>
inline
int
Atom
::
get_property
<
int
>
(
const
std
::
string_view
name
)
const
{
auto
v
=
mImpl
->
get_property
(
name
);
return
v
.
empty
()
?
0
:
stoi
(
v
);
}
template
<>
inline
float
Atom
::
get_property
<
float
>
(
const
std
::
string_view
name
)
const
{
return
stof
(
mImpl
->
get_property
(
name
));
}
inline
void
swap
(
mmcif
::
Atom
&
a
,
mmcif
::
Atom
&
b
)
{
...
...
@@ -216,19 +270,16 @@ typedef std::vector<Atom> AtomView;
class
Residue
{
public
:
// constructors should be private, but that's not possible for now (needed in emplace)
// constructor for waters
Residue
(
const
Structure
&
structure
,
const
std
::
string
&
compoundID
,
const
std
::
string
&
asymID
,
const
std
::
string
&
authSeqID
);
// constructor for a residue without a sequence number
// constructor
Residue
(
const
Structure
&
structure
,
const
std
::
string
&
compoundID
,
const
std
::
string
&
asymID
);
// constructor for a residue with a sequence number
Residue
(
const
Structure
&
structure
,
const
std
::
string
&
compoundID
,
const
std
::
string
&
asymID
,
int
seqID
,
const
std
::
string
&
authSeqID
);
const
std
::
string
&
asymID
,
int
seqID
=
0
,
const
std
::
string
&
authSeqID
=
{})
:
mStructure
(
&
structure
)
,
mCompoundID
(
compoundID
)
,
mAsymID
(
asymID
)
,
mSeqID
(
seqID
)
,
mAuthSeqID
(
authSeqID
)
{
}
Residue
(
const
Residue
&
rhs
)
=
delete
;
Residue
&
operator
=
(
const
Residue
&
rhs
)
=
delete
;
...
...
src/Structure.cpp
View file @
f7b98c05
This diff is collapsed.
Click to expand it.
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