4444import molecule .qm .qmdata as qmdata
4545import molecule .qm .symmetry as symmetry
4646import molecule .quantity
47- #import molecule.statmech
47+ # import molecule.statmech
4848import molecule .thermo
4949from molecule .qm .qmdata import parse_cclib_data
5050from molecule .thermo import ThermoData
@@ -408,19 +408,28 @@ def parse(self):
408408 parser = self .get_parser (self .output_file_path )
409409 parser .logger .setLevel (
410410 logging .ERROR
411- ) # cf. http://cclib.sourceforge.net/wiki/index.php/Using_cclib#Additional_information
412- parser .rotcons = (
411+ ) # cf. https://cclib.github.io/index.html#how-to-use-cclib
412+ parser .molmass = None # give it an attribute and it won't delete it, leaving it on the parser object
413+ parser .rotcons = ( # for cclib < 1.8.0
413414 []
414- ) # give it an attribute and it won't delete it, leaving it on the parser object
415- parser .molmass = None # give it an attribute and it won't delete it, leaving it on the parser object
416- cclib_data = parser .parse ()
415+ )
416+ parser .rotconsts = ( # for cclib >= 1.8.0
417+ []
418+ )
419+ cclib_data = parser .parse () # fills in either parser.rotcons or parser.rotconsts but not both
420+ assert bool (parser .rotconsts ) != bool (parser .rotcons )
421+ if parser .rotcons : # for cclib < 1.8.0
422+ cclib_data .rotcons = (
423+ parser .rotcons
424+ )
425+ else : # for cclib >= 1.8.0
426+ cclib_data .rotconsts = (
427+ parser .rotconsts
428+ )
417429 radical_number = self .molecule .get_radical_count ()
418- cclib_data .rotcons = (
419- parser .rotcons
420- ) # this hack required because rotcons not part of a default cclib data object
421430 cclib_data .molmass = (
422431 parser .molmass
423- ) # this hack required because rotcons not part of a default cclib data object
432+ ) # this hack required because molmass is not part of a default cclib data object
424433 qm_data = parse_cclib_data (
425434 cclib_data , radical_number + 1
426435 ) # Should `radical_number+1` be `self.molecule.multiplicity` in the next line of code? It's the electronic ground state degeneracy.
@@ -520,11 +529,11 @@ def load_thermo_data(self):
520529 self .qm_data = local_context ["qmData" ]
521530 return thermo
522531
523- def get_augmented_inchi_key (self ):
532+ def get_augmented_inchi_key (self , backend = 'rdkit-first' ):
524533 """
525534 Returns the augmented InChI from self.molecule
526535 """
527- return self .molecule .to_augmented_inchi_key ()
536+ return self .molecule .to_augmented_inchi_key (backend = backend )
528537
529538 def get_mol_file_path_for_calculation (self , attempt ):
530539 """
@@ -555,7 +564,7 @@ def calculate_chirality_correction(self):
555564 if self .point_group .chiral :
556565 return molecule .quantity .constants .R * math .log (2 )
557566 else :
558- return 0.
567+ return 0.0
559568
560569 # def calculate_thermo_data(self):
561570 # """
@@ -567,16 +576,21 @@ def calculate_chirality_correction(self):
567576 # assert self.qm_data, "Need QM Data first in order to calculate thermo."
568577 # assert self.point_group, "Need Point Group first in order to calculate thermo."
569578 #
570- # mass = getattr(self.qm_data, ' molecularMass' , None)
579+ # mass = getattr(self.qm_data, " molecularMass" , None)
571580 # if mass is None:
572581 # # If using a cclib that doesn't read molecular mass, for example
573- # mass = sum(molecule.molecule.element.get_element(int(a)).mass for a in self.qm_data.atomicNumbers)
574- # mass = molecule.quantity.Mass(mass, 'kg/mol')
582+ # mass = sum(
583+ # molecule.molecule.element.get_element(int(a)).mass
584+ # for a in self.qm_data.atomicNumbers
585+ # )
586+ # mass = molecule.quantity.Mass(mass, "kg/mol")
575587 # trans = molecule.statmech.IdealGasTranslation(mass=mass)
576588 # if self.point_group.linear:
577589 # # there should only be one rotational constant for a linear rotor
578- # rotational_constant = molecule.quantity.Frequency(max(self.qm_data.rotationalConstants.value),
579- # self.qm_data.rotationalConstants.units)
590+ # rotational_constant = molecule.quantity.Frequency(
591+ # max(self.qm_data.rotationalConstants.value),
592+ # self.qm_data.rotationalConstants.units,
593+ # )
580594 # rot = molecule.statmech.LinearRotor(
581595 # rotationalConstant=rotational_constant,
582596 # symmetry=self.point_group.symmetry_number,
@@ -591,9 +605,11 @@ def calculate_chirality_correction(self):
591605 #
592606 # # @todo: We need to extract or calculate E0 somehow from the qmdata
593607 # E0 = (0, "kJ/mol")
594- # self.statesmodel = molecule.statmech.Conformer(E0=E0,
595- # modes=[trans, rot, vib],
596- # spin_multiplicity=self.qm_data.groundStateDegeneracy)
608+ # self.statesmodel = molecule.statmech.Conformer(
609+ # E0=E0,
610+ # modes=[trans, rot, vib],
611+ # spin_multiplicity=self.qm_data.groundStateDegeneracy,
612+ # )
597613 #
598614 # # we will use number of atoms from above (alternatively, we could use the chemGraph); this is needed to test whether the species is monoatomic
599615 # # SI units are J/mol, but converted to kJ/mol for generating the thermo.
@@ -612,7 +628,7 @@ def calculate_chirality_correction(self):
612628 # S298=(S298, "J/(mol*K)"),
613629 # Tmin=(300.0, "K"),
614630 # Tmax=(2000.0, "K"),
615- # comment=comment
631+ # comment=comment,
616632 # )
617633 # self.thermo = thermo
618634 # return thermo
0 commit comments