proteindatabank¶
Convert an OPTIMADE structure, in the format of
StructureResource
to a PDB file or PDBx/mmCIF file (Protein Data Bank).
For more information on the file formats, see this FAQ page from the wwPDB website.
Note
These conversion functions are inspired heavily by the similar conversion functions in the ASE library.
See here (PDB) and here (PDBx/mmCIF) for the original ASE code.
For more information on the ASE library, see their documentation.
These conversion functions both rely on the NumPy library.
Warning
Currently, the PDBx/mmCIF conversion function is not parsing as a complete PDBx/mmCIF file.
NUMPY_NOT_FOUND = 'NumPy not found, cannot convert structure to your desired format'
module-attribute
¶
__all__ = ('get_pdb', 'get_pdbx_mmcif')
module-attribute
¶
AdapterPackageNotFound
¶
Bases: OptimadeWarning
The package for an adapter cannot be found.
Source code in optimade/adapters/warnings.py
6 7 |
|
OptimadeStructure
¶
Bases: EntryResource
Representing a structure.
Source code in optimade/models/structures.py
1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 |
|
OptimadeStructureSpecies
¶
Bases: BaseModel
A list describing the species of the sites of this structure.
Species can represent pure chemical elements, virtual-crystal atoms representing a statistical occupation of a given site by multiple chemical elements, and/or a location to which there are attached atoms, i.e., atoms whose precise location are unknown beyond that they are attached to that position (frequently used to indicate hydrogen atoms attached to another element, e.g., a carbon with three attached hydrogens might represent a methyl group, -CH3).
- Examples:
[ {"name": "Ti", "chemical_symbols": ["Ti"], "concentration": [1.0]} ]
: any site with this species is occupied by a Ti atom.[ {"name": "Ti", "chemical_symbols": ["Ti", "vacancy"], "concentration": [0.9, 0.1]} ]
: any site with this species is occupied by a Ti atom with 90 % probability, and has a vacancy with 10 % probability.[ {"name": "BaCa", "chemical_symbols": ["vacancy", "Ba", "Ca"], "concentration": [0.05, 0.45, 0.5], "mass": [0.0, 137.327, 40.078]} ]
: any site with this species is occupied by a Ba atom with 45 % probability, a Ca atom with 50 % probability, and by a vacancy with 5 % probability. The mass of this site is (on average) 88.5 a.m.u.[ {"name": "C12", "chemical_symbols": ["C"], "concentration": [1.0], "mass": [12.0]} ]
: any site with this species is occupied by a carbon isotope with mass 12.[ {"name": "C13", "chemical_symbols": ["C"], "concentration": [1.0], "mass": [13.0]} ]
: any site with this species is occupied by a carbon isotope with mass 13.[ {"name": "CH3", "chemical_symbols": ["C"], "concentration": [1.0], "attached": ["H"], "nattached": [3]} ]
: any site with this species is occupied by a methyl group, -CH3, which is represented without specifying precise positions of the hydrogen atoms.
Source code in optimade/models/structures.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
cell_to_cellpar(cell, radians=False)
¶
Returns the cell parameters [a, b, c, alpha, beta, gamma]
.
Angles are in degrees unless radian=True
is used.
Note
Based on ASE code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell |
tuple[Vector3D, Vector3D, Vector3D]
|
A Cartesian 3x3 cell. This equates to the
|
required |
radians |
bool
|
Use radians instead of degrees (default) for angles. |
False
|
Returns:
Type | Description |
---|---|
list[float]
|
The unit cell parameters as a |
Source code in optimade/adapters/structures/utils.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
cellpar_to_cell(cellpar, ab_normal=(0, 0, 1), a_direction=None)
¶
Return a 3x3 cell matrix from cellpar=[a,b,c,alpha,beta,gamma]
.
Angles must be in degrees.
The returned cell is orientated such that a and b
are normal to ab_normal
and a is parallel to the projection of
a_direction
in the a-b plane.
Default a_direction
is (1,0,0), unless this is parallel to
ab_normal
, in which case default a_direction
is (0,0,1).
The returned cell has the vectors va, vb and vc along the rows. The
cell will be oriented such that va and vb are normal to ab_normal
and va will be along the projection of a_direction
onto the a-b
plane.
Example
cell = cellpar_to_cell([1, 2, 4, 10, 20, 30], (0, 1, 1), (1, 2, 3)) np.round(cell, 3) array([[ 0.816, -0.408, 0.408], [ 1.992, -0.13 , 0.13 ], [ 3.859, -0.745, 0.745]])
Note
Direct copy of ASE code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cellpar |
list[float]
|
The unit cell parameters as a Note: The angles must be given in degrees. |
required |
ab_normal |
tuple[int, int, int]
|
Unit vector normal to the ab-plane. |
(0, 0, 1)
|
a_direction |
Optional[tuple[int, int, int]]
|
Unit vector defining the a-direction (default: |
None
|
Returns:
Type | Description |
---|---|
list[Vector3D]
|
A Cartesian 3x3 cell. |
list[Vector3D]
|
This should equate to the |
list[Vector3D]
|
|
Source code in optimade/adapters/structures/utils.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
fractional_coordinates(cell, cartesian_positions)
¶
Returns fractional coordinates and wraps coordinates to [0,1[
.
Note
Based on ASE code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell |
tuple[Vector3D, Vector3D, Vector3D]
|
A Cartesian 3x3 cell. This equates to the
|
required |
cartesian_positions |
list[Vector3D]
|
A list of cartesian atomic positions. This equates to the
|
required |
Returns:
Type | Description |
---|---|
list[Vector3D]
|
A list of fractional coordinates for the atomic positions. |
Source code in optimade/adapters/structures/utils.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
get_pdb(optimade_structure)
¶
Write Protein Data Bank (PDB) structure in the old PDB format from OPTIMADE structure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
optimade_structure |
StructureResource
|
OPTIMADE structure. |
required |
Returns:
Type | Description |
---|---|
str
|
A PDB file as a single Python |
Source code in optimade/adapters/structures/proteindatabank.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
get_pdbx_mmcif(optimade_structure)
¶
Write Protein Data Bank (PDB) structure in the PDBx/mmCIF format from OPTIMADE structure.
Warning
The result of this function can currently not be parsed as a complete PDBx/mmCIF file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
optimade_structure |
StructureResource
|
OPTIMADE structure. |
required |
Return
A modern PDBx/mmCIF file as a single Python str
object.
Source code in optimade/adapters/structures/proteindatabank.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
scaled_cell(cell)
¶
Return a scaled 3x3 cell from cartesian 3x3 cell (lattice_vectors
).
This 3x3 matrix can be used to calculate the fractional coordinates from the cartesian_site_positions.
This is based on PDB's method of calculating SCALE from CRYST data. For more info, see this site.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell |
tuple[Vector3D, Vector3D, Vector3D]
|
A Cartesian 3x3 cell. This equates to the
|
required |
Returns:
Type | Description |
---|---|
tuple[Vector3D, Vector3D, Vector3D]
|
A scaled 3x3 cell. |
Source code in optimade/adapters/structures/utils.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
valid_lattice_vector(lattice_vec)
¶
Source code in optimade/adapters/structures/utils.py
23 24 25 26 27 28 29 30 31 |
|