Commit 15db026e by Maarten L. Hekkelman

Merge branch 'develop' of github.com:PDB-REDO/libcifpp into develop

parents 19f2fd75 627d3b9d
...@@ -7,3 +7,4 @@ CMakeSettings.json ...@@ -7,3 +7,4 @@ CMakeSettings.json
msvc/ msvc/
src/revision.hpp src/revision.hpp
test/test-create_sugar_?.cif test/test-create_sugar_?.cif
Testing/
...@@ -35,10 +35,13 @@ include(CheckIncludeFiles) ...@@ -35,10 +35,13 @@ include(CheckIncludeFiles)
include(CheckLibraryExists) include(CheckLibraryExists)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
include(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
include(GenerateExportHeader)
set(CXX_EXTENSIONS OFF) set(CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set(CMAKE_CXX_VISIBILITY_PRESET hidden)
# set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
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")
...@@ -224,7 +227,6 @@ set(project_headers ...@@ -224,7 +227,6 @@ set(project_headers
${PROJECT_SOURCE_DIR}/include/cif++/datablock.hpp ${PROJECT_SOURCE_DIR}/include/cif++/datablock.hpp
${PROJECT_SOURCE_DIR}/include/cif++/file.hpp ${PROJECT_SOURCE_DIR}/include/cif++/file.hpp
${PROJECT_SOURCE_DIR}/include/cif++/validate.hpp ${PROJECT_SOURCE_DIR}/include/cif++/validate.hpp
${PROJECT_SOURCE_DIR}/include/cif++/list.hpp
${PROJECT_SOURCE_DIR}/include/cif++/iterator.hpp ${PROJECT_SOURCE_DIR}/include/cif++/iterator.hpp
${PROJECT_SOURCE_DIR}/include/cif++/parser.hpp ${PROJECT_SOURCE_DIR}/include/cif++/parser.hpp
${PROJECT_SOURCE_DIR}/include/cif++/forward_decl.hpp ${PROJECT_SOURCE_DIR}/include/cif++/forward_decl.hpp
...@@ -249,6 +251,7 @@ set(project_headers ...@@ -249,6 +251,7 @@ set(project_headers
add_library(cifpp ${project_sources} ${project_headers} ${PROJECT_SOURCE_DIR}/src/symop_table_data.hpp) add_library(cifpp ${project_sources} ${project_headers} ${PROJECT_SOURCE_DIR}/src/symop_table_data.hpp)
add_library(cifpp::cifpp ALIAS cifpp) add_library(cifpp::cifpp ALIAS cifpp)
generate_export_header(cifpp EXPORT_FILE_NAME cif++/exports.hpp)
if(BOOST_REGEX) if(BOOST_REGEX)
target_compile_definitions(cifpp PRIVATE USE_BOOST_REGEX=1 BOOST_REGEX_STANDALONE=1) target_compile_definitions(cifpp PRIVATE USE_BOOST_REGEX=1 BOOST_REGEX_STANDALONE=1)
...@@ -263,7 +266,7 @@ set_target_properties(cifpp PROPERTIES POSITION_INDEPENDENT_CODE ON) ...@@ -263,7 +266,7 @@ set_target_properties(cifpp PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(cifpp target_include_directories(cifpp
PUBLIC PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>" "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include;${PROJECT_BINARY_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
) )
...@@ -343,6 +346,12 @@ install( ...@@ -343,6 +346,12 @@ install(
COMPONENT Devel COMPONENT Devel
) )
install(
FILES ${PROJECT_BINARY_DIR}/cif++/exports.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cif++
COMPONENT Devel
)
install(FILES install(FILES
${PROJECT_SOURCE_DIR}/rsrc/mmcif_ddl.dic ${PROJECT_SOURCE_DIR}/rsrc/mmcif_ddl.dic
${PROJECT_SOURCE_DIR}/rsrc/mmcif_pdbx.dic ${PROJECT_SOURCE_DIR}/rsrc/mmcif_pdbx.dic
......
Version 5.0.6 Version 5.0.6
- Fix file::contains, using iequals - Fix file::contains, using iequals
- Fix is_cis
Version 5.0.5 Version 5.0.5
- Fix code to work on 32 bit machines - Fix code to work on 32 bit machines
......
...@@ -204,7 +204,7 @@ struct atom_type_info ...@@ -204,7 +204,7 @@ struct atom_type_info
float radii[kRadiusTypeCount]; float radii[kRadiusTypeCount];
}; };
extern const atom_type_info kKnownAtoms[]; extern CIFPP_EXPORT const atom_type_info kKnownAtoms[];
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// AtomTypeTraits // AtomTypeTraits
......
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
#pragma once #pragma once
#include <array>
#include <cif++/forward_decl.hpp> #include <cif++/forward_decl.hpp>
#include <cif++/condition.hpp> #include <cif++/condition.hpp>
...@@ -35,6 +33,8 @@ ...@@ -35,6 +33,8 @@
#include <cif++/row.hpp> #include <cif++/row.hpp>
#include <cif++/validate.hpp> #include <cif++/validate.hpp>
#include <array>
// TODO: implement all of: // TODO: implement all of:
// https://en.cppreference.com/w/cpp/named_req/Container // https://en.cppreference.com/w/cpp/named_req/Container
// https://en.cppreference.com/w/cpp/named_req/SequenceContainer // https://en.cppreference.com/w/cpp/named_req/SequenceContainer
......
...@@ -29,15 +29,15 @@ ...@@ -29,15 +29,15 @@
/// \file This file contains the definition for the class compound, encapsulating /// \file This file contains the definition for the class compound, encapsulating
/// the information found for compounds in the CCD. /// the information found for compounds in the CCD.
#include <cif++.hpp>
#include <cif++/atom_type.hpp>
#include <cif++/point.hpp>
#include <map> #include <map>
#include <set> #include <set>
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#include <cif++.hpp>
#include <cif++/atom_type.hpp>
#include <cif++/point.hpp>
namespace cif namespace cif
{ {
...@@ -180,7 +180,7 @@ class compound_factory ...@@ -180,7 +180,7 @@ class compound_factory
~compound_factory(); ~compound_factory();
static const std::map<std::string, char> kAAMap, kBaseMap; static CIFPP_EXPORT const std::map<std::string, char> kAAMap, kBaseMap;
private: private:
compound_factory(); compound_factory();
...@@ -195,4 +195,4 @@ class compound_factory ...@@ -195,4 +195,4 @@ class compound_factory
std::shared_ptr<compound_factory_impl> m_impl; std::shared_ptr<compound_factory_impl> m_impl;
}; };
} // namespace pdbx } // namespace cif
...@@ -26,14 +26,14 @@ ...@@ -26,14 +26,14 @@
#pragma once #pragma once
#include <cif++/row.hpp>
#include <cassert> #include <cassert>
#include <functional> #include <functional>
#include <iostream> #include <iostream>
#include <regex> #include <regex>
#include <utility> #include <utility>
#include <cif++/row.hpp>
namespace cif namespace cif
{ {
...@@ -859,4 +859,4 @@ namespace literals ...@@ -859,4 +859,4 @@ namespace literals
} }
} // namespace literals } // namespace literals
} // namespace cif } // namespace cif
\ No newline at end of file
...@@ -26,9 +26,8 @@ ...@@ -26,9 +26,8 @@
#pragma once #pragma once
#include <cif++/forward_decl.hpp>
#include <cif++/category.hpp> #include <cif++/category.hpp>
#include <cif++/forward_decl.hpp>
namespace cif namespace cif
{ {
...@@ -88,7 +87,7 @@ class datablock : public std::list<category> ...@@ -88,7 +87,7 @@ class datablock : public std::list<category>
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
bool operator==(const datablock &rhs) const; bool operator==(const datablock &rhs) const;
private: private:
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <list> #include <list>
#include <cif++/exports.hpp>
#include <cif++/datablock.hpp> #include <cif++/datablock.hpp>
#include <cif++/parser.hpp> #include <cif++/parser.hpp>
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#pragma once #pragma once
#include <cif++/exports.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
......
...@@ -26,6 +26,12 @@ ...@@ -26,6 +26,12 @@
#pragma once #pragma once
#include <cif++/exports.hpp>
#include <cif++/forward_decl.hpp>
#include <cif++/text.hpp>
#include <cif++/utilities.hpp>
#include <cassert>
#include <charconv> #include <charconv>
#include <cstring> #include <cstring>
#include <iomanip> #include <iomanip>
...@@ -35,9 +41,6 @@ ...@@ -35,9 +41,6 @@
#include <optional> #include <optional>
#include <utility> #include <utility>
#include <cif++/forward_decl.hpp>
#include <cif++/text.hpp>
/// \file item.hpp /// \file item.hpp
/// This file contains the declaration of item but also the item_value and item_handle /// This file contains the declaration of item but also the item_value and item_handle
/// These handle the storage of and access to the data for a single data field. /// These handle the storage of and access to the data for a single data field.
...@@ -45,8 +48,6 @@ ...@@ -45,8 +48,6 @@
namespace cif namespace cif
{ {
extern int VERBOSE;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
/// \brief item is a transient class that is used to pass data into rows /// \brief item is a transient class that is used to pass data into rows
/// but it also takes care of formatting data. /// but it also takes care of formatting data.
...@@ -353,7 +354,7 @@ struct item_handle ...@@ -353,7 +354,7 @@ struct item_handle
{ {
} }
static const item_handle s_null_item; static CIFPP_EXPORT const item_handle s_null_item;
friend void swap(item_handle a, item_handle b) friend void swap(item_handle a, item_handle b)
{ {
......
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022 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.
*/
#pragma once
#include <memory>
namespace cif
{
// --------------------------------------------------------------------
template<typename Allocator = std::allocator<void>>
class list
{
public:
protected:
struct list_item
{
list_item *m_next = nullptr;
};
using list_item_allocator_type = typename std::allocator_traits<Alloc>::template rebind_alloc<list_item>;
using list_item_allocator_traits = std::allocator_traits<item_allocator_type>;
list_item_allocator_traits::pointer get_item()
{
list_item_allocator_type ia(get_allocator());
return list_item_allocator_traits::allocate(ia, 1);
}
template<typename ...Arguments>
list_item *create_list_item(uint16_t column_ix, Arguments... args)
{
auto p = this->get_item();
list_item_allocator_type ia(get_allocator());
list_item_allocator_traits::construct(ia, p, std::forward<Arguments>(args)...);
return p;
}
void delete_list_item(list_item *iv)
{
list_item_allocator_type ia(get_allocator());
list_item_allocator_traits::destroy(ia, iv);
list_item_allocator_traits::deallocate(ia, iv, 1);
}
list_item *m_head = nullptr, *m_tail = nullptr;
};
} // namespace cif
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
#pragma once #pragma once
#include <numeric>
#include <cif++/atom_type.hpp> #include <cif++/atom_type.hpp>
#include <numeric>
#if __cpp_lib_format #if __cpp_lib_format
#include <format> #include <format>
#endif #endif
......
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
#pragma once #pragma once
#include <cif++/row.hpp>
#include <map> #include <map>
#include <regex> #include <regex>
#include <cif++/row.hpp>
namespace cif namespace cif
{ {
...@@ -94,7 +94,7 @@ class sac_parser ...@@ -94,7 +94,7 @@ class sac_parser
static bool is_unquoted_string(std::string_view text) static bool is_unquoted_string(std::string_view text)
{ {
bool result = is_ordinary(text.front()); bool result = text.empty() or is_ordinary(text.front());
if (result) if (result)
{ {
......
...@@ -26,19 +26,15 @@ ...@@ -26,19 +26,15 @@
#pragma once #pragma once
#include <cif++.hpp>
#include <string> #include <string>
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#include <cif++.hpp>
namespace cif namespace cif
{ {
extern const int
kResidueNrWildcard,
kNoSeqNum;
struct tls_selection; struct tls_selection;
struct tls_residue; struct tls_residue;
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#pragma once #pragma once
#include <cif++/exports.hpp>
#include <cmath> #include <cmath>
#include <complex> #include <complex>
#include <functional> #include <functional>
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#pragma once #pragma once
#include <cif++/exports.hpp>
#include <array> #include <array>
#include <cstdint> #include <cstdint>
#include <string> #include <string>
...@@ -50,8 +52,8 @@ struct space_group ...@@ -50,8 +52,8 @@ struct space_group
int nr; int nr;
}; };
extern const space_group kSpaceGroups[]; extern CIFPP_EXPORT const space_group kSpaceGroups[];
extern const std::size_t kNrOfSpaceGroups; extern CIFPP_EXPORT const std::size_t kNrOfSpaceGroups;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -139,8 +141,8 @@ struct symop_datablock ...@@ -139,8 +141,8 @@ struct symop_datablock
static_assert(sizeof(symop_datablock) == sizeof(uint64_t), "Size of symop_data is wrong"); static_assert(sizeof(symop_datablock) == sizeof(uint64_t), "Size of symop_data is wrong");
extern const symop_datablock kSymopNrTable[]; extern CIFPP_EXPORT const symop_datablock kSymopNrTable[];
extern const std::size_t kSymopNrTableSize; extern CIFPP_EXPORT const std::size_t kSymopNrTableSize;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#pragma once #pragma once
#include <cif++/exports.hpp>
#include <charconv> #include <charconv>
#include <cmath> #include <cmath>
#include <limits> #include <limits>
...@@ -34,7 +36,6 @@ ...@@ -34,7 +36,6 @@
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#if __has_include(<experimental/type_traits>) #if __has_include(<experimental/type_traits>)
#include <experimental/type_traits> #include <experimental/type_traits>
#else #else
...@@ -249,7 +250,7 @@ typedef std::set<std::string, iless> iset; ...@@ -249,7 +250,7 @@ typedef std::set<std::string, iless> iset;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// This really makes a difference, having our own tolower routines // This really makes a difference, having our own tolower routines
extern const uint8_t kCharToLowerMap[256]; extern CIFPP_EXPORT const uint8_t kCharToLowerMap[256];
inline char tolower(int ch) inline char tolower(int ch)
{ {
...@@ -448,8 +449,8 @@ std::to_chars_result to_chars(char *first, char *last, FloatType &value, chars_f ...@@ -448,8 +449,8 @@ std::to_chars_result to_chars(char *first, char *last, FloatType &value, chars_f
template <typename FloatType, std::enable_if_t<std::is_floating_point_v<FloatType>, int> = 0> template <typename FloatType, std::enable_if_t<std::is_floating_point_v<FloatType>, int> = 0>
std::to_chars_result to_chars(char *first, char *last, FloatType &value, chars_format fmt, int precision) std::to_chars_result to_chars(char *first, char *last, FloatType &value, chars_format fmt, int precision)
{ {
int size = last - first; int size = static_cast<int>(last - first);
int r; int r = 0;
switch (fmt) switch (fmt)
{ {
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#pragma once #pragma once
#include <cif++/exports.hpp>
#include <filesystem> #include <filesystem>
#ifndef STDOUT_FILENO #ifndef STDOUT_FILENO
...@@ -50,7 +52,7 @@ ...@@ -50,7 +52,7 @@
namespace cif namespace cif
{ {
extern int VERBOSE; extern CIFPP_EXPORT int VERBOSE;
// the git 'build' number // the git 'build' number
std::string get_version_nr(); std::string get_version_nr();
......
...@@ -26,13 +26,13 @@ ...@@ -26,13 +26,13 @@
#pragma once #pragma once
#include <cif++/text.hpp>
#include <filesystem> #include <filesystem>
#include <list> #include <list>
#include <mutex> #include <mutex>
#include <utility> #include <utility>
#include <cif++/text.hpp>
namespace cif namespace cif
{ {
......
...@@ -24,14 +24,14 @@ ...@@ -24,14 +24,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <numeric>
#include <stack>
#include <cif++/category.hpp> #include <cif++/category.hpp>
#include <cif++/datablock.hpp> #include <cif++/datablock.hpp>
#include <cif++/parser.hpp> #include <cif++/parser.hpp>
#include <cif++/utilities.hpp> #include <cif++/utilities.hpp>
#include <numeric>
#include <stack>
// TODO: Find out what the rules are exactly for linked items, the current implementation // TODO: Find out what the rules are exactly for linked items, the current implementation
// is inconsistent. It all depends whether a link is satified if a field taking part in the // is inconsistent. It all depends whether a link is satified if a field taking part in the
// set of linked items is null at one side and not null in the other. // set of linked items is null at one side and not null in the other.
...@@ -1241,10 +1241,10 @@ size_t category::erase(condition &&cond, std::function<void(row_handle)> &&visit ...@@ -1241,10 +1241,10 @@ size_t category::erase(condition &&cond, std::function<void(row_handle)> &&visit
for (auto &&[childCat, link] : m_child_links) for (auto &&[childCat, link] : m_child_links)
{ {
auto cond = get_children_condition(*ri, *childCat); auto ccond = get_children_condition(*ri, *childCat);
if (not cond) if (not ccond)
continue; continue;
potential_orphans[childCat] = std::move(potential_orphans[childCat]) or std::move(cond); potential_orphans[childCat] = std::move(potential_orphans[childCat]) or std::move(ccond);
} }
save_value sv(m_validator); save_value sv(m_validator);
......
...@@ -24,16 +24,15 @@ ...@@ -24,16 +24,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cif++/compound.hpp>
#include <filesystem>
#include <fstream>
#include <map> #include <map>
#include <mutex> #include <mutex>
#include <numeric> #include <numeric>
#include <shared_mutex> #include <shared_mutex>
#include <filesystem>
#include <fstream>
#include <cif++/compound.hpp>
namespace fs = std::filesystem; namespace fs = std::filesystem;
namespace cif namespace cif
......
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cassert>
#include <cif++/row.hpp> #include <cif++/row.hpp>
#include <cassert>
namespace cif namespace cif
{ {
......
...@@ -24,22 +24,16 @@ ...@@ -24,22 +24,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cassert>
#include <iostream>
#include <map>
#include <regex>
#include <stack>
#include <cif++/utilities.hpp> #include <cif++/utilities.hpp>
#include <cif++/forward_decl.hpp> #include <cif++/forward_decl.hpp>
#include <cif++/parser.hpp> #include <cif++/parser.hpp>
#include <cif++/file.hpp> #include <cif++/file.hpp>
namespace cif #include <cassert>
{ #include <iostream>
extern int VERBOSE; #include <map>
} #include <regex>
#include <stack>
namespace cif namespace cif
{ {
......
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cif++.hpp>
#include <cif++/pdb/cif2pdb.hpp>
#include <cif++/gzio.hpp>
#include <cmath> #include <cmath>
#include <deque> #include <deque>
#include <iomanip> #include <iomanip>
...@@ -31,9 +35,6 @@ ...@@ -31,9 +35,6 @@
#include <regex> #include <regex>
#include <set> #include <set>
#include <cif++.hpp>
#include <cif++/pdb/cif2pdb.hpp>
#include <cif++/gzio.hpp>
namespace cif::pdb namespace cif::pdb
{ {
......
...@@ -24,17 +24,16 @@ ...@@ -24,17 +24,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <iomanip>
#include <map>
#include <set>
#include <stack>
#include <cif++.hpp> #include <cif++.hpp>
#include <cif++/pdb/pdb2cif.hpp> #include <cif++/pdb/pdb2cif.hpp>
#include <cif++/pdb/pdb2cif_remark_3.hpp> #include <cif++/pdb/pdb2cif_remark_3.hpp>
#include <cif++/gzio.hpp> #include <cif++/gzio.hpp>
#include <iomanip>
#include <map>
#include <set>
#include <stack>
using cif::category; using cif::category;
using cif::datablock; using cif::datablock;
using cif::iequals; using cif::iequals;
......
...@@ -25,12 +25,11 @@ ...@@ -25,12 +25,11 @@
*/ */
#include <cif++.hpp> #include <cif++.hpp>
#include <cif++/pdb/pdb2cif_remark_3.hpp>
#include <map> #include <map>
#include <set> #include <set>
#include <cif++/pdb/pdb2cif_remark_3.hpp>
namespace cif::pdb namespace cif::pdb
{ {
......
...@@ -27,12 +27,12 @@ ...@@ -27,12 +27,12 @@
// #include <sys/ioctl.h> // #include <sys/ioctl.h>
// #include <termios.h> // #include <termios.h>
#include <iomanip>
#include <iostream>
#include <cif++.hpp> #include <cif++.hpp>
#include <cif++/pdb/tls.hpp> #include <cif++/pdb/tls.hpp>
#include <iomanip>
#include <iostream>
namespace cif namespace cif
{ {
......
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cif++/point.hpp>
#include <cassert> #include <cassert>
#include <random> #include <random>
#include <cif++/point.hpp>
namespace cif namespace cif
{ {
...@@ -369,7 +369,7 @@ quaternion construct_for_dihedral_angle(point p1, point p2, point p3, point p4, ...@@ -369,7 +369,7 @@ quaternion construct_for_dihedral_angle(point p1, point p2, point p3, point p4,
float dh = dihedral_angle(p1, p2, p3, p4); float dh = dihedral_angle(p1, p2, p3, p4);
for (int iteration = 0; iteration < 100; ++iteration) for (int iteration = 0; iteration < 100; ++iteration)
{ {
float delta = std::fmod(angle - dh, 360); float delta = std::fmod(angle - dh, 360.0f);
if (delta < -180) if (delta < -180)
delta += 360; delta += 360;
......
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdexcept>
#include <cif++/symmetry.hpp> #include <cif++/symmetry.hpp>
#include <stdexcept>
#include "./symop_table_data.hpp" #include "./symop_table_data.hpp"
namespace cif namespace cif
......
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cif++/text.hpp>
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cif++/text.hpp>
namespace cif namespace cif
{ {
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cif++/utilities.hpp>
#include "revision.hpp"
#include <atomic> #include <atomic>
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>
...@@ -44,10 +47,6 @@ ...@@ -44,10 +47,6 @@
#include <termios.h> #include <termios.h>
#endif #endif
#include <cif++/utilities.hpp>
#include "revision.hpp"
namespace fs = std::filesystem; namespace fs = std::filesystem;
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -408,9 +407,9 @@ struct rsrc_imp ...@@ -408,9 +407,9 @@ struct rsrc_imp
#if _MSC_VER #if _MSC_VER
extern "C" const mrsrc::rsrc_imp *gResourceIndexDefault[1] = {}; extern "C" CIFPP_EXPORT const mrsrc::rsrc_imp *gResourceIndexDefault[1] = {};
extern "C" const char *gResourceDataDefault[1] = {}; extern "C" CIFPP_EXPORT const char *gResourceDataDefault[1] = {};
extern "C" const char *gResourceNameDefault[1] = {}; extern "C" CIFPP_EXPORT const char *gResourceNameDefault[1] = {};
extern "C" const mrsrc::rsrc_imp gResourceIndex[]; extern "C" const mrsrc::rsrc_imp gResourceIndex[];
extern "C" const char gResourceData[]; extern "C" const char gResourceData[];
......
...@@ -24,6 +24,11 @@ ...@@ -24,6 +24,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <cif++/dictionary_parser.hpp>
#include <cif++/validate.hpp>
#include <cif++/utilities.hpp>
#include <cif++/gzio.hpp>
#include <cassert> #include <cassert>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
...@@ -41,12 +46,6 @@ using boost::regex; ...@@ -41,12 +46,6 @@ using boost::regex;
using std::regex; using std::regex;
#endif #endif
#include <cif++/dictionary_parser.hpp>
#include <cif++/validate.hpp>
#include <cif++/utilities.hpp>
#include <cif++/gzio.hpp>
namespace cif namespace cif
{ {
......
...@@ -96,87 +96,87 @@ BOOST_AUTO_TEST_CASE(sugar_name_1) ...@@ -96,87 +96,87 @@ BOOST_AUTO_TEST_CASE(sugar_name_1)
} }
} }
// -------------------------------------------------------------------- // // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(create_sugar_1) // BOOST_AUTO_TEST_CASE(create_sugar_1)
{ // {
using namespace cif::literals; // using namespace cif::literals;
const std::filesystem::path example(gTestDir / "1juh.cif.gz"); // const std::filesystem::path example(gTestDir / "1juh.cif.gz");
cif::file file(example.string()); // cif::file file(example.string());
cif::mm::structure s(file); // cif::mm::structure s(file);
// collect atoms from asym L first // // collect atoms from asym L first
auto &NAG = s.get_residue("L"); // auto &NAG = s.get_residue("L");
auto nagAtoms = NAG.atoms(); // auto nagAtoms = NAG.atoms();
std::vector<cif::row_initializer> ai; // std::vector<cif::row_initializer> ai;
auto &db = s.get_datablock(); // auto &db = s.get_datablock();
auto &as = db["atom_site"]; // auto &as = db["atom_site"];
// NOTE, row_initializer does not actually hold the data, so copy it first // // NOTE, row_initializer does not actually hold the data, so copy it first
// before it gets destroyed by remove_residue // // before it gets destroyed by remove_residue
for (auto r : as.find("label_asym_id"_key == "L")) // for (auto r : as.find("label_asym_id"_key == "L"))
/*auto &ri = */ai.emplace_back(r); // /*auto &ri = */ai.emplace_back(r);
s.remove_residue(NAG); // s.remove_residue(NAG);
auto &branch = s.create_branch(ai); // auto &branch = s.create_branch(ai);
BOOST_CHECK_EQUAL(branch.name(), "2-acetamido-2-deoxy-beta-D-glucopyranose"); // BOOST_CHECK_EQUAL(branch.name(), "2-acetamido-2-deoxy-beta-D-glucopyranose");
BOOST_CHECK_EQUAL(branch.size(), 1); // BOOST_CHECK_EQUAL(branch.size(), 1);
BOOST_CHECK_EQUAL(branch[0].atoms().size(), nagAtoms.size()); // BOOST_CHECK_EQUAL(branch[0].atoms().size(), nagAtoms.size());
BOOST_CHECK(file.is_valid()); // BOOST_CHECK(file.is_valid());
file.save(gTestDir / "test-create_sugar_1.cif"); // file.save(gTestDir / "test-create_sugar_1.cif");
} // }
// -------------------------------------------------------------------- // // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(create_sugar_2) // BOOST_AUTO_TEST_CASE(create_sugar_2)
{ // {
using namespace cif::literals; // using namespace cif::literals;
const std::filesystem::path example(gTestDir / "1juh.cif.gz"); // const std::filesystem::path example(gTestDir / "1juh.cif.gz");
cif::file file(example.string()); // cif::file file(example.string());
cif::mm::structure s(file); // cif::mm::structure s(file);
// Get branch for H // // Get branch for H
auto &bH = s.get_branch_by_asym_id("H"); // auto &bH = s.get_branch_by_asym_id("H");
BOOST_CHECK_EQUAL(bH.size(), 2); // BOOST_CHECK_EQUAL(bH.size(), 2);
std::vector<cif::row_initializer> ai[2]; // std::vector<cif::row_initializer> ai[2];
auto &db = s.get_datablock(); // auto &db = s.get_datablock();
auto &as = db["atom_site"]; // auto &as = db["atom_site"];
for (size_t i = 0; i < 2; ++i) // for (size_t i = 0; i < 2; ++i)
{ // {
for (auto r : as.find("label_asym_id"_key == "H" and "auth_seq_id"_key == i + 1)) // for (auto r : as.find("label_asym_id"_key == "H" and "auth_seq_id"_key == i + 1))
/*auto &ri = */ai[i].emplace_back(r); // /*auto &ri = */ai[i].emplace_back(r);
} // }
s.remove_branch(bH); // s.remove_branch(bH);
BOOST_CHECK(file.is_valid()); // BOOST_CHECK(file.is_valid());
auto &bN = s.create_branch(ai[0]); // auto &bN = s.create_branch(ai[0]);
s.extend_branch(bN.get_asym_id(), ai[1], 1, "O4"); // s.extend_branch(bN.get_asym_id(), ai[1], 1, "O4");
BOOST_CHECK_EQUAL(bN.name(), "2-acetamido-2-deoxy-beta-D-glucopyranose-(1-4)-2-acetamido-2-deoxy-beta-D-glucopyranose"); // BOOST_CHECK_EQUAL(bN.name(), "2-acetamido-2-deoxy-beta-D-glucopyranose-(1-4)-2-acetamido-2-deoxy-beta-D-glucopyranose");
BOOST_CHECK_EQUAL(bN.size(), 2); // BOOST_CHECK_EQUAL(bN.size(), 2);
BOOST_CHECK(file.is_valid()); // BOOST_CHECK(file.is_valid());
file.save(gTestDir / "test-create_sugar_2.cif"); // file.save(gTestDir / "test-create_sugar_2.cif");
BOOST_CHECK_NO_THROW(cif::mm::structure s2(file)); // BOOST_CHECK_NO_THROW(cif::mm::structure s2(file));
} // }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
......
...@@ -93,13 +93,13 @@ BOOST_AUTO_TEST_CASE(t1) ...@@ -93,13 +93,13 @@ BOOST_AUTO_TEST_CASE(t1)
const auto &&[angle0, axis0] = cif::quaternion_to_angle_axis(q); const auto &&[angle0, axis0] = cif::quaternion_to_angle_axis(q);
std::vector<cif::point> p1{ std::vector<cif::point> p1{
{ 16.979, 13.301, 44.555 }, { 16.979f, 13.301f, 44.555f },
{ 18.150, 13.525, 43.680 }, { 18.150f, 13.525f, 43.680f },
{ 18.656, 14.966, 43.784 }, { 18.656f, 14.966f, 43.784f },
{ 17.890, 15.889, 44.078 }, { 17.890f, 15.889f, 44.078f },
{ 17.678, 13.270, 42.255 }, { 17.678f, 13.270f, 42.255f },
{ 16.248, 13.734, 42.347 }, { 16.248f, 13.734f, 42.347f },
{ 15.762, 13.216, 43.724 } { 15.762f, 13.216f, 43.724f }
}; };
auto p2 = p1; auto p2 = p1;
...@@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(t1) ...@@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(t1)
for (auto &p : p1) for (auto &p : p1)
p.rotate(q2); p.rotate(q2);
float rmsd = cif::RMSd(p1, p2); auto rmsd = cif::RMSd(p1, p2);
BOOST_TEST(rmsd < 1e-5); BOOST_TEST(rmsd < 1e-5);
...@@ -175,27 +175,27 @@ BOOST_AUTO_TEST_CASE(dh_q_1) ...@@ -175,27 +175,27 @@ BOOST_AUTO_TEST_CASE(dh_q_1)
float angle; float angle;
cif::point pts[4]; cif::point pts[4];
} tests[] = { } tests[] = {
{ -97.5, { -97.5f,
{ { 68.8649979, -7.34800005, 54.3769989 }, { { 68.8649979f, -7.34800005f, 54.3769989f },
{ 68.1350021, -8.18700027, 53.6489983 }, { 68.1350021f, -8.18700027f, 53.6489983f },
{ 68.7760239, -9.07335377, 52.7140236 }, { 68.7760239f, -9.07335377f, 52.7140236f },
{ 68.9000015, -10.3944235, 53.2217026 } } }, { 68.9000015f, -10.3944235f, 53.2217026f } } },
{ 80.3, { 80.3f,
{ { 0.304512024, 0.531184196, 2.25860214 }, { { 0.304512024f, 0.531184196f, 2.25860214f },
{ 0.956512451, 0.0321846008, 1.07460022 }, { 0.956512451f, 0.0321846008f, 1.07460022f },
{ 0, 0, 0 }, { 0, 0, 0 },
{ 0.21336633, -1.09552193, -0.878999829 } } }, { 0.21336633f, -1.09552193f, -0.878999829f } } },
{ -97.5, { -97.5f,
{ { 0.088973999, 1.72535372, 1.66297531 }, { { 0.088973999f, 1.72535372f, 1.66297531f },
{ -0.641021729, 0.886353493, 0.93497467 }, { -0.641021729f, 0.886353493f, 0.93497467f },
{ 0, 0, 0 }, { 0, 0, 0 },
{ 1.29433727, -0.395142615, 0.432300746 } } }, { 1.29433727f, -0.395142615f, 0.432300746f } } },
{ -97.5, { -97.5f,
{ {
{ 0.088973999, 1.72535372, 1.66297531 }, { 0.088973999f, 1.72535372f, 1.66297531f },
{ -0.641021729, 0.886353493, 0.93497467 }, { -0.641021729f, 0.886353493f, 0.93497467f },
{ 0, 0, 0 }, { 0, 0, 0 },
{ 1.33983064, 0.384027064, -0.275154471 }, { 1.33983064f, 0.384027064f, -0.275154471f },
} } } }
}; };
......
...@@ -78,23 +78,23 @@ bool init_unit_test() ...@@ -78,23 +78,23 @@ bool init_unit_test()
BOOST_AUTO_TEST_CASE(cc_1) BOOST_AUTO_TEST_CASE(cc_1)
{ {
std::tuple<std::string_view, float, char> tests[] = { std::tuple<std::string_view, float, char> tests[] = {
{ "1.0", 1.0, 0 }, { "1.0", 1.0f, 0 },
{ "1.0e10", 1.0e10, 0 }, { "1.0e10", 1.0e10f, 0 },
{ "-1.1e10", -1.1e10, 0 }, { "-1.1e10", -1.1e10f, 0 },
{ "-.2e11", -.2e11, 0 }, { "-.2e11", -.2e11f, 0 },
{ "1.3e-10", 1.3e-10, 0 }, { "1.3e-10", 1.3e-10f, 0 },
{ "1.0 ", 1.0, ' ' }, { "1.0 ", 1.0f, ' ' },
{ "1.0e10 ", 1.0e10, ' ' }, { "1.0e10 ", 1.0e10f, ' ' },
{ "-1.1e10 ", -1.1e10, ' ' }, { "-1.1e10 ", -1.1e10f, ' ' },
{ "-.2e11 ", -.2e11, ' ' }, { "-.2e11 ", -.2e11f, ' ' },
{ "1.3e-10 ", 1.3e-10, ' ' }, { "1.3e-10 ", 1.3e-10f, ' ' },
{ "3.0", 3.0, 0 }, { "3.0", 3.0f, 0 },
{ "3.0 ", 3.0, ' ' }, { "3.0 ", 3.0f, ' ' },
{ "3.000000", 3.0, 0 }, { "3.000000", 3.0f, 0 },
{ "3.000000 ", 3.0, ' ' }, { "3.000000 ", 3.0f, ' ' },
}; };
for (const auto &[txt, val, ch] : tests) for (const auto &[txt, val, ch] : tests)
...@@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(cc_1) ...@@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(cc_1)
BOOST_AUTO_TEST_CASE(cc_2) BOOST_AUTO_TEST_CASE(cc_2)
{ {
std::tuple<float, int, std::string_view> tests[] = { std::tuple<float, int, std::string_view> tests[] = {
{ 1.1, 1, "1.1" } { 1.1f, 1, "1.1" }
}; };
for (const auto &[val, prec, test] : tests) for (const auto &[val, prec, test] : tests)
...@@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE(item_1) ...@@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE(item_1)
using namespace cif; using namespace cif;
item i1("1", "1"); item i1("1", "1");
item i2("2", 2.0); item i2("2", 2.0f);
item i3("3", '3'); item i3("3", '3');
item ci1(i1); item ci1(i1);
...@@ -163,23 +163,23 @@ BOOST_AUTO_TEST_CASE(r_1) ...@@ -163,23 +163,23 @@ BOOST_AUTO_TEST_CASE(r_1)
c.emplace({ c.emplace({
{ "f-1", 1 }, { "f-1", 1 },
{ "f-2", "two" }, { "f-2", "two" },
{ "f-3", 3.0, 3 }, { "f-3", 3.0f, 3 },
}); });
auto row = c.front(); auto row = c.front();
BOOST_CHECK_EQUAL(row["f-1"].compare(1), 0); BOOST_CHECK_EQUAL(row["f-1"].compare(1), 0);
BOOST_CHECK_EQUAL(row["f-2"].compare("two"), 0); BOOST_CHECK_EQUAL(row["f-2"].compare("two"), 0);
BOOST_CHECK_EQUAL(row["f-3"].compare(3.0), 0); // This fails when running in valgrind... sigh BOOST_CHECK_EQUAL(row["f-3"].compare(3.0f), 0); // This fails when running in valgrind... sigh
const auto &[f1, f2, f3] = row.get<int, std::string, float>("f-1", "f-2", "f-3"); const auto &[f1, f2, f3] = row.get<int, std::string, float>("f-1", "f-2", "f-3");
BOOST_CHECK_EQUAL(f1, 1); BOOST_CHECK_EQUAL(f1, 1);
BOOST_CHECK_EQUAL(f2, "two"); BOOST_CHECK_EQUAL(f2, "two");
BOOST_CHECK_EQUAL(f3, 3.0); // This fails when running in valgrind... sigh BOOST_CHECK_EQUAL(f3, 3.0f); // This fails when running in valgrind... sigh
BOOST_CHECK_EQUAL(row.get<int>("f-1"), 1); BOOST_CHECK_EQUAL(row.get<int>("f-1"), 1);
BOOST_CHECK_EQUAL(row.get<std::string>("f-2"), "two"); BOOST_CHECK_EQUAL(row.get<std::string>("f-2"), "two");
BOOST_CHECK_EQUAL(row.get<float>("f-3"), 3.0); BOOST_CHECK_EQUAL(row.get<float>("f-3"), 3.0f);
int f_1; int f_1;
std::string f_2; std::string f_2;
...@@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE(r_1) ...@@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE(r_1)
BOOST_CHECK_EQUAL(f_1, 1); BOOST_CHECK_EQUAL(f_1, 1);
BOOST_CHECK_EQUAL(f_2, "two"); BOOST_CHECK_EQUAL(f_2, "two");
BOOST_CHECK_EQUAL(f_3, 3.0); // This fails when running in valgrind... sigh BOOST_CHECK_EQUAL(f_3, 3.0f); // This fails when running in valgrind... sigh
} }
BOOST_AUTO_TEST_CASE(r_2) BOOST_AUTO_TEST_CASE(r_2)
...@@ -486,14 +486,14 @@ _test.value ...@@ -486,14 +486,14 @@ _test.value
BOOST_CHECK_EQUAL(++n, 1); BOOST_CHECK_EQUAL(++n, 1);
BOOST_CHECK_EQUAL(r["id"].as<int>(), 1); BOOST_CHECK_EQUAL(r["id"].as<int>(), 1);
BOOST_CHECK_EQUAL(r["name"].as<std::string>(), "aap"); BOOST_CHECK_EQUAL(r["name"].as<std::string>(), "aap");
BOOST_CHECK_EQUAL(r["value"].as<float>(), 1.0); BOOST_CHECK_EQUAL(r["value"].as<float>(), 1.0f);
} }
auto t = test.find(cif::key("id") == 1); auto t = test.find(cif::key("id") == 1);
BOOST_CHECK(not t.empty()); BOOST_CHECK(not t.empty());
BOOST_CHECK_EQUAL(t.front()["name"].as<std::string>(), "aap"); BOOST_CHECK_EQUAL(t.front()["name"].as<std::string>(), "aap");
auto t2 = test.find(cif::key("value") == 1.2); auto t2 = test.find(cif::key("value") == 1.2f);
BOOST_CHECK(not t2.empty()); BOOST_CHECK(not t2.empty());
BOOST_CHECK_EQUAL(t2.front()["name"].as<std::string>(), "mies"); BOOST_CHECK_EQUAL(t2.front()["name"].as<std::string>(), "mies");
} }
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
set -e set -e
if [ "$EUID" -ne 0 ] # Get the effective UID, but do so in a compatible way (we may be running dash)
euid=${EUID:-$(id -u)}
if [ "${euid}" -ne 0 ] ; then
then echo "Please run as root" then echo "Please run as root"
exit exit
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment