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
a29e3e8d
Unverified
Commit
a29e3e8d
authored
Aug 30, 2021
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create symop table
parent
dd5df1bb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
103 additions
and
27 deletions
+103
-27
CMakeLists.txt
+44
-3
include/cif++/CifUtils.hpp
+2
-4
src/SymOpTable_data.hpp
+0
-0
src/Symmetry.cpp
+1
-1
test/rename-compound-test.cpp
+19
-8
tools/symop-map-generator.cpp
+37
-11
No files found.
CMakeLists.txt
View file @
a29e3e8d
...
@@ -30,6 +30,26 @@ endif()
...
@@ -30,6 +30,26 @@ endif()
option
(
BUILD_SHARED_LIBS
"Build a shared library instead of a static one"
OFF
)
option
(
BUILD_SHARED_LIBS
"Build a shared library instead of a static one"
OFF
)
set
(
CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON
)
set
(
CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON
)
# Only try to recreate SymOpTable_data.hpp if CCP4 is known
option
(
CCP4
"The location where ccp4 is installed"
""
)
if
(
DEFINED CCP4 AND EXISTS
${
CCP4
}
)
set
(
CCP4 $ENV{CCP4}
)
set
(
CLIBD
${
CCP4
}
/lib/data
)
elseif
(
NOT DEFINED CCP4 AND DEFINED $ENV{CCP4} AND EXISTS $ENV{CCP4}
)
set
(
CCP4 $ENV{CCP4}
)
set
(
CLIBD
${
CCP4
}
/lib/data
)
endif
()
if
(
EXISTS
"
${
CCP4
}
"
)
option
(
RECREATE_SYMOP_DATA
"Recreate SymOp data table in case it is out of date"
ON
)
if
(
RECREATE_SYMOP_DATA AND NOT EXISTS
"
${
CLIBD
}
/syminfo.lib"
)
message
(
FATAL_ERROR
"Symop data table recreation requested, but file syminfo.lib was not found in
${
CLIBD
}
"
)
endif
()
else
()
message
(
"Not trying to recreate SymOpTable_data.hpp since CCP4 is not defined"
)
endif
()
# set(CMAKE_DEBUG_POSTFIX d)
# set(CMAKE_DEBUG_POSTFIX d)
if
(
MSVC
)
if
(
MSVC
)
...
@@ -128,6 +148,27 @@ include_directories(${CMAKE_BINARY_DIR} PRIVATE)
...
@@ -128,6 +148,27 @@ include_directories(${CMAKE_BINARY_DIR} PRIVATE)
string
(
TIMESTAMP BUILD_DATE_TIME
"%Y-%m-%dT%H:%M:%SZ"
UTC
)
string
(
TIMESTAMP BUILD_DATE_TIME
"%Y-%m-%dT%H:%M:%SZ"
UTC
)
configure_file
(
"
${
CMAKE_SOURCE_DIR
}
/src/revision.hpp.in"
"
${
CMAKE_BINARY_DIR
}
/revision.hpp"
@ONLY
)
configure_file
(
"
${
CMAKE_SOURCE_DIR
}
/src/revision.hpp.in"
"
${
CMAKE_BINARY_DIR
}
/revision.hpp"
@ONLY
)
# SymOp data table
if
(
RECREATE_SYMOP_DATA
)
# The tool to create the table
add_executable
(
symop-map-generator
"
${
CMAKE_SOURCE_DIR
}
/tools/symop-map-generator.cpp"
)
target_link_libraries
(
symop-map-generator Threads::Threads
${
Boost_LIBRARIES
}
)
set
(
$ENV{CLIBD}
${
CLIBD
}
)
add_custom_command
(
OUTPUT
${
CMAKE_SOURCE_DIR
}
/src/SymOpTable_data.hpp
COMMAND $<TARGET_FILE:symop-map-generator>
${
CLIBD
}
/syminfo.lib
${
CMAKE_SOURCE_DIR
}
/src/SymOpTable_data.hpp
)
add_custom_target
(
OUTPUT
${
CMAKE_SOURCE_DIR
}
/src/SymOpTable_data.hpp
DEPENDS symop-map-generator
"$ENV{CLIBD}/syminfo.lib"
)
endif
()
# Sources
# Sources
set
(
project_sources
set
(
project_sources
...
@@ -166,7 +207,7 @@ set(project_headers
...
@@ -166,7 +207,7 @@ set(project_headers
${
PROJECT_SOURCE_DIR
}
/include/cif++/TlsParser.hpp
${
PROJECT_SOURCE_DIR
}
/include/cif++/TlsParser.hpp
)
)
add_library
(
cifpp
${
project_sources
}
${
project_headers
}
)
add_library
(
cifpp
${
project_sources
}
${
project_headers
}
${
PROJECT_SOURCE_DIR
}
/src/SymOpTable_data.hpp
)
set_target_properties
(
cifpp PROPERTIES POSITION_INDEPENDENT_CODE ON
)
set_target_properties
(
cifpp PROPERTIES POSITION_INDEPENDENT_CODE ON
)
target_include_directories
(
cifpp
target_include_directories
(
cifpp
...
@@ -352,11 +393,11 @@ if(CIFPP_BUILD_TESTS)
...
@@ -352,11 +393,11 @@ if(CIFPP_BUILD_TESTS)
add_custom_command
(
add_custom_command
(
OUTPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/Run
${
CIFPP_TEST
}
.touch
OUTPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/Run
${
CIFPP_TEST
}
.touch
COMMAND $<TARGET_FILE:
${
CIFPP_TEST
}
>
COMMAND $<TARGET_FILE:
${
CIFPP_TEST
}
>
WORKING_DIRECTORY
${
CMAKE
_SOURCE_DIR
}
/test
)
WORKING_DIRECTORY
${
PROJECT
_SOURCE_DIR
}
/test
)
add_test
(
NAME
${
CIFPP_TEST
}
add_test
(
NAME
${
CIFPP_TEST
}
COMMAND $<TARGET_FILE:
${
CIFPP_TEST
}
>
COMMAND $<TARGET_FILE:
${
CIFPP_TEST
}
>
WORKING_DIRECTORY
${
CMAKE
_SOURCE_DIR
}
/test
)
WORKING_DIRECTORY
${
PROJECT
_SOURCE_DIR
}
/test
)
endforeach
()
endforeach
()
endif
()
endif
()
...
...
include/cif++/CifUtils.hpp
View file @
a29e3e8d
...
@@ -48,13 +48,11 @@
...
@@ -48,13 +48,11 @@
#include "cif++/Cif++Export.hpp"
#include "cif++/Cif++Export.hpp"
#if _MSC_VER
#if _MSC_VER
# pragma warning (disable : 4355) // this is used in Base Initializer list
# pragma warning (disable : 4996) // unsafe function or variable (strcpy e.g.)
# pragma warning (disable : 4996) // unsafe function or variable
# pragma warning (disable : 4068) // unknown pragma
# 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 : 4100) // unreferenced formal parameter
# pragma warning (disable : 4101) // unreferenced local variable
# pragma warning (disable : 4101) // unreferenced local variable
# define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING 1
#endif
#endif
namespace
cif
namespace
cif
...
...
src/SymOpTable_data.
c
pp
→
src/SymOpTable_data.
h
pp
View file @
a29e3e8d
File moved
src/Symmetry.cpp
View file @
a29e3e8d
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#include "cif++/Symmetry.hpp"
#include "cif++/Symmetry.hpp"
#include "cif++/CifUtils.hpp"
#include "cif++/CifUtils.hpp"
#include "SymOpTable_data.
c
pp"
#include "SymOpTable_data.
h
pp"
namespace
mmcif
namespace
mmcif
{
{
...
...
test/rename-compound-test.cpp
View file @
a29e3e8d
...
@@ -12,18 +12,29 @@ namespace po = boost::program_options;
...
@@ -12,18 +12,29 @@ namespace po = boost::program_options;
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
cif
::
VERBOSE
=
3
;
cif
::
VERBOSE
=
3
;
mmcif
::
CompoundFactory
::
instance
().
pushDictionary
(
"RXA.cif"
);
mmcif
::
File
f
(
"../examples/1cbs.cif.gz"
);
try
mmcif
::
Structure
structure
(
f
);
{
if
(
std
::
filesystem
::
exists
(
"../data/components.cif"
))
cif
::
addFileResource
(
"components.cif"
,
"../data/components.cif"
);
mmcif
::
CompoundFactory
::
instance
().
pushDictionary
(
"RXA.cif"
);
mmcif
::
File
f
(
"../examples/1cbs.cif.gz"
);
mmcif
::
Structure
structure
(
f
);
auto
&
res
=
structure
.
getResidue
(
"B"
,
"REA"
);
auto
&
res
=
structure
.
getResidue
(
"B"
,
"REA"
);
structure
.
changeResidue
(
res
,
"RXA"
,
{});
structure
.
changeResidue
(
res
,
"RXA"
,
{});
structure
.
cleanupEmptyCategories
();
structure
.
cleanupEmptyCategories
();
f
.
file
().
save
(
std
::
cout
);
f
.
file
().
save
(
std
::
cout
);
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cerr
<<
e
.
what
()
<<
std
::
endl
;
exit
(
1
);
}
return
0
;
return
0
;
}
}
tools/symop-map-generator.cpp
View file @
a29e3e8d
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include <cassert>
#include <cassert>
#include <array>
#include <iostream>
#include <iostream>
#include <iomanip>
#include <iomanip>
#include <fstream>
#include <fstream>
...
@@ -33,9 +34,12 @@
...
@@ -33,9 +34,12 @@
#include <map>
#include <map>
#include <filesystem>
#include <filesystem>
#include <boost/program_options.hpp>
#include <cstdlib>
#include <cstdlib>
namespace
fs
=
std
::
filesystem
;
namespace
fs
=
std
::
filesystem
;
namespace
po
=
boost
::
program_options
;
std
::
regex
kNameRx
(
R"(^(\d+) +(\d+) +(\d+) +(\S+) +(\S+) +(\S+) +'([^']+)'( +'([^']+)')?(?: +!.+)?$)"
);
std
::
regex
kNameRx
(
R"(^(\d+) +(\d+) +(\d+) +(\S+) +(\S+) +(\S+) +'([^']+)'( +'([^']+)')?(?: +!.+)?$)"
);
...
@@ -185,18 +189,42 @@ int main(int argc, char* const argv[])
...
@@ -185,18 +189,42 @@ int main(int argc, char* const argv[])
try
try
{
{
if
(
argc
!=
2
)
po
::
options_description
visible_options
(
"symop-map-generator symlib-file output-file"
);
throw
std
::
runtime_error
(
"Usage: symom-map-generator <outputfile>"
);
visible_options
.
add_options
()
(
"help,h"
,
"Display help message"
)
(
"verbose,v"
,
"Verbose output"
)
;
po
::
options_description
hidden_options
(
"hidden options"
);
hidden_options
.
add_options
()
(
"input,i"
,
po
::
value
<
std
::
string
>
(),
"Input file"
)
(
"output,o"
,
po
::
value
<
std
::
string
>
(),
"Output file"
);
po
::
options_description
cmdline_options
;
cmdline_options
.
add
(
visible_options
).
add
(
hidden_options
);
po
::
positional_options_description
p
;
p
.
add
(
"input"
,
1
);
p
.
add
(
"output"
,
1
);
po
::
variables_map
vm
;
po
::
store
(
po
::
command_line_parser
(
argc
,
argv
).
options
(
cmdline_options
).
positional
(
p
).
run
(),
vm
);
po
::
notify
(
vm
);
if
(
vm
.
count
(
"input"
)
==
0
or
vm
.
count
(
"output"
)
==
0
or
vm
.
count
(
"help"
))
{
std
::
cerr
<<
visible_options
<<
std
::
endl
;
exit
(
vm
.
count
(
"help"
)
==
0
);
}
fs
::
path
input
(
vm
[
"input"
].
as
<
std
::
string
>
());
fs
::
path
output
(
vm
[
"output"
].
as
<
std
::
string
>
());
tmpFile
=
output
.
parent_path
()
/
(
output
.
filename
().
string
()
+
".tmp"
);
tmpFile
=
argv
[
1
]
+
".tmp"
s
;
std
::
ofstream
out
(
tmpFile
);
std
::
ofstream
out
(
tmpFile
);
if
(
not
out
.
is_open
())
if
(
not
out
.
is_open
())
throw
std
::
runtime_error
(
"Failed to open output file"
);
throw
std
::
runtime_error
(
"Failed to open output file"
);
const
char
*
CLIBD
=
getenv
(
"CLIBD"
);
if
(
CLIBD
==
nullptr
)
throw
std
::
runtime_error
(
"CCP4 not sourced"
);
// --------------------------------------------------------------------
// --------------------------------------------------------------------
...
@@ -216,15 +244,13 @@ int main(int argc, char* const argv[])
...
@@ -216,15 +244,13 @@ int main(int argc, char* const argv[])
std
::
map
<
int
,
SymInfoBlock
>
symInfo
;
std
::
map
<
int
,
SymInfoBlock
>
symInfo
;
int
symopnr
,
mysymnr
=
10000
;
int
symopnr
,
mysymnr
=
10000
;
std
::
ifstream
file
(
CLIBD
+
"/syminfo.lib"
s
);
std
::
ifstream
file
(
input
);
if
(
not
file
.
is_open
())
if
(
not
file
.
is_open
())
throw
std
::
runtime_error
(
"Could not open syminfo.lib file"
);
throw
std
::
runtime_error
(
"Could not open syminfo.lib file"
);
enum
class
State
{
skip
,
spacegroup
}
state
=
State
::
skip
;
enum
class
State
{
skip
,
spacegroup
}
state
=
State
::
skip
;
std
::
string
line
;
std
::
string
line
;
std
::
string
Hall
;
std
::
vector
<
std
::
string
>
old
;
const
std
::
regex
rx
(
R"(^symbol +(Hall|xHM|old) +'(.+?)'(?: +'(.+?)')?$)"
),
const
std
::
regex
rx
(
R"(^symbol +(Hall|xHM|old) +'(.+?)'(?: +'(.+?)')?$)"
),
rx2
(
R"(symbol ccp4 (\d+))"
);;
rx2
(
R"(symbol ccp4 (\d+))"
);;
...
@@ -383,7 +409,7 @@ const size_t kSymopNrTableSize = sizeof(kSymopNrTable) / sizeof(SymopDataBlock);
...
@@ -383,7 +409,7 @@ const size_t kSymopNrTableSize = sizeof(kSymopNrTable) / sizeof(SymopDataBlock);
)"
<<
std
::
endl
;
)"
<<
std
::
endl
;
out
.
close
();
out
.
close
();
fs
::
rename
(
tmpFile
,
argv
[
1
]
);
fs
::
rename
(
tmpFile
,
output
);
}
}
catch
(
const
std
::
exception
&
ex
)
catch
(
const
std
::
exception
&
ex
)
{
{
...
...
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