qcelemental.molparse.to_string(molrec: Dict, dtype: str, units: str = None, *, atom_format: str = None, ghost_format: str = None, width: int = 17, prec: int = 12, return_data: bool = False) → Union[str, Tuple[str, Dict]][source]

Format a string representation of QM molecule.

  • molrec (Dict) – Psi4 json Molecule spec.

  • dtype (str, {'xyz', 'cfour', 'nwchem', 'molpro', '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 (str, optional) – 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 (str, optional) – 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 (str, optional) – General format is '@{elem}'. Like atom_format, but this formatter is used when real=False. To suppress ghost atoms, use ghost_format=’’.

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

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

  • return_data (bool, optional) – 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.


  • 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.