aiida.tools.dbexporters package¶
Subpackages¶
Submodules¶
-
aiida.tools.dbexporters.tcod.
_assert_same_parents
(a, b)[source]¶ Checks whether two supplied nodes have the same immediate parent. Can be used to check whether two data nodes originate from the same calculation.
Parameters: - a – an instance of subclass of
aiida.orm.nodes.node.Node
- b – an instance of subclass of
aiida.orm.nodes.node.Node
Raises: ValueError – if the condition is not met.
- a – an instance of subclass of
-
aiida.tools.dbexporters.tcod.
_collect_calculation_data
(calc)[source]¶ Recursively collects calculations from the tree, starting at given calculation.
-
aiida.tools.dbexporters.tcod.
_collect_files
(base, path='')[source]¶ Recursively collects files from the tree, starting at a given path.
Retrieve metadata from attached calculation and pseudopotentials and prepare it to be saved in TCOD CIF.
-
aiida.tools.dbexporters.tcod.
_get_calculation
(node)[source]¶ Gets the parent (immediate) calculation, attached as the input of the node.
Parameters: node – an instance of subclass of aiida.orm.nodes.node.Node
Returns: an instance of subclass of aiida.orm.nodes.process.process.ProcessNode
Raises: aiida.common.MultipleObjectsError – if the node has more than one calculation attached.
-
aiida.tools.dbexporters.tcod.
_inline_to_standalone_script
(calc)[source]¶ Create executable Python script for execution of inline script.
Note
the output bash script may not always be correct, since it is simply formed from:
- contents of the file, which contains the original
\*_inline
function; - call of the original
\*_inline
function with input nodes; - storing of the output nodes.
Execution of generated bash script should result in ModificationNotAllowed exception, since the nodes, that are created by the
\*_inline
function, are already stored.- contents of the file, which contains the original
-
aiida.tools.dbexporters.tcod.
add_metadata_inline
(*args, **kwargs)[source]¶ Add metadata of original exported node to the produced TCOD CIF.
Parameters: - what – an original exported node.
- node – a
aiida.orm.nodes.data.cif.CifData
instance. - parameters – a
aiida.orm.nodes.data.dict.Dict
instance, produced by the same calculation as the original exported node. - args – a
aiida.orm.nodes.data.dict.Dict
instance, containing parameters for the control of metadata collection and inclusion in the producedaiida.orm.nodes.data.cif.CifData
.
Returns: dict with
aiida.orm.nodes.data.cif.CifData
Raises: ValueError – if tags present in
args.get_dict()['additional_tags']
are not valid CIF tags.Note
can be used as inline calculation.
-
aiida.tools.dbexporters.tcod.
cif_encode_contents
(content, gzip=False, gzip_threshold=1024)[source]¶ Encodes data for usage in CIF text field in a best possible way: binary data is encoded using Base64 encoding; text with non-ASCII symbols, too long lines or lines starting with semicolons (‘;’) is encoded using Quoted-printable encoding.
The encoding is performed byte-by-byte, so Unicode code points spanning more than one byte will be split and encoded separately.
Parameters: content – the content to be encoded in bytes Return content: encoded content in bytes Return encoding: a string specifying used encoding (None, ‘base64’, ‘ncr’, ‘quoted-printable’, ‘gzip+base64’)
-
aiida.tools.dbexporters.tcod.
decode_textfield
(content, method)[source]¶ Decodes the contents of encoded CIF textfield.
Parameters: - content – the content to be decoded as bytes
- method – method, which was used for encoding the contents (None, ‘base64’, ‘ncr’, ‘quoted-printable’, ‘gzip+base64’)
Returns: decoded content as bytes
Raises: ValueError – if the encoding method is unknown
-
aiida.tools.dbexporters.tcod.
decode_textfield_base64
(content)[source]¶ Decodes the contents for CIF textfield from Base64 using standard Python implementation (
base64.standard_b64decode()
)Parameters: content – contents as bytes Returns: decoded string as bytes
-
aiida.tools.dbexporters.tcod.
decode_textfield_gzip_base64
(content)[source]¶ Decodes the contents for CIF textfield from Base64 and decompresses them with gzip.
Parameters: content – contents as bytes Returns: decoded string as bytes
-
aiida.tools.dbexporters.tcod.
decode_textfield_ncr
(content)[source]¶ Decodes the contents for CIF textfield from Numeric Character Reference.
Parameters: content – contents as bytes Returns: decoded string as bytes
-
aiida.tools.dbexporters.tcod.
decode_textfield_quoted_printable
(content)[source]¶ Decodes the contents for CIF textfield from quoted-printable encoding.
Parameters: content – contents as bytes Returns: decoded string as bytes
-
aiida.tools.dbexporters.tcod.
deposit
(what, type, author_name=None, author_email=None, url=None, title=None, username=None, password=False, user_email=None, code=None, computer=None, replace=None, message=None, **kwargs)[source]¶ Launches a
aiida.orm.nodes.process.calculation.calcjob.CalcJobNode
to deposit data node to *COD-type database.Returns: launched aiida.orm.nodes.process.calculation.calcjob.CalcJobNode
instance.Raises: ValueError – if any of the required parameters are not given.
-
aiida.tools.dbexporters.tcod.
deposition_cmdline_parameters
(parser, expclass='Data')[source]¶ Provides descriptions of command line options, that are used to control the process of deposition to TCOD.
Parameters: - parser – an argparse.Parser instance
- expclass – name of the exported class to be shown in help string for the command line options
Note
This method must not set any default values for command line options in order not to clash with any other data deposition plugins.
-
aiida.tools.dbexporters.tcod.
encode_textfield_base64
(content, foldwidth=76)[source]¶ Encodes the contents for CIF textfield in Base64 using standard Python implementation (
base64.standard_b64encode()
).Parameters: - content – contents as bytes
- foldwidth – maximum width of line (default is 76)
Returns: encoded string as bytes
-
aiida.tools.dbexporters.tcod.
encode_textfield_gzip_base64
(content, **kwargs)[source]¶ Gzips the given string and encodes it in Base64.
Parameters: content – contents as bytes Returns: encoded string as bytes
-
aiida.tools.dbexporters.tcod.
encode_textfield_ncr
(content)[source]¶ Encodes the contents for CIF textfield in Numeric Character Reference. Encoded characters:
\x09
,\x0A
,\x0D
,\x20
–\x7E
;- ‘
;
’, if encountered on the beginning of the line; - ‘
\t
’ - ‘
.
’ and ‘?
’, if comprise the entire textfield.
Parameters: content – contents as bytes Returns: encoded string as bytes
-
aiida.tools.dbexporters.tcod.
encode_textfield_quoted_printable
(content)[source]¶ Encodes the contents for CIF textfield in quoted-printable encoding. In addition to non-ASCII characters, that are encoded by Python function
quopri.encodestring()
, following characters are encoded:- ‘
;
’, if encountered on the beginning of the line; - ‘
\t
’ and ‘\r
’; - ‘
.
’ and ‘?
’, if comprise the entire textfield.
Parameters: content – contents as bytes Returns: encoded string as bytes - ‘
-
aiida.tools.dbexporters.tcod.
export_cif
(what, **kwargs)[source]¶ Exports given coordinate-containing *Data node to string of CIF format.
Returns: string with contents of CIF file.
-
aiida.tools.dbexporters.tcod.
export_cifnode
(what, parameters=None, trajectory_index=None, store=False, reduce_symmetry=True, **kwargs)[source]¶ The main exporter function. Exports given coordinate-containing *Data node to
aiida.orm.nodes.data.cif.CifData
node, ready to be exported to TCOD. All *Data types, having methodget_cif()
, are supported in addition toaiida.orm.nodes.data.cif.CifData
.Parameters: - what – data node to be exported.
- parameters – a
aiida.orm.nodes.data.dict.Dict
instance, produced by the same calculation as the original exported node. - trajectory_index – a step to be converted and exported in case a
aiida.orm.nodes.data.array.trajectory.TrajectoryData
is exported. - store – boolean indicating whether to store intermediate nodes or not. Default False.
- dump_aiida_database – boolean indicating whether to include the dump of AiiDA database (containing only transitive closure of the exported node). Default True.
- exclude_external_contents – boolean indicating whether to exclude nodes from AiiDA database dump, that are taken from external repositores and have a URL link allowing to refetch their contents. Default False.
- gzip – boolean indicating whether to Gzip large CIF text fields. Default False.
- gzip_threshold – integer indicating the maximum size (in bytes) of uncompressed CIF text fields when the gzip option is in action. Default 1024.
Returns: a
aiida.orm.nodes.data.cif.CifData
node.
-
aiida.tools.dbexporters.tcod.
export_values
(what, **kwargs)[source]¶ Exports given coordinate-containing *Data node to PyCIFRW CIF data structure.
Returns: CIF data structure. Note
Requires PyCIFRW.
-
aiida.tools.dbexporters.tcod.
extend_with_cmdline_parameters
(parser, expclass='Data')[source]¶ Provides descriptions of command line options, that are used to control the process of exporting data to TCOD CIF files.
Parameters: - parser – an argparse.Parser instance
- expclass – name of the exported class to be shown in help string for the command line options
Note
This method must not set any default values for command line options in order not to clash with any other data export plugins.
-
aiida.tools.dbexporters.tcod.
translate_calculation_specific_values
(calc, translator, **kwargs)[source]¶ Translates calculation-specific values from
aiida.orm.nodes.process.calculation.calcjob.CalcJobNode
subclass to appropriate TCOD CIF tags.Parameters: - calc – an instance of
aiida.orm.nodes.process.calculation.calcjob.CalcJobNode
subclass. - translator – class, derived from
aiida.tools.dbexporters.tcod_plugins.BaseTcodtranslator
.
Raises: ValueError – if translator is not derived from proper class.
- calc – an instance of