Esempio n. 1
0
def _to_fml(ds,nmol,sublist):
    """Returns a list of nmol fml.Molecule objects.

    * ds      :: dataset objects
    * nmol    :: number of molecules
    * sublist :: list of indices of molecules to be converted to
                 ase Atoms object.

    """

    list_of_mol=[]

    if nmol==None:
      nmol=ds.nmol

    if sublist==None:
      sublist=ds.list_of_mol[:nmol]
    else:
      sublist=np.array(ds.list_of_mol)[sublist]


    for m in sublist:
        fmlm=fml.Molecule()

        fmlm.natoms=m.natm
        fmlm.atomtypes=m.symb
        fmlm.nuclear_charges=m.z
        fmlm.coordinates=m.R

        list_of_mol.append(fmlm)

    return list_of_mol
Esempio n. 2
0
def create_mols(args):
    t = time.time()
    filenames = args.input
    all_coordinates = []
    if len(filenames) == 1:
        # trajectory
        with open(filenames[0]) as f:
            lines = f.readlines()
            charges, atom_names, residues, coordinates, remaining_lines = parse_first_frame(
                lines)
            all_coordinates = parse_trajectory(remaining_lines)
            all_coordinates = [coordinates] + all_coordinates
    else:
        with open(filenames[0]) as f:
            lines = f.readlines()
        charges, atom_names, residues, coordinates, _ = parse_first_frame(
            lines)
        all_coordinates.append(coordinates)
        for filename in filenames[1:]:
            with open(filename) as f:
                lines = f.readlines()
            all_coordinates.append(parse_frame(lines))
    atomtypes = np.asarray([charge_to_atype[charge] for charge in charges])
    print "Parsed input in %.1f seconds" % (time.time() - t)

    # check if some of the structures have the same coordinates
    #for i, coord_i in enumerate(all_coordinates):
    #    for j, coord_j in enumerate(all_coordinates):
    #        if j <= i:
    #            continue
    #        if np.allclose(coord_i[:50], coord_j[:50]):
    #            print filenames[i], filenames[j]

    t = time.time()
    mols = np.empty(len(all_coordinates), dtype=object)
    for i in range(mols.size):
        mol = fml.Molecule()
        mol.natoms = charges.size
        mol.atomtypes = atomtypes
        mol.atomnames = atom_names
        mol.nuclear_charges = charges
        mol.coordinates = all_coordinates[i]
        mol.residues = residues
        generate_descriptor(mol, args)
        mols[i] = mol
    print "Generated descriptors in %.1f seconds" % (time.time() - t)
    return mols
Esempio n. 3
0
from fml.math.distance import get_l2_distance_arad
from fml.kernels import get_atomic_kernels_arad

if __name__ == "__main__":

    # Get list of xyzfilenames
    path = "../tests/xyz/"
    filenames = os.listdir(path)

    mols = []

    # Make list of fml.Molecule()
    for filename in filenames:

        # Initialize molecule
        mol = fml.Molecule()

        # Read coordinates etc from xyz file
        mol.read_xyz(path + filename)

        # Generate ARAD descriptor, size = max size of molecule
        mol.generate_arad_descriptor(size=20)

        # Add mols to list
        mols.append(mol)

    x1 = []
    z1 = []

    # Make list of molecules
    for mol in mols[:5]:
Esempio n. 4
0
                                acti, actj, nacti, nactj, actmax, sigma_space,
                                pd, r_width, c_width)

    # K = np.swapaxes(K,0,5)
    # K = np.swapaxes(K,1,4)
    # K = np.swapaxes(K,2,3)
    # K = np.swapaxes(K,4,5)

    return K


if __name__ == "__main__":

    import sys

    moli = fml.Molecule()
    molj = fml.Molecule()

    moli.read_xyz(sys.argv[1])
    molj.read_xyz(sys.argv[2])

    K = pyforce_kernel(moli, molj, 0.5)

    # # L = fsingle_force_kernel(moli.coordinates, molj.coordinates, moli.natoms, molj.natoms, 0.5, 0.6)

    L = single_force_kernel(moli, molj, 0.5)
    print L
    # print "K"
    # print K

    mols = [moli, molj]