cif
Cif
Class to represent data extracted from a CIF standard file format.
Parameters
cif_data : dict dictionary of CIF keys and values
Source code in chmpy/fmt/cif.py
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 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 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
|
current_data_block
property
return the current data block, adding the key if necessary
from_file(filename)
classmethod
from_string(contents)
classmethod
is_comment_line(line)
is_data_line(line)
check if the line contains a value for the currentt key
Source code in chmpy/fmt/cif.py
is_data_name_line(line)
is_empty_line(line)
parse(ignore_uncertainty=True)
parse the entire CIF contents
Source code in chmpy/fmt/cif.py
parse_comment_line()
parse_data_block_name()
parse a data block name
Source code in chmpy/fmt/cif.py
parse_data_name()
parse a single data name i.e key for the cif_data dictionary
Source code in chmpy/fmt/cif.py
parse_loop_block()
parse values contained in a _loop block
Source code in chmpy/fmt/cif.py
parse_quoted_block(delimiter=';')
parse an entire quoted block, delimited by delimiter
Source code in chmpy/fmt/cif.py
to_file(filename)
to_string()
represent the data in this :objCif
textually in the CIF format
Source code in chmpy/fmt/cif.py
format_field(x)
format a field to fixed precision if float otherwise as a string
Source code in chmpy/fmt/cif.py
is_scalar(value)
needs_quote(string)
check if a string needs to be quoted (i.e. it has a space or quotation marks in it
parse_quote(string, delimiter=';')
extract a value contained within quotes, with an optional change of delimiter
Parameters
string: str the string containing the value to parse
bool, optional
the quote delimiter, default ';'
Returns
value the string contained inside the quotes
parse_quote(";quote text;") 'quote text' parse_quote(":'quote text':", delimiter="'") ":'quote text':" parse_quote(":'quote text':", delimiter=":") "'quote text'" parse_quote("'-y, x-y, z'", delimiter="'") '-y, x-y, z'
Source code in chmpy/fmt/cif.py
parse_value(string, with_uncertainty=False)
parse a value from a cif file to its appropriate type e.g. int, float, str etc. Will handle uncertainty values contained in parentheses.
Parameters
string: str the string containing the value to parse
bool, optional
return a tuple including uncertainty if a numeric type is expected
Returns
value the value coerced into the appropriate type
parse_value("2.3(1)", with_uncertainty=True) (2.3, 1) parse_value("string help") 'string help' parse_value("3.1415") * 4 12.566