Beispiel #1
0
 def test_calculate_conformer(self):
     if os.path.exists(os.path.expandvars("$AUTOTST/test/species")):
         shutil.rmtree(os.path.expandvars("$AUTOTST/test/species"))
     conformer = Conformer(smiles='CC', index=0)
     result = self.job.calculate_conformer(conformer=conformer)
     self.assertTrue(result)
     conformer = Conformer(smiles='CC(Cl)(Cl)Cl', index=0)
     result = self.job.calculate_conformer(conformer=conformer)
     self.assertFalse(result)
Beispiel #2
0
    def get_rdkit_mol(self,
                      rmg_molecule=None,
                      reaction_family="H_Abstraction",
                      distance_data=None):
        """
        A method to create an rdkit geometry... slightly different than that of the conformer method
        returns both the rdkit_molecule and the bm
        """
        if not rmg_molecule:
            rmg_molecule = self.rmg_molecule
        rdkit_molecule = Chem.RWMol(
            Conformer().get_rdkit_mol(rmg_molecule=rmg_molecule))

        labels, atom_match = self.get_labels(rmg_molecule, reaction_family)
        for i, atom in enumerate(rmg_molecule.atoms):
            assert atom.number == rdkit_molecule.GetAtoms()[i].GetAtomicNum()

        if len(labels) == 3:

            rd_copy = rdkit_molecule.__copy__()

            lbl1, lbl2, lbl3 = labels

            if not rd_copy.GetBondBetweenAtoms(lbl1, lbl2):
                rd_copy.AddBond(lbl1,
                                lbl2,
                                order=rdkit.Chem.rdchem.BondType.SINGLE)
            else:
                rd_copy.AddBond(lbl2,
                                lbl3,
                                order=rdkit.Chem.rdchem.BondType.SINGLE)

            self._pseudo_geometry = rd_copy

        logging.info("Initially embedded molecule")

        bm = None

        if distance_data:
            logging.info("Getting bounds matrix")
            bm = self.get_bounds_matrix(rdkit_molecule=rdkit_molecule)

            if len(labels) > 0:

                logging.info("Editing bounds matrix")
                bm = self.edit_matrix(rmg_molecule, bm, labels, distance_data)

            logging.info("Performing triangle smoothing on bounds matrix.")
            DistanceGeometry.DoTriangleSmoothing(bm)

            logging.info("Now attempting to embed using edited bounds matrix.")

            rdkit_molecule = self.rd_embed(rdkit_molecule,
                                           10000,
                                           bm=bm,
                                           match=atom_match)[0]

        return rdkit_molecule, bm
Beispiel #3
0
 def test_load_conformer_attributes(self):
     charge = 0
     mult = 1
     label = 'CC(C)C'
     base = 'CC{C}C'
     self.orca.conformer = Conformer(smiles='CC(C)C')
     self.orca.load_conformer_attributes()
     self.assertTrue([charge,mult,label,base] == 
                     [self.orca.charge,self.orca.mult,self.orca.label,self.orca.base])
Beispiel #4
0
 def get_angles(self):
     test_conf = Conformer()
     test_conf.rmg_molecule = self.rmg_molecule
     try:
         test_conf._rdkit_molecule = self._pseudo_geometry
     except:
         self.get_rdkit_mol()
         test_conf._rdkit_molecule = self._pseudo_geometry
     test_conf._ase_molecule = self.ase_molecule
     return test_conf.get_angles()
Beispiel #5
0
    def get_rdkit_mol(self):
        """
        A method to create an rdkit geometry... slightly different than that of the conformer method
        returns both the rdkit_molecule and the bm
        """
        self.rdkit_molecule = Conformer(
            rmg_molecule=self.rmg_molecule).get_rdkit_mol()

        self.get_labels()
        for i, atom in enumerate(self.rmg_molecule.atoms):
            assert atom.number == self.rdkit_molecule.GetAtoms(
            )[i].GetAtomicNum()

        if len(self.labels) == 3:

            rd_copy = Chem.RWMol(self.rdkit_molecule.__copy__())

            lbl1, lbl2, lbl3 = self.labels

            if not rd_copy.GetBondBetweenAtoms(lbl1, lbl2):
                rd_copy.AddBond(lbl1,
                                lbl2,
                                order=rdkit.Chem.rdchem.BondType.SINGLE)
            elif not rd_copy.GetBondBetweenAtoms(lbl2, lbl3):
                rd_copy.AddBond(lbl2,
                                lbl3,
                                order=rdkit.Chem.rdchem.BondType.SINGLE)

            self._pseudo_geometry = rd_copy

        logging.info("Initially embedded molecule")

        self.bm = None

        if self.distance_data:
            logging.info("Getting bounds matrix")
            self.bm = self.get_bounds_matrix()

            if len(self.labels) > 0:
                logging.info("Editing bounds matrix")
                self.bm = self.edit_matrix()

            logging.info("Performing triangle smoothing on bounds matrix.")
            DistanceGeometry.DoTriangleSmoothing(self.bm)

            logging.info("Now attempting to embed using edited bounds matrix.")

            self.rd_embed()
        return self.rdkit_molecule
Beispiel #6
0
 def setUp(self):
     self.conformer = Conformer("NC(O)C=CC")
     self.conformer.get_molecules()
Beispiel #7
0
 def test_conformer_calc(self):
     autotst_gaussian_confomer = Gaussian(conformer=Conformer(
         smiles='CCC')).get_conformer_calc()
     calc_dict = autotst_gaussian_confomer.todict()
     self.assertIsInstance(autotst_gaussian_confomer, ASEGaussian)
     self.assertIsInstance(calc_dict, dict)
Beispiel #8
0
 def get_angles(self):
     return Conformer().get_angles(self._pseudo_geometry, self.ase_molecule)
Beispiel #9
0
 def get_bonds(self):
     return Conformer().get_bonds(self._pseudo_geometry, self.ase_molecule,
                                  self.rmg_molecule)
Beispiel #10
0
 def setUp(self):
     self.conformer = Conformer(smiles='CC')
Beispiel #11
0
 def setUp(self):
     conf = Conformer(smiles='C')
     self.orca = Orca(conformer=conf, directory=os.path.expandvars(
         "$AUTOTST/autotst/calculator/fod"))
Beispiel #12
0
 def get_torsions(self):
     test_conf = Conformer()
     test_conf.rmg_molecule = self.rmg_molecule
     test_conf.rdkit_molecule = self._pseudo_geometry
     test_conf.ase_molecule = self.ase_molecule
     return test_conf.get_torsions()
 def test_calculate_conformer(self):
     conformer = Conformer(smiles='CC', index=0)
     result = self.job.calculate_conformer(conformer=conformer)
     self.assertTrue(result)
Beispiel #14
0
 def setUp(self):
     self.conformer = Conformer("CC(C)C=CC")
     self.conformer_3rad = Conformer("[C]=[CH]")
     self.conformer_4rad = Conformer("[C]=[C]")