Structure Prediction Utilities Module
Miscellaneous utilities for data manipulation.
Miscellaneous tools for data parsing.
- smact.structure_prediction.utilities.convert_next_gen_mprest_data()[source]
Converts the MPDataDoc object returned by a next-gen MP query to a dictionary
- Parameters
doc (MPDataDoc) – A MPDataDoc object (based on a pydantic model) with fields ‘structure’ and ‘material_id’
- Returns
A dictionary containing at least the keys ‘structure’ and ‘material_id’, with the associated values.
- smact.structure_prediction.utilities.get_sign(charge: int) str [source]
Get string representation of a number’s sign.
- Parameters
charge (int) – The number whose sign to derive.
- Returns
either ‘+’, ‘-’, or ‘’ for neutral.
- Return type
sign (str)
- smact.structure_prediction.utilities.parse_spec(species: str) Tuple[str, int] [source]
Parse a species string into its element and charge.
- Parameters
species (str) – String representation of a species in the format {element}{absolute_charge}{sign}.
- Returns
A tuple of (element, signed_charge).
Examples
>>> parse_spec("Fe2+") ('Fe', 2) >>> parse_spec("O2-") ('O', -2)
- smact.structure_prediction.utilities.unparse_spec(species: Tuple[str, int]) str [source]
Unparse a species into a string representation.
The analogue of
parse_spec()
.- Parameters
of (A tuple) –
- Returns
String of {element}{absolute_charge}{sign}.
Examples
>>> unparse_spec(("Fe", 2)) 'Fe2+' >>> unparse_spec(("O", -2)) 'O2-'