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
7f820449
Unverified
Commit
7f820449
authored
Dec 08, 2021
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formatting
parent
ecb2cf5f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
193 additions
and
189 deletions
+193
-189
include/cif++/AtomType.hpp
+166
-162
include/cif++/BondMap.hpp
+27
-27
src/AtomType.cpp
+0
-0
src/BondMap.cpp
+0
-0
No files found.
include/cif++/AtomType.hpp
View file @
7f820449
/*-
/*-
* SPDX-License-Identifier: BSD-2-Clause
* SPDX-License-Identifier: BSD-2-Clause
*
*
* Copyright (c) 2020 NKI/AVL, Netherlands Cancer Institute
* Copyright (c) 2020 NKI/AVL, Netherlands Cancer Institute
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer
* list of conditions and the following disclaimer
* 2. Redistributions in binary form must reproduce the above copyright notice,
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* 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
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
...
@@ -29,150 +29,151 @@
...
@@ -29,150 +29,151 @@
#pragma once
#pragma once
#include <cstdint>
#include <cstdint>
#include <string>
#include <stdexcept>
#include <stdexcept>
#include <string>
namespace
mmcif
namespace
mmcif
{
{
enum
AtomType
:
uint8_t
enum
AtomType
:
uint8_t
{
{
Nn
=
0
,
// Unknown
Nn
=
0
,
// Unknown
H
=
1
,
// Hydrogen
H
=
1
,
// Hydrogen
He
=
2
,
// Helium
He
=
2
,
// Helium
Li
=
3
,
// Lithium
Li
=
3
,
// Lithium
Be
=
4
,
// Beryllium
Be
=
4
,
// Beryllium
B
=
5
,
// Boron
B
=
5
,
// Boron
C
=
6
,
// Carbon
C
=
6
,
// Carbon
N
=
7
,
// Nitrogen
N
=
7
,
// Nitrogen
O
=
8
,
// Oxygen
O
=
8
,
// Oxygen
F
=
9
,
// Fluorine
F
=
9
,
// Fluorine
Ne
=
10
,
// Neon
Ne
=
10
,
// Neon
Na
=
11
,
// Sodium
Na
=
11
,
// Sodium
Mg
=
12
,
// Magnesium
Mg
=
12
,
// Magnesium
Al
=
13
,
// Aluminium
Al
=
13
,
// Aluminium
Si
=
14
,
// Silicon
Si
=
14
,
// Silicon
P
=
15
,
// Phosphorus
P
=
15
,
// Phosphorus
S
=
16
,
// Sulfur
S
=
16
,
// Sulfur
Cl
=
17
,
// Chlorine
Cl
=
17
,
// Chlorine
Ar
=
18
,
// Argon
Ar
=
18
,
// Argon
K
=
19
,
// Potassium
K
=
19
,
// Potassium
Ca
=
20
,
// Calcium
Ca
=
20
,
// Calcium
Sc
=
21
,
// Scandium
Sc
=
21
,
// Scandium
Ti
=
22
,
// Titanium
Ti
=
22
,
// Titanium
V
=
23
,
// Vanadium
V
=
23
,
// Vanadium
Cr
=
24
,
// Chromium
Cr
=
24
,
// Chromium
Mn
=
25
,
// Manganese
Mn
=
25
,
// Manganese
Fe
=
26
,
// Iron
Fe
=
26
,
// Iron
Co
=
27
,
// Cobalt
Co
=
27
,
// Cobalt
Ni
=
28
,
// Nickel
Ni
=
28
,
// Nickel
Cu
=
29
,
// Copper
Cu
=
29
,
// Copper
Zn
=
30
,
// Zinc
Zn
=
30
,
// Zinc
Ga
=
31
,
// Gallium
Ga
=
31
,
// Gallium
Ge
=
32
,
// Germanium
Ge
=
32
,
// Germanium
As
=
33
,
// Arsenic
As
=
33
,
// Arsenic
Se
=
34
,
// Selenium
Se
=
34
,
// Selenium
Br
=
35
,
// Bromine
Br
=
35
,
// Bromine
Kr
=
36
,
// Krypton
Kr
=
36
,
// Krypton
Rb
=
37
,
// Rubidium
Rb
=
37
,
// Rubidium
Sr
=
38
,
// Strontium
Sr
=
38
,
// Strontium
Y
=
39
,
// Yttrium
Y
=
39
,
// Yttrium
Zr
=
40
,
// Zirconium
Zr
=
40
,
// Zirconium
Nb
=
41
,
// Niobium
Nb
=
41
,
// Niobium
Mo
=
42
,
// Molybdenum
Mo
=
42
,
// Molybdenum
Tc
=
43
,
// Technetium
Tc
=
43
,
// Technetium
Ru
=
44
,
// Ruthenium
Ru
=
44
,
// Ruthenium
Rh
=
45
,
// Rhodium
Rh
=
45
,
// Rhodium
Pd
=
46
,
// Palladium
Pd
=
46
,
// Palladium
Ag
=
47
,
// Silver
Ag
=
47
,
// Silver
Cd
=
48
,
// Cadmium
Cd
=
48
,
// Cadmium
In
=
49
,
// Indium
In
=
49
,
// Indium
Sn
=
50
,
// Tin
Sn
=
50
,
// Tin
Sb
=
51
,
// Antimony
Sb
=
51
,
// Antimony
Te
=
52
,
// Tellurium
Te
=
52
,
// Tellurium
I
=
53
,
// Iodine
I
=
53
,
// Iodine
Xe
=
54
,
// Xenon
Xe
=
54
,
// Xenon
Cs
=
55
,
// Caesium
Cs
=
55
,
// Caesium
Ba
=
56
,
// Barium
Ba
=
56
,
// Barium
La
=
57
,
// Lanthanum
La
=
57
,
// Lanthanum
Hf
=
72
,
// Hafnium
Hf
=
72
,
// Hafnium
Ta
=
73
,
// Tantalum
Ta
=
73
,
// Tantalum
W
=
74
,
// Tungsten
W
=
74
,
// Tungsten
Re
=
75
,
// Rhenium
Re
=
75
,
// Rhenium
Os
=
76
,
// Osmium
Os
=
76
,
// Osmium
Ir
=
77
,
// Iridium
Ir
=
77
,
// Iridium
Pt
=
78
,
// Platinum
Pt
=
78
,
// Platinum
Au
=
79
,
// Gold
Au
=
79
,
// Gold
Hg
=
80
,
// Mercury
Hg
=
80
,
// Mercury
Tl
=
81
,
// Thallium
Tl
=
81
,
// Thallium
Pb
=
82
,
// Lead
Pb
=
82
,
// Lead
Bi
=
83
,
// Bismuth
Bi
=
83
,
// Bismuth
Po
=
84
,
// Polonium
Po
=
84
,
// Polonium
At
=
85
,
// Astatine
At
=
85
,
// Astatine
Rn
=
86
,
// Radon
Rn
=
86
,
// Radon
Fr
=
87
,
// Francium
Fr
=
87
,
// Francium
Ra
=
88
,
// Radium
Ra
=
88
,
// Radium
Ac
=
89
,
// Actinium
Ac
=
89
,
// Actinium
Rf
=
104
,
// Rutherfordium
Rf
=
104
,
// Rutherfordium
Db
=
105
,
// Dubnium
Db
=
105
,
// Dubnium
Sg
=
106
,
// Seaborgium
Sg
=
106
,
// Seaborgium
Bh
=
107
,
// Bohrium
Bh
=
107
,
// Bohrium
Hs
=
108
,
// Hassium
Hs
=
108
,
// Hassium
Mt
=
109
,
// Meitnerium
Mt
=
109
,
// Meitnerium
Ds
=
110
,
// Darmstadtium
Ds
=
110
,
// Darmstadtium
Rg
=
111
,
// Roentgenium
Rg
=
111
,
// Roentgenium
Cn
=
112
,
// Copernicium
Cn
=
112
,
// Copernicium
Nh
=
113
,
// Nihonium
Nh
=
113
,
// Nihonium
Fl
=
114
,
// Flerovium
Fl
=
114
,
// Flerovium
Mc
=
115
,
// Moscovium
Mc
=
115
,
// Moscovium
Lv
=
116
,
// Livermorium
Lv
=
116
,
// Livermorium
Ts
=
117
,
// Tennessine
Ts
=
117
,
// Tennessine
Og
=
118
,
// Oganesson
Og
=
118
,
// Oganesson
Ce
=
58
,
// Cerium
Ce
=
58
,
// Cerium
Pr
=
59
,
// Praseodymium
Pr
=
59
,
// Praseodymium
Nd
=
60
,
// Neodymium
Nd
=
60
,
// Neodymium
Pm
=
61
,
// Promethium
Pm
=
61
,
// Promethium
Sm
=
62
,
// Samarium
Sm
=
62
,
// Samarium
Eu
=
63
,
// Europium
Eu
=
63
,
// Europium
Gd
=
64
,
// Gadolinium
Gd
=
64
,
// Gadolinium
Tb
=
65
,
// Terbium
Tb
=
65
,
// Terbium
Dy
=
66
,
// Dysprosium
Dy
=
66
,
// Dysprosium
Ho
=
67
,
// Holmium
Ho
=
67
,
// Holmium
Er
=
68
,
// Erbium
Er
=
68
,
// Erbium
Tm
=
69
,
// Thulium
Tm
=
69
,
// Thulium
Yb
=
70
,
// Ytterbium
Yb
=
70
,
// Ytterbium
Lu
=
71
,
// Lutetium
Lu
=
71
,
// Lutetium
Th
=
90
,
// Thorium
Th
=
90
,
// Thorium
Pa
=
91
,
// Protactinium
Pa
=
91
,
// Protactinium
U
=
92
,
// Uranium
U
=
92
,
// Uranium
Np
=
93
,
// Neptunium
Np
=
93
,
// Neptunium
Pu
=
94
,
// Plutonium
Pu
=
94
,
// Plutonium
Am
=
95
,
// Americium
Am
=
95
,
// Americium
Cm
=
96
,
// Curium
Cm
=
96
,
// Curium
Bk
=
97
,
// Berkelium
Bk
=
97
,
// Berkelium
Cf
=
98
,
// Californium
Cf
=
98
,
// Californium
Es
=
99
,
// Einsteinium
Es
=
99
,
// Einsteinium
Fm
=
100
,
// Fermium
Fm
=
100
,
// Fermium
Md
=
101
,
// Mendelevium
Md
=
101
,
// Mendelevium
No
=
102
,
// Nobelium
No
=
102
,
// Nobelium
Lr
=
103
,
// Lawrencium
Lr
=
103
,
// Lawrencium
D
=
129
,
// Deuterium
D
=
129
,
// Deuterium
};
};
// --------------------------------------------------------------------
// --------------------------------------------------------------------
// AtomTypeInfo
// AtomTypeInfo
enum
RadiusType
{
enum
RadiusType
{
eRadiusCalculated
,
eRadiusCalculated
,
eRadiusEmpirical
,
eRadiusEmpirical
,
eRadiusCovalentEmpirical
,
eRadiusCovalentEmpirical
,
...
@@ -188,12 +189,12 @@ enum RadiusType {
...
@@ -188,12 +189,12 @@ enum RadiusType {
struct
AtomTypeInfo
struct
AtomTypeInfo
{
{
AtomType
type
;
AtomType
type
;
std
::
string
name
;
std
::
string
name
;
std
::
string
symbol
;
std
::
string
symbol
;
float
weight
;
float
weight
;
bool
metal
;
bool
metal
;
float
radii
[
eRadiusTypeCount
];
float
radii
[
eRadiusTypeCount
];
};
};
extern
const
AtomTypeInfo
kKnownAtoms
[];
extern
const
AtomTypeInfo
kKnownAtoms
[];
...
@@ -205,25 +206,25 @@ class AtomTypeTraits
...
@@ -205,25 +206,25 @@ class AtomTypeTraits
{
{
public
:
public
:
AtomTypeTraits
(
AtomType
a
);
AtomTypeTraits
(
AtomType
a
);
AtomTypeTraits
(
const
std
::
string
&
symbol
);
AtomTypeTraits
(
const
std
::
string
&
symbol
);
AtomType
type
()
const
{
return
mInfo
->
type
;
}
AtomType
type
()
const
{
return
mInfo
->
type
;
}
std
::
string
name
()
const
{
return
mInfo
->
name
;
}
std
::
string
name
()
const
{
return
mInfo
->
name
;
}
std
::
string
symbol
()
const
{
return
mInfo
->
symbol
;
}
std
::
string
symbol
()
const
{
return
mInfo
->
symbol
;
}
float
weight
()
const
{
return
mInfo
->
weight
;
}
float
weight
()
const
{
return
mInfo
->
weight
;
}
bool
isMetal
()
const
{
return
mInfo
->
metal
;
}
bool
isMetal
()
const
{
return
mInfo
->
metal
;
}
static
bool
isElement
(
const
std
::
string
&
symbol
);
static
bool
isElement
(
const
std
::
string
&
symbol
);
static
bool
isMetal
(
const
std
::
string
&
symbol
);
static
bool
isMetal
(
const
std
::
string
&
symbol
);
float
radius
(
RadiusType
type
=
eRadiusSingleBond
)
const
float
radius
(
RadiusType
type
=
eRadiusSingleBond
)
const
{
{
if
(
type
>=
eRadiusTypeCount
)
if
(
type
>=
eRadiusTypeCount
)
throw
std
::
invalid_argument
(
"invalid radius requested"
);
throw
std
::
invalid_argument
(
"invalid radius requested"
);
return
mInfo
->
radii
[
type
]
/
100.
f
;
return
mInfo
->
radii
[
type
]
/
100.
f
;
}
}
// data type encapsulating the Waasmaier & Kirfel scattering factors
// data type encapsulating the Waasmaier & Kirfel scattering factors
// in a simplified form (only a and b).
// in a simplified form (only a and b).
// Added the electrion scattering factors as well
// Added the electrion scattering factors as well
...
@@ -231,15 +232,18 @@ class AtomTypeTraits
...
@@ -231,15 +232,18 @@ class AtomTypeTraits
{
{
double
a
[
6
],
b
[
6
];
double
a
[
6
],
b
[
6
];
};
};
// to get the Cval and Siva values, use this constant as charge:
// to get the Cval and Siva values, use this constant as charge:
enum
{
kWKSFVal
=
-
99
};
enum
{
const
SFData
&
wksf
(
int
charge
=
0
)
const
;
kWKSFVal
=
-
99
const
SFData
&
elsf
()
const
;
};
const
SFData
&
wksf
(
int
charge
=
0
)
const
;
const
SFData
&
elsf
()
const
;
private
:
private
:
const
struct
AtomTypeInfo
*
mInfo
;
const
struct
AtomTypeInfo
*
mInfo
;
};
};
}
}
// namespace mmcif
include/cif++/BondMap.hpp
View file @
7f820449
/*-
/*-
* SPDX-License-Identifier: BSD-2-Clause
* SPDX-License-Identifier: BSD-2-Clause
*
*
* Copyright (c) 2020 NKI/AVL, Netherlands Cancer Institute
* Copyright (c) 2020 NKI/AVL, Netherlands Cancer Institute
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer
* list of conditions and the following disclaimer
* 2. Redistributions in binary form must reproduce the above copyright notice,
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* 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
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
...
@@ -26,9 +26,9 @@
...
@@ -26,9 +26,9 @@
#pragma once
#pragma once
#include <unordered_map>
#include <filesystem>
#include <filesystem>
#include <stdexcept>
#include <stdexcept>
#include <unordered_map>
#include "cif++/Structure.hpp"
#include "cif++/Structure.hpp"
...
@@ -38,39 +38,40 @@ namespace mmcif
...
@@ -38,39 +38,40 @@ namespace mmcif
class
BondMapException
:
public
std
::
runtime_error
class
BondMapException
:
public
std
::
runtime_error
{
{
public
:
public
:
BondMapException
(
const
std
::
string
&
msg
)
BondMapException
(
const
std
::
string
&
msg
)
:
runtime_error
(
msg
)
{}
:
runtime_error
(
msg
)
{
}
};
};
class
BondMap
class
BondMap
{
{
public
:
public
:
BondMap
(
const
Structure
&
p
);
BondMap
(
const
Structure
&
p
);
BondMap
(
const
BondMap
&
)
=
delete
;
BondMap
(
const
BondMap
&
)
=
delete
;
BondMap
&
operator
=
(
const
BondMap
&
)
=
delete
;
BondMap
&
operator
=
(
const
BondMap
&
)
=
delete
;
bool
operator
()(
const
Atom
&
a
,
const
Atom
&
b
)
const
bool
operator
()(
const
Atom
&
a
,
const
Atom
&
b
)
const
{
{
return
isBonded
(
index
.
at
(
a
.
id
()),
index
.
at
(
b
.
id
()));
return
isBonded
(
index
.
at
(
a
.
id
()),
index
.
at
(
b
.
id
()));
}
}
bool
is1_4
(
const
Atom
&
a
,
const
Atom
&
b
)
const
bool
is1_4
(
const
Atom
&
a
,
const
Atom
&
b
)
const
{
{
uint32_t
ixa
=
index
.
at
(
a
.
id
());
uint32_t
ixa
=
index
.
at
(
a
.
id
());
uint32_t
ixb
=
index
.
at
(
b
.
id
());
uint32_t
ixb
=
index
.
at
(
b
.
id
());
return
bond_1_4
.
count
(
key
(
ixa
,
ixb
));
return
bond_1_4
.
count
(
key
(
ixa
,
ixb
));
}
}
// links coming from the struct_conn records:
// links coming from the struct_conn records:
std
::
vector
<
std
::
string
>
linked
(
const
Atom
&
a
)
const
;
std
::
vector
<
std
::
string
>
linked
(
const
Atom
&
a
)
const
;
// This list of atomID's is comming from either CCD or the CCP4 dictionaries loaded
// This list of atomID's is comming from either CCD or the CCP4 dictionaries loaded
static
std
::
vector
<
std
::
string
>
atomIDsForCompound
(
const
std
::
string
&
compoundID
);
static
std
::
vector
<
std
::
string
>
atomIDsForCompound
(
const
std
::
string
&
compoundID
);
private
:
private
:
bool
isBonded
(
uint32_t
ai
,
uint32_t
bi
)
const
bool
isBonded
(
uint32_t
ai
,
uint32_t
bi
)
const
{
{
return
bond
.
count
(
key
(
ai
,
bi
))
!=
0
;
return
bond
.
count
(
key
(
ai
,
bi
))
!=
0
;
...
@@ -82,20 +83,19 @@ class BondMap
...
@@ -82,20 +83,19 @@ class BondMap
std
::
swap
(
a
,
b
);
std
::
swap
(
a
,
b
);
return
static_cast
<
uint64_t
>
(
a
)
|
(
static_cast
<
uint64_t
>
(
b
)
<<
32
);
return
static_cast
<
uint64_t
>
(
a
)
|
(
static_cast
<
uint64_t
>
(
b
)
<<
32
);
}
}
std
::
tuple
<
uint32_t
,
uint32_t
>
dekey
(
uint64_t
k
)
const
std
::
tuple
<
uint32_t
,
uint32_t
>
dekey
(
uint64_t
k
)
const
{
{
return
std
::
make_tuple
(
return
std
::
make_tuple
(
static_cast
<
uint32_t
>
(
k
>>
32
),
static_cast
<
uint32_t
>
(
k
>>
32
),
static_cast
<
uint32_t
>
(
k
)
static_cast
<
uint32_t
>
(
k
));
);
}
}
uint32_t
dim
;
uint32_t
dim
;
std
::
unordered_map
<
std
::
string
,
uint32_t
>
index
;
std
::
unordered_map
<
std
::
string
,
uint32_t
>
index
;
std
::
set
<
uint64_t
>
bond
,
bond_1_4
;
std
::
set
<
uint64_t
>
bond
,
bond_1_4
;
std
::
map
<
std
::
string
,
std
::
set
<
std
::
string
>>
link
;
std
::
map
<
std
::
string
,
std
::
set
<
std
::
string
>>
link
;
};
};
}
}
// namespace mmcif
src/AtomType.cpp
View file @
7f820449
This diff is collapsed.
Click to expand it.
src/BondMap.cpp
View file @
7f820449
This diff is collapsed.
Click to expand it.
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