aiida.tools.dbexporters package

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.node.Node
  • b – an instance of subclass of aiida.orm.node.Node
Raises:

ValueError – if the condition is not met.

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.

aiida.tools.dbexporters.tcod._collect_tags(node, calc, parameters=None, dump_aiida_database=True, exclude_external_contents=False, gzip=False, gzip_threshold=1024)[source]

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.node.Node
Returns:an instance of subclass of aiida.orm.calculation.Calculation
Raises: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.

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.

Parameters:content – the content to be encoded
Return content:encoded content
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
  • method – method, which was used for encoding the contents (None, ‘base64’, ‘ncr’, ‘quoted-printable’, ‘gzip+base64’)
Returns:

decoded content

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 – a string with contents
Returns:decoded string
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 – a string with contents
Returns:decoded string
aiida.tools.dbexporters.tcod.decode_textfield_ncr(content)[source]

Decodes the contents for CIF textfield from Numeric Character Reference.

Parameters:content – a string with contents
Returns:decoded string
aiida.tools.dbexporters.tcod.decode_textfield_quoted_printable(content)[source]

Decodes the contents for CIF textfield from quoted-printable encoding.

Parameters:content – a string with contents
Returns:decoded string
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_label='cif_cod_deposit', computer_name=None, replace=None, message=None, **kwargs)[source]

Launches a aiida.orm.implementation.general.calculation.job.AbstractJobCalculation to deposit data node to *COD-type database.

Returns:launched aiida.orm.implementation.general.calculation.job.AbstractJobCalculation 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 – a string with contents
  • foldwidth – maximum width of line (default is 76)
Returns:

encoded string

aiida.tools.dbexporters.tcod.encode_textfield_gzip_base64(content, **kwargs)[source]

Gzips the given string and encodes it in Base64.

Parameters:content – a string with contents
Returns:encoded string
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 – a string with contents
Returns:encoded string
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 – a string with contents
Returns:encoded string
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.data.cif.CifData node, ready to be exported to TCOD. All *Data types, having method _get_cif(), are supported in addition to aiida.orm.data.cif.CifData.

Parameters:
  • what – data node to be exported.
  • parameters – a aiida.orm.data.parameter.ParameterData 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.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.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.implementation.general.calculation.job.AbstractJobCalculation subclass to appropriate TCOD CIF tags.

Parameters:
Raises:

ValueError – if translator is not derived from proper class.