File Formats#
Avogadro allows scripts to translate between formats which Avogadro already handles and new formats (e.g., to use packages like cclib).
The script must handle the following command line arguments:
--metadataPrint metadata describing the format and the script’s abilities and exit.--readRead data from standard input and produce a standard representation on standard output.--writeRead a standard representation from standard input and write the formatted result to standard output.
Format scripts do not need to handle both --read and --write options.
For example a format could be intended to only read in a new format by converting
to cjson.
Identify the Format with --metadata#
Running the script with the --metadata option should print a JSON object
of the following form:
{
"inputFormat": "cml",
"outputFormat": "cml",
"operations": ["read", "write"],
"identifier": "Unique Name",
"name": "User-friendly Name",
"description": "Description of format.",
"specificationUrl": "http://url.specifying.format/if/any/exist",
"fileExtensions": ["ext"],
"mimeTypes": ["chemical/x-ext"]
}
Details:
inputFormatindicates the format that the script can convert to the implemented format by the--writecommand. Allowed values are"cml","cjson", or"xyz". See the--writedocumentation for more detail.outputFormatindicates the format that the script can convert to from the implemented format by the--readcommand. Allowed values are"cml","cjson", or"xyz". See the--readdocumentation for more detail.operationsspecifies the scripts capabilities. The array should contain"read"if the script implements the--readoption, and/or"write"if--writeis available.identifieris a unique identifier. The value must only be unique amongst script formats, as it will be prefixed with “User Script: “ internally by Avogadro.nameis a user-friendly name for the format.descriptionis a description of the format, along with any relevant help text for users.specificationUrlis the URL of the format specification if available (or relevant web page/wiki otherwise).fileExtensionsis an array specifying the file extensions that this format supports.mimeTypesis an array specifying the mime types that this format supports.
- Required members are:
operationsinputFormat(if"write"is specified inoperations)outputFormat(if"read"is specified inoperations)identifiername
- Optional members are:
descriptionspecificationUrlfileExtensionsmimeTypes
Reading a format with --read#
If "read" is specified in the operations --metadata output along with
a valid outputFormat, Avogadro will call the script with --read and
write the implemented format to the script’s standard input. The script shall
convert the input to outputFormat and print it to standard output.
Writing a format with --write#
If "write" is specified in the operations --metadata output along with
a valid inputFormat, Avogadro will call the script with --write and
write the inputFormat to the script’s standard input. The script shall
convert the input to the implemented format and print it to standard output.