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
81c0d019
Commit
81c0d019
authored
Aug 18, 2021
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaning up all warnings in MSVC
parent
1d2f997e
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
424 additions
and
399 deletions
+424
-399
.gitignore
+1
-0
CMakeLists.txt
+20
-22
include/cif++/Cif++.hpp
+1
-1
include/cif++/CifUtils.hpp
+12
-2
include/cif++/PDB2Cif.hpp
+16
-15
include/cif++/Point.hpp
+2
-2
include/cif++/Structure.hpp
+187
-190
src/BondMap.cpp
+3
-6
src/Cif++.cpp
+30
-23
src/Cif2PDB.cpp
+12
-12
src/CifParser.cpp
+1
-1
src/CifUtils.cpp
+10
-4
src/CifValidator.cpp
+2
-2
src/Compound.cpp
+7
-7
src/PDB2Cif.cpp
+0
-0
src/PDB2CifRemark3.cpp
+2
-2
src/Point.cpp
+9
-9
src/Secondary.cpp
+26
-26
src/Structure.cpp
+83
-75
No files found.
.gitignore
View file @
81c0d019
...
...
@@ -8,3 +8,4 @@ test/pdb2cif-test
test/rename-compound-test
tools/update-dictionary-script
data/
CMakeSettings.json
CMakeLists.txt
View file @
81c0d019
...
...
@@ -15,10 +15,6 @@ include(CMakePackageConfigHelpers)
include
(
Dart
)
include
(
GenerateExportHeader
)
set
(
PACKAGE
${
PROJECT_NAME
}
)
set
(
PACKAGE_VERSION
${
PROJECT_VERSION
}
)
add_definitions
(
-DVERSION=
${
PACKAGE_VERSION
}
)
set
(
CXX_EXTENSIONS OFF
)
set
(
CMAKE_CXX_STANDARD 17
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
...
...
@@ -31,6 +27,9 @@ if(MSVC)
set
(
CMAKE_EXE_LINKER_FLAGS
"
${
CMAKE_EXE_LINKER_FLAGS
}
"
)
endif
()
# Build shared libraries by default (not my cup of tea, but hey)
option
(
BUILD_SHARED_LIBS
"Build a shared library instead of a static one"
ON
)
set
(
CMAKE_DEBUG_POSTFIX d
)
if
(
MSVC
)
...
...
@@ -163,18 +162,15 @@ include_directories(
${
PROJECT_SOURCE_DIR
}
/src
)
add_library
(
cifpp
SHARED
${
project_sources
}
${
project_headers
}
)
add_library
(
cifpp
${
project_sources
}
${
project_headers
}
)
set_target_properties
(
cifpp PROPERTIES
SOVERSION
${
PROJECT_VERSION
}
INTERFACE_cifpp_MAJOR_VERSION cifpp_MAJOR_VERSION
COMPATIBLE_INTERFACE_STRING cifpp_MAJOR_VERSION
)
add_library
(
cifpp_static STATIC
${
project_sources
}
${
project_headers
}
)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"AppleClang"
)
target_link_options
(
cifpp PRIVATE -undefined dynamic_lookup
)
target_link_options
(
cifpp_static PRIVATE -undefined dynamic_lookup
)
endif
(
CMAKE_CXX_COMPILER_ID STREQUAL
"AppleClang"
)
# download the components.cif file from CCD
...
...
@@ -212,13 +208,23 @@ add_custom_target(COMPONENTS ALL DEPENDS ${COMPONENTS_CIF})
include_directories
(
${
Boost_INCLUDE_DIRS
}
)
link_libraries
(
${
Boost_LIBRARIES
}
)
add_compile_definitions
(
CACHE_DIR=
"
${
SHARE_INSTALL_DIR
}
/libcifpp"
DATA_DIR=
"
${
SHARE_INSTALL_DIR
}
/libcifpp"
)
set
(
INCLUDE_INSTALL_DIR
${
CMAKE_INSTALL_INCLUDEDIR
}
)
set
(
LIBRARY_INSTALL_DIR
${
CMAKE_INSTALL_LIBDIR
}
)
set
(
SHARE_INSTALL_DIR
${
CMAKE_INSTALL_DATADIR
}
/libcifpp
)
set
(
ConfigPackageLocation lib/cmake/cifpp
)
# Fix cache dir
add_compile_definitions
(
# CACHE_DIR="${CMAKE_INSTALL_PREFIX}/${SHARE_INSTALL_DIR}"
DATA_DIR=
"
${
CMAKE_INSTALL_PREFIX
}
/
${
SHARE_INSTALL_DIR
}
"
)
generate_export_header
(
cifpp
)
# Install rules
install
(
TARGETS cifpp
cifpp_static
install
(
TARGETS cifpp
EXPORT cifppTargets
ARCHIVE DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
LIBRARY DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
...
...
@@ -241,15 +247,9 @@ install(FILES
${
PROJECT_SOURCE_DIR
}
/rsrc/mmcif_ddl.dic
${
PROJECT_SOURCE_DIR
}
/rsrc/mmcif_pdbx_v50.dic
${
PROJECT_SOURCE_DIR
}
/data/components.cif
DESTINATION
${
CMAKE_INSTALL_DATA
DIR
}
DESTINATION
${
SHARE_INSTALL_
DIR
}
)
set
(
INCLUDE_INSTALL_DIR include
)
set
(
LIBRARY_INSTALL_DIR lib
)
set
(
SHARE_INSTALL_DIR share/libcifpp
)
set
(
ConfigPackageLocation lib/cmake/cifpp
)
configure_package_config_file
(
cmake/cifppConfig.cmake.in
${
CMAKE_CURRENT_BINARY_DIR
}
/cifpp/cifppConfig.cmake
INSTALL_DESTINATION
${
ConfigPackageLocation
}
...
...
@@ -310,7 +310,7 @@ if(CIFPP_BUILD_TESTS)
${
CMAKE_CURRENT_BINARY_DIR
}
# for config.h
)
target_link_libraries
(
${
CIFPP_TEST
}
cifpp_static
Threads::Threads
${
Boost_LIBRARIES
}
)
target_link_libraries
(
${
CIFPP_TEST
}
$<TARGET_OBJECTS:cifpp>
Threads::Threads
${
Boost_LIBRARIES
}
)
if
(
${
ZLIB_FOUND
}
)
target_link_libraries
(
${
CIFPP_TEST
}
ZLIB::ZLIB
)
...
...
@@ -329,8 +329,8 @@ if(CIFPP_BUILD_TESTS)
add_custom_command
(
OUTPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/Run
${
CIFPP_TEST
}
.touch
COMMAND
$
{
CMAKE_CURRENT_BINARY_DIR
}
/
${
CIFPP_TEST
}
)
COMMAND $
<TARGET_FILE:
${
CIFPP_TEST
}
>
WORKING_DIRECTORY
${
CMAKE_SOURCE_DIR
}
/test
)
add_test
(
NAME
${
CIFPP_TEST
}
COMMAND $<TARGET_FILE:
${
CIFPP_TEST
}
>
...
...
@@ -338,5 +338,3 @@ if(CIFPP_BUILD_TESTS)
endforeach
()
endif
()
include/cif++/Cif++.hpp
View file @
81c0d019
...
...
@@ -1961,7 +1961,7 @@ class Category
void
write
(
std
::
ostream
&
os
);
void
write
(
std
::
ostream
&
os
,
const
std
::
vector
<
std
::
string
>&
order
);
void
write
(
std
::
ostream
&
os
,
const
std
::
vector
<
in
t
>&
order
,
bool
includeEmptyColumns
);
void
write
(
std
::
ostream
&
os
,
const
std
::
vector
<
size_
t
>&
order
,
bool
includeEmptyColumns
);
size_t
addColumn
(
const
std
::
string
&
name
);
...
...
include/cif++/CifUtils.hpp
View file @
81c0d019
...
...
@@ -47,6 +47,16 @@
#include "cifpp_export.h"
#if _MSC_VER
# pragma warning (disable : 4355) // this is used in Base Initializer list
# pragma warning (disable : 4996) // unsafe function or variable
# pragma warning (disable : 4068) // unknown pragma
# pragma warning (disable : 4996) // stl copy()
# pragma warning (disable : 4800) // BOOL conversion
# pragma warning (disable : 4100) // unreferenced formal parameter
# pragma warning (disable : 4101) // unreferenced local variable
#endif
namespace
cif
{
...
...
@@ -85,7 +95,7 @@ typedef std::set<std::string, iless> iset;
extern
const
uint8_t
kCharToLowerMap
[
256
];
inline
char
tolower
(
char
ch
)
inline
char
tolower
(
int
ch
)
{
return
static_cast
<
char
>
(
kCharToLowerMap
[
static_cast
<
uint8_t
>
(
ch
)]);
}
...
...
@@ -102,7 +112,7 @@ std::string cifIdForNumber(int number);
// --------------------------------------------------------------------
// custom wordwrapping routine
std
::
vector
<
std
::
string
>
wordWrap
(
const
std
::
string
&
text
,
unsigned
in
t
width
);
std
::
vector
<
std
::
string
>
wordWrap
(
const
std
::
string
&
text
,
size_
t
width
);
// --------------------------------------------------------------------
// Code helping with terminal i/o
...
...
include/cif++/PDB2Cif.hpp
View file @
81c0d019
...
...
@@ -32,22 +32,23 @@
struct
PDBRecord
{
PDBRecord
*
mNext
;
uint32_t
mLineNr
;
char
mName
[
11
];
size_t
mVlen
;
char
mValue
[
0
];
PDBRecord
*
mNext
;
uint32_t
mLineNr
;
char
mName
[
11
];
size_t
mVlen
;
char
mValue
[
1
];
PDBRecord
(
uint32_t
lineNr
,
const
std
::
string
&
name
,
const
std
::
string
&
value
);
PDBRecord
(
uint32_t
lineNr
,
const
std
::
string
&
name
,
const
std
::
string
&
value
);
~
PDBRecord
();
void
*
operator
new
(
size_t
);
void
*
operator
new
(
size_t
size
,
size_t
vLen
);
void
operator
delete
(
void
*
p
);
bool
is
(
const
char
*
name
)
const
;
void
*
operator
new
(
size_t
);
void
*
operator
new
(
size_t
size
,
size_t
vLen
);
void
operator
delete
(
void
*
p
);
void
operator
delete
(
void
*
p
,
size_t
vLen
);
bool
is
(
const
char
*
name
)
const
;
char
vC
(
size_t
column
);
std
::
string
vS
(
size_t
columnFirst
,
size_t
columnLast
=
std
::
numeric_limits
<
size_t
>::
max
());
int
vI
(
int
columnFirst
,
int
columnLast
);
...
...
@@ -56,4 +57,4 @@ struct PDBRecord
// --------------------------------------------------------------------
void
ReadPDBFile
(
std
::
istream
&
pdbFile
,
cif
::
File
&
cifFile
);
void
ReadPDBFile
(
std
::
istream
&
pdbFile
,
cif
::
File
&
cifFile
);
include/cif++/Point.hpp
View file @
81c0d019
...
...
@@ -39,8 +39,8 @@ namespace mmcif
typedef
boost
::
math
::
quaternion
<
float
>
quaternion
;
const
long
double
kPI
=
3.141592653589793238462643383279502884
L
;
const
double
kPI
=
3.141592653589793238462643383279502884
;
// --------------------------------------------------------------------
...
...
include/cif++/Structure.hpp
View file @
81c0d019
...
...
@@ -29,9 +29,9 @@
#include <numeric>
#include "cif++/AtomType.hpp"
#include "cif++/Point.hpp"
#include "cif++/Compound.hpp"
#include "cif++/Cif++.hpp"
#include "cif++/Compound.hpp"
#include "cif++/Point.hpp"
/*
To modify a structure, you will have to use actions.
...
...
@@ -61,29 +61,29 @@ class File;
class
Atom
{
public
:
// Atom(const structure& s, const std::string& id);
// Atom(const structure& s, const std::string& id);
Atom
();
Atom
(
struct
AtomImpl
*
impl
);
Atom
(
const
Atom
&
rhs
);
Atom
(
struct
AtomImpl
*
impl
);
Atom
(
const
Atom
&
rhs
);
// a special constructor to create symmetry copies
Atom
(
const
Atom
&
rhs
,
const
Point
&
symmmetry_location
,
const
std
::
string
&
symmetry_operation
);
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
mImpl_
!=
nullptr
;
}
// return a copy of this atom, with data copied instead of referenced
Atom
clone
()
const
;
Atom
&
operator
=
(
const
Atom
&
rhs
);
const
std
::
string
&
id
()
const
;
Atom
&
operator
=
(
const
Atom
&
rhs
);
const
std
::
string
&
id
()
const
;
AtomType
type
()
const
;
Point
location
()
const
;
void
location
(
Point
p
);
// for direct access to underlying data, be careful!
const
cif
::
Row
getRow
()
const
;
const
cif
::
Row
getRowAniso
()
const
;
...
...
@@ -92,26 +92,26 @@ class Atom
bool
isSymmetryCopy
()
const
;
std
::
string
symmetry
()
const
;
// const clipper::RTop_orth& symop() const;
const
Compound
&
comp
()
const
;
const
Compound
&
comp
()
const
;
bool
isWater
()
const
;
int
charge
()
const
;
float
uIso
()
const
;
bool
getAnisoU
(
float
anisou
[
6
])
const
;
float
occupancy
()
const
;
template
<
typename
T
>
T
property
(
const
std
::
string
&
name
)
const
;
void
property
(
const
std
::
string
&
name
,
const
std
::
string
&
value
);
template
<
typename
T
,
std
::
enable_if_t
<
std
::
is_arithmetic_v
<
T
>
,
int
>
=
0
>
void
property
(
const
std
::
string
&
name
,
const
T
&
value
)
template
<
typename
T
>
T
property
(
const
std
::
string
&
name
)
const
;
void
property
(
const
std
::
string
&
name
,
const
std
::
string
&
value
);
template
<
typename
T
,
std
::
enable_if_t
<
std
::
is_arithmetic_v
<
T
>
,
int
>
=
0
>
void
property
(
const
std
::
string
&
name
,
const
T
&
value
)
{
property
(
name
,
std
::
to_string
(
value
));
}
// specifications
std
::
string
labelAtomID
()
const
;
std
::
string
labelCompID
()
const
;
...
...
@@ -120,18 +120,18 @@ class Atom
int
labelSeqID
()
const
;
std
::
string
labelAltID
()
const
;
bool
isAlternate
()
const
;
std
::
string
authAtomID
()
const
;
std
::
string
authCompID
()
const
;
std
::
string
authAsymID
()
const
;
std
::
string
authSeqID
()
const
;
std
::
string
pdbxAuthInsCode
()
const
;
std
::
string
pdbxAuthAltID
()
const
;
std
::
string
labelID
()
const
;
// label_comp_id + '_' + label_asym_id + '_' + label_seq_id
std
::
string
pdbID
()
const
;
// auth_comp_id + '_' + auth_asym_id + '_' + auth_seq_id + pdbx_PDB_ins_code
bool
operator
==
(
const
Atom
&
rhs
)
const
;
std
::
string
labelID
()
const
;
// label_comp_id + '_' + label_asym_id + '_' + label_seq_id
std
::
string
pdbID
()
const
;
// auth_comp_id + '_' + auth_asym_id + '_' + auth_seq_id + pdbx_PDB_ins_code
bool
operator
==
(
const
Atom
&
rhs
)
const
;
// // get clipper format Atom
// clipper::Atom toClipper() const;
...
...
@@ -139,7 +139,7 @@ class Atom
// 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
...
...
@@ -148,42 +148,42 @@ class Atom
auto
atomID
=
labelAtomID
();
return
atomID
==
"N"
or
atomID
==
"O"
or
atomID
==
"C"
or
atomID
==
"CA"
;
}
void
swap
(
Atom
&
b
)
void
swap
(
Atom
&
b
)
{
std
::
swap
(
mImpl_
,
b
.
mImpl_
);
}
int
compare
(
const
Atom
&
b
)
const
;
int
compare
(
const
Atom
&
b
)
const
;
bool
operator
<
(
const
Atom
&
rhs
)
const
bool
operator
<
(
const
Atom
&
rhs
)
const
{
return
compare
(
rhs
)
<
0
;
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Atom
&
atom
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Atom
&
atom
);
private
:
friend
class
Structure
;
void
setID
(
int
id
);
AtomImpl
*
impl
();
const
AtomImpl
*
impl
()
const
;
AtomImpl
*
impl
();
const
AtomImpl
*
impl
()
const
;
struct
AtomImpl
*
mImpl_
;
struct
AtomImpl
*
mImpl_
;
};
inline
void
swap
(
mmcif
::
Atom
&
a
,
mmcif
::
Atom
&
b
)
inline
void
swap
(
mmcif
::
Atom
&
a
,
mmcif
::
Atom
&
b
)
{
a
.
swap
(
b
);
}
inline
double
Distance
(
const
Atom
&
a
,
const
Atom
&
b
)
inline
double
Distance
(
const
Atom
&
a
,
const
Atom
&
b
)
{
return
Distance
(
a
.
location
(),
b
.
location
());
}
inline
double
DistanceSquared
(
const
Atom
&
a
,
const
Atom
&
b
)
inline
double
DistanceSquared
(
const
Atom
&
a
,
const
Atom
&
b
)
{
return
DistanceSquared
(
a
.
location
(),
b
.
location
());
}
...
...
@@ -198,59 +198,59 @@ class Residue
// 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
);
Residue
(
const
Structure
&
structure
,
const
std
::
string
&
compoundID
,
const
std
::
string
&
asymID
,
const
std
::
string
&
authSeqID
);
// constructor for a residue without a sequence number
Residue
(
const
Structure
&
structure
,
const
std
::
string
&
compoundID
,
const
std
::
string
&
asymID
);
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
);
Residue
(
const
Structure
&
structure
,
const
std
::
string
&
compoundID
,
const
std
::
string
&
asymID
,
int
seqID
,
const
std
::
string
&
authSeqID
);
Residue
(
const
Residue
&
rhs
)
=
delete
;
Residue
&
operator
=
(
const
Residue
&
rhs
)
=
delete
;
Residue
(
const
Residue
&
rhs
)
=
delete
;
Residue
&
operator
=
(
const
Residue
&
rhs
)
=
delete
;
Residue
(
Residue
&&
rhs
);
Residue
&
operator
=
(
Residue
&&
rhs
);
Residue
(
Residue
&&
rhs
);
Residue
&
operator
=
(
Residue
&&
rhs
);
virtual
~
Residue
();
const
Compound
&
compound
()
const
;
const
AtomView
&
atoms
()
const
;
const
Compound
&
compound
()
const
;
const
AtomView
&
atoms
()
const
;
/// \brief Unique atoms returns only the atoms without alternates and the first of each alternate atom id.
AtomView
unique_atoms
()
const
;
AtomView
unique_atoms
()
const
;
/// \brief The alt ID used for the unique atoms
std
::
string
unique_alt_id
()
const
;
std
::
string
unique_alt_id
()
const
;
Atom
atomByID
(
const
std
::
string
&
atomID
)
const
;
Atom
atomByID
(
const
std
::
string
&
atomID
)
const
;
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
;
std
::
string
authInsCode
()
const
;
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
;
std
::
string
authInsCode
()
const
;
// return a human readable PDB-like auth id (chain+seqnr+iCode)
std
::
string
authID
()
const
;
std
::
string
authID
()
const
;
// similar for mmCIF space
std
::
string
labelID
()
const
;
std
::
string
labelID
()
const
;
// Is this residue a single entity?
bool
isEntity
()
const
;
bool
isWater
()
const
{
return
mCompoundID
==
"HOH"
;
}
const
Structure
&
structure
()
const
{
return
*
mStructure
;
}
bool
isWater
()
const
{
return
mCompoundID
==
"HOH"
;
}
const
Structure
&
structure
()
const
{
return
*
mStructure
;
}
bool
empty
()
const
{
return
mStructure
==
nullptr
;
}
bool
empty
()
const
{
return
mStructure
==
nullptr
;
}
bool
hasAlternateAtoms
()
const
;
...
...
@@ -261,44 +261,43 @@ class Residue
std
::
set
<
std
::
string
>
getAtomIDs
()
const
;
/// \brief Return the list of atoms having ID \a atomID
AtomView
getAtomsByID
(
const
std
::
string
&
atomID
)
const
;
AtomView
getAtomsByID
(
const
std
::
string
&
atomID
)
const
;
// some routines for 3d work
std
::
tuple
<
Point
,
float
>
centerAndRadius
()
const
;
std
::
tuple
<
Point
,
float
>
centerAndRadius
()
const
;
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Residue
&
res
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Residue
&
res
);
protected
:
Residue
()
{}
friend
class
Polymer
;
const
Structure
*
mStructure
=
nullptr
;
std
::
string
mCompoundID
,
mAsymID
;
const
Structure
*
mStructure
=
nullptr
;
std
::
string
mCompoundID
,
mAsymID
;
int
mSeqID
=
0
;
// Watch out, this is used only to label waters... The rest of the code relies on
// MapLabelToAuth to get this info. Perhaps we should rename this member field.
std
::
string
mAuthSeqID
;
std
::
string
mAuthSeqID
;
AtomView
mAtoms
;
};
// --------------------------------------------------------------------
// a monomer models a single Residue in a protein chain
// a monomer models a single Residue in a protein chain
class
Monomer
:
public
Residue
{
public
:
// Monomer();
Monomer
(
const
Monomer
&
rhs
)
=
delete
;
Monomer
&
operator
=
(
const
Monomer
&
rhs
)
=
delete
;
Monomer
(
Monomer
&&
rhs
);
Monomer
&
operator
=
(
Monomer
&&
rhs
);
// Monomer();
Monomer
(
const
Monomer
&
rhs
)
=
delete
;
Monomer
&
operator
=
(
const
Monomer
&
rhs
)
=
delete
;
Monomer
(
Monomer
&&
rhs
);
Monomer
&
operator
=
(
Monomer
&&
rhs
);
Monomer
(
const
Polymer
&
polymer
,
uint32_t
index
,
int
seqID
,
const
std
::
string
&
authSeqID
,
const
std
::
string
&
compoundID
);
Monomer
(
const
Polymer
&
polymer
,
size_t
index
,
int
seqID
,
const
std
::
string
&
authSeqID
,
const
std
::
string
&
compoundID
);
bool
is_first_in_chain
()
const
;
bool
is_last_in_chain
()
const
;
...
...
@@ -308,7 +307,7 @@ class Monomer : public Residue
bool
has_kappa
()
const
;
// Assuming this is really an amino acid...
float
phi
()
const
;
float
psi
()
const
;
float
alpha
()
const
;
...
...
@@ -316,10 +315,10 @@ class Monomer : public Residue
float
tco
()
const
;
float
omega
()
const
;
// torsion angles
size_t
nrOfChis
()
const
;
float
chi
(
size_t
i
)
const
;
// torsion angles
size_t
nrOfChis
()
const
;
float
chi
(
size_t
i
)
const
;
bool
isCis
()
const
;
/// \brief Returns true if the four atoms C, CA, N and O are present
...
...
@@ -328,27 +327,27 @@ class Monomer : public Residue
/// \brief Returns true if any of the backbone atoms has an alternate
bool
hasAlternateBackboneAtoms
()
const
;
Atom
CAlpha
()
const
{
return
atomByID
(
"CA"
);
}
Atom
C
()
const
{
return
atomByID
(
"C"
);
}
Atom
N
()
const
{
return
atomByID
(
"N"
);
}
Atom
O
()
const
{
return
atomByID
(
"O"
);
}
Atom
H
()
const
{
return
atomByID
(
"H"
);
}
Atom
CAlpha
()
const
{
return
atomByID
(
"CA"
);
}
Atom
C
()
const
{
return
atomByID
(
"C"
);
}
Atom
N
()
const
{
return
atomByID
(
"N"
);
}
Atom
O
()
const
{
return
atomByID
(
"O"
);
}
Atom
H
()
const
{
return
atomByID
(
"H"
);
}
bool
isBondedTo
(
const
Monomer
&
rhs
)
const
bool
isBondedTo
(
const
Monomer
&
rhs
)
const
{
return
this
!=
&
rhs
and
areBonded
(
*
this
,
rhs
);
}
static
bool
areBonded
(
const
Monomer
&
a
,
const
Monomer
&
b
,
float
errorMargin
=
0.5
f
);
static
bool
isCis
(
const
Monomer
&
a
,
const
Monomer
&
b
);
static
float
omega
(
const
Monomer
&
a
,
const
Monomer
&
b
);
static
bool
areBonded
(
const
Monomer
&
a
,
const
Monomer
&
b
,
float
errorMargin
=
0.5
f
);
static
bool
isCis
(
const
Monomer
&
a
,
const
Monomer
&
b
);
static
float
omega
(
const
Monomer
&
a
,
const
Monomer
&
b
);
// for LEU and VAL
float
chiralVolume
()
const
;
// for LEU and VAL
float
chiralVolume
()
const
;
private
:
const
Polymer
*
mPolymer
;
uint32_t
mIndex
;
const
Polymer
*
mPolymer
;
size_t
mIndex
;
};
// --------------------------------------------------------------------
...
...
@@ -356,32 +355,31 @@ class Monomer : public Residue
class
Polymer
:
public
std
::
vector
<
Monomer
>
{
public
:
Polymer
(
const
Structure
&
s
,
const
std
::
string
&
entityID
,
const
std
::
string
&
asymID
);
Polymer
(
const
Structure
&
s
,
const
std
::
string
&
entityID
,
const
std
::
string
&
asymID
);
Polymer
(
const
Polymer
&
)
=
delete
;
Polymer
&
operator
=
(
const
Polymer
&
)
=
delete
;
// Polymer(Polymer&& rhs) = delete;
// Polymer& operator=(Polymer&& rhs) = de;
Polymer
(
const
Polymer
&
)
=
delete
;
Polymer
&
operator
=
(
const
Polymer
&
)
=
delete
;
Monomer
&
getBySeqID
(
int
seqID
);
const
Monomer
&
getBySeqID
(
int
seqID
)
const
;
// Polymer(Polymer&& rhs) = delete;
// Polymer& operator=(Polymer&& rhs) = de;
Monomer
&
getBySeqID
(
int
seqID
);
const
Monomer
&
getBySeqID
(
int
seqID
)
const
;
Structure
*
structure
()
const
{
return
mStructure
;
}
std
::
string
asymID
()
const
{
return
mAsymID
;
}
std
::
string
entityID
()
const
{
return
mEntityID
;
}
Structure
*
structure
()
const
{
return
mStructure
;
}
std
::
string
asymID
()
const
{
return
mAsymID
;
}
std
::
string
entityID
()
const
{
return
mEntityID
;
}
std
::
string
chainID
()
const
;
int
Distance
(
const
Monomer
&
a
,
const
Monomer
&
b
)
const
;
private
:
int
Distance
(
const
Monomer
&
a
,
const
Monomer
&
b
)
const
;
Structure
*
mStructure
;
std
::
string
mEntityID
;
std
::
string
mAsymID
;
cif
::
RowSet
mPolySeq
;
private
:
Structure
*
mStructure
;
std
::
string
mEntityID
;
std
::
string
mAsymID
;
cif
::
RowSet
mPolySeq
;
};
// --------------------------------------------------------------------
...
...
@@ -392,33 +390,32 @@ class File : public std::enable_shared_from_this<File>
{
public
:
File
();
File
(
const
std
::
string
&
path
);
File
(
const
char
*
data
,
size_t
length
);
// good luck trying to find out what it is...
File
(
const
std
::
string
&
path
);
File
(
const
char
*
data
,
size_t
length
);
// good luck trying to find out what it is...
~
File
();
File
(
const
File
&
)
=
delete
;
File
&
operator
=
(
const
File
&
)
=
delete
;
File
(
const
File
&
)
=
delete
;
File
&
operator
=
(
const
File
&
)
=
delete
;
void
load
(
const
std
::
string
&
path
);
void
save
(
const
std
::
string
&
path
);
Structure
*
model
(
size_t
nr
=
1
);
void
load
(
const
std
::
string
&
path
);
void
save
(
const
std
::
string
&
path
);
struct
FileImpl
&
impl
()
const
{
return
*
mImpl
;
}
Structure
*
model
(
size_t
nr
=
1
);
cif
::
Datablock
&
data
();
cif
::
File
&
file
();
struct
FileImpl
&
impl
()
const
{
return
*
mImpl
;
}
private
:
cif
::
Datablock
&
data
();
cif
::
File
&
file
();
struct
FileImpl
*
mImpl
;
private
:
struct
FileImpl
*
mImpl
;
};
// --------------------------------------------------------------------
enum
class
StructureOpenOptions
{
SkipHydrogen
=
1
<<
0
SkipHydrogen
=
1
<<
0
};
inline
bool
operator
&
(
StructureOpenOptions
a
,
StructureOpenOptions
b
)
...
...
@@ -431,67 +428,67 @@ inline bool operator&(StructureOpenOptions a, StructureOpenOptions b)
class
Structure
{
public
:
Structure
(
File
&
p
,
uint32
_t
modelNr
=
1
,
StructureOpenOptions
options
=
{});
Structure
&
operator
=
(
const
Structure
&
)
=
delete
;
Structure
(
File
&
p
,
size
_t
modelNr
=
1
,
StructureOpenOptions
options
=
{});
Structure
&
operator
=
(
const
Structure
&
)
=
delete
;
~
Structure
();
// Create a read-only clone of the current structure (for multithreaded calculations that move atoms)
Structure
(
const
Structure
&
);
Structure
(
const
Structure
&
);
File
&
getFile
()
const
;
File
&
getFile
()
const
;
const
AtomView
&
atoms
()
const
{
return
mAtoms
;
}
const
AtomView
&
atoms
()
const
{
return
mAtoms
;
}
AtomView
waters
()
const
;
const
std
::
list
<
Polymer
>&
polymers
()
const
{
return
mPolymers
;
}
std
::
list
<
Polymer
>&
polymers
()
{
return
mPolymers
;
}
const
std
::
vector
<
Residue
>&
nonPolymers
()
const
{
return
mNonPolymers
;
}
const
std
::
vector
<
Residue
>&
branchResidues
()
const
{
return
mBranchResidues
;
}
const
std
::
list
<
Polymer
>
&
polymers
()
const
{
return
mPolymers
;
}
std
::
list
<
Polymer
>
&
polymers
()
{
return
mPolymers
;
}
const
std
::
vector
<
Residue
>
&
nonPolymers
()
const
{
return
mNonPolymers
;
}
const
std
::
vector
<
Residue
>
&
branchResidues
()
const
{
return
mBranchResidues
;
}
Atom
getAtomByID
(
std
::
string
id
)
const
;
// Atom getAtomByLocation(Point pt, float maxDistance) const;
Atom
getAtomByLabel
(
const
std
::
string
&
atomID
,
const
std
::
string
&
asymID
,
const
std
::
string
&
compID
,
int
seqID
,
const
std
::
string
&
altID
=
""
);
Atom
getAtomByLabel
(
const
std
::
string
&
atomID
,
const
std
::
string
&
asymID
,
const
std
::
string
&
compID
,
int
seqID
,
const
std
::
string
&
altID
=
""
);
/// \brief Get a residue, if \a seqID is zero, the non-polymers are searched
const
Residue
&
getResidue
(
const
std
::
string
&
asymID
,
const
std
::
string
&
compID
,
int
seqID
=
0
)
const
;
const
Residue
&
getResidue
(
const
std
::
string
&
asymID
,
const
std
::
string
&
compID
,
int
seqID
=
0
)
const
;
// map between auth and label locations
std
::
tuple
<
std
::
string
,
int
,
std
::
string
>
MapAuthToLabel
(
const
std
::
string
&
asymID
,
const
std
::
string
&
seqID
,
const
std
::
string
&
compID
,
const
std
::
string
&
insCode
=
""
);
std
::
tuple
<
std
::
string
,
std
::
string
,
std
::
string
,
std
::
string
>
MapLabelToAuth
(
const
std
::
string
&
asymID
,
int
seqID
,
const
std
::
string
&
compID
);
std
::
tuple
<
std
::
string
,
int
,
std
::
string
>
MapAuthToLabel
(
const
std
::
string
&
asymID
,
const
std
::
string
&
seqID
,
const
std
::
string
&
compID
,
const
std
::
string
&
insCode
=
""
);
std
::
tuple
<
std
::
string
,
std
::
string
,
std
::
string
,
std
::
string
>
MapLabelToAuth
(
const
std
::
string
&
asymID
,
int
seqID
,
const
std
::
string
&
compID
);
// returns chain, seqnr, icode
std
::
tuple
<
char
,
int
,
char
>
MapLabelToAuth
(
const
std
::
string
&
asymID
,
int
seqID
)
const
;
std
::
tuple
<
char
,
int
,
char
>
MapLabelToAuth
(
const
std
::
string
&
asymID
,
int
seqID
)
const
;
// returns chain,seqnr,comp,iCode
std
::
tuple
<
std
::
string
,
int
,
std
::
string
,
std
::
string
>
MapLabelToPDB
(
const
std
::
string
&
asymID
,
int
seqID
,
const
std
::
string
&
compID
,
const
std
::
string
&
authSeqID
)
const
;
std
::
tuple
<
std
::
string
,
int
,
std
::
string
,
std
::
string
>
MapLabelToPDB
(
const
std
::
string
&
asymID
,
int
seqID
,
const
std
::
string
&
compID
,
const
std
::
string
&
authSeqID
)
const
;
std
::
tuple
<
std
::
string
,
int
,
std
::
string
>
MapPDBToLabel
(
const
std
::
string
&
asymID
,
int
seqID
,
const
std
::
string
&
compID
,
const
std
::
string
&
iCode
)
const
;
std
::
tuple
<
std
::
string
,
int
,
std
::
string
>
MapPDBToLabel
(
const
std
::
string
&
asymID
,
int
seqID
,
const
std
::
string
&
compID
,
const
std
::
string
&
iCode
)
const
;
// Actions
void
removeAtom
(
Atom
&
a
);
void
swapAtoms
(
Atom
&
a1
,
Atom
&
a2
);
// swap the labels for these atoms
void
moveAtom
(
Atom
&
a
,
Point
p
);
// move atom to a new location
void
changeResidue
(
const
Residue
&
res
,
const
std
::
string
&
newCompound
,
const
std
::
vector
<
std
::
tuple
<
std
::
string
,
std
::
string
>>&
remappedAtoms
);
void
removeAtom
(
Atom
&
a
);
void
swapAtoms
(
Atom
&
a1
,
Atom
&
a2
);
// swap the labels for these atoms
void
moveAtom
(
Atom
&
a
,
Point
p
);
// move atom to a new location
void
changeResidue
(
const
Residue
&
res
,
const
std
::
string
&
newCompound
,
const
std
::
vector
<
std
::
tuple
<
std
::
string
,
std
::
string
>>
&
remappedAtoms
);
/// To sort the atoms in order of model > asym-id > res-id > atom-id
/// Will asssign new atom_id's to all atoms. Be carefull
void
sortAtoms
();
const
std
::
vector
<
Residue
>
&
getNonPolymers
()
const
{
return
mNonPolymers
;
}
const
std
::
vector
<
Residue
>
&
getBranchResidues
()
const
{
return
mBranchResidues
;
}
const
std
::
vector
<
Residue
>
&
getNonPolymers
()
const
{
return
mNonPolymers
;
}
const
std
::
vector
<
Residue
>
&
getBranchResidues
()
const
{
return
mBranchResidues
;
}
void
cleanupEmptyCategories
();
private
:
...
...
@@ -500,20 +497,20 @@ class Structure
// friend residue_view;
// friend residue_iterator;
cif
::
Category
&
category
(
const
char
*
name
)
const
;
cif
::
Datablock
&
datablock
()
const
;
cif
::
Category
&
category
(
const
char
*
name
)
const
;
cif
::
Datablock
&
datablock
()
const
;
void
insertCompound
(
const
std
::
string
&
compoundID
,
bool
isEntity
);
void
insertCompound
(
const
std
::
string
&
compoundID
,
bool
isEntity
);
void
loadData
();
void
updateAtomIndex
();
File
&
mFile
;
uint32_t
mModelNr
;
AtomView
mAtoms
;
std
::
vector
<
size_t
>
mAtomIndex
;
std
::
list
<
Polymer
>
mPolymers
;
std
::
vector
<
Residue
>
mNonPolymers
,
mBranchResidues
;
File
&
mFile
;
size_t
mModelNr
;
AtomView
mAtoms
;
std
::
vector
<
size_t
>
mAtomIndex
;
std
::
list
<
Polymer
>
mPolymers
;
std
::
vector
<
Residue
>
mNonPolymers
,
mBranchResidues
;
};
}
}
// namespace mmcif
src/BondMap.cpp
View file @
81c0d019
...
...
@@ -289,7 +289,7 @@ class CompoundBondMap
auto
i
=
mAtomIDIndex
.
find
(
id
);
if
(
i
==
mAtomIDIndex
.
end
())
{
result
=
mAtomIDIndex
.
size
(
);
result
=
uint32_t
(
mAtomIDIndex
.
size
()
);
mAtomIDIndex
[
id
]
=
result
;
}
else
...
...
@@ -354,15 +354,12 @@ BondMap::BondMap(const Structure& p)
auto
&
compoundBondInfo
=
CompoundBondMap
::
instance
();
auto
atoms
=
p
.
atoms
();
dim
=
atoms
.
size
(
);
dim
=
uint32_t
(
atoms
.
size
()
);
// bond = std::vector<bool>(dim * (dim - 1), false);
for
(
auto
&
atom
:
atoms
)
{
size_t
ix
=
index
.
size
();
index
[
atom
.
id
()]
=
ix
;
};
index
[
atom
.
id
()]
=
uint32_t
(
index
.
size
());
auto
bindAtoms
=
[
this
](
const
std
::
string
&
a
,
const
std
::
string
&
b
)
{
...
...
src/Cif++.cpp
View file @
81c0d019
...
...
@@ -68,7 +68,7 @@ struct ItemValue
uint32_t
mColumnIndex
;
char
mText
[
4
];
ItemValue
(
const
char
*
v
,
uint32
_t
columnIndex
);
ItemValue
(
const
char
*
v
,
size
_t
columnIndex
);
~
ItemValue
();
bool
empty
()
const
{
return
mText
[
0
]
==
0
or
((
mText
[
0
]
==
'.'
or
mText
[
0
]
==
'?'
)
and
mText
[
1
]
==
0
);
}
...
...
@@ -77,13 +77,15 @@ struct ItemValue
void
*
operator
new
(
size_t
size
,
size_t
dataSize
);
void
operator
delete
(
void
*
p
);
void
operator
delete
(
void
*
p
,
size_t
dataSize
);
};
// --------------------------------------------------------------------
ItemValue
::
ItemValue
(
const
char
*
value
,
uint32
_t
columnIndex
)
:
mNext
(
nullptr
),
mColumnIndex
(
columnIndex
)
ItemValue
::
ItemValue
(
const
char
*
value
,
size
_t
columnIndex
)
:
mNext
(
nullptr
),
mColumnIndex
(
uint32_t
(
columnIndex
)
)
{
assert
(
columnIndex
<
std
::
numeric_limits
<
uint32_t
>::
max
());
strcpy
(
mText
,
value
);
}
...
...
@@ -109,6 +111,11 @@ void ItemValue::operator delete(void* p)
free
(
p
);
}
void
ItemValue
::
operator
delete
(
void
*
p
,
size_t
dataSize
)
{
free
(
p
);
}
// --------------------------------------------------------------------
// itemColumn contains info about a column or field in a Category
...
...
@@ -124,8 +131,8 @@ struct ItemRow
{
~
ItemRow
();
void
drop
(
uint32
_t
columnIx
);
const
char
*
c_str
(
uint32
_t
columnIx
)
const
;
void
drop
(
size
_t
columnIx
);
const
char
*
c_str
(
size
_t
columnIx
)
const
;
std
::
string
str
()
const
{
...
...
@@ -181,7 +188,7 @@ ItemRow::~ItemRow()
delete
mValues
;
}
void
ItemRow
::
drop
(
uint32
_t
columnIx
)
void
ItemRow
::
drop
(
size
_t
columnIx
)
{
if
(
mValues
!=
nullptr
and
mValues
->
mColumnIndex
==
columnIx
)
{
...
...
@@ -212,7 +219,7 @@ void ItemRow::drop(uint32_t columnIx)
#endif
}
const
char
*
ItemRow
::
c_str
(
uint32
_t
columnIx
)
const
const
char
*
ItemRow
::
c_str
(
size
_t
columnIx
)
const
{
const
char
*
result
=
kEmptyResult
;
...
...
@@ -1393,11 +1400,11 @@ std::string Category::getUniqueID(std::function<std::string(int)> generator)
if
(
mCatValidator
!=
nullptr
and
mCatValidator
->
mKeys
.
size
()
==
1
)
key
=
mCatValidator
->
mKeys
.
front
();
in
t
nr
=
size
()
+
1
;
size_
t
nr
=
size
()
+
1
;
for
(;;)
{
std
::
string
result
=
generator
(
nr
++
);
std
::
string
result
=
generator
(
int
(
nr
++
)
);
if
(
exists
(
Key
(
key
)
==
result
))
continue
;
...
...
@@ -1429,7 +1436,7 @@ void Category::drop(const std::string& field)
if
(
ci
!=
mColumns
.
end
())
{
uint32
_t
columnIx
=
ci
-
mColumns
.
begin
();
size
_t
columnIx
=
ci
-
mColumns
.
begin
();
for
(
auto
pi
=
mHead
;
pi
!=
nullptr
;
pi
=
pi
->
mNext
)
pi
->
drop
(
columnIx
);
...
...
@@ -2299,7 +2306,7 @@ size_t writeValue(std::ostream& os, std::string value, size_t offset, size_t wid
}
void
Category
::
write
(
std
::
ostream
&
os
,
const
std
::
vector
<
in
t
>&
order
,
bool
includeEmptyColumns
)
void
Category
::
write
(
std
::
ostream
&
os
,
const
std
::
vector
<
size_
t
>&
order
,
bool
includeEmptyColumns
)
{
if
(
empty
())
return
;
...
...
@@ -2437,7 +2444,7 @@ void Category::write(std::ostream& os, const std::vector<int>& order, bool inclu
void
Category
::
write
(
std
::
ostream
&
os
)
{
std
::
vector
<
in
t
>
order
(
mColumns
.
size
());
std
::
vector
<
size_
t
>
order
(
mColumns
.
size
());
iota
(
order
.
begin
(),
order
.
end
(),
0
);
write
(
os
,
order
,
false
);
}
...
...
@@ -2448,7 +2455,7 @@ void Category::write(std::ostream& os, const std::vector<std::string>& columns)
for
(
auto
&
c
:
columns
)
addColumn
(
c
);
std
::
vector
<
in
t
>
order
;
std
::
vector
<
size_
t
>
order
;
order
.
reserve
(
mColumns
.
size
());
for
(
auto
&
c
:
columns
)
...
...
@@ -2541,7 +2548,7 @@ void Category::update_value(RowSet &&rows, const std::string &tag, const std::st
for
(
auto
child
:
children
)
{
Condition
cond
;
Condition
cond
_c
;
for
(
size_t
ix
=
0
;
ix
<
linked
->
mParentKeys
.
size
();
++
ix
)
{
...
...
@@ -2550,10 +2557,10 @@ void Category::update_value(RowSet &&rows, const std::string &tag, const std::st
// TODO add code to *NOT* test mandatory fields for Empty
cond
=
std
::
move
(
cond
)
&&
Key
(
pk
)
==
child
[
ck
].
c_str
();
cond
_c
=
std
::
move
(
cond_c
)
&&
Key
(
pk
)
==
child
[
ck
].
c_str
();
}
auto
parents
=
find
(
std
::
move
(
cond
));
auto
parents
=
find
(
std
::
move
(
cond
_c
));
if
(
parents
.
empty
())
{
process
.
push_back
(
child
);
...
...
@@ -2646,7 +2653,7 @@ void Row::assign(const std::vector<Item>& values)
{
auto
cat
=
mData
->
mCategory
;
std
::
map
<
std
::
string
,
std
::
tuple
<
in
t
,
std
::
string
,
std
::
string
>>
changed
;
std
::
map
<
std
::
string
,
std
::
tuple
<
size_
t
,
std
::
string
,
std
::
string
>>
changed
;
for
(
auto
&
value
:
values
)
{
...
...
@@ -2844,11 +2851,11 @@ void Row::assign(size_t column, const std::string& value, bool skipUpdateLinked)
}
else
{
const
char
*
value
=
(
*
this
)[
pk
].
c_str
();
if
(
*
value
==
0
)
const
char
*
pk_
value
=
(
*
this
)[
pk
].
c_str
();
if
(
*
pk_
value
==
0
)
cond
=
std
::
move
(
cond
)
&&
Key
(
ck
)
==
Empty
();
else
cond
=
std
::
move
(
cond
)
&&
((
Key
(
ck
)
==
value
)
or
Key
(
ck
)
==
Empty
());
cond
=
std
::
move
(
cond
)
&&
((
Key
(
ck
)
==
pk_
value
)
or
Key
(
ck
)
==
Empty
());
}
}
...
...
@@ -2878,11 +2885,11 @@ void Row::assign(size_t column, const std::string& value, bool skipUpdateLinked)
cond_n
=
std
::
move
(
cond_n
)
&&
Key
(
ck
)
==
value
;
else
{
const
char
*
value
=
(
*
this
)[
pk
].
c_str
();
if
(
*
value
==
0
)
const
char
*
pk_
value
=
(
*
this
)[
pk
].
c_str
();
if
(
*
pk_
value
==
0
)
cond_n
=
std
::
move
(
cond_n
)
&&
Key
(
ck
)
==
Empty
();
else
cond_n
=
std
::
move
(
cond_n
)
&&
((
Key
(
ck
)
==
value
)
or
Key
(
ck
)
==
Empty
());
cond_n
=
std
::
move
(
cond_n
)
&&
((
Key
(
ck
)
==
pk_
value
)
or
Key
(
ck
)
==
Empty
());
}
}
...
...
src/Cif2PDB.cpp
View file @
81c0d019
...
...
@@ -232,7 +232,7 @@ std::vector<std::string> MapAsymIDs2ChainIDs(const std::vector<std::string>& asy
}
// support for wrapping text using a 'continuation marker'
int
WriteContinuedLine
(
std
::
ostream
&
pdbFile
,
std
::
string
header
,
int
&
count
,
int
cLen
,
std
::
string
text
,
int
lStart
=
0
)
size_t
WriteContinuedLine
(
std
::
ostream
&
pdbFile
,
std
::
string
header
,
int
&
count
,
int
cLen
,
std
::
string
text
,
std
::
string
::
size_type
lStart
=
0
)
{
if
(
lStart
==
0
)
{
...
...
@@ -242,7 +242,7 @@ int WriteContinuedLine(std::ostream& pdbFile, std::string header, int& count, in
lStart
=
header
.
length
()
+
cLen
;
}
int
maxLength
=
80
-
lStart
-
1
;
std
::
string
::
size_type
maxLength
=
80
-
lStart
-
1
;
std
::
vector
<
std
::
string
>
lines
=
cif
::
wordWrap
(
text
,
maxLength
);
...
...
@@ -268,15 +268,15 @@ int WriteContinuedLine(std::ostream& pdbFile, std::string header, int& count, in
}
in
t
WriteOneContinuedLine
(
std
::
ostream
&
pdbFile
,
std
::
string
header
,
int
cLen
,
std
::
string
line
,
int
lStart
=
0
)
size_
t
WriteOneContinuedLine
(
std
::
ostream
&
pdbFile
,
std
::
string
header
,
int
cLen
,
std
::
string
line
,
int
lStart
=
0
)
{
int
count
=
0
;
return
WriteContinuedLine
(
pdbFile
,
header
,
count
,
cLen
,
line
,
lStart
);
}
in
t
WriteCitation
(
std
::
ostream
&
pdbFile
,
Datablock
&
db
,
Row
r
,
int
reference
)
size_
t
WriteCitation
(
std
::
ostream
&
pdbFile
,
Datablock
&
db
,
Row
r
,
int
reference
)
{
in
t
result
=
0
;
size_
t
result
=
0
;
std
::
string
s1
;
...
...
@@ -2441,18 +2441,18 @@ void WriteRemark350(std::ostream& pdbFile, Datablock& db)
for
(
auto
bm
:
c1
)
{
std
::
string
id
,
detail
s
,
method
,
oligomer
;
cif
::
tie
(
id
,
detail
s
,
method
,
oligomer
)
=
bm
.
get
(
"id"
,
"details"
,
"method_details"
,
"oligomeric_details"
);
std
::
string
id
,
detail
,
method
,
oligomer
;
cif
::
tie
(
id
,
detail
,
method
,
oligomer
)
=
bm
.
get
(
"id"
,
"details"
,
"method_details"
,
"oligomeric_details"
);
pdbFile
<<
RM
(
""
)
<<
std
::
endl
<<
RM
(
"BIOMOLECULE: "
)
<<
id
<<
std
::
endl
;
ba
::
to_upper
(
oligomer
);
if
(
detail
s
==
"author_defined_assembly"
or
details
==
"author_and_software_defined_assembly"
)
if
(
detail
==
"author_defined_assembly"
or
detail
==
"author_and_software_defined_assembly"
)
pdbFile
<<
RM
(
"AUTHOR DETERMINED BIOLOGICAL UNIT: "
)
<<
oligomer
<<
std
::
endl
;
if
(
detail
s
==
"software_defined_assembly"
or
details
==
"author_and_software_defined_assembly"
)
if
(
detail
==
"software_defined_assembly"
or
detail
==
"author_and_software_defined_assembly"
)
pdbFile
<<
RM
(
"SOFTWARE DETERMINED QUATERNARY STRUCTURE: "
)
<<
oligomer
<<
std
::
endl
;
if
(
not
method
.
empty
())
...
...
@@ -3070,7 +3070,7 @@ int WriteHeterogen(std::ostream& pdbFile, Datablock& db)
}
}
int
nr
=
count_if
(
hets
.
begin
(),
hets
.
end
(),
[
hetID
](
auto
&
h
)
->
bool
{
return
h
.
hetID
==
hetID
;
});
auto
nr
=
count_if
(
hets
.
begin
(),
hets
.
end
(),
[
hetID
](
auto
&
h
)
->
bool
{
return
h
.
hetID
==
hetID
;
});
for
(
auto
r
:
db
[
"chem_comp"
].
find
(
cif
::
Key
(
"id"
)
==
hetID
))
{
...
...
@@ -3428,7 +3428,7 @@ int WriteMiscellaneousFeatures(std::ostream& pdbFile, Datablock& db)
std
::
string
siteID
=
std
::
get
<
0
>
(
s
);
std
::
deque
<
std
::
string
>&
res
=
std
::
get
<
1
>
(
s
);
in
t
numRes
=
res
.
size
();
size_
t
numRes
=
res
.
size
();
int
nr
=
1
;
while
(
res
.
empty
()
==
false
)
...
...
@@ -3533,7 +3533,7 @@ std::tuple<int,int> WriteCoordinatesForModel(std::ostream& pdbFile, Datablock& d
auto
ri
=
atom_site
.
begin
();
std
::
string
id
,
group
,
name
,
altLoc
,
resName
,
chainID
,
iCode
,
element
;
int
resSeq
,
charge
;
int
resSeq
=
0
,
charge
;
for
(;;)
{
...
...
src/CifParser.cpp
View file @
81c0d019
...
...
@@ -599,7 +599,7 @@ DatablockIndex SacParser::indexDatablocks()
case
data_name
:
if
(
isNonBlank
(
ch
))
datablock
.
insert
(
datablock
.
end
(),
ch
);
datablock
.
insert
(
datablock
.
end
(),
ch
ar
(
ch
)
);
else
if
(
isspace
(
ch
))
{
if
(
not
datablock
.
empty
())
...
...
src/CifUtils.cpp
View file @
81c0d019
...
...
@@ -401,7 +401,7 @@ std::string::const_iterator nextLineBreak(std::string::const_iterator text, std:
return
text
;
}
std
::
vector
<
std
::
string
>
wrapLine
(
const
std
::
string
&
text
,
unsigned
in
t
width
)
std
::
vector
<
std
::
string
>
wrapLine
(
const
std
::
string
&
text
,
size_
t
width
)
{
std
::
vector
<
std
::
string
>
result
;
std
::
vector
<
size_t
>
offsets
=
{
0
};
...
...
@@ -462,7 +462,7 @@ std::vector<std::string> wrapLine(const std::string &text, unsigned int width)
return
result
;
}
std
::
vector
<
std
::
string
>
wordWrap
(
const
std
::
string
&
text
,
unsigned
in
t
width
)
std
::
vector
<
std
::
string
>
wordWrap
(
const
std
::
string
&
text
,
size_
t
width
)
{
std
::
vector
<
std
::
string
>
paragraphs
;
ba
::
split
(
paragraphs
,
text
,
ba
::
is_any_of
(
"
\n
"
));
...
...
@@ -490,6 +490,9 @@ std::vector<std::string> wordWrap(const std::string &text, unsigned int width)
#include <Windows.h>
#include <libloaderapi.h>
#include <wincon.h>
#include <codecvt>
namespace
cif
{
...
...
@@ -498,7 +501,6 @@ uint32_t get_terminal_width()
return
TERM_WIDTH
;
}
// I don't have a windows machine to test the following code, please accept my apologies in case it fails...
std
::
string
GetExecutablePath
()
{
WCHAR
buffer
[
4096
];
...
...
@@ -509,7 +511,11 @@ std::string GetExecutablePath()
std
::
wstring
ws
(
buffer
);
return
std
::
string
(
ws
.
begin
(),
ws
.
end
());
// convert from utf16 to utf8
std
::
wstring_convert
<
std
::
codecvt_utf8
<
wchar_t
>>
conv1
;
std
::
string
u8str
=
conv1
.
to_bytes
(
ws
);
return
u8str
;
}
#else
...
...
src/CifValidator.cpp
View file @
81c0d019
...
...
@@ -121,8 +121,8 @@ int ValidateType::compare(const char* a, const char* b) const
if
(
mPrimitiveType
==
DDL_PrimitiveType
::
UChar
)
{
ca
=
to
upp
er
(
ca
);
cb
=
to
upp
er
(
cb
);
ca
=
to
low
er
(
ca
);
cb
=
to
low
er
(
cb
);
}
result
=
ca
-
cb
;
...
...
src/Compound.cpp
View file @
81c0d019
...
...
@@ -172,23 +172,23 @@ Compound::Compound(cif::Datablock &db, const std::string &id, const std::string
for
(
auto
row
:
chemCompBond
)
{
CompoundBond
bond
;
std
::
string
type
;
cif
::
tie
(
bond
.
atomID
[
0
],
bond
.
atomID
[
1
],
type
,
bond
.
aromatic
)
=
row
.
get
(
"atom_id_1"
,
"atom_id_2"
,
"type"
,
"aromatic"
);
std
::
string
b
type
;
cif
::
tie
(
bond
.
atomID
[
0
],
bond
.
atomID
[
1
],
b
type
,
bond
.
aromatic
)
=
row
.
get
(
"atom_id_1"
,
"atom_id_2"
,
"type"
,
"aromatic"
);
using
cif
::
iequals
;
if
(
iequals
(
type
,
"single"
))
if
(
iequals
(
b
type
,
"single"
))
bond
.
type
=
BondType
::
sing
;
else
if
(
iequals
(
type
,
"double"
))
else
if
(
iequals
(
b
type
,
"double"
))
bond
.
type
=
BondType
::
doub
;
else
if
(
iequals
(
type
,
"triple"
))
else
if
(
iequals
(
b
type
,
"triple"
))
bond
.
type
=
BondType
::
trip
;
else
if
(
iequals
(
type
,
"deloc"
)
or
iequals
(
type
,
"aromat"
)
or
iequals
(
type
,
"aromatic"
))
else
if
(
iequals
(
btype
,
"deloc"
)
or
iequals
(
btype
,
"aromat"
)
or
iequals
(
b
type
,
"aromatic"
))
bond
.
type
=
BondType
::
delo
;
else
{
if
(
cif
::
VERBOSE
)
std
::
cerr
<<
"Unimplemented chem_comp_bond.type "
<<
type
<<
" in "
<<
id
<<
std
::
endl
;
std
::
cerr
<<
"Unimplemented chem_comp_bond.type "
<<
b
type
<<
" in "
<<
id
<<
std
::
endl
;
bond
.
type
=
BondType
::
sing
;
}
mBonds
.
push_back
(
std
::
move
(
bond
));
...
...
src/PDB2Cif.cpp
View file @
81c0d019
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/PDB2CifRemark3.cpp
View file @
81c0d019
...
...
@@ -1479,8 +1479,8 @@ bool Remark3Parser::parse(const std::string& expMethod, PDBRecord* r, cif::Datab
}
else
{
for
(
auto
r
:
cat1
)
cat2
.
emplace
(
r
);
for
(
auto
r
s
:
cat1
)
cat2
.
emplace
(
r
s
);
}
}
}
...
...
src/Point.cpp
View file @
81c0d019
...
...
@@ -45,10 +45,10 @@ quaternion Normalize(quaternion q)
t
*=
t
;
double
length
=
sqrt
(
t
.
sum
());
double
length
=
s
td
::
s
qrt
(
t
.
sum
());
if
(
length
>
0.001
)
q
/=
length
;
q
/=
static_cast
<
quaternion
::
value_type
>
(
length
)
;
else
q
=
quaternion
(
1
,
0
,
0
,
0
);
...
...
@@ -67,7 +67,7 @@ std::tuple<double,Point> QuaternionToAngleAxis(quaternion q)
angle
=
angle
*
180
/
kPI
;
// axis:
double
s
=
sqrt
(
1
-
q
.
R_component_1
()
*
q
.
R_component_1
());
float
s
=
std
::
sqrt
(
1
-
q
.
R_component_1
()
*
q
.
R_component_1
());
if
(
s
<
0.001
)
s
=
1
;
...
...
@@ -108,7 +108,7 @@ Point Centroid(std::vector<Point>& Points)
for
(
Point
&
pt
:
Points
)
result
+=
pt
;
result
/=
Points
.
size
(
);
result
/=
static_cast
<
float
>
(
Points
.
size
()
);
return
result
;
}
...
...
@@ -158,7 +158,7 @@ double LargestDepressedQuarticSolution(double a, double b, double c)
std
::
complex
<
double
>
W
=
std
::
sqrt
(
a
+
2.0
*
y
);
// And to get the final result:
// result = (±W + sqrt(-(3 * alpha + 2 * y ± 2 * beta / W))) / 2;
// result = (±W + s
td::s
qrt(-(3 * alpha + 2 * y ± 2 * beta / W))) / 2;
// We want the largest result, so:
std
::
valarray
<
double
>
t
(
4
);
...
...
@@ -289,15 +289,15 @@ Point Nudge(Point p, float offset)
std
::
uniform_real_distribution
<>
randomAngle
(
0
,
2
*
kPI
);
std
::
normal_distribution
<>
randomOffset
(
0
,
offset
);
float
theta
=
randomAngle
(
rng
);
float
phi1
=
randomAngle
(
rng
)
-
kPI
;
float
phi2
=
randomAngle
(
rng
)
-
kPI
;
float
theta
=
static_cast
<
float
>
(
randomAngle
(
rng
)
);
float
phi1
=
static_cast
<
float
>
(
randomAngle
(
rng
)
-
kPI
)
;
float
phi2
=
static_cast
<
float
>
(
randomAngle
(
rng
)
-
kPI
)
;
quaternion
q
=
boost
::
math
::
spherical
(
1.0
f
,
theta
,
phi1
,
phi2
);
Point
r
{
0
,
0
,
1
};
r
.
rotate
(
q
);
r
*=
randomOffset
(
rng
);
r
*=
static_cast
<
float
>
(
randomOffset
(
rng
)
);
return
p
+
r
;
}
...
...
src/Secondary.cpp
View file @
81c0d019
...
...
@@ -154,21 +154,21 @@ struct BridgeParner
// --------------------------------------------------------------------
const
float
// kSSBridgeDistance = 3.0,
kMinimalDistance
=
0.5
,
kMinimalCADistance
=
9.0
,
kMinHBondEnergy
=
-
9.9
,
kMaxHBondEnergy
=
-
0.5
,
kCouplingConstant
=
-
27.888
,
// = -332 * 0.42 * 0.2
kMaxPeptideBondLength
=
2.5
;
// kSSBridgeDistance = 3.0
f
,
kMinimalDistance
=
0.5
f
,
kMinimalCADistance
=
9.0
f
,
kMinHBondEnergy
=
-
9.9
f
,
kMaxHBondEnergy
=
-
0.5
f
,
kCouplingConstant
=
-
27.888
f
,
// = -332 * 0.42 * 0.2
kMaxPeptideBondLength
=
2.5
f
;
const
float
kRadiusN
=
1.65
,
kRadiusCA
=
1.87
,
kRadiusC
=
1.76
,
kRadiusO
=
1.4
,
kRadiusSideAtom
=
1.8
,
kRadiusWater
=
1.4
;
kRadiusN
=
1.65
f
,
kRadiusCA
=
1.87
f
,
kRadiusC
=
1.76
f
,
kRadiusO
=
1.4
f
,
kRadiusSideAtom
=
1.8
f
,
kRadiusWater
=
1.4
f
;
struct
Res
{
...
...
@@ -233,7 +233,7 @@ struct Res
auto
pc
=
mPrev
->
mC
;
auto
po
=
mPrev
->
mO
;
double
CODistance
=
Distance
(
pc
,
po
);
float
CODistance
=
static_cast
<
float
>
(
Distance
(
pc
,
po
)
);
mH
.
mX
+=
(
pc
.
mX
-
po
.
mX
)
/
CODistance
;
mH
.
mY
+=
(
pc
.
mY
-
po
.
mY
)
/
CODistance
;
...
...
@@ -429,16 +429,16 @@ MSurfaceDots::MSurfaceDots(int32_t N)
{
auto
P
=
2
*
N
+
1
;
const
double
kGoldenRatio
=
(
1
+
sqrt
(
5.0
))
/
2
;
const
float
kGoldenRatio
=
(
1
+
std
::
sqrt
(
5.0
f
))
/
2
;
mWeight
=
(
4
*
kPI
)
/
P
;
for
(
auto
i
=
-
N
;
i
<=
N
;
++
i
)
{
double
lat
=
asin
((
2.0
*
i
)
/
P
);
double
lon
=
fmod
(
i
,
kGoldenRatio
)
*
2
*
kPI
/
kGoldenRatio
;
float
lat
=
std
::
asin
((
2.0
f
*
i
)
/
P
);
float
lon
=
static_cast
<
float
>
(
std
::
fmod
(
i
,
kGoldenRatio
)
*
2
*
kPI
/
kGoldenRatio
)
;
mPoints
.
emplace_back
(
s
in
(
lon
)
*
cos
(
lat
),
cos
(
lon
)
*
cos
(
lat
),
sin
(
lat
));
mPoints
.
emplace_back
(
s
td
::
sin
(
lon
)
*
std
::
cos
(
lat
),
std
::
cos
(
lon
)
*
std
::
cos
(
lat
),
std
::
sin
(
lat
));
}
}
...
...
@@ -768,7 +768,7 @@ void CalculateBetaSheets(std::vector<Res>& inResidues, DSSP_Statistics& stats)
{
ladderset
.
insert
(
&
bridge
);
uint32
_t
n
=
bridge
.
i
.
size
();
size
_t
n
=
bridge
.
i
.
size
();
if
(
n
>
kHistogramSize
)
n
=
kHistogramSize
;
...
...
@@ -815,7 +815,7 @@ void CalculateBetaSheets(std::vector<Res>& inResidues, DSSP_Statistics& stats)
++
ladder
;
}
uint32
_t
nrOfLaddersPerSheet
=
sheetset
.
size
();
size
_t
nrOfLaddersPerSheet
=
sheetset
.
size
();
if
(
nrOfLaddersPerSheet
>
kHistogramSize
)
nrOfLaddersPerSheet
=
kHistogramSize
;
if
(
nrOfLaddersPerSheet
==
1
and
(
*
sheetset
.
begin
())
->
i
.
size
()
>
1
)
...
...
@@ -1179,9 +1179,9 @@ DSSPImpl::DSSPImpl(const Structure& s, int min_poly_proline_stretch_length)
,
m_min_poly_proline_stretch_length
(
min_poly_proline_stretch_length
)
{
size_t
nRes
=
accumulate
(
mPolymers
.
begin
(),
mPolymers
.
end
(),
0
.0
,
[](
double
s
,
auto
&
p
)
{
return
s
+
p
.
size
();
});
0
ULL
,
[](
size_t
s
,
auto
&
p
)
{
return
s
+
p
.
size
();
});
mStats
.
nrOfChains
=
mPolymers
.
size
(
);
mStats
.
nrOfChains
=
static_cast
<
uint32_t
>
(
mPolymers
.
size
()
);
mResidues
.
reserve
(
nRes
);
int
resNumber
=
0
;
...
...
@@ -1214,7 +1214,7 @@ DSSPImpl::DSSPImpl(const Structure& s, int min_poly_proline_stretch_length)
}
}
mStats
.
nrOfResidues
=
mResidues
.
size
(
);
mStats
.
nrOfResidues
=
static_cast
<
uint32_t
>
(
mResidues
.
size
()
);
for
(
size_t
i
=
0
;
i
+
1
<
mResidues
.
size
();
++
i
)
{
...
...
@@ -1272,7 +1272,7 @@ void DSSPImpl::calculateSecondaryStructure()
switch
(
r
.
GetHelixFlag
(
helixType
))
{
case
Helix
:
:
Start
:
helix
[
static_cast
<
int
>
(
helixType
)]
=
'>'
;
break
;
case
Helix
:
:
Middle
:
helix
[
static_cast
<
int
>
(
helixType
)]
=
helixType
==
HelixType
::
rh_pp
?
'P'
:
'3'
+
static_cast
<
int
>
(
helixType
);
break
;
case
Helix
:
:
Middle
:
helix
[
static_cast
<
int
>
(
helixType
)]
=
helixType
==
HelixType
::
rh_pp
?
'P'
:
'3'
+
static_cast
<
char
>
(
helixType
);
break
;
case
Helix
:
:
StartAndEnd
:
helix
[
static_cast
<
int
>
(
helixType
)]
=
'X'
;
break
;
case
Helix
:
:
End
:
helix
[
static_cast
<
int
>
(
helixType
)]
=
'<'
;
break
;
case
Helix
:
:
None
:
helix
[
static_cast
<
int
>
(
helixType
)]
=
' '
;
break
;
...
...
@@ -1289,10 +1289,10 @@ void DSSPImpl::calculateSecondaryStructure()
}
// finish statistics
mStats
.
nrOfSSBridges
=
mSSBonds
.
size
(
);
mStats
.
nrOfSSBridges
=
static_cast
<
uint32_t
>
(
mSSBonds
.
size
()
);
mStats
.
nrOfIntraChainSSBridges
=
0
;
in
t
ssBondNr
=
0
;
uint8_
t
ssBondNr
=
0
;
for
(
const
auto
&
[
a
,
b
]
:
mSSBonds
)
{
if
(
a
==
b
)
...
...
src/Structure.cpp
View file @
81c0d019
...
...
@@ -66,8 +66,8 @@ struct FileImpl
void
FileImpl
::
load_data
(
const
char
*
data
,
size_t
length
)
{
bool
gzipped
=
length
>
2
and
data
[
0
]
==
(
char
)
0x1f
and
data
[
1
]
==
(
char
)
0x8b
;
bool
bzip2ed
=
length
>
3
and
data
[
0
]
==
(
char
)
0x42
and
data
[
1
]
==
(
char
)
0x5A
and
data
[
2
]
==
(
char
)
0x68
;
bool
gzipped
=
length
>
2
and
data
[
0
]
==
static_cast
<
char
>
(
0x1f
)
and
data
[
1
]
==
static_cast
<
char
>
(
0x8b
)
;
bool
bzip2ed
=
length
>
3
and
data
[
0
]
==
static_cast
<
char
>
(
0x42
)
and
data
[
1
]
==
static_cast
<
char
>
(
0x5A
)
and
data
[
2
]
==
static_cast
<
char
>
(
0x68
)
;
try
{
...
...
@@ -459,7 +459,7 @@ struct AtomImpl
int
mRefcount
;
cif
::
Row
mRow
;
mutable
const
Compound
*
mCompound
=
nullptr
;
float
mRadius
=
nan
(
"4"
);
float
mRadius
=
std
::
nanf
(
"4"
);
mutable
std
::
map
<
std
::
string
,
std
::
string
>
mCachedProperties
;
bool
mSymmetryCopy
=
false
;
...
...
@@ -596,7 +596,7 @@ float Atom::uIso() const
if
(
not
property
<
std
::
string
>
(
"U_iso_or_equiv"
).
empty
())
result
=
property
<
float
>
(
"U_iso_or_equiv"
);
else
if
(
not
property
<
std
::
string
>
(
"B_iso_or_equiv"
).
empty
())
result
=
property
<
float
>
(
"B_iso_or_equiv"
)
/
(
8
*
kPI
*
kPI
);
result
=
property
<
float
>
(
"B_iso_or_equiv"
)
/
static_cast
<
float
>
(
8
*
kPI
*
kPI
);
else
throw
std
::
runtime_error
(
"Missing B_iso or U_iso"
);
...
...
@@ -686,9 +686,9 @@ std::string Atom::labelID() const
std
::
string
Atom
::
pdbID
()
const
{
return
property
<
std
::
string
>
(
"auth_comp_id"
)
+
'_'
+
property
<
std
::
string
>
(
"auth_asym_id"
)
+
'_'
+
property
<
std
::
string
>
(
"auth_seq_id"
)
+
property
<
std
::
string
>
(
"pdbx_PDB_ins_code"
);
property
<
std
::
string
>
(
"auth_asym_id"
)
+
'_'
+
property
<
std
::
string
>
(
"auth_seq_id"
)
+
property
<
std
::
string
>
(
"pdbx_PDB_ins_code"
);
}
Point
Atom
::
location
()
const
...
...
@@ -744,7 +744,7 @@ bool Atom::isWater() const
bool
Atom
::
operator
==
(
const
Atom
&
rhs
)
const
{
return
impl
()
==
rhs
.
impl
()
or
(
&
impl
()
->
mFile
==
&
rhs
.
impl
()
->
mFile
and
impl
()
->
mID
==
rhs
.
impl
()
->
mID
);
(
&
impl
()
->
mFile
==
&
rhs
.
impl
()
->
mFile
and
impl
()
->
mID
==
rhs
.
impl
()
->
mID
);
}
// clipper::Atom Atom::toClipper() const
...
...
@@ -795,7 +795,7 @@ std::ostream &operator<<(std::ostream &os, const Atom &atom)
// First constructor used to be for waters only, but now accepts sugars as well.
Residue
::
Residue
(
const
Structure
&
structure
,
const
std
::
string
&
compoundID
,
const
std
::
string
&
asymID
,
const
std
::
string
&
authSeqID
)
const
std
::
string
&
asymID
,
const
std
::
string
&
authSeqID
)
:
mStructure
(
&
structure
)
,
mCompoundID
(
compoundID
)
,
mAsymID
(
asymID
)
...
...
@@ -804,7 +804,7 @@ Residue::Residue(const Structure &structure, const std::string &compoundID,
for
(
auto
&
a
:
mStructure
->
atoms
())
{
if
(
a
.
labelAsymID
()
!=
mAsymID
or
a
.
labelCompID
()
!=
mCompoundID
)
a
.
labelCompID
()
!=
mCompoundID
)
continue
;
if
(
compoundID
==
"HOH"
)
...
...
@@ -824,13 +824,13 @@ Residue::Residue(const Structure &structure, const std::string &compoundID,
assert
(
not
mAtoms
.
empty
());
}
Residue
::
Residue
(
const
Structure
&
structure
,
const
std
::
string
&
compoundID
,
const
std
::
string
&
asymID
)
Residue
::
Residue
(
const
Structure
&
structure
,
const
std
::
string
&
compoundID
,
const
std
::
string
&
asymID
)
:
Residue
(
structure
,
compoundID
,
asymID
,
0
,
{})
{
}
Residue
::
Residue
(
const
Structure
&
structure
,
const
std
::
string
&
compoundID
,
const
std
::
string
&
asymID
,
int
seqID
,
const
std
::
string
&
authSeqID
)
const
std
::
string
&
asymID
,
int
seqID
,
const
std
::
string
&
authSeqID
)
:
mStructure
(
&
structure
)
,
mCompoundID
(
compoundID
)
,
mAsymID
(
asymID
)
...
...
@@ -845,7 +845,7 @@ Residue::Residue(const Structure &structure, const std::string &compoundID,
continue
;
if
(
a
.
labelAsymID
()
!=
mAsymID
or
a
.
labelCompID
()
!=
mCompoundID
)
a
.
labelCompID
()
!=
mCompoundID
)
continue
;
mAtoms
.
push_back
(
a
);
...
...
@@ -967,7 +967,8 @@ std::string Residue::unique_alt_id() const
if
(
mStructure
==
nullptr
)
throw
std
::
runtime_error
(
"Invalid Residue object"
);
auto
firstAlt
=
std
::
find_if
(
mAtoms
.
begin
(),
mAtoms
.
end
(),
[](
auto
&
a
)
{
return
not
a
.
labelAltID
().
empty
();
});
auto
firstAlt
=
std
::
find_if
(
mAtoms
.
begin
(),
mAtoms
.
end
(),
[](
auto
&
a
)
{
return
not
a
.
labelAltID
().
empty
();
});
return
firstAlt
!=
mAtoms
.
end
()
?
firstAlt
->
labelAltID
()
:
""
;
}
...
...
@@ -1092,7 +1093,7 @@ std::tuple<Point, float> Residue::centerAndRadius() const
for
(
auto
&
pt
:
pts
)
{
auto
d
=
Distance
(
pt
,
center
);
float
d
=
static_cast
<
float
>
(
Distance
(
pt
,
center
)
);
if
(
radius
<
d
)
radius
=
d
;
}
...
...
@@ -1102,7 +1103,8 @@ std::tuple<Point, float> Residue::centerAndRadius() const
bool
Residue
::
hasAlternateAtoms
()
const
{
return
std
::
find_if
(
mAtoms
.
begin
(),
mAtoms
.
end
(),
[](
const
Atom
&
atom
)
{
return
atom
.
isAlternate
();
})
!=
mAtoms
.
end
();
return
std
::
find_if
(
mAtoms
.
begin
(),
mAtoms
.
end
(),
[](
const
Atom
&
atom
)
{
return
atom
.
isAlternate
();
})
!=
mAtoms
.
end
();
}
std
::
set
<
std
::
string
>
Residue
::
getAtomIDs
()
const
...
...
@@ -1143,7 +1145,7 @@ std::ostream &operator<<(std::ostream &os, const Residue &res)
//{
//}
Monomer
::
Monomer
(
const
Polymer
&
polymer
,
uint32_t
index
,
int
seqID
,
const
std
::
string
&
authSeqID
,
const
std
::
string
&
compoundID
)
Monomer
::
Monomer
(
const
Polymer
&
polymer
,
size_t
index
,
int
seqID
,
const
std
::
string
&
authSeqID
,
const
std
::
string
&
compoundID
)
:
Residue
(
*
polymer
.
structure
(),
compoundID
,
polymer
.
asymID
(),
seqID
,
authSeqID
)
,
mPolymer
(
&
polymer
)
,
mIndex
(
index
)
...
...
@@ -1210,7 +1212,7 @@ float Monomer::phi() const
{
auto
&
prev
=
mPolymer
->
operator
[](
mIndex
-
1
);
if
(
prev
.
mSeqID
+
1
==
mSeqID
)
result
=
DihedralAngle
(
prev
.
C
().
location
(),
N
().
location
(),
CAlpha
().
location
(),
C
().
location
(
));
result
=
static_cast
<
float
>
(
DihedralAngle
(
prev
.
C
().
location
(),
N
().
location
(),
CAlpha
().
location
(),
C
().
location
()
));
}
}
catch
(
const
std
::
exception
&
ex
)
...
...
@@ -1232,7 +1234,7 @@ float Monomer::psi() const
{
auto
&
next
=
mPolymer
->
operator
[](
mIndex
+
1
);
if
(
mSeqID
+
1
==
next
.
mSeqID
)
result
=
DihedralAngle
(
N
().
location
(),
CAlpha
().
location
(),
C
().
location
(),
next
.
N
().
location
(
));
result
=
static_cast
<
float
>
(
DihedralAngle
(
N
().
location
(),
CAlpha
().
location
(),
C
().
location
(),
next
.
N
().
location
()
));
}
}
catch
(
const
std
::
exception
&
ex
)
...
...
@@ -1256,7 +1258,7 @@ float Monomer::alpha() const
auto
&
next
=
mPolymer
->
operator
[](
mIndex
+
1
);
auto
&
nextNext
=
mPolymer
->
operator
[](
mIndex
+
2
);
result
=
DihedralAngle
(
prev
.
CAlpha
().
location
(),
CAlpha
().
location
(),
next
.
CAlpha
().
location
(),
nextNext
.
CAlpha
().
location
(
));
result
=
static_cast
<
float
>
(
DihedralAngle
(
prev
.
CAlpha
().
location
(),
CAlpha
().
location
(),
next
.
CAlpha
().
location
(),
nextNext
.
CAlpha
().
location
()
));
}
}
catch
(
const
std
::
exception
&
ex
)
...
...
@@ -1270,7 +1272,7 @@ float Monomer::alpha() const
float
Monomer
::
kappa
()
const
{
double
result
=
360
;
float
result
=
360
;
try
{
...
...
@@ -1282,8 +1284,8 @@ float Monomer::kappa() const
if
(
prevPrev
.
mSeqID
+
4
==
nextNext
.
mSeqID
)
{
double
ckap
=
CosinusAngle
(
CAlpha
().
location
(),
prevPrev
.
CAlpha
().
location
(),
nextNext
.
CAlpha
().
location
(),
CAlpha
().
location
());
double
skap
=
sqrt
(
1
-
ckap
*
ckap
);
result
=
atan2
(
skap
,
ckap
)
*
180
/
kPI
;
double
skap
=
s
td
::
s
qrt
(
1
-
ckap
*
ckap
);
result
=
static_cast
<
float
>
(
std
::
atan2
(
skap
,
ckap
)
*
180
/
kPI
)
;
}
}
}
...
...
@@ -1299,7 +1301,7 @@ float Monomer::kappa() const
float
Monomer
::
tco
()
const
{
double
result
=
0.0
;
float
result
=
0.0
;
try
{
...
...
@@ -1307,7 +1309,7 @@ float Monomer::tco() const
{
auto
&
prev
=
mPolymer
->
operator
[](
mIndex
-
1
);
if
(
prev
.
mSeqID
+
1
==
mSeqID
)
result
=
CosinusAngle
(
C
().
location
(),
O
().
location
(),
prev
.
C
().
location
(),
prev
.
O
().
location
(
));
result
=
static_cast
<
float
>
(
CosinusAngle
(
C
().
location
(),
O
().
location
(),
prev
.
C
().
location
(),
prev
.
O
().
location
()
));
}
}
catch
(
const
std
::
exception
&
ex
)
...
...
@@ -1322,7 +1324,7 @@ float Monomer::tco() const
float
Monomer
::
omega
()
const
{
double
result
=
360
;
float
result
=
360
;
try
{
...
...
@@ -1393,11 +1395,11 @@ float Monomer::chi(size_t nr) const
atoms
.
back
()
=
"CG2"
;
}
result
=
DihedralAngle
(
result
=
static_cast
<
float
>
(
DihedralAngle
(
atomByID
(
atoms
[
nr
+
0
]).
location
(),
atomByID
(
atoms
[
nr
+
1
]).
location
(),
atomByID
(
atoms
[
nr
+
2
]).
location
(),
atomByID
(
atoms
[
nr
+
3
]).
location
());
atomByID
(
atoms
[
nr
+
3
]).
location
())
)
;
}
}
catch
(
const
std
::
exception
&
e
)
...
...
@@ -1444,7 +1446,8 @@ bool Monomer::isComplete() const
bool
Monomer
::
hasAlternateBackboneAtoms
()
const
{
bool
result
;
bool
result
=
false
;
for
(
auto
&
a
:
mAtoms
)
{
if
(
not
a
.
isAlternate
())
...
...
@@ -1457,6 +1460,7 @@ bool Monomer::hasAlternateBackboneAtoms() const
break
;
}
}
return
result
;
}
...
...
@@ -1472,7 +1476,7 @@ float Monomer::chiralVolume() const
auto
atom3
=
atomByID
(
"CD2"
);
result
=
DotProduct
(
atom1
.
location
()
-
centre
.
location
(),
CrossProduct
(
atom2
.
location
()
-
centre
.
location
(),
atom3
.
location
()
-
centre
.
location
()));
CrossProduct
(
atom2
.
location
()
-
centre
.
location
(),
atom3
.
location
()
-
centre
.
location
()));
}
else
if
(
mCompoundID
==
"VAL"
)
{
...
...
@@ -1482,7 +1486,7 @@ float Monomer::chiralVolume() const
auto
atom3
=
atomByID
(
"CG2"
);
result
=
DotProduct
(
atom1
.
location
()
-
centre
.
location
(),
CrossProduct
(
atom2
.
location
()
-
centre
.
location
(),
atom3
.
location
()
-
centre
.
location
()));
CrossProduct
(
atom2
.
location
()
-
centre
.
location
(),
atom3
.
location
()
-
centre
.
location
()));
}
return
result
;
...
...
@@ -1504,7 +1508,7 @@ bool Monomer::areBonded(const Monomer &a, const Monomer &b, float errorMargin)
double
omega
=
DihedralAngle
(
atoms
[
0
],
atoms
[
1
],
atoms
[
2
],
atoms
[
3
]);
bool
cis
=
abs
(
omega
)
<=
30.0
;
float
maxCACADistance
=
cis
?
3.0
:
3.8
;
float
maxCACADistance
=
cis
?
3.0
f
:
3.8
f
;
result
=
abs
(
distanceCACA
-
maxCACADistance
)
<
errorMargin
;
}
...
...
@@ -1521,11 +1525,11 @@ float Monomer::omega(const mmcif::Monomer &a, const mmcif::Monomer &b)
try
{
result
=
DihedralAngle
(
result
=
static_cast
<
float
>
(
DihedralAngle
(
a
.
atomByID
(
"CA"
).
location
(),
a
.
atomByID
(
"C"
).
location
(),
b
.
atomByID
(
"N"
).
location
(),
b
.
atomByID
(
"CA"
).
location
());
b
.
atomByID
(
"CA"
).
location
())
)
;
}
catch
(...)
{
...
...
@@ -1636,7 +1640,7 @@ Polymer::Polymer(const Structure &s, const std::string &entityID, const std::str
,
mAsymID
(
asymID
)
,
mPolySeq
(
s
.
category
(
"pdbx_poly_seq_scheme"
),
cif
::
Key
(
"asym_id"
)
==
mAsymID
and
cif
::
Key
(
"entity_id"
)
==
mEntityID
)
{
std
::
map
<
uint32_t
,
uint32
_t
>
ix
;
std
::
map
<
size_t
,
size
_t
>
ix
;
reserve
(
mPolySeq
.
size
());
...
...
@@ -1646,7 +1650,7 @@ Polymer::Polymer(const Structure &s, const std::string &entityID, const std::str
std
::
string
compoundID
,
authSeqID
;
cif
::
tie
(
seqID
,
authSeqID
,
compoundID
)
=
r
.
get
(
"seq_id"
,
"auth_seq_num"
,
"mon_id"
);
uint32
_t
index
=
size
();
size
_t
index
=
size
();
// store only the first
if
(
not
ix
.
count
(
seqID
))
...
...
@@ -1770,7 +1774,7 @@ cif::File &File::file()
// --------------------------------------------------------------------
// Structure
Structure
::
Structure
(
File
&
f
,
uint32
_t
modelNr
,
StructureOpenOptions
options
)
Structure
::
Structure
(
File
&
f
,
size
_t
modelNr
,
StructureOpenOptions
options
)
:
mFile
(
f
)
,
mModelNr
(
modelNr
)
{
...
...
@@ -1779,15 +1783,15 @@ Structure::Structure(File &f, uint32_t modelNr, StructureOpenOptions options)
for
(
auto
&
a
:
atomCat
)
{
std
::
string
id
,
type
S
ymbol
;
std
::
optional
<
uint32_t
>
modelN
r
;
std
::
string
id
,
type
_s
ymbol
;
std
::
optional
<
size_t
>
model_n
r
;
cif
::
tie
(
id
,
type
Symbol
,
modelN
r
)
=
a
.
get
(
"id"
,
"type_symbol"
,
"pdbx_PDB_model_num"
);
cif
::
tie
(
id
,
type
_symbol
,
model_n
r
)
=
a
.
get
(
"id"
,
"type_symbol"
,
"pdbx_PDB_model_num"
);
if
(
model
Nr
and
*
modelN
r
!=
mModelNr
)
if
(
model
_nr
and
*
model_n
r
!=
mModelNr
)
continue
;
if
((
options
bitand
StructureOpenOptions
::
SkipHydrogen
)
and
type
S
ymbol
==
"H"
)
if
((
options
bitand
StructureOpenOptions
::
SkipHydrogen
)
and
type
_s
ymbol
==
"H"
)
continue
;
mAtoms
.
emplace_back
(
new
AtomImpl
(
f
,
id
,
a
));
...
...
@@ -1859,12 +1863,14 @@ void Structure::updateAtomIndex()
iota
(
mAtomIndex
.
begin
(),
mAtomIndex
.
end
(),
0
);
sort
(
mAtomIndex
.
begin
(),
mAtomIndex
.
end
(),
[
this
](
size_t
a
,
size_t
b
)
{
return
mAtoms
[
a
].
id
()
<
mAtoms
[
b
].
id
();
});
sort
(
mAtomIndex
.
begin
(),
mAtomIndex
.
end
(),
[
this
](
size_t
a
,
size_t
b
)
{
return
mAtoms
[
a
].
id
()
<
mAtoms
[
b
].
id
();
});
}
void
Structure
::
sortAtoms
()
{
sort
(
mAtoms
.
begin
(),
mAtoms
.
end
(),
[](
auto
&
a
,
auto
&
b
)
{
return
a
.
compare
(
b
)
<
0
;
});
sort
(
mAtoms
.
begin
(),
mAtoms
.
end
(),
[](
auto
&
a
,
auto
&
b
)
{
return
a
.
compare
(
b
)
<
0
;
});
int
id
=
1
;
for
(
auto
&
atom
:
mAtoms
)
...
...
@@ -1908,7 +1914,8 @@ AtomView Structure::waters() const
Atom
Structure
::
getAtomByID
(
std
::
string
id
)
const
{
auto
i
=
std
::
lower_bound
(
mAtomIndex
.
begin
(),
mAtomIndex
.
end
(),
id
,
[
this
](
auto
&
a
,
auto
&
b
)
{
return
mAtoms
[
a
].
id
()
<
b
;
});
id
,
[
this
](
auto
&
a
,
auto
&
b
)
{
return
mAtoms
[
a
].
id
()
<
b
;
});
// auto i = find_if(mAtoms.begin(), mAtoms.end(),
// [&id](auto& a) { return a.id() == id; });
...
...
@@ -1924,10 +1931,10 @@ Atom Structure::getAtomByLabel(const std::string &atomID, const std::string &asy
for
(
auto
&
a
:
mAtoms
)
{
if
(
a
.
labelAtomID
()
==
atomID
and
a
.
labelAsymID
()
==
asymID
and
a
.
labelCompID
()
==
compID
and
a
.
labelSeqID
()
==
seqID
and
a
.
labelAltID
()
==
altID
)
a
.
labelAsymID
()
==
asymID
and
a
.
labelCompID
()
==
compID
and
a
.
labelSeqID
()
==
seqID
and
a
.
labelAltID
()
==
altID
)
{
return
a
;
}
...
...
@@ -2006,12 +2013,12 @@ std::tuple<char, int, char> Structure::MapLabelToAuth(
try
{
result
=
std
::
make_tuple
(
auth_asym_id
.
front
(),
std
::
stoi
(
auth_seq_num
),
pdb_ins_code
.
empty
()
?
' '
:
pdb_ins_code
.
front
());
pdb_ins_code
.
empty
()
?
' '
:
pdb_ins_code
.
front
());
}
catch
(
const
std
::
exception
&
ex
)
catch
(
const
std
::
exception
&
ex
)
{
result
=
std
::
make_tuple
(
auth_asym_id
.
front
(),
0
,
pdb_ins_code
.
empty
()
?
' '
:
pdb_ins_code
.
front
());
pdb_ins_code
.
empty
()
?
' '
:
pdb_ins_code
.
front
());
}
found
=
true
;
...
...
@@ -2030,7 +2037,7 @@ std::tuple<char, int, char> Structure::MapLabelToAuth(
r
.
front
().
get
(
"pdb_strand_id"
,
"pdb_seq_num"
,
"pdb_ins_code"
);
result
=
std
::
make_tuple
(
pdb_strand_id
.
front
(),
pdb_seq_num
,
pdb_ins_code
.
empty
()
?
' '
:
pdb_ins_code
.
front
());
pdb_ins_code
.
empty
()
?
' '
:
pdb_ins_code
.
front
());
found
=
true
;
}
...
...
@@ -2082,7 +2089,7 @@ std::tuple<std::string, int, std::string, std::string> Structure::MapLabelToPDB(
}
std
::
tuple
<
std
::
string
,
int
,
std
::
string
>
Structure
::
MapPDBToLabel
(
const
std
::
string
&
asymID
,
int
seqID
,
const
std
::
string
&
compID
,
const
std
::
string
&
iCode
)
const
const
std
::
string
&
compID
,
const
std
::
string
&
iCode
)
const
{
auto
&
db
=
datablock
();
...
...
@@ -2154,10 +2161,10 @@ void Structure::insertCompound(const std::string &compoundID, bool isEntity)
if
(
r
.
empty
())
{
chemComp
.
emplace
({{
"id"
,
compoundID
},
{
"name"
,
compound
->
name
()},
{
"formula"
,
compound
->
formula
()},
{
"formula_weight"
,
compound
->
formulaWeight
()},
{
"type"
,
compound
->
type
()}});
{
"name"
,
compound
->
name
()},
{
"formula"
,
compound
->
formula
()},
{
"formula_weight"
,
compound
->
formulaWeight
()},
{
"type"
,
compound
->
type
()}});
}
if
(
isEntity
)
...
...
@@ -2169,13 +2176,13 @@ void Structure::insertCompound(const std::string &compoundID, bool isEntity)
std
::
string
entityID
=
std
::
to_string
(
entity
.
size
()
+
1
);
entity
.
emplace
({{
"id"
,
entityID
},
{
"type"
,
"non-polymer"
},
{
"pdbx_description"
,
compound
->
name
()},
{
"formula_weight"
,
compound
->
formulaWeight
()}});
{
"type"
,
"non-polymer"
},
{
"pdbx_description"
,
compound
->
name
()},
{
"formula_weight"
,
compound
->
formulaWeight
()}});
pdbxEntityNonpoly
.
emplace
({{
"entity_id"
,
entityID
},
{
"name"
,
compound
->
name
()},
{
"comp_id"
,
compoundID
}});
{
"name"
,
compound
->
name
()},
{
"comp_id"
,
compoundID
}});
}
}
}
...
...
@@ -2298,7 +2305,7 @@ void Structure::moveAtom(Atom &a, Point p)
}
void
Structure
::
changeResidue
(
const
Residue
&
res
,
const
std
::
string
&
newCompound
,
const
std
::
vector
<
std
::
tuple
<
std
::
string
,
std
::
string
>>
&
remappedAtoms
)
const
std
::
vector
<
std
::
tuple
<
std
::
string
,
std
::
string
>>
&
remappedAtoms
)
{
using
namespace
cif
::
literals
;
...
...
@@ -2326,15 +2333,15 @@ void Structure::changeResidue(const Residue &res, const std::string &newCompound
{
entityID
=
entity
.
getUniqueID
(
""
);
entity
.
emplace
({{
"id"
,
entityID
},
{
"type"
,
"non-polymer"
},
{
"pdbx_description"
,
compound
->
name
()},
{
"formula_weight"
,
compound
->
formulaWeight
()}});
{
"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
}});
{
"name"
,
compound
->
name
()},
{
"comp_id"
,
newCompound
}});
auto
&
pdbxNonPolyScheme
=
db
[
"pdbx_nonpoly_scheme"
];
for
(
auto
&
nps
:
pdbxNonPolyScheme
.
find
(
"asym_id"
_key
==
asymID
))
...
...
@@ -2349,10 +2356,10 @@ void Structure::changeResidue(const Residue &res, const std::string &newCompound
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
()}});
{
"name"
,
compound
->
name
()},
{
"formula"
,
compound
->
formula
()},
{
"formula_weight"
,
compound
->
formulaWeight
()},
{
"type"
,
compound
->
type
()}});
}
// update the struct_asym for the new entity
...
...
@@ -2369,7 +2376,8 @@ void Structure::changeResidue(const Residue &res, const std::string &newCompound
std
::
string
a1
,
a2
;
tie
(
a1
,
a2
)
=
a
;
auto
i
=
find_if
(
atoms
.
begin
(),
atoms
.
end
(),
[
&
](
const
Atom
&
a
)
{
return
a
.
labelAtomID
()
==
a1
;
});
auto
i
=
find_if
(
atoms
.
begin
(),
atoms
.
end
(),
[
&
](
const
Atom
&
a
)
{
return
a
.
labelAtomID
()
==
a1
;
});
if
(
i
==
atoms
.
end
())
{
std
::
cerr
<<
"Missing atom for atom ID "
<<
a1
<<
std
::
endl
;
...
...
@@ -2456,7 +2464,7 @@ void Structure::cleanupEmptyCategories()
std
::
string
type
,
id
;
cif
::
tie
(
type
,
id
)
=
entity
.
get
(
"type"
,
"id"
);
std
::
optional
<
in
t
>
count
;
std
::
optional
<
size_
t
>
count
;
if
(
type
==
"polymer"
)
count
=
db
[
"entity_poly"
].
find
(
"entity_id"
_key
==
id
).
size
();
else
if
(
type
==
"non-polymer"
or
type
==
"water"
)
...
...
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