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
fb59adcf
Unverified
Commit
fb59adcf
authored
Apr 12, 2023
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix symmetry rotational numbers
parent
4acca8a3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
109 additions
and
72 deletions
+109
-72
CMakeLists.txt
+2
-2
include/cif++/symmetry.hpp
+44
-33
src/symmetry.cpp
+1
-1
src/symop-map-generator.cpp
+62
-36
src/symop_table_data.hpp
+0
-0
No files found.
CMakeLists.txt
View file @
fb59adcf
...
@@ -191,12 +191,12 @@ if(CIFPP_RECREATE_SYMOP_DATA)
...
@@ -191,12 +191,12 @@ if(CIFPP_RECREATE_SYMOP_DATA)
add_custom_command
(
add_custom_command
(
OUTPUT
${
PROJECT_SOURCE_DIR
}
/src/symop_table_data.hpp
OUTPUT
${
PROJECT_SOURCE_DIR
}
/src/symop_table_data.hpp
COMMAND $<TARGET_FILE:symop-map-generator> $ENV{CLIBD}/syminfo.lib
${
PROJECT_SOURCE_DIR
}
/src/symop_table_data.hpp
COMMAND $<TARGET_FILE:symop-map-generator> $ENV{CLIBD}/syminfo.lib $
ENV{CLIBD}/symop.lib
$
{
PROJECT_SOURCE_DIR
}
/src/symop_table_data.hpp
)
)
add_custom_target
(
add_custom_target
(
OUTPUT
${
PROJECT_SOURCE_DIR
}
/src/symop_table_data.hpp
OUTPUT
${
PROJECT_SOURCE_DIR
}
/src/symop_table_data.hpp
DEPENDS symop-map-generator
"$ENV{CLIBD}/syminfo.lib"
DEPENDS symop-map-generator
"$ENV{CLIBD}/syminfo.lib"
"$ENV{CLIBD}/symop.lib"
)
)
endif
()
endif
()
...
...
include/cif++/symmetry.hpp
View file @
fb59adcf
...
@@ -60,21 +60,21 @@ extern CIFPP_EXPORT const std::size_t kNrOfSpaceGroups;
...
@@ -60,21 +60,21 @@ extern CIFPP_EXPORT const std::size_t kNrOfSpaceGroups;
struct
symop_data
struct
symop_data
{
{
constexpr
symop_data
(
const
std
::
array
<
int
,
15
>
&
data
)
constexpr
symop_data
(
const
std
::
array
<
int
,
15
>
&
data
)
:
m_packed
((
data
[
0
]
&
0x03ULL
)
<<
34
bitor
:
m_packed
((
data
[
0
]
bitand
0x03ULL
)
<<
34
bitor
(
data
[
1
]
&
0x03ULL
)
<<
32
bitor
(
data
[
1
]
bitand
0x03ULL
)
<<
32
bitor
(
data
[
2
]
&
0x03ULL
)
<<
30
bitor
(
data
[
2
]
bitand
0x03ULL
)
<<
30
bitor
(
data
[
3
]
&
0x03ULL
)
<<
28
bitor
(
data
[
3
]
bitand
0x03ULL
)
<<
28
bitor
(
data
[
4
]
&
0x03ULL
)
<<
26
bitor
(
data
[
4
]
bitand
0x03ULL
)
<<
26
bitor
(
data
[
5
]
&
0x03ULL
)
<<
24
bitor
(
data
[
5
]
bitand
0x03ULL
)
<<
24
bitor
(
data
[
6
]
&
0x03ULL
)
<<
22
bitor
(
data
[
6
]
bitand
0x03ULL
)
<<
22
bitor
(
data
[
7
]
&
0x03ULL
)
<<
20
bitor
(
data
[
7
]
bitand
0x03ULL
)
<<
20
bitor
(
data
[
8
]
&
0x03ULL
)
<<
18
bitor
(
data
[
8
]
bitand
0x03ULL
)
<<
18
bitor
(
data
[
9
]
&
0x07ULL
)
<<
15
bitor
(
data
[
9
]
bitand
0x07ULL
)
<<
15
bitor
(
data
[
10
]
&
0x07ULL
)
<<
12
bitor
(
data
[
10
]
bitand
0x07ULL
)
<<
12
bitor
(
data
[
11
]
&
0x07ULL
)
<<
9
bitor
(
data
[
11
]
bitand
0x07ULL
)
<<
9
bitor
(
data
[
12
]
&
0x07ULL
)
<<
6
bitor
(
data
[
12
]
bitand
0x07ULL
)
<<
6
bitor
(
data
[
13
]
&
0x07ULL
)
<<
3
bitor
(
data
[
13
]
bitand
0x07ULL
)
<<
3
bitor
(
data
[
14
]
&
0x07ULL
)
<<
0
)
(
data
[
14
]
bitand
0x07ULL
)
<<
0
)
{
{
}
}
...
@@ -88,24 +88,35 @@ struct symop_data
...
@@ -88,24 +88,35 @@ struct symop_data
return
m_packed
<
rhs
.
m_packed
;
return
m_packed
<
rhs
.
m_packed
;
}
}
std
::
array
<
int
,
15
>
data
()
const
inline
constexpr
int
unpack3
(
int
offset
)
const
{
int
result
=
(
m_packed
>>
offset
)
bitand
0x03
;
return
result
==
3
?
-
1
:
result
;
}
inline
constexpr
int
unpack7
(
int
offset
)
const
{
return
(
m_packed
>>
offset
)
bitand
0x07
;
}
constexpr
std
::
array
<
int
,
15
>
data
()
const
{
{
return
{
return
{
static_cast
<
int
>
(
m_packed
>>
34
)
bitand
0x03
,
unpack3
(
34
)
,
static_cast
<
int
>
(
m_packed
>>
32
)
bitand
0x03
,
unpack3
(
32
)
,
static_cast
<
int
>
(
m_packed
>>
30
)
bitand
0x03
,
unpack3
(
30
)
,
static_cast
<
int
>
(
m_packed
>>
28
)
bitand
0x03
,
unpack3
(
28
)
,
static_cast
<
int
>
(
m_packed
>>
26
)
bitand
0x03
,
unpack3
(
26
)
,
static_cast
<
int
>
(
m_packed
>>
24
)
bitand
0x03
,
unpack3
(
24
)
,
static_cast
<
int
>
(
m_packed
>>
22
)
bitand
0x03
,
unpack3
(
22
)
,
static_cast
<
int
>
(
m_packed
>>
20
)
bitand
0x03
,
unpack3
(
20
)
,
static_cast
<
int
>
(
m_packed
>>
18
)
bitand
0x03
,
unpack3
(
18
)
,
static_cast
<
int
>
(
m_packed
>>
15
)
bitand
0x07
,
unpack7
(
15
)
,
static_cast
<
int
>
(
m_packed
>>
12
)
bitand
0x07
,
unpack7
(
12
)
,
static_cast
<
int
>
(
m_packed
>>
9
)
bitand
0x07
,
unpack7
(
9
)
,
static_cast
<
int
>
(
m_packed
>>
6
)
bitand
0x07
,
unpack7
(
6
)
,
static_cast
<
int
>
(
m_packed
>>
3
)
bitand
0x07
,
unpack7
(
3
)
,
static_cast
<
int
>
(
m_packed
>>
0
)
bitand
0x07
,
unpack7
(
0
)
};
};
}
}
...
@@ -125,8 +136,8 @@ struct symop_data
...
@@ -125,8 +136,8 @@ struct symop_data
struct
symop_datablock
struct
symop_datablock
{
{
constexpr
symop_datablock
(
int
spacegroup
,
int
rotational_number
,
const
std
::
array
<
int
,
15
>
&
rt_data
)
constexpr
symop_datablock
(
int
spacegroup
,
int
rotational_number
,
const
std
::
array
<
int
,
15
>
&
rt_data
)
:
m_v
((
spacegroup
&
0xffffULL
)
<<
48
bitor
:
m_v
((
spacegroup
bitand
0xffffULL
)
<<
48
bitor
(
rotational_number
&
0xffULL
)
<<
40
bitor
(
rotational_number
bitand
0xffULL
)
<<
40
bitor
symop_data
(
rt_data
).
m_packed
)
symop_data
(
rt_data
).
m_packed
)
{
{
}
}
...
...
src/symmetry.cpp
View file @
fb59adcf
...
@@ -34,7 +34,7 @@ namespace cif
...
@@ -34,7 +34,7 @@ namespace cif
{
{
// --------------------------------------------------------------------
// --------------------------------------------------------------------
// Unfortunately, clipper has a different numbering scheme than
PDB
// Unfortunately, clipper has a different numbering scheme than
CCP4
// for rotation numbers. So we created a table to map those.
// for rotation numbers. So we created a table to map those.
// Perhaps a bit over the top, but hey....
// Perhaps a bit over the top, but hey....
...
...
src/symop-map-generator.cpp
View file @
fb59adcf
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include <cassert>
#include <cassert>
#include <array>
#include <array>
#include <charconv>
#include <iostream>
#include <iostream>
#include <iomanip>
#include <iomanip>
#include <fstream>
#include <fstream>
...
@@ -169,7 +170,7 @@ class SymopParser
...
@@ -169,7 +170,7 @@ class SymopParser
}
}
Token
m_lookahead
;
Token
m_lookahead
;
int
m_nr
;
int
m_nr
=
-
1
;
std
::
string
m_s
;
std
::
string
m_s
;
std
::
string
::
const_iterator
m_p
,
m_e
;
std
::
string
::
const_iterator
m_p
,
m_e
;
...
@@ -230,14 +231,15 @@ int main(int argc, char* const argv[])
...
@@ -230,14 +231,15 @@ int main(int argc, char* const argv[])
try
try
{
{
if
(
argc
!=
3
)
if
(
argc
!=
4
)
{
{
std
::
cerr
<<
"Usage symop-map-generator <
input-file>
<output-file>"
<<
std
::
endl
;
std
::
cerr
<<
"Usage symop-map-generator <
syminfo.lib-file> <symop.lib-file> <
<output-file>"
<<
std
::
endl
;
exit
(
1
);
exit
(
1
);
}
}
fs
::
path
input
(
argv
[
1
]);
fs
::
path
syminfolib
(
argv
[
1
]);
fs
::
path
output
(
argv
[
2
]);
fs
::
path
symoplib
(
argv
[
2
]);
fs
::
path
output
(
argv
[
3
]);
tmpFile
=
output
.
parent_path
()
/
(
output
.
filename
().
string
()
+
".tmp"
);
tmpFile
=
output
.
parent_path
()
/
(
output
.
filename
().
string
()
+
".tmp"
);
...
@@ -261,22 +263,51 @@ int main(int argc, char* const argv[])
...
@@ -261,22 +263,51 @@ int main(int argc, char* const argv[])
};
};
std
::
map
<
int
,
SymInfoBlock
>
symInfo
;
std
::
map
<
int
,
SymInfoBlock
>
symInfo
;
int
symopnr
=
0
,
mysymnr
=
10000
;
std
::
ifstream
file
(
input
);
std
::
ifstream
file
(
symoplib
);
if
(
not
file
.
is_open
())
throw
std
::
runtime_error
(
"Could not open symop.lib file"
);
std
::
string
line
;
int
sgnr
=
0
;
int
rnr
=
0
;
while
(
getline
(
file
,
line
))
{
if
(
line
.
empty
())
continue
;
if
(
std
::
isdigit
(
line
[
0
]))
// start of new spacegroup
{
auto
r
=
std
::
from_chars
(
line
.
data
(),
line
.
data
()
+
line
.
length
(),
sgnr
);
if
(
r
.
ec
!=
std
::
errc
())
throw
std
::
runtime_error
(
"Error parsing symop.lib file"
);
rnr
=
1
;
continue
;
}
if
(
not
std
::
isspace
(
line
[
0
])
or
sgnr
==
0
)
throw
std
::
runtime_error
(
"Error parsing symop.lib file"
);
SymopParser
p
;
data
.
emplace_back
(
sgnr
,
rnr
,
p
.
parse
(
line
));
++
rnr
;
}
file
.
close
();
file
.
open
(
syminfolib
);
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
;
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+))"
);;
SymInfoBlock
cur
=
{};
SymInfoBlock
cur
=
{};
std
::
vector
<
std
::
array
<
int
,
15
>>
symops
,
cenops
;
//
std::vector<std::array<int,15>> symops, cenops;
while
(
getline
(
file
,
line
))
while
(
getline
(
file
,
line
))
{
{
...
@@ -284,12 +315,7 @@ int main(int argc, char* const argv[])
...
@@ -284,12 +315,7 @@ int main(int argc, char* const argv[])
{
{
case
State
:
:
skip
:
case
State
:
:
skip
:
if
(
line
==
"begin_spacegroup"
)
if
(
line
==
"begin_spacegroup"
)
{
state
=
State
::
spacegroup
;
state
=
State
::
spacegroup
;
symopnr
=
1
;
++
mysymnr
;
cur
=
{
mysymnr
};
}
break
;
break
;
case
State
:
:
spacegroup
:
case
State
:
:
spacegroup
:
...
@@ -314,34 +340,34 @@ int main(int argc, char* const argv[])
...
@@ -314,34 +340,34 @@ int main(int argc, char* const argv[])
if
(
nr
!=
0
)
if
(
nr
!=
0
)
cur
.
nr
=
nr
;
cur
.
nr
=
nr
;
}
}
else
if
(
line
.
compare
(
0
,
6
,
"symop "
)
==
0
)
//
else if (line.compare(0, 6, "symop ") == 0)
{
//
{
SymopParser
p
;
//
SymopParser p;
symops
.
emplace_back
(
p
.
parse
(
line
.
substr
(
6
)));
//
symops.emplace_back(p.parse(line.substr(6)));
}
//
}
else
if
(
line
.
compare
(
0
,
6
,
"cenop "
)
==
0
)
//
else if (line.compare(0, 6, "cenop ") == 0)
{
//
{
SymopParser
p
;
//
SymopParser p;
cenops
.
emplace_back
(
p
.
parse
(
line
.
substr
(
6
)));
//
cenops.emplace_back(p.parse(line.substr(6)));
}
//
}
else
if
(
line
==
"end_spacegroup"
)
else
if
(
line
==
"end_spacegroup"
)
{
{
for
(
auto
&
cenop
:
cenops
)
//
for (auto& cenop: cenops)
{
//
{
for
(
auto
symop
:
symops
)
//
for (auto symop: symops)
{
//
{
symop
=
move_symop
(
symop
,
cenop
);
//
symop = move_symop(symop, cenop);
data
.
emplace_back
(
cur
.
nr
,
symopnr
,
symop
);
//
data.emplace_back(cur.nr, symopnr, symop);
++
symopnr
;
//
++symopnr;
}
//
}
}
//
}
symInfo
.
emplace
(
cur
.
nr
,
cur
);
symInfo
.
emplace
(
cur
.
nr
,
cur
);
state
=
State
::
skip
;
state
=
State
::
skip
;
symops
.
clear
();
//
symops.clear();
cenops
.
clear
();
//
cenops.clear();
}
}
break
;
break
;
}
}
...
...
src/symop_table_data.hpp
View file @
fb59adcf
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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