schrodinger.application.matsci.qeschema.qeschema.documents module¶
- schrodinger.application.matsci.qeschema.qeschema.documents.requires_xml_data(method)[source]¶
A decorator for XML document methods that require XML data to be loaded.
- class schrodinger.application.matsci.qeschema.qeschema.documents.XmlDocument(source=None, schema=None)[source]¶
Bases:
object
Base class for a generic XML document based on an XSD schema. The schema associated is used for checking types, validation of the XML data and for lookup of default values. XML data is loaded into memory into an ElementTree structure. Data files can be also in JSON or YAML format, in these cases the data source is converted to XML when loading.
- Parameters
source – can be a
xmlschema.XMLResource
instance or a file-like object or a file path or an URL of a resource or a string containing the XML data.schema – can be a
xmlschema.XMLSchema
instance or a file-like object or a file path or an URL of a resource or a string containing the XSD schema.
- Variables
SEARCH_PATHS – the sequence of search paths used by
fetch_schema
for fetching schemas.root – the root element of the XML tree.
filename – the filepath of the data source file.
format – the format of the data source file (XML, JSON, YAML).
errors – the list of detected validation errors.
schema – the
XMLSchema
instance associated with the document.
- SEARCH_PATHS = ('.',)¶
- DEFAULT_SCHEMA = None¶
- property namespaces¶
XML data namespaces map, a dictionary that maps prefixes to URI. An empty dictionary if the XML data file is not loaded or it doesn’t contain any namespace declaration.
- read(filename, validation='strict', **kwargs)[source]¶
Reads XML data from a file encoded in XML, JSON or YAML format.
- Parameters
filename – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance in case of a non-XML data source.
- from_xml(source, validation='strict', **kwargs)[source]¶
Load XML data. Data is validated against the schema.
- Parameters
source – a filepath to an XML file or a string containing XML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for creating the
xmlschema.XMLResource
instance used for reading the XML data.
- Returns
a couple with the root element of the XML ElementTree a list containing the detected errors.
- from_json(source, validation='strict', **kwargs)[source]¶
Load JSON encoded data. Data is converted to an XML ElementTree structure and validated against the schema.
- Parameters
source – a filepath to a JSON file or a string containing JSON data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
the root element of the XML ElementTree data structure and a list containing the detected errors.
- Raise
an
xmlschema.XMLSchemaValidationError
if validation is strict and at least an error is found.
- from_yaml(source, validation='strict', **kwargs)[source]¶
Converts a YAML encoded file to an XML ElementTree structure. Data is validated against the schema during conversion.
- Parameters
source – a filepath to a YAML file or a string containing YAML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- from_dict(data, validation='strict', **kwargs)[source]¶
Converts a Python object to an XML ElementTree structure. Object data is validated against the schema during conversion.
- Parameters
data – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- write(filename, output_format='xml', validation='strict', **kwargs)[source]¶
Write loaded XML data to a file. Binds the document to saved file if it’s not already bound to another file.
- Parameters
filename – filepath of the destination file.
output_format – the data format of the output file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- to_dict(validation='strict', **kwargs)[source]¶
Converts loaded XML data to a nested dictionary.
- Parameters
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- Returns
a dictionary.
- to_json(filename=None, validation='strict', **kwargs)[source]¶
Converts loaded XML data to a JSON string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- to_yaml(filename=None, validation='strict', **kwargs)[source]¶
Converts loaded XML data to YAML string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- find(path, namespaces=None)[source]¶
Find first matching element by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- findall(path, namespaces=None)[source]¶
Find all matching subelements by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- class schrodinger.application.matsci.qeschema.qeschema.documents.QeDocument(source=None, schema=None, input_builder=None)[source]¶
Bases:
schrodinger.application.matsci.qeschema.qeschema.documents.XmlDocument
Abstract base class for schema-based XML documents of Quantum ESPRESSO applications.
- SEARCH_PATHS = ('/scr/buildbot/savedbuilds/2022-2/NB/build-128/internal/lib/python3.8/site-packages/schrodinger/application/matsci/qeschema/qeschema/schemas', '/scr/buildbot/savedbuilds/2022-2/NB/build-128/internal/lib/python3.8/site-packages/schrodinger/application/matsci/qeschema/qeschema/schemas/releases', '.')¶
- DEFAULT_INPUT_BUILDER = None¶
- property input_path¶
The path to XML input section.
- property output_path¶
The path to XML input section.
- write_fortran_input(filename)[source]¶
Converts the XML input data to a Fortran namelist input and writes it to a file.
- Parameters
filename – the pathname of the file to use to save the Fortran namelist.
- get_fortran_input(use_defaults=True)[source]¶
Converts the XML input data to a Fortran namelist input.
- Parameters
use_defaults – use the defaults of the XSD schema to fill missing values.
- Returns
a string.
- DEFAULT_SCHEMA = None¶
- classmethod fetch_schema(filename)¶
- find(path, namespaces=None)¶
Find first matching element by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- findall(path, namespaces=None)¶
Find all matching subelements by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- from_dict(data, validation='strict', **kwargs)¶
Converts a Python object to an XML ElementTree structure. Object data is validated against the schema during conversion.
- Parameters
data – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- from_json(source, validation='strict', **kwargs)¶
Load JSON encoded data. Data is converted to an XML ElementTree structure and validated against the schema.
- Parameters
source – a filepath to a JSON file or a string containing JSON data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
the root element of the XML ElementTree data structure and a list containing the detected errors.
- Raise
an
xmlschema.XMLSchemaValidationError
if validation is strict and at least an error is found.
- from_xml(source, validation='strict', **kwargs)¶
Load XML data. Data is validated against the schema.
- Parameters
source – a filepath to an XML file or a string containing XML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for creating the
xmlschema.XMLResource
instance used for reading the XML data.
- Returns
a couple with the root element of the XML ElementTree a list containing the detected errors.
- from_yaml(source, validation='strict', **kwargs)¶
Converts a YAML encoded file to an XML ElementTree structure. Data is validated against the schema during conversion.
- Parameters
source – a filepath to a YAML file or a string containing YAML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- iter(tag=None)¶
- property namespaces¶
XML data namespaces map, a dictionary that maps prefixes to URI. An empty dictionary if the XML data file is not loaded or it doesn’t contain any namespace declaration.
- read(filename, validation='strict', **kwargs)¶
Reads XML data from a file encoded in XML, JSON or YAML format.
- Parameters
filename – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance in case of a non-XML data source.
- to_dict(validation='strict', **kwargs)¶
Converts loaded XML data to a nested dictionary.
- Parameters
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- Returns
a dictionary.
- to_json(filename=None, validation='strict', **kwargs)¶
Converts loaded XML data to a JSON string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- to_yaml(filename=None, validation='strict', **kwargs)¶
Converts loaded XML data to YAML string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- write(filename, output_format='xml', validation='strict', **kwargs)¶
Write loaded XML data to a file. Binds the document to saved file if it’s not already bound to another file.
- Parameters
filename – filepath of the destination file.
output_format – the data format of the output file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- class schrodinger.application.matsci.qeschema.qeschema.documents.PwDocument(source=None, schema=None, input_builder=None)[source]¶
Bases:
schrodinger.application.matsci.qeschema.qeschema.documents.QeDocument
Class to manage PW XML documents.
- DEFAULT_SCHEMA = 'qes.xsd'¶
- DEFAULT_INPUT_BUILDER¶
alias of
schrodinger.application.matsci.qeschema.qeschema.converters.PwInputConverter
- get_atomic_positions()[source]¶
Gets atomic symbols and atomic positions from XML output data.
- Returns
the list of atomic symbols and a nested list containing the coordinates
- get_cell_parameters()[source]¶
Gets cell parameters from an XML output data.
- Returns
a nested list containing the cell vectors in Bohr atomic units
- get_stress()[source]¶
Gets stress tensor from the XML output data, if present.
- Returns
nested list containing the stress tensor in C order
- get_forces()[source]¶
Gets forces from the XML output data, if present.
- Returns
the list of atomic symbols plus a nested list with the forces in atomic units
- get_k_points()[source]¶
Extracts the k_points list from the XML output data.
- Returns
nested list with k_points
- get_ks_eigenvalues()[source]¶
Extracts the eigenvalues from the XML output data.
- Returns
nested list of KS eigenvalues for each k_point in Hartree Units
- get_total_energy()[source]¶
Extracts the total energy from the XML output data.
- Returns
total energy in Hartree Units
- SEARCH_PATHS = ('/scr/buildbot/savedbuilds/2022-2/NB/build-128/internal/lib/python3.8/site-packages/schrodinger/application/matsci/qeschema/qeschema/schemas', '/scr/buildbot/savedbuilds/2022-2/NB/build-128/internal/lib/python3.8/site-packages/schrodinger/application/matsci/qeschema/qeschema/schemas/releases', '.')¶
- __init__(source=None, schema=None, input_builder=None)¶
- classmethod fetch_schema(filename)¶
- find(path, namespaces=None)¶
Find first matching element by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- findall(path, namespaces=None)¶
Find all matching subelements by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- from_dict(data, validation='strict', **kwargs)¶
Converts a Python object to an XML ElementTree structure. Object data is validated against the schema during conversion.
- Parameters
data – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- from_json(source, validation='strict', **kwargs)¶
Load JSON encoded data. Data is converted to an XML ElementTree structure and validated against the schema.
- Parameters
source – a filepath to a JSON file or a string containing JSON data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
the root element of the XML ElementTree data structure and a list containing the detected errors.
- Raise
an
xmlschema.XMLSchemaValidationError
if validation is strict and at least an error is found.
- from_xml(source, validation='strict', **kwargs)¶
Load XML data. Data is validated against the schema.
- Parameters
source – a filepath to an XML file or a string containing XML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for creating the
xmlschema.XMLResource
instance used for reading the XML data.
- Returns
a couple with the root element of the XML ElementTree a list containing the detected errors.
- from_yaml(source, validation='strict', **kwargs)¶
Converts a YAML encoded file to an XML ElementTree structure. Data is validated against the schema during conversion.
- Parameters
source – a filepath to a YAML file or a string containing YAML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- get_fortran_input(use_defaults=True)¶
Converts the XML input data to a Fortran namelist input.
- Parameters
use_defaults – use the defaults of the XSD schema to fill missing values.
- Returns
a string.
- property input_path¶
The path to XML input section.
- iter(tag=None)¶
- property namespaces¶
XML data namespaces map, a dictionary that maps prefixes to URI. An empty dictionary if the XML data file is not loaded or it doesn’t contain any namespace declaration.
- property output_path¶
The path to XML input section.
- read(filename, validation='strict', **kwargs)¶
Reads XML data from a file encoded in XML, JSON or YAML format.
- Parameters
filename – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance in case of a non-XML data source.
- to_dict(validation='strict', **kwargs)¶
Converts loaded XML data to a nested dictionary.
- Parameters
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- Returns
a dictionary.
- to_json(filename=None, validation='strict', **kwargs)¶
Converts loaded XML data to a JSON string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- to_yaml(filename=None, validation='strict', **kwargs)¶
Converts loaded XML data to YAML string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- write(filename, output_format='xml', validation='strict', **kwargs)¶
Write loaded XML data to a file. Binds the document to saved file if it’s not already bound to another file.
- Parameters
filename – filepath of the destination file.
output_format – the data format of the output file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- write_fortran_input(filename)¶
Converts the XML input data to a Fortran namelist input and writes it to a file.
- Parameters
filename – the pathname of the file to use to save the Fortran namelist.
- class schrodinger.application.matsci.qeschema.qeschema.documents.PhononDocument(source=None, schema=None, input_builder=None)[source]¶
Bases:
schrodinger.application.matsci.qeschema.qeschema.documents.QeDocument
Class to manage Phonon XML documents.
- DEFAULT_SCHEMA = 'ph_xmlschema.xsd'¶
- DEFAULT_INPUT_BUILDER¶
alias of
schrodinger.application.matsci.qeschema.qeschema.converters.PhononInputConverter
- property input_path¶
The path to XML input section.
- property output_path¶
The path to XML input section.
- get_fortran_input(use_defaults=False)[source]¶
Overrides get_fortran_input() setting use_defaults optional argument to False.
- Parameters
use_defaults –
- Returns
the input as obtained from its input builder
- SEARCH_PATHS = ('/scr/buildbot/savedbuilds/2022-2/NB/build-128/internal/lib/python3.8/site-packages/schrodinger/application/matsci/qeschema/qeschema/schemas', '/scr/buildbot/savedbuilds/2022-2/NB/build-128/internal/lib/python3.8/site-packages/schrodinger/application/matsci/qeschema/qeschema/schemas/releases', '.')¶
- __init__(source=None, schema=None, input_builder=None)¶
- classmethod fetch_schema(filename)¶
- find(path, namespaces=None)¶
Find first matching element by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- findall(path, namespaces=None)¶
Find all matching subelements by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- from_dict(data, validation='strict', **kwargs)¶
Converts a Python object to an XML ElementTree structure. Object data is validated against the schema during conversion.
- Parameters
data – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- from_json(source, validation='strict', **kwargs)¶
Load JSON encoded data. Data is converted to an XML ElementTree structure and validated against the schema.
- Parameters
source – a filepath to a JSON file or a string containing JSON data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
the root element of the XML ElementTree data structure and a list containing the detected errors.
- Raise
an
xmlschema.XMLSchemaValidationError
if validation is strict and at least an error is found.
- from_xml(source, validation='strict', **kwargs)¶
Load XML data. Data is validated against the schema.
- Parameters
source – a filepath to an XML file or a string containing XML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for creating the
xmlschema.XMLResource
instance used for reading the XML data.
- Returns
a couple with the root element of the XML ElementTree a list containing the detected errors.
- from_yaml(source, validation='strict', **kwargs)¶
Converts a YAML encoded file to an XML ElementTree structure. Data is validated against the schema during conversion.
- Parameters
source – a filepath to a YAML file or a string containing YAML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- iter(tag=None)¶
- property namespaces¶
XML data namespaces map, a dictionary that maps prefixes to URI. An empty dictionary if the XML data file is not loaded or it doesn’t contain any namespace declaration.
- read(filename, validation='strict', **kwargs)¶
Reads XML data from a file encoded in XML, JSON or YAML format.
- Parameters
filename – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance in case of a non-XML data source.
- to_dict(validation='strict', **kwargs)¶
Converts loaded XML data to a nested dictionary.
- Parameters
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- Returns
a dictionary.
- to_json(filename=None, validation='strict', **kwargs)¶
Converts loaded XML data to a JSON string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- to_yaml(filename=None, validation='strict', **kwargs)¶
Converts loaded XML data to YAML string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- write(filename, output_format='xml', validation='strict', **kwargs)¶
Write loaded XML data to a file. Binds the document to saved file if it’s not already bound to another file.
- Parameters
filename – filepath of the destination file.
output_format – the data format of the output file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- write_fortran_input(filename)¶
Converts the XML input data to a Fortran namelist input and writes it to a file.
- Parameters
filename – the pathname of the file to use to save the Fortran namelist.
- class schrodinger.application.matsci.qeschema.qeschema.documents.NebDocument(source=None, schema=None, input_builder=None)[source]¶
Bases:
schrodinger.application.matsci.qeschema.qeschema.documents.QeDocument
Class to manage NEB XML documents.
- DEFAULT_SCHEMA = 'qes_neb.xsd'¶
- DEFAULT_INPUT_BUILDER¶
alias of
schrodinger.application.matsci.qeschema.qeschema.converters.NebInputConverter
- SEARCH_PATHS = ('/scr/buildbot/savedbuilds/2022-2/NB/build-128/internal/lib/python3.8/site-packages/schrodinger/application/matsci/qeschema/qeschema/schemas', '/scr/buildbot/savedbuilds/2022-2/NB/build-128/internal/lib/python3.8/site-packages/schrodinger/application/matsci/qeschema/qeschema/schemas/releases', '.')¶
- __init__(source=None, schema=None, input_builder=None)¶
- classmethod fetch_schema(filename)¶
- find(path, namespaces=None)¶
Find first matching element by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- findall(path, namespaces=None)¶
Find all matching subelements by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- from_dict(data, validation='strict', **kwargs)¶
Converts a Python object to an XML ElementTree structure. Object data is validated against the schema during conversion.
- Parameters
data – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- from_json(source, validation='strict', **kwargs)¶
Load JSON encoded data. Data is converted to an XML ElementTree structure and validated against the schema.
- Parameters
source – a filepath to a JSON file or a string containing JSON data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
the root element of the XML ElementTree data structure and a list containing the detected errors.
- Raise
an
xmlschema.XMLSchemaValidationError
if validation is strict and at least an error is found.
- from_xml(source, validation='strict', **kwargs)¶
Load XML data. Data is validated against the schema.
- Parameters
source – a filepath to an XML file or a string containing XML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for creating the
xmlschema.XMLResource
instance used for reading the XML data.
- Returns
a couple with the root element of the XML ElementTree a list containing the detected errors.
- from_yaml(source, validation='strict', **kwargs)¶
Converts a YAML encoded file to an XML ElementTree structure. Data is validated against the schema during conversion.
- Parameters
source – a filepath to a YAML file or a string containing YAML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- get_fortran_input(use_defaults=True)¶
Converts the XML input data to a Fortran namelist input.
- Parameters
use_defaults – use the defaults of the XSD schema to fill missing values.
- Returns
a string.
- property input_path¶
The path to XML input section.
- iter(tag=None)¶
- property namespaces¶
XML data namespaces map, a dictionary that maps prefixes to URI. An empty dictionary if the XML data file is not loaded or it doesn’t contain any namespace declaration.
- property output_path¶
The path to XML input section.
- read(filename, validation='strict', **kwargs)¶
Reads XML data from a file encoded in XML, JSON or YAML format.
- Parameters
filename – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance in case of a non-XML data source.
- to_dict(validation='strict', **kwargs)¶
Converts loaded XML data to a nested dictionary.
- Parameters
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- Returns
a dictionary.
- to_json(filename=None, validation='strict', **kwargs)¶
Converts loaded XML data to a JSON string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- to_yaml(filename=None, validation='strict', **kwargs)¶
Converts loaded XML data to YAML string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- write(filename, output_format='xml', validation='strict', **kwargs)¶
Write loaded XML data to a file. Binds the document to saved file if it’s not already bound to another file.
- Parameters
filename – filepath of the destination file.
output_format – the data format of the output file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- write_fortran_input(filename)¶
Converts the XML input data to a Fortran namelist input and writes it to a file.
- Parameters
filename – the pathname of the file to use to save the Fortran namelist.
- class schrodinger.application.matsci.qeschema.qeschema.documents.TdDocument(source=None, schema=None, input_builder=None)[source]¶
Bases:
schrodinger.application.matsci.qeschema.qeschema.documents.QeDocument
Class to manage TDDFPT XML documents.
- DEFAULT_SCHEMA = 'tddfpt.xsd'¶
- DEFAULT_INPUT_BUILDER¶
alias of
schrodinger.application.matsci.qeschema.qeschema.converters.TdInputConverter
- SEARCH_PATHS = ('/scr/buildbot/savedbuilds/2022-2/NB/build-128/internal/lib/python3.8/site-packages/schrodinger/application/matsci/qeschema/qeschema/schemas', '/scr/buildbot/savedbuilds/2022-2/NB/build-128/internal/lib/python3.8/site-packages/schrodinger/application/matsci/qeschema/qeschema/schemas/releases', '.')¶
- __init__(source=None, schema=None, input_builder=None)¶
- classmethod fetch_schema(filename)¶
- find(path, namespaces=None)¶
Find first matching element by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- findall(path, namespaces=None)¶
Find all matching subelements by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- from_dict(data, validation='strict', **kwargs)¶
Converts a Python object to an XML ElementTree structure. Object data is validated against the schema during conversion.
- Parameters
data – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- from_json(source, validation='strict', **kwargs)¶
Load JSON encoded data. Data is converted to an XML ElementTree structure and validated against the schema.
- Parameters
source – a filepath to a JSON file or a string containing JSON data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
the root element of the XML ElementTree data structure and a list containing the detected errors.
- Raise
an
xmlschema.XMLSchemaValidationError
if validation is strict and at least an error is found.
- from_xml(source, validation='strict', **kwargs)¶
Load XML data. Data is validated against the schema.
- Parameters
source – a filepath to an XML file or a string containing XML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for creating the
xmlschema.XMLResource
instance used for reading the XML data.
- Returns
a couple with the root element of the XML ElementTree a list containing the detected errors.
- from_yaml(source, validation='strict', **kwargs)¶
Converts a YAML encoded file to an XML ElementTree structure. Data is validated against the schema during conversion.
- Parameters
source – a filepath to a YAML file or a string containing YAML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- get_fortran_input(use_defaults=True)¶
Converts the XML input data to a Fortran namelist input.
- Parameters
use_defaults – use the defaults of the XSD schema to fill missing values.
- Returns
a string.
- property input_path¶
The path to XML input section.
- iter(tag=None)¶
- property namespaces¶
XML data namespaces map, a dictionary that maps prefixes to URI. An empty dictionary if the XML data file is not loaded or it doesn’t contain any namespace declaration.
- property output_path¶
The path to XML input section.
- read(filename, validation='strict', **kwargs)¶
Reads XML data from a file encoded in XML, JSON or YAML format.
- Parameters
filename – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance in case of a non-XML data source.
- to_dict(validation='strict', **kwargs)¶
Converts loaded XML data to a nested dictionary.
- Parameters
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- Returns
a dictionary.
- to_json(filename=None, validation='strict', **kwargs)¶
Converts loaded XML data to a JSON string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- to_yaml(filename=None, validation='strict', **kwargs)¶
Converts loaded XML data to YAML string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- write(filename, output_format='xml', validation='strict', **kwargs)¶
Write loaded XML data to a file. Binds the document to saved file if it’s not already bound to another file.
- Parameters
filename – filepath of the destination file.
output_format – the data format of the output file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- write_fortran_input(filename)¶
Converts the XML input data to a Fortran namelist input and writes it to a file.
- Parameters
filename – the pathname of the file to use to save the Fortran namelist.
- class schrodinger.application.matsci.qeschema.qeschema.documents.TdSpectrumDocument(source=None, schema=None, input_builder=None)[source]¶
Bases:
schrodinger.application.matsci.qeschema.qeschema.documents.QeDocument
Class to manage turbo-spectrum XML inputs
- SEARCH_PATHS = ('/scr/buildbot/savedbuilds/2022-2/NB/build-128/internal/lib/python3.8/site-packages/schrodinger/application/matsci/qeschema/qeschema/schemas', '/scr/buildbot/savedbuilds/2022-2/NB/build-128/internal/lib/python3.8/site-packages/schrodinger/application/matsci/qeschema/qeschema/schemas/releases', '.')¶
- __init__(source=None, schema=None, input_builder=None)¶
- classmethod fetch_schema(filename)¶
- find(path, namespaces=None)¶
Find first matching element by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- findall(path, namespaces=None)¶
Find all matching subelements by tag name or path.
- Parameters
path – is a string having either an element tag or an XPath,
namespaces – is an optional mapping from namespace prefix to full name.
- Returns
the first matching element, or None if no element was found
- from_dict(data, validation='strict', **kwargs)¶
Converts a Python object to an XML ElementTree structure. Object data is validated against the schema during conversion.
- Parameters
data – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- from_json(source, validation='strict', **kwargs)¶
Load JSON encoded data. Data is converted to an XML ElementTree structure and validated against the schema.
- Parameters
source – a filepath to a JSON file or a string containing JSON data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
the root element of the XML ElementTree data structure and a list containing the detected errors.
- Raise
an
xmlschema.XMLSchemaValidationError
if validation is strict and at least an error is found.
- from_xml(source, validation='strict', **kwargs)¶
Load XML data. Data is validated against the schema.
- Parameters
source – a filepath to an XML file or a string containing XML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for creating the
xmlschema.XMLResource
instance used for reading the XML data.
- Returns
a couple with the root element of the XML ElementTree a list containing the detected errors.
- from_yaml(source, validation='strict', **kwargs)¶
Converts a YAML encoded file to an XML ElementTree structure. Data is validated against the schema during conversion.
- Parameters
source – a filepath to a YAML file or a string containing YAML data.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance.
- Returns
a couple with the root element of the XML ElementTree and a list containing the detected errors.
- get_fortran_input(use_defaults=True)¶
Converts the XML input data to a Fortran namelist input.
- Parameters
use_defaults – use the defaults of the XSD schema to fill missing values.
- Returns
a string.
- iter(tag=None)¶
- property namespaces¶
XML data namespaces map, a dictionary that maps prefixes to URI. An empty dictionary if the XML data file is not loaded or it doesn’t contain any namespace declaration.
- property output_path¶
The path to XML input section.
- read(filename, validation='strict', **kwargs)¶
Reads XML data from a file encoded in XML, JSON or YAML format.
- Parameters
filename – filepath of the data source file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options to pass to the encoding method of the schema instance in case of a non-XML data source.
- to_dict(validation='strict', **kwargs)¶
Converts loaded XML data to a nested dictionary.
- Parameters
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- Returns
a dictionary.
- to_json(filename=None, validation='strict', **kwargs)¶
Converts loaded XML data to a JSON string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- to_yaml(filename=None, validation='strict', **kwargs)¶
Converts loaded XML data to YAML string or file.
- Parameters
filename – filepath of the destination file. Binds the document to this file if it’s not already bound to another file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- write(filename, output_format='xml', validation='strict', **kwargs)¶
Write loaded XML data to a file. Binds the document to saved file if it’s not already bound to another file.
- Parameters
filename – filepath of the destination file.
output_format – the data format of the output file.
validation – validation mode, can be ‘strict’, ‘lax’ or ‘skip’.
kwargs – other options for the decoding method of the schema instance.
- write_fortran_input(filename)¶
Converts the XML input data to a Fortran namelist input and writes it to a file.
- Parameters
filename – the pathname of the file to use to save the Fortran namelist.
- DEFAULT_SCHEMA = 'qes_spectrum.xsd'¶
- DEFAULT_INPUT_BUILDER¶
alias of
schrodinger.application.matsci.qeschema.qeschema.converters.TdSpectrumInputConverter
- property input_path¶
The path to XML input section.