示例#1
0
def main():
    args = parse_args()

    # check if files exist
    if not os.path.isfile(args.infile):
	    raise Exception("File not found: {0}!".format(args.infile))
    outdir = os.path.dirname(args.outfile)
    if not os.path.exists(outdir):
	    raise Exception("Output directory not found: {0}!".format(outdir))

    # perform conversion
    try:
        print 'Performing InterMol conversion:'
        print '    From: {0}'.format(args.infile)
        print '    To: {0}'.format(args.outfile)

        name = 'system'
        Driver.initSystem(name) # what does this name do?
        Driver.load(args.infile)
        Driver.write(args.outfile)
    except:
        print 'Failed at InterMol conversion'
        sys.exit(1)

    # calc input energies
    if args.energy:
        e_in, e_infile = evaluate.desmond_energies(args.infile, args.cfgfile, args.despath)
        print 'Total energy from %s:' % e_infile
        print e_in
        e_out, e_outfile = evaluate.desmond_energies(args.outfile, args.cfgfile, args.despath)    
        print 'Total energy from %s:' % e_outfile
        print e_out
示例#2
0
def lammps_to_gromacs(name, gropath='', grosuff='', lmppath='', lmpbin='lmp_openmpi',
        energy=True, clean=True):
    """Test lammps to gromacs conversion
    """
    lmp_in = os.path.join('Inputs/Lammps/', name, 'data.lmp')
    if not os.path.isfile(lmp_in):
        raise Exception("File not found: {0}!".format(lmp_in))

    top_out = os.path.join('Outputs/LammpsToGromacs/', name, 'topol.top')
    gro_out = os.path.join('Outputs/LammpsToGromacs/', name, 'conf.gro')

    # calc input energies
    if energy:
        e_in = lammps_energies(name, 'in', lmppath, lmpbin)

    # where the magic happens
    Driver.initSystem(name)
    Driver.load(lmp_in)
    Driver.write(top_out, gro_out)

    # calc output energies
    if energy:
        e_out = gromacs_energies(name, top_out, gro_out, 'LtoG', gropath, grosuff)

    # delete gromacs backup files
    if clean:
        import glob
        filelist = glob.glob("Inputs/Gromacs/{name}/#*#".format(name=name))
        filelist += glob.glob("Outputs/GromacsToGromacs/{name}/#*#".format(name=name))
        for f in filelist:
            os.remove(f)
    if energy:
       return combine_energy_results(e_in, e_out)
示例#3
0
def lammps_to_lammps(name, lmppath='', lmpbin='lmp_openmpi', energy=True,
        verbose=False):
    """Test lammps to lammps conversion
    """

    lmp_in = os.path.join('Inputs/Lammps/', name, 'data.lmp')
    if not os.path.isfile(lmp_in):
        raise Exception("File not found: {0}!".format(lmp_in))

    lmp_out = os.path.join('Outputs/LammpsToLammps/', name, 'data.lmp')

    # calc input energies
    if energy:
        e_in = lammps_energies(name, 'in', lmppath, lmpbin, verbose)

    # where the magic happens
    Driver.initSystem(name)
    Driver.load(lmp_in)
    Driver.write(lmp_out)

    # calc output energies
    if energy:
        e_out = lammps_energies(name, 'LtoL', lmppath, lmpbin)

    if energy:
       return combine_energy_results(e_in, e_out)
示例#4
0
def gromacs_to_gromacs(name="system2_GMX", top=None, gro=None, gropath="", grosuff="", energy=True, clean=True):
    """Test gromacs to gromacs conversion
    """

    if top == None:
        top = os.path.join(name, "topol.top")

    if gro == None:
        gro = os.path.join(name, "conf.gro")

    gro_in = os.path.join("Inputs/Gromacs/", gro)
    if not os.path.isfile(gro_in):
        raise Exception("File not found: {0}!".format(gro_in))

    top_in = os.path.join("Inputs/Gromacs/", top)
    if not os.path.isfile(top_in):
        raise Exception("File not found: {0}!".format(top_in))

    top_out = os.path.join("Outputs/GromacsToGromacs/", name, "topol.top")
    gro_out = os.path.join("Outputs/GromacsToGromacs/", name, "conf.gro")

    # calc input energies
    if energy:
        e_in = gromacs_energies(name, top_in, gro_in, "in", gropath, grosuff)

    # where the magic happens
    Driver.initSystem(name)
    Driver.load(top_in, gro_in)
    Driver.write(top_out, gro_out)

    # calc output energies
    if energy:
        e_out = gromacs_energies(name, top_out, gro_out, "GtoG", gropath, grosuff)

    # delete gromacs backup files
    if clean:
        import glob

        filelist = glob.glob("Inputs/Gromacs/{name}/#*#".format(name=name))
        filelist += glob.glob("Outputs/GromacsToGromacs/{name}/#*#".format(name=name))
        for f in filelist:
            os.remove(f)
    if energy:
        return combine_energy_results(e_in, e_out)
示例#5
0
def desmond_to_desmond(name='2PPN', cms=None, despath=None,
        energy=True, clean=True):
    """Test gromacs to gromacs conversion
    """

    if cms == None:
        cms = os.path.join(name,'desmond.cms')
    cms_in = os.path.join('Inputs/Desmond/', cms)    

    if not os.path.isfile(cms_in):
	    raise Exception("File not found: {0}!".format(cms_in))
    
    cms_out = os.path.join('Outputs/DesmondToDesmond/', name, 'desmond-converted.cms')

    #calc input energies
    if energy:
        elines_in = desmond_energies(name,cms_in,'in',despath)

    Driver.initSystem(name)
    Driver.load(cms_in)
    Driver.write(cms_out)

    # calc output energies
    if energy:
        elines_out = desmond_energies(name,cms_out,'DtoD',despath)    

        #MRS: this comparison is not working yet.

        e_in  = np.zeros([len(elines_in)],float)
        e_out = np.zeros([len(elines_out)],float)
        for i, e in enumerate(elines_in):
            eins  = elines_in[i].split()
            eouts = elines_out[i].split()
            e_in[i] = float(eins[1])
            e_out[i] = float(eouts[1])
            enames.append()

        diff = e_in - e_out
        rms = np.sqrt(np.mean(diff ** 2))
        return rms, enames, e_in, e_out
    else:
        return 0,0,0,0
示例#6
0
#--- cmd line options ---
parser = OptionParser()
parser.add_option('-p', type='str', dest='top', default='system2_GMX.top',
        help="Topology .top file")
parser.add_option('-c', type='str', dest='gro', default='system2_GMX.gro',
        help="Structure .gro file")
parser.add_option('-n', type='str', dest='name', default='system',
        help="Name of system")

(options, args) = parser.parse_args()
gro = options.gro
gro_in = os.path.join('Inputs/Gromacs/', gro)
if not os.path.isfile(gro_in):
    raise Exception("File not found: {0}!".format(gro_in))

top = options.top
top_in = os.path.join('Inputs/Gromacs/', top)
if not os.path.isfile(top_in):
    raise Exception("File not found: {0}!".format(top_in))

name = options.name

cms_out = os.path.join('Outputs/GromacsToDesmond/', name + '.cms')
#--- end of options ---

Driver.initSystem(name)

Driver.load(top_in, gro_in)
Driver.write(cms_out)
示例#7
0
#             get_energy_out
#             compare energies
         
#loop over all test cases for all x_to_y combinations
#List of Desmond files to be converted
filenames = ['a2a_dppc-out', 'protein', 'Rilpivirine', 'simulated_annealing_example', 'lck_Me_Cl_complex_12_1', 'lck_Me_Cl_solvent_12_1']

#Convert Desmond files to Desmond and Gromacs
for name in filenames:
    cms_in = os.path.join('Inputs/Desmond/', name, name+ '.cms')
    if not os.path.isfile(cms_in):
        #raise Exception ("File not found: {0}!".format(cms_in))
        error.write('\n(%s) -- File not found: {0}!' %(cms_in))
        pass
    try:
        Driver.load(cms_in)
    except:
        e = sys.exc_info()
        error.write('\n(%s) -- %s--line %s' %(name, e, sys.exc_traceback.tb_lineno))
        pass

    cms_out = os.path.join('Outputs', 'DesmondToDesmond', name, name+ '_OUT.cms')
    try:
        Driver.write(cms_out)
    except:
        e = sys.exc_info()
        error.write('\n(%s) -- %s--line %s' %(name, e, sys.exc_traceback.tb_lineno))
        pass

    gro_out = os.path.join('Outputs', 'DesmondToGromacs',  name+ '_OUT.gro')
    top_out = os.path.join('Outputs', 'DesmondToGromacs',  name+ '_OUT.top')