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
9160adb1
Unverified
Commit
9160adb1
authored
Feb 02, 2022
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into trunk
parents
6c0a4180
3ebf4338
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
280 additions
and
110 deletions
+280
-110
CMakeLists.txt
+14
-34
Config.cmake.in
+2
-1
cmake/FindAtomic.cmake
+64
-0
cmake/FindFilesystem.cmake
+2
-0
cmake/VersionString.cmake
+77
-0
include/cif++/CifUtils.hpp
+0
-4
include/cif++/Point.hpp
+1
-2
include/cif++/Structure.hpp
+49
-21
src/CifUtils.cpp
+5
-38
src/PDB2Cif.cpp
+5
-2
src/Structure.cpp
+59
-1
src/revision.hpp.in
+0
-5
test/unit-test.cpp
+2
-2
No files found.
CMakeLists.txt
View file @
9160adb1
...
@@ -37,17 +37,16 @@ include(CheckIncludeFiles)
...
@@ -37,17 +37,16 @@ include(CheckIncludeFiles)
include
(
CheckLibraryExists
)
include
(
CheckLibraryExists
)
include
(
CMakePackageConfigHelpers
)
include
(
CMakePackageConfigHelpers
)
include
(
Dart
)
include
(
Dart
)
include
(
FindFilesystem
)
include
(
GenerateExportHeader
)
include
(
GenerateExportHeader
)
set
(
CXX_EXTENSIONS OFF
)
set
(
CXX_EXTENSIONS OFF
)
set
(
CMAKE_CXX_STANDARD 17
)
set
(
CMAKE_CXX_STANDARD 17
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
# https://stackoverflow.com/questions/63902528/program-crashes-when-filesystempath-is-destroyed
find_package
(
Filesystem REQUIRED
)
find_package
(
Filesystem REQUIRED
)
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"GNU"
)
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"GNU"
)
# https://stackoverflow.com/questions/63902528/program-crashes-when-filesystempath-is-destroyed
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers"
)
elseif
(
MSVC
)
elseif
(
MSVC
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/W4"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/W4"
)
...
@@ -122,20 +121,6 @@ if(MSVC)
...
@@ -122,20 +121,6 @@ if(MSVC)
message
(
STATUS
"The library and auxiliary files will be installed in $ENV{LOCALAPPDATA}/
${
PROJECT_NAME
}
"
)
message
(
STATUS
"The library and auxiliary files will be installed in $ENV{LOCALAPPDATA}/
${
PROJECT_NAME
}
"
)
set
(
CMAKE_INSTALL_PREFIX
"$ENV{LOCALAPPDATA}/
${
PROJECT_NAME
}
"
CACHE PATH
"..."
FORCE
)
set
(
CMAKE_INSTALL_PREFIX
"$ENV{LOCALAPPDATA}/
${
PROJECT_NAME
}
"
CACHE PATH
"..."
FORCE
)
endif
()
endif
()
# Find out the processor type for the target
if
(
${
CMAKE_SYSTEM_PROCESSOR
}
STREQUAL
"AMD64"
)
set
(
COFF_TYPE
"x64"
)
elseif
(
${
CMAKE_SYSTEM_PROCESSOR
}
STREQUAL
"i386"
)
set
(
COFF_TYPE
"x86"
)
elseif
(
${
CMAKE_SYSTEM_PROCESSOR
}
STREQUAL
"ARM64"
)
set
(
COFF_TYPE
"arm64"
)
else
()
message
(
FATAL_ERROR
"Unsupported or unknown processor type
${
CMAKE_SYSTEM_PROCESSOR
}
"
)
endif
()
# for mrc, just in case
list
(
APPEND CMAKE_PREFIX_PATH
"$ENV{LOCALAPPDATA}/mrc"
)
endif
()
endif
()
if
(
UNIX AND NOT APPLE AND NOT BUILD_FOR_CCP4 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
)
if
(
UNIX AND NOT APPLE AND NOT BUILD_FOR_CCP4 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
)
...
@@ -175,24 +160,18 @@ find_package(Boost 1.70.0 REQUIRED COMPONENTS system iostreams regex program_opt
...
@@ -175,24 +160,18 @@ find_package(Boost 1.70.0 REQUIRED COMPONENTS system iostreams regex program_opt
if
(
NOT MSVC AND Boost_USE_STATIC_LIBS
)
if
(
NOT MSVC AND Boost_USE_STATIC_LIBS
)
find_package
(
ZLIB REQUIRED
)
find_package
(
ZLIB REQUIRED
)
list
(
APPEND CIFPP_REQUIRED_LIBRARIES ZLIB::ZLIB
)
endif
()
endif
()
# Create a revision file, containing the current git version info
include
(
FindFilesystem
)
list
(
APPEND CIFPP_REQUIRED_LIBRARIES
${
STDCPPFS_LIBRARY
}
)
include
(
GetGitRevisionDescription
)
option
(
GENERATE_CUSTOM_VERSION
"Generate a custom version string"
OFF
)
if
(
GIT-NOTFOUND OR HEAD-HASH-NOTFOUND OR NOT GENERATE_CUSTOM_VERSION
)
get_git_head_revision
(
REFSPEC COMMITHASH
)
# Generate our own version string
include
(
FindAtomic
)
git_describe_working_tree
(
BUILD_VERSION_STRING --match=build --dirty
)
list
(
APPEND CIFPP_REQUIRED_LIBRARIES
${
STDCPPATOMIC_LIBRARY
}
)
else
()
SET
(
BUILD_VERSION_STRING
${
PROJECT_VERSION
}
)
endif
()
#
generate version.h
#
Create a revision file, containing the current git version info
string
(
TIMESTAMP BUILD_DATE_TIME
"%Y-%m-%dT%H:%M:%SZ"
UTC
)
include
(
VersionString
)
configure_file
(
"
${
CMAKE_SOURCE_DIR
}
/src/revision.hpp.in"
"
${
CMAKE_BINARY_DIR
}
/revision.hpp"
@ONLY
)
write_version_header
(
"LibCIFPP"
)
# SymOp data table
# SymOp data table
if
(
CIFPP_RECREATE_SYMOP_DATA
)
if
(
CIFPP_RECREATE_SYMOP_DATA
)
...
@@ -200,7 +179,7 @@ if(CIFPP_RECREATE_SYMOP_DATA)
...
@@ -200,7 +179,7 @@ if(CIFPP_RECREATE_SYMOP_DATA)
add_executable
(
symop-map-generator
"
${
CMAKE_SOURCE_DIR
}
/tools/symop-map-generator.cpp"
)
add_executable
(
symop-map-generator
"
${
CMAKE_SOURCE_DIR
}
/tools/symop-map-generator.cpp"
)
target_link_libraries
(
symop-map-generator Threads::Threads
${
Boost_LIBRARIES
}
std::filesystem
${
ZLIB
_LIBRARIES
}
)
target_link_libraries
(
symop-map-generator Threads::Threads
${
Boost_LIBRARIES
}
${
CIFPP_REQUIRED
_LIBRARIES
}
)
if
(
Boost_INCLUDE_DIR
)
if
(
Boost_INCLUDE_DIR
)
target_include_directories
(
symop-map-generator PUBLIC
${
Boost_INCLUDE_DIR
}
)
target_include_directories
(
symop-map-generator PUBLIC
${
Boost_INCLUDE_DIR
}
)
endif
()
endif
()
...
@@ -271,7 +250,8 @@ target_include_directories(cifpp
...
@@ -271,7 +250,8 @@ target_include_directories(cifpp
${
CMAKE_BINARY_DIR
}
${
CMAKE_BINARY_DIR
}
)
)
target_link_libraries
(
cifpp Threads::Threads
${
Boost_LIBRARIES
}
std::filesystem
${
ZLIB_LIBRARIES
}
)
target_link_libraries
(
cifpp PUBLIC Threads::Threads Boost::regex Boost::iostreams
${
CIFPP_REQUIRED_LIBRARIES
}
)
# target_link_libraries(cifpp PRIVATE)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"AppleClang"
)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"AppleClang"
)
target_link_options
(
cifpp PRIVATE -undefined dynamic_lookup
)
target_link_options
(
cifpp PRIVATE -undefined dynamic_lookup
)
...
@@ -331,7 +311,7 @@ install(TARGETS cifpp
...
@@ -331,7 +311,7 @@ install(TARGETS cifpp
RUNTIME DESTINATION
${
CMAKE_INSTALL_BINDIR
}
RUNTIME DESTINATION
${
CMAKE_INSTALL_BINDIR
}
INCLUDES DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
)
INCLUDES DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
)
if
(
MSVC
)
if
(
MSVC
AND BUILD_SHARED_LIBS
)
install
(
install
(
FILES $<TARGET_PDB_FILE:
${
PROJECT_NAME
}
>
FILES $<TARGET_PDB_FILE:
${
PROJECT_NAME
}
>
DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
...
@@ -428,7 +408,7 @@ if(CIFPP_BUILD_TESTS)
...
@@ -428,7 +408,7 @@ if(CIFPP_BUILD_TESTS)
${
CMAKE_CURRENT_BINARY_DIR
}
# for config.h
${
CMAKE_CURRENT_BINARY_DIR
}
# for config.h
)
)
target_link_libraries
(
${
CIFPP_TEST
}
PRIVATE Threads::Threads cifpp
${
Boost_LIBRARIES
}
std::filesystem
${
ZLIB_LIBRARIES
}
)
target_link_libraries
(
${
CIFPP_TEST
}
PRIVATE Threads::Threads cifpp
)
if
(
CIFPP_USE_RSRC
)
if
(
CIFPP_USE_RSRC
)
mrc_target_resources
(
${
CIFPP_TEST
}
${
CMAKE_SOURCE_DIR
}
/rsrc/mmcif_pdbx_v50.dic
)
mrc_target_resources
(
${
CIFPP_TEST
}
${
CMAKE_SOURCE_DIR
}
/rsrc/mmcif_pdbx_v50.dic
)
...
...
Config.cmake.in
View file @
9160adb1
@PACKAGE_INIT@
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
include(CMakeFindDependencyMacro)
find_dependency(Boost 1.70.0 REQUIRED COMPONENTS system iostreams regex program_options)
find_dependency(Threads)
find_dependency(Boost 1.70.0 REQUIRED COMPONENTS system iostreams regex)
if(NOT WIN32)
if(NOT WIN32)
find_dependency(ZLIB)
find_dependency(ZLIB)
endif()
endif()
...
...
cmake/FindAtomic.cmake
0 → 100644
View file @
9160adb1
# Simple check to see if we need a library for std::atomic
if
(
TARGET std::atomic
)
return
()
endif
()
cmake_minimum_required
(
VERSION 3.10
)
include
(
CMakePushCheckState
)
include
(
CheckIncludeFileCXX
)
include
(
CheckCXXSourceRuns
)
cmake_push_check_state
()
set
(
CMAKE_CXX_STANDARD 17
)
check_include_file_cxx
(
"atomic"
_CXX_ATOMIC_HAVE_HEADER
)
mark_as_advanced
(
_CXX_ATOMIC_HAVE_HEADER
)
set
(
code
[[
#include <atomic>
int main(int argc, char** argv) {
std::atomic<long long> s;
++s;
return 0;
}
]]
)
check_cxx_source_runs
(
"
${
code
}
"
_CXX_ATOMIC_BUILTIN
)
if
(
_CXX_ATOMIC_BUILTIN
)
set
(
_found 1
)
else
()
list
(
APPEND CMAKE_REQUIRED_LIBRARIES atomic
)
list
(
APPEND FOLLY_LINK_LIBRARIES atomic
)
check_cxx_source_runs
(
"
${
code
}
"
_CXX_ATOMIC_LIB_NEEDED
)
if
(
NOT _CXX_ATOMIC_LIB_NEEDED
)
message
(
FATAL_ERROR
"unable to link C++ std::atomic code: you may need \
to install GNU libatomic"
)
else
()
set
(
_found 1
)
endif
()
endif
()
if
(
_found
)
add_library
(
std::atomic INTERFACE IMPORTED
)
set_property
(
TARGET std::atomic APPEND PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_14
)
if
(
_CXX_ATOMIC_BUILTIN
)
# Nothing to add...
elseif
(
_CXX_ATOMIC_LIB_NEEDED
)
set_target_properties
(
std::atomic PROPERTIES IMPORTED_LIBNAME atomic
)
set
(
STDCPPATOMIC_LIBRARY atomic
)
endif
()
endif
()
cmake_pop_check_state
()
set
(
Atomic_FOUND
${
_found
}
CACHE BOOL
"TRUE if we can run a program using std::atomic"
FORCE
)
if
(
Atomic_FIND_REQUIRED AND NOT Atomic_FOUND
)
message
(
FATAL_ERROR
"Cannot run simple program using std::atomic"
)
endif
()
cmake/FindFilesystem.cmake
View file @
9160adb1
...
@@ -59,8 +59,10 @@ if(_found)
...
@@ -59,8 +59,10 @@ if(_found)
# Nothing to add...
# Nothing to add...
elseif
(
CXX_FILESYSTEM_STDCPPFS_NEEDED
)
elseif
(
CXX_FILESYSTEM_STDCPPFS_NEEDED
)
set_target_properties
(
std::filesystem PROPERTIES IMPORTED_LIBNAME stdc++fs
)
set_target_properties
(
std::filesystem PROPERTIES IMPORTED_LIBNAME stdc++fs
)
set
(
STDCPPFS_LIBRARY stdc++fs
)
elseif
(
CXX_FILESYSTEM_CPPFS_NEEDED
)
elseif
(
CXX_FILESYSTEM_CPPFS_NEEDED
)
set_target_properties
(
std::filesystem PROPERTIES IMPORTED_LIBNAME c++fs
)
set_target_properties
(
std::filesystem PROPERTIES IMPORTED_LIBNAME c++fs
)
set
(
STDCPPFS_LIBRARY c++fs
)
endif
()
endif
()
endif
()
endif
()
...
...
cmake/VersionString.cmake
0 → 100644
View file @
9160adb1
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2021 NKI/AVL, Netherlands Cancer Institute
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cmake_minimum_required
(
VERSION 3.15
)
# Create a revision file, containing the current git version info, if any
function
(
write_version_header
)
include
(
GetGitRevisionDescription
)
if
(
NOT
(
GIT-NOTFOUND OR HEAD-HASH-NOTFOUND
))
git_describe_working_tree
(
BUILD_VERSION_STRING --match=build --dirty
)
if
(
BUILD_VERSION_STRING MATCHES
"build-([0-9]+)-g([0-9a-f]+)(-dirty)?"
)
set
(
BUILD_GIT_TAGREF
"
${
CMAKE_MATCH_2
}
"
)
if
(
CMAKE_MATCH_3
)
set
(
BUILD_VERSION_STRING
"
${
CMAKE_MATCH_1
}
*"
)
else
()
set
(
BUILD_VERSION_STRING
"
${
CMAKE_MATCH_1
}
"
)
endif
()
endif
()
else
()
set
(
BUILD_VERSION_STRING
"no git info available"
)
endif
()
include_directories
(
${
CMAKE_BINARY_DIR
}
PRIVATE
)
string
(
TIMESTAMP BUILD_DATE_TIME
"%Y-%m-%dT%H:%M:%SZ"
UTC
)
if
(
ARGC GREATER 0
)
set
(
VAR_PREFIX
"
${
ARGV0
}
"
)
endif
()
file
(
WRITE
"
${
CMAKE_BINARY_DIR
}
/revision.hpp.in"
[[// Generated revision file
#pragma once
#include <ostream>
const char k@VAR_PREFIX@ProjectName[] = "@PROJECT_NAME@";
const char k@VAR_PREFIX@VersionNumber[] = "@PROJECT_VERSION@";
const char k@VAR_PREFIX@VersionGitTag[] = "@BUILD_GIT_TAGREF@";
const char k@VAR_PREFIX@BuildInfo[] = "@BUILD_VERSION_STRING@";
const char k@VAR_PREFIX@BuildDate[] = "@BUILD_DATE_TIME@";
inline void write_version_string(std::ostream &os, bool verbose)
{
os << k@VAR_PREFIX@ProjectName << " version " << k@VAR_PREFIX@VersionNumber << std::endl;
if (verbose)
{
os << "build: " << k@VAR_PREFIX@BuildInfo << ' ' << k@VAR_PREFIX@BuildDate << std::endl;
if (k@VAR_PREFIX@VersionGitTag[0] != 0)
os << "git tag: " << k@VAR_PREFIX@VersionGitTag << std::endl;
}
}
]]
)
configure_file
(
"
${
CMAKE_BINARY_DIR
}
/revision.hpp.in"
"
${
CMAKE_BINARY_DIR
}
/revision.hpp"
@ONLY
)
endfunction
()
include/cif++/CifUtils.hpp
View file @
9160adb1
...
@@ -26,11 +26,7 @@
...
@@ -26,11 +26,7 @@
#pragma once
#pragma once
#include <cassert>
#include <filesystem>
#include <filesystem>
#include <iostream>
#include <list>
#include <memory>
#include <set>
#include <set>
#include <vector>
#include <vector>
...
...
include/cif++/Point.hpp
View file @
9160adb1
...
@@ -371,8 +371,7 @@ auto DistancePointToLine(const PointF<F> &l1, const PointF<F> &l2, const PointF<
...
@@ -371,8 +371,7 @@ auto DistancePointToLine(const PointF<F> &l1, const PointF<F> &l2, const PointF<
// a random direction with a distance randomly chosen from a normal
// a random direction with a distance randomly chosen from a normal
// distribution with a stddev of offset.
// distribution with a stddev of offset.
template
<
typename
F
>
Point
Nudge
(
Point
p
,
float
offset
);
PointF
<
F
>
Nudge
(
PointF
<
F
>
p
,
F
offset
);
// --------------------------------------------------------------------
// --------------------------------------------------------------------
// We use quaternions to do rotations in 3d space
// We use quaternions to do rotations in 3d space
...
...
include/cif++/Structure.hpp
View file @
9160adb1
...
@@ -141,6 +141,8 @@ class Atom
...
@@ -141,6 +141,8 @@ class Atom
void
set_property
(
const
std
::
string_view
name
,
const
std
::
string
&
value
)
void
set_property
(
const
std
::
string_view
name
,
const
std
::
string
&
value
)
{
{
if
(
not
mImpl
)
throw
std
::
logic_error
(
"Error trying to modify an uninitialized atom"
);
mImpl
->
set_property
(
name
,
value
);
mImpl
->
set_property
(
name
,
value
);
}
}
...
@@ -150,11 +152,16 @@ class Atom
...
@@ -150,11 +152,16 @@ class Atom
set_property
(
name
,
std
::
to_string
(
value
));
set_property
(
name
,
std
::
to_string
(
value
));
}
}
const
std
::
string
&
id
()
const
{
return
mImpl
->
mID
;
}
const
std
::
string
&
id
()
const
{
return
impl
().
mID
;
}
AtomType
type
()
const
{
return
mImpl
->
mType
;
}
AtomType
type
()
const
{
return
impl
().
mType
;
}
Point
location
()
const
{
return
mImpl
->
mLocation
;
}
Point
location
()
const
{
return
impl
().
mLocation
;
}
void
location
(
Point
p
)
{
mImpl
->
moveTo
(
p
);
}
void
location
(
Point
p
)
{
if
(
not
mImpl
)
throw
std
::
logic_error
(
"Error trying to modify an uninitialized atom"
);
mImpl
->
moveTo
(
p
);
}
/// \brief Translate the position of this atom by \a t
/// \brief Translate the position of this atom by \a t
void
translate
(
Point
t
);
void
translate
(
Point
t
);
...
@@ -169,33 +176,33 @@ class Atom
...
@@ -169,33 +176,33 @@ class Atom
void
translateRotateAndTranslate
(
Point
t1
,
Quaternion
q
,
Point
t2
);
void
translateRotateAndTranslate
(
Point
t1
,
Quaternion
q
,
Point
t2
);
// for direct access to underlying data, be careful!
// for direct access to underlying data, be careful!
const
cif
::
Row
getRow
()
const
{
return
mImpl
->
mRow
;
}
const
cif
::
Row
getRow
()
const
{
return
impl
().
mRow
;
}
const
cif
::
Row
getRowAniso
()
const
;
const
cif
::
Row
getRowAniso
()
const
;
bool
isSymmetryCopy
()
const
{
return
mImpl
->
mSymmetryCopy
;
}
bool
isSymmetryCopy
()
const
{
return
impl
().
mSymmetryCopy
;
}
std
::
string
symmetry
()
const
{
return
mImpl
->
mSymmetryOperator
;
}
std
::
string
symmetry
()
const
{
return
impl
().
mSymmetryOperator
;
}
const
Compound
&
comp
()
const
{
return
mImpl
->
comp
();
}
const
Compound
&
comp
()
const
{
return
impl
().
comp
();
}
bool
isWater
()
const
{
return
mImpl
->
mCompID
==
"HOH"
or
mImpl
->
mCompID
==
"H2O"
or
mImpl
->
mCompID
==
"WAT"
;
}
bool
isWater
()
const
{
return
impl
().
mCompID
==
"HOH"
or
impl
().
mCompID
==
"H2O"
or
impl
().
mCompID
==
"WAT"
;
}
int
charge
()
const
;
int
charge
()
const
;
float
uIso
()
const
;
float
uIso
()
const
;
bool
getAnisoU
(
float
anisou
[
6
])
const
{
return
mImpl
->
getAnisoU
(
anisou
);
}
bool
getAnisoU
(
float
anisou
[
6
])
const
{
return
impl
().
getAnisoU
(
anisou
);
}
float
occupancy
()
const
;
float
occupancy
()
const
;
// specifications
// specifications
const
std
::
string
&
labelAtomID
()
const
{
return
mImpl
->
mAtomID
;
}
const
std
::
string
&
labelAtomID
()
const
{
return
impl
().
mAtomID
;
}
const
std
::
string
&
labelCompID
()
const
{
return
mImpl
->
mCompID
;
}
const
std
::
string
&
labelCompID
()
const
{
return
impl
().
mCompID
;
}
const
std
::
string
&
labelAsymID
()
const
{
return
mImpl
->
mAsymID
;
}
const
std
::
string
&
labelAsymID
()
const
{
return
impl
().
mAsymID
;
}
std
::
string
labelEntityID
()
const
;
std
::
string
labelEntityID
()
const
;
int
labelSeqID
()
const
{
return
mImpl
->
mSeqID
;
}
int
labelSeqID
()
const
{
return
impl
().
mSeqID
;
}
const
std
::
string
&
labelAltID
()
const
{
return
mImpl
->
mAltID
;
}
const
std
::
string
&
labelAltID
()
const
{
return
impl
().
mAltID
;
}
bool
isAlternate
()
const
{
return
not
mImpl
->
mAltID
.
empty
();
}
bool
isAlternate
()
const
{
return
not
impl
().
mAltID
.
empty
();
}
std
::
string
authAtomID
()
const
;
std
::
string
authAtomID
()
const
;
std
::
string
authCompID
()
const
;
std
::
string
authCompID
()
const
;
std
::
string
authAsymID
()
const
;
std
::
string
authAsymID
()
const
;
const
std
::
string
&
authSeqID
()
const
{
return
mImpl
->
mAuthSeqID
;
}
const
std
::
string
&
authSeqID
()
const
{
return
impl
().
mAuthSeqID
;
}
std
::
string
pdbxAuthInsCode
()
const
;
std
::
string
pdbxAuthInsCode
()
const
;
std
::
string
pdbxAuthAltID
()
const
;
std
::
string
pdbxAuthAltID
()
const
;
...
@@ -218,7 +225,7 @@ class Atom
...
@@ -218,7 +225,7 @@ class Atom
std
::
swap
(
mImpl
,
b
.
mImpl
);
std
::
swap
(
mImpl
,
b
.
mImpl
);
}
}
int
compare
(
const
Atom
&
b
)
const
{
return
mImpl
->
compare
(
*
b
.
mImpl
);
}
int
compare
(
const
Atom
&
b
)
const
{
return
impl
().
compare
(
*
b
.
mImpl
);
}
bool
operator
<
(
const
Atom
&
rhs
)
const
bool
operator
<
(
const
Atom
&
rhs
)
const
{
{
...
@@ -232,26 +239,33 @@ class Atom
...
@@ -232,26 +239,33 @@ class Atom
void
setID
(
int
id
);
void
setID
(
int
id
);
const
AtomImpl
&
impl
()
const
{
if
(
not
mImpl
)
throw
std
::
runtime_error
(
"Uninitialized atom, not found?"
);
return
*
mImpl
;
}
std
::
shared_ptr
<
AtomImpl
>
mImpl
;
std
::
shared_ptr
<
AtomImpl
>
mImpl
;
};
};
template
<>
template
<>
inline
std
::
string
Atom
::
get_property
<
std
::
string
>
(
const
std
::
string_view
name
)
const
inline
std
::
string
Atom
::
get_property
<
std
::
string
>
(
const
std
::
string_view
name
)
const
{
{
return
mImpl
->
get_property
(
name
);
return
impl
().
get_property
(
name
);
}
}
template
<>
template
<>
inline
int
Atom
::
get_property
<
int
>
(
const
std
::
string_view
name
)
const
inline
int
Atom
::
get_property
<
int
>
(
const
std
::
string_view
name
)
const
{
{
auto
v
=
mImpl
->
get_property
(
name
);
auto
v
=
impl
().
get_property
(
name
);
return
v
.
empty
()
?
0
:
stoi
(
v
);
return
v
.
empty
()
?
0
:
stoi
(
v
);
}
}
template
<>
template
<>
inline
float
Atom
::
get_property
<
float
>
(
const
std
::
string_view
name
)
const
inline
float
Atom
::
get_property
<
float
>
(
const
std
::
string_view
name
)
const
{
{
return
stof
(
mImpl
->
get_property
(
name
));
return
stof
(
impl
().
get_property
(
name
));
}
}
inline
void
swap
(
mmcif
::
Atom
&
a
,
mmcif
::
Atom
&
b
)
inline
void
swap
(
mmcif
::
Atom
&
a
,
mmcif
::
Atom
&
b
)
...
@@ -559,6 +573,12 @@ class Structure
...
@@ -559,6 +573,12 @@ class Structure
/// \brief Get a the single residue for an asym with id \a asymID
/// \brief Get a the single residue for an asym with id \a asymID
Residue
&
getResidue
(
const
std
::
string
&
asymID
);
Residue
&
getResidue
(
const
std
::
string
&
asymID
);
/// \brief Get a the residue for atom \a atom
Residue
&
getResidue
(
const
mmcif
::
Atom
&
atom
);
/// \brief Get a the residue for atom \a atom
const
Residue
&
getResidue
(
const
mmcif
::
Atom
&
atom
)
const
;
// map between auth and label locations
// map between auth and label locations
std
::
tuple
<
std
::
string
,
int
,
std
::
string
>
MapAuthToLabel
(
const
std
::
string
&
asymID
,
std
::
tuple
<
std
::
string
,
int
,
std
::
string
>
MapAuthToLabel
(
const
std
::
string
&
asymID
,
...
@@ -599,6 +619,14 @@ class Structure
...
@@ -599,6 +619,14 @@ class Structure
/// \return The newly create asym ID
/// \return The newly create asym ID
std
::
string
createNonpoly
(
const
std
::
string
&
entity_id
,
const
std
::
vector
<
mmcif
::
Atom
>
&
atoms
);
std
::
string
createNonpoly
(
const
std
::
string
&
entity_id
,
const
std
::
vector
<
mmcif
::
Atom
>
&
atoms
);
/// \brief Create a new NonPolymer struct_asym with atoms constructed from info in \a atom_info, returns asym_id.
/// This method creates new atom records filled with info from the info.
///
/// \param entity_id The entity ID of the new nonpoly
/// \param atoms The array of sets of cif::item data containing the data for the atoms.
/// \return The newly create asym ID
std
::
string
createNonpoly
(
const
std
::
string
&
entity_id
,
std
::
vector
<
std
::
vector
<
cif
::
Item
>>
&
atom_info
);
/// \brief To sort the atoms in order of model > asym-id > res-id > atom-id
/// \brief 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
/// Will asssign new atom_id's to all atoms. Be carefull
void
sortAtoms
();
void
sortAtoms
();
...
...
src/CifUtils.cpp
View file @
9160adb1
...
@@ -25,19 +25,14 @@
...
@@ -25,19 +25,14 @@
*/
*/
#include <atomic>
#include <atomic>
#include <chrono>
#include <cmath>
#include <cmath>
#include <cstdio>
#include <filesystem>
#include <fstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iostream>
#include <map>
#include <map>
#include <mutex>
#include <mutex>
#include <regex>
#include <regex>
#include <sstream>
#include <sstream>
#include <thread>
#include <thread>
#include <tuple>
#if defined(_MSC_VER)
#if defined(_MSC_VER)
#define TERM_WIDTH 80
#define TERM_WIDTH 80
...
@@ -50,6 +45,8 @@
...
@@ -50,6 +45,8 @@
#include "cif++/CifUtils.hpp"
#include "cif++/CifUtils.hpp"
#include "revision.hpp"
namespace
ba
=
boost
::
algorithm
;
namespace
ba
=
boost
::
algorithm
;
namespace
fs
=
std
::
filesystem
;
namespace
fs
=
std
::
filesystem
;
...
@@ -64,39 +61,9 @@ extern int VERBOSE;
...
@@ -64,39 +61,9 @@ extern int VERBOSE;
std
::
string
get_version_nr
()
std
::
string
get_version_nr
()
{
{
const
std
::
regex
std
::
ostringstream
s
;
rxVersionNr1
(
R"(build-(\d+)-g[0-9a-f]{7}(-dirty)?)"
),
write_version_string
(
s
,
false
);
rxVersionNr2
(
R"(libcifpp-version: (\d+\.\d+\.\d+))"
);
return
s
.
str
();
#include "revision.hpp"
struct
membuf
:
public
std
::
streambuf
{
membuf
(
char
*
data
,
size_t
length
)
{
this
->
setg
(
data
,
data
,
data
+
length
);
}
}
buffer
(
const_cast
<
char
*>
(
kRevision
),
sizeof
(
kRevision
));
std
::
istream
is
(
&
buffer
);
std
::
string
line
,
result
;
while
(
getline
(
is
,
line
))
{
std
::
smatch
m
;
if
(
std
::
regex_match
(
line
,
m
,
rxVersionNr1
))
{
result
=
m
[
1
];
if
(
m
[
2
].
matched
)
result
+=
'*'
;
break
;
}
// always the first, replace with more specific if followed by the other info
if
(
std
::
regex_match
(
line
,
m
,
rxVersionNr2
))
result
=
m
[
1
];
}
return
result
;
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
...
...
src/PDB2Cif.cpp
View file @
9160adb1
...
@@ -657,7 +657,7 @@ class PDBFileParser
...
@@ -657,7 +657,7 @@ class PDBFileParser
int
mSeqNum
;
int
mSeqNum
;
char
mIcode
;
char
mIcode
;
int
mDbSeqNum
;
int
mDbSeqNum
=
0
;
bool
mSeen
=
false
;
bool
mSeen
=
false
;
std
::
set
<
std
::
string
>
mAlts
;
std
::
set
<
std
::
string
>
mAlts
;
...
@@ -941,7 +941,10 @@ class PDBFileParser
...
@@ -941,7 +941,10 @@ class PDBFileParser
std
::
string
pdb2cifDate
(
std
::
string
s
)
std
::
string
pdb2cifDate
(
std
::
string
s
)
{
{
std
::
error_code
ec
;
std
::
error_code
ec
;
return
pdb2cifDate
(
s
,
ec
);
auto
result
=
pdb2cifDate
(
s
,
ec
);
if
(
ec
and
cif
::
VERBOSE
>
0
)
std
::
cerr
<<
"Invalid date("
<<
s
<<
"): "
<<
ec
.
message
()
<<
std
::
endl
;
return
result
;
}
}
std
::
string
pdb2cifAuth
(
std
::
string
author
)
std
::
string
pdb2cifAuth
(
std
::
string
author
)
...
...
src/Structure.cpp
View file @
9160adb1
...
@@ -1667,6 +1667,16 @@ Residue &Structure::getResidue(const std::string &asymID)
...
@@ -1667,6 +1667,16 @@ Residue &Structure::getResidue(const std::string &asymID)
return
const_cast
<
Residue
&>
(
const_cast
<
Structure
const
&>
(
*
this
).
getResidue
(
asymID
));
return
const_cast
<
Residue
&>
(
const_cast
<
Structure
const
&>
(
*
this
).
getResidue
(
asymID
));
}
}
Residue
&
Structure
::
getResidue
(
const
mmcif
::
Atom
&
atom
)
{
return
getResidue
(
atom
.
labelAsymID
(),
atom
.
labelCompID
(),
atom
.
labelSeqID
());
}
const
Residue
&
Structure
::
getResidue
(
const
mmcif
::
Atom
&
atom
)
const
{
return
getResidue
(
atom
.
labelAsymID
(),
atom
.
labelCompID
(),
atom
.
labelSeqID
());
}
File
&
Structure
::
getFile
()
const
File
&
Structure
::
getFile
()
const
{
{
return
mFile
;
return
mFile
;
...
@@ -2078,7 +2088,8 @@ std::string Structure::createNonpoly(const std::string &entity_id, const std::ve
...
@@ -2078,7 +2088,8 @@ std::string Structure::createNonpoly(const std::string &entity_id, const std::ve
{
{
auto
atom_id
=
atom_site
.
getUniqueID
(
""
);
auto
atom_id
=
atom_site
.
getUniqueID
(
""
);
auto
&&
[
row
,
inserted
]
=
atom_site
.
emplace
({{
"group_PDB"
,
atom
.
get_property
<
std
::
string
>
(
"group_PDB"
)},
auto
&&
[
row
,
inserted
]
=
atom_site
.
emplace
({
{
"group_PDB"
,
atom
.
get_property
<
std
::
string
>
(
"group_PDB"
)},
{
"id"
,
atom_id
},
{
"id"
,
atom_id
},
{
"type_symbol"
,
atom
.
get_property
<
std
::
string
>
(
"type_symbol"
)},
{
"type_symbol"
,
atom
.
get_property
<
std
::
string
>
(
"type_symbol"
)},
{
"label_atom_id"
,
atom
.
get_property
<
std
::
string
>
(
"label_atom_id"
)},
{
"label_atom_id"
,
atom
.
get_property
<
std
::
string
>
(
"label_atom_id"
)},
...
@@ -2107,6 +2118,53 @@ std::string Structure::createNonpoly(const std::string &entity_id, const std::ve
...
@@ -2107,6 +2118,53 @@ std::string Structure::createNonpoly(const std::string &entity_id, const std::ve
return
asym_id
;
return
asym_id
;
}
}
std
::
string
Structure
::
createNonpoly
(
const
std
::
string
&
entity_id
,
std
::
vector
<
std
::
vector
<
cif
::
Item
>>
&
atom_info
)
{
using
namespace
cif
::
literals
;
cif
::
Datablock
&
db
=
*
mFile
.
impl
().
mDb
;
auto
&
struct_asym
=
db
[
"struct_asym"
];
std
::
string
asym_id
=
struct_asym
.
getUniqueID
();
struct_asym
.
emplace
({{
"id"
,
asym_id
},
{
"pdbx_blank_PDB_chainid_flag"
,
"N"
},
{
"pdbx_modified"
,
"N"
},
{
"entity_id"
,
entity_id
},
{
"details"
,
"?"
}});
std
::
string
comp_id
=
db
[
"pdbx_entity_nonpoly"
].
find1
<
std
::
string
>
(
"entity_id"
_key
==
entity_id
,
"comp_id"
);
auto
&
atom_site
=
db
[
"atom_site"
];
auto
&
res
=
mNonPolymers
.
emplace_back
(
*
this
,
comp_id
,
asym_id
);
for
(
auto
&
atom
:
atom_info
)
{
auto
atom_id
=
atom_site
.
getUniqueID
(
""
);
atom
.
insert
(
atom
.
end
(),
{
{
"group_PDB"
,
"HETATM"
},
{
"id"
,
atom_id
},
{
"label_comp_id"
,
comp_id
},
{
"label_asym_id"
,
asym_id
},
{
"label_seq_id"
,
""
},
{
"label_entity_id"
,
entity_id
},
{
"auth_comp_id"
,
comp_id
},
{
"auth_asym_id"
,
asym_id
},
{
"auth_seq_id"
,
""
},
{
"pdbx_PDB_model_num"
,
1
},
{
"label_alt_id"
,
""
}
});
auto
&&
[
row
,
inserted
]
=
atom_site
.
emplace
(
atom
.
begin
(),
atom
.
end
());
auto
&
newAtom
=
mAtoms
.
emplace_back
(
std
::
make_shared
<
Atom
::
AtomImpl
>
(
db
,
atom_id
,
row
));
res
.
addAtom
(
newAtom
);
}
return
asym_id
;
}
void
Structure
::
cleanupEmptyCategories
()
void
Structure
::
cleanupEmptyCategories
()
{
{
using
namespace
cif
::
literals
;
using
namespace
cif
::
literals
;
...
...
src/revision.hpp.in
deleted
100644 → 0
View file @
6c0a4180
const char kRevision[] = R"(
lib@PROJECT_NAME@-version: @PROJECT_VERSION@
@BUILD_VERSION_STRING@
Date: @BUILD_DATE_TIME@
)";
test/unit-test.cpp
View file @
9160adb1
...
@@ -1735,12 +1735,12 @@ BOOST_AUTO_TEST_CASE(t1)
...
@@ -1735,12 +1735,12 @@ BOOST_AUTO_TEST_CASE(t1)
auto
p2
=
p1
;
auto
p2
=
p1
;
Point
c1
=
CenterPoints
(
p1
);
CenterPoints
(
p1
);
for
(
auto
&
p
:
p2
)
for
(
auto
&
p
:
p2
)
p
.
rotate
(
q
);
p
.
rotate
(
q
);
Point
c2
=
CenterPoints
(
p2
);
CenterPoints
(
p2
);
auto
q2
=
AlignPoints
(
p1
,
p2
);
auto
q2
=
AlignPoints
(
p1
,
p2
);
...
...
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