Utility Functions
Sierra provides a simple and convenient set of functions to store and load any of its models.
sierra.dump
dump((Any) obj, (Union[str, Path, io.IOBase]) file, (str) encoding) -> None
:
The dump()
function writes the given obj
into a file
.
Arguments
obj
-
The object to be dumped into a file. This can be any model type supported by Sierra, e.g. be a
ConformersInput
, aHessianResult
or aMolecule
.- Type:
Any
- Type:
file
-
The file (or filename) into which the data will be written.
- Type: One of: [
str
,Path
,io.IOBase
]
- Type: One of: [
encoding
-
The format in which the file will be written.
- Type:
str
- Default:
"msgpack-entos"
- Type:
Returns
None
sierra.dumps
dumps((Any) obj, (str) encoding) -> Union[str, bytes]
:
The dumps()
function creates a str
or bytes
representation of a model.
Arguments
obj
-
The object to be dumped into a file. This can be any model type supported by Sierra, e.g. be a
ConformersInput
, aHessianResult
or aMolecule
.- Type:
Any
- Type:
encoding
-
The format in which the string will be written.
- Type:
str
- Default:
"msgpack-entos"
- Type:
Returns
Depending on the encoding
, a str
or bytes
representation of the model.
sierra.load
load((Union[str, Path, io.IOBase]) file, (str) encoding, (bool) object_hooks) -> Any
:
The load()
function loads data which has been written using the dump()
function and converts it into a Sierra model.
Arguments
file
-
The file (or filename) from which the data is read.
- Type: One of: [
str
,Path
,io.IOBase
]
- Type: One of: [
encoding
-
The format of the data in the file.
- Type:
str
- Default:
"msgpack-entos"
- Type:
object_hooks
-
A flag that can be set to
False
to avoid conversion of the raw data into known Sierra models.- Type:
bool
- Default:
True
- Type:
Returns
A Sierra model containing the data present in the file
.
sierra.loads
loads((Union[str, bytes]) blob, (str) encoding, (bool) object_hooks) -> Any
:
The loads()
function decodes data given in a str
or bytes
representation and converts it into a Sierra model.
Arguments
blob
-
The data that will be decoded.
- Type: One of: [
str
,bytes
]
- Type: One of: [
encoding
-
The format of the data in the blob.
- Type:
str
- Default:
"msgpack-entos"
- Type:
object_hooks
-
A flag that can be set to
False
to avoid conversion of the raw data into known Sierra models.- Type:
bool
- Default:
True
- Type:
Returns
A Sierra model containing the data present in the blob
of data.
sierra.build_concatenated_xyzplus
build_concatenated_xyzplus((List[Molecule]) molecules, (Optional[Union[str, Path]]) filename) -> Optional[str]
:
This function builds, and optionally writes to 'filename', the geometry of the 'molecules' in concatenated XYZ+ format.
A newline is added to the end of the text as per the POSIX file standards.
Arguments
molecules
-
The list of molecules to write.
- Type:
List[Molecule]
- Type:
filename
-
If specified, the molecule is written to this file. If no
filename
is provided, the result is returned as astr
.- Type:
Optional[Union[str, Path]]
- Default: None
- Type:
Returns
None
if a filename
has been specified, and otherwise a str
with the same content.