Example #1
0
def main():
    parser = argparse.ArgumentParser(description="Convert a pele database for an angle-axis system into PATHSAMPLE format. The following types of system are currently implemented: 'tetrahedron','otp'")

    parser.add_argument("database", type=str, help="Database file name")
    parser.add_argument("system", type=str, help="System name")
    parser.add_argument("nmol", type=int, help="Number of rigid molecules in the system")

    args = parser.parse_args()

    db = Database(db=args.database, createdb=False)

    if args.system=="tetrahedron":
        import playground
        system = playground.plate_folding.geometric_folding.PlateFolder(args.nmol)
    elif args.system=="otp":
        from pele.pele.angleaxis._otp_cluster import OTPCluster
        system = OTPCluster(args.nmol)
    elif args.system=="tip4p":
        import playground
        system = playground.gmin_tip4p.tip4p_system.TIP4pSystem()
    else:
        raise AttributeError("Unknown system type specified.")

    topology = system.aatopology
    writer = WritePathsampleDB(db,coordsconverter=topology.to_atomistic)
    writer.write_db()
    def test1(self):
        current_dir = os.path.dirname(__file__)
        db = Database()
        converter = OptimDBConverter(
            db,
            mindata=os.path.join(current_dir, "min.data"),
            tsdata=os.path.join(current_dir, "ts.data"),
            pointsmin=os.path.join(current_dir, "points.min"),
            pointsts=os.path.join(current_dir, "points.ts"),
            endianness="<")

        converter.convert()

        mdata = tempfile.NamedTemporaryFile(delete=True)
        tsdata = tempfile.NamedTemporaryFile(delete=True)
        pm = tempfile.NamedTemporaryFile(delete=True)
        pts = tempfile.NamedTemporaryFile(delete=True)
        print mdata.name, tsdata.name
        writer = WritePathsampleDB(db,
                                   mindata=mdata.name,
                                   tsdata=tsdata.name,
                                   pointsmin=pm.name,
                                   pointsts=pts.name,
                                   endianness="<")

        writer.write_db()

        d1 = np.genfromtxt(os.path.join(current_dir, "min.data"))[:, :3]
        d2 = np.genfromtxt(mdata.name)[:, :3]
        _base_test.assert_arrays_almost_equal(self, d1, d2)

        d1 = np.genfromtxt(os.path.join(current_dir,
                                        "ts.data")).reshape(-1, 8)[:, :5]
        d2 = np.genfromtxt(tsdata.name).reshape(-1, 8)[:, :5]
        print d1, d2
        _base_test.assert_arrays_almost_equal(self, d1, d2)

        self.assertEqual(sha1_of_file(os.path.join(current_dir, "points.min")),
                         sha1_of_file(pm.name))
        self.assertEqual(sha1_of_file(os.path.join(current_dir, "points.ts")),
                         sha1_of_file(pts.name))
    def test2(self):
        from pele.utils.tests.test_disconnectivity_graph import create_random_database

        db = create_random_database(nmin=20, nts=15)

        delete = False
        mdata = tempfile.NamedTemporaryFile(delete=delete, suffix=".min.data")
        tsdata = tempfile.NamedTemporaryFile(delete=delete, suffix=".ts.data")
        pm = tempfile.NamedTemporaryFile(delete=delete)
        pts = tempfile.NamedTemporaryFile(delete=delete)
        print mdata.name, tsdata.name
        writer = WritePathsampleDB(db,
                                   mindata=mdata.name,
                                   tsdata=tsdata.name,
                                   pointsmin=pm.name,
                                   pointsts=pts.name,
                                   endianness="<")

        writer.write_db()

        newdb = Database()
        reader = OptimDBConverter(newdb,
                                  mindata=mdata.name,
                                  tsdata=tsdata.name,
                                  pointsmin=pm.name,
                                  pointsts=pts.name,
                                  endianness="<")
        reader.convert()

        for m1, m2 in izip(db.minima(), newdb.minima()):
            self.assertAlmostEqual(m1.energy, m2.energy)
            _base_test.assert_arrays_almost_equal(self, m1.coords, m2.coords)

        for ts1, ts2 in izip(db.transition_states(),
                             newdb.transition_states()):
            self.assertAlmostEqual(ts1.energy, ts2.energy)
            _base_test.assert_arrays_almost_equal(self, ts1.coords, ts2.coords)
            self.assertAlmostEqual(ts1.minimum1.energy, ts2.minimum1.energy)
            self.assertAlmostEqual(ts1.minimum2.energy, ts2.minimum2.energy)
 def test1(self):
     current_dir = os.path.dirname(__file__)
     db = Database()
     converter = OptimDBConverter(db, 
                                  mindata=os.path.join(current_dir, "min.data"),
                                  tsdata=os.path.join(current_dir, "ts.data"),
                                  pointsmin=os.path.join(current_dir, "points.min"),
                                  pointsts=os.path.join(current_dir, "points.ts"),
                                  endianness="<")
     
     converter.convert()
     
     mdata = tempfile.NamedTemporaryFile(delete=True)
     tsdata = tempfile.NamedTemporaryFile(delete=True)
     pm = tempfile.NamedTemporaryFile(delete=True)
     pts = tempfile.NamedTemporaryFile(delete=True)
     print(mdata.name, tsdata.name)
     writer = WritePathsampleDB(db,
                                mindata=mdata.name,
                                tsdata=tsdata.name,
                                pointsmin=pm.name,
                                pointsts=pts.name,
                                endianness="<")
     
     writer.write_db()
     
     d1 = np.genfromtxt(os.path.join(current_dir, "min.data"))[:,:3]
     d2 = np.genfromtxt(mdata.name)[:,:3]
     _base_test.assert_arrays_almost_equal(self, d1, d2)
     
     d1 = np.genfromtxt(os.path.join(current_dir, "ts.data")).reshape(-1,8)[:,:5]
     d2 = np.genfromtxt(tsdata.name).reshape(-1,8)[:,:5]
     print(d1, d2)
     _base_test.assert_arrays_almost_equal(self, d1, d2)
     
     self.assertEqual(sha1_of_file(os.path.join(current_dir, "points.min")),
                      sha1_of_file(pm.name))
     self.assertEqual(sha1_of_file(os.path.join(current_dir, "points.ts")),
                      sha1_of_file(pts.name))
 def test2(self):
     from pele.utils.tests.test_disconnectivity_graph import create_random_database
     
     db = create_random_database(nmin=20, nts=15)
     
     delete=False
     mdata = tempfile.NamedTemporaryFile(delete=delete, suffix=".min.data")
     tsdata = tempfile.NamedTemporaryFile(delete=delete, suffix=".ts.data")
     pm = tempfile.NamedTemporaryFile(delete=delete)
     pts = tempfile.NamedTemporaryFile(delete=delete)
     print(mdata.name, tsdata.name)
     writer = WritePathsampleDB(db,
                                mindata=mdata.name,
                                tsdata=tsdata.name,
                                pointsmin=pm.name,
                                pointsts=pts.name,
                                endianness="<")
     
     writer.write_db()
     
     newdb = Database()
     reader = OptimDBConverter(newdb,
                               mindata=mdata.name,
                               tsdata=tsdata.name,
                               pointsmin=pm.name,
                               pointsts=pts.name,
                               endianness="<")
     reader.convert()
     
     for m1, m2 in zip(db.minima(), newdb.minima()):
         self.assertAlmostEqual(m1.energy, m2.energy)
         _base_test.assert_arrays_almost_equal(self, m1.coords, m2.coords)
     
     for ts1, ts2 in zip(db.transition_states(), newdb.transition_states()):
         self.assertAlmostEqual(ts1.energy, ts2.energy)
         _base_test.assert_arrays_almost_equal(self, ts1.coords, ts2.coords)
         self.assertAlmostEqual(ts1.minimum1.energy, ts2.minimum1.energy)
         self.assertAlmostEqual(ts1.minimum2.energy, ts2.minimum2.energy)
Example #6
0
def write_pathsample_db(db, write_points=True):
    writer = WritePathsampleDB(db, write_points=write_points)
    writer.write_db()
Example #7
0
def write_pathsample_db(db):
    writer = WritePathsampleDB(db)
    writer.write_db()
Example #8
0
def write_pathsample_db(db):
    writer = WritePathsampleDB(db)
    writer.write_db()