qcelemental.molparse.to_string(molrec, dtype, units=None, *, atom_format=None, ghost_format=None, width=17, prec=12, return_data=False)[source]

Format a string representation of QM molecule.

  • molrec (Dict) – Psi4 json Molecule spec.

  • dtype (str) – {“xyz”, “cfour”, “nwchem”, “molpro”, “orca”, “turbomole”, “qchem”} Overall string format. Note that it’s possible to request variations that don’t fit the dtype spec so may not be re-readable (e.g., ghost and mass in nucleus label with 'xyz'). ‘cfour’ forces nucleus label, ignoring atom_format, ghost_format

  • units (Optional[str]) – Units in which to write string. Usually Angstrom or Bohr but may be any length unit. There is not an option to write in intrinsic/input units. For dtype='xyz', units='Bohr' where the format doesn’t have a slot to specify units, “au” is added so that readable as dtype='xyz+'.

  • atom_format (Optional[str]) – General format is '{elem}'. A format string that may contain fields ‘elea’ (-1 will be ‘’), ‘elez’, ‘elem’, ‘mass’, ‘elbl’ in any arrangement. For example, if a format naturally uses element symbol and you want atomic number instead with mass info, too, pass '{elez}@{mass}'. See ghost_format for handling field ‘real’.

  • ghost_format (Optional[str]) – General format is '@{elem}'. Like atom_format, but this formatter is used when real=False. To suppress ghost atoms, use ghost_format=’’.

  • width (int) – Field width for formatting coordinate float.

  • prec (int) – Number of decimal places for formatting coordinate float.

  • return_data (bool) – Whether to return dictionary with additional info from the molrec that’s not expressible in the string but may be of interest to the QC program. Note that field names are in QCSchema, not molrec, language.

Return type:

Union[str, Tuple[str, Dict]]


  • str – String representation of the molecule.

  • str, dict

    When return_data=True, return additionally a dictionary

    • keywords: key, value pairs for processing molecule info into options

    • fields: aspects of qcelemental.models.Molecule expressed into string or keywords. Model fields not listed are lost in QCSchema -> QC DSL translation.