Skip to content

Commit

Permalink
save XYZ in YAML file
Browse files Browse the repository at this point in the history
  • Loading branch information
alongd committed Jun 26, 2018
1 parent a8c2a36 commit 891a6a1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
23 changes: 23 additions & 0 deletions rmgpy/cantherm/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from yaml import Dumper, Loader, SafeLoader

import rmgpy.constants as constants
from rmgpy.molecule.element import elementList
from rmgpy.molecule.translator import toInChI, toInChIKey
from rmgpy.thermo import NASA, NASAPolynomial, Wilhoit, ThermoData
from rmgpy.statmech.conformer import Conformer
Expand Down Expand Up @@ -281,6 +282,7 @@ def __init__(self, species=None, author='', level_of_theory='', model_chemistry=
self.InChI_Key = inchi_key

self.conformer = species.conformer
self.update_xyz_string()

if species.symmetryNumber != -1:
self.symmetryNumber = species.symmetryNumber
Expand Down Expand Up @@ -327,6 +329,7 @@ def update_species_attributes(self, species):
self.InChI = inchi
self.InChI_Key = inchi_key
self.conformer = species.conformer
self.update_xyz_string()
if species.symmetryNumber != -1:
self.symmetryNumber = species.symmetryNumber
if species.transportData is not None:
Expand All @@ -338,6 +341,26 @@ def update_species_attributes(self, species):
if species.thermo is not None:
self.thermo = species.thermo

def update_xyz_string(self):
if self.conformer is not None and self.conformer.number is not None:
# generate an xyz-format string from the Conformer coordinates
xyz_string = '{0}\n{1}'.format(len(self.conformer.number.value_si), self.label)
for i, coorlist in enumerate(self.conformer.coordinates.value_si):
for element in elementList:
if element.number == int(self.conformer.number.value_si[i]):
element_symbol = element.symbol
break
else:
raise ValueError('Could not find element symbol corresponding to atom number {0}'.format(
self.conformer.number.value_si[i]))
xyz_string += '\n{0} {1} {2} {3}'.format(element_symbol,
coorlist[0],
coorlist[1],
coorlist[2])
else:
xyz_string = ''
self.xyz = xyz_string

def as_dictionary(self):
"""
Output all attributes of CanthermSpecies in a dictionary format
Expand Down
3 changes: 1 addition & 2 deletions rmgpy/cantherm/statmech.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
from rmgpy.statmech.torsion import Torsion, HinderedRotor, FreeRotor
from rmgpy.statmech.conformer import Conformer
from rmgpy.molecule import Molecule
from rmgpy.molecule.element import elementList
from rmgpy.molecule.converter import fromOBMol
from rmgpy.exceptions import InputError, InvalidAdjacencyListError

Expand Down Expand Up @@ -505,7 +504,7 @@ def load(self, is_pdep=False):

self.species.conformer = conformer

def load_species_from_database_file(self, is_pdep):
def load_species_from_database_file(self, is_pdep=False):
"""
Load the species with all statMech data from the .yml file
"""
Expand Down

0 comments on commit 891a6a1

Please sign in to comment.