示例#1
0
文件: e_2_xyz.py 项目: atomsos/simpy
def replicate(xyz_info, args):
    fname = args.f[0]
    nlines = xyz_info.natoms + 2
    nframe = xyzBlock(fname, nlines)

    na, nb, nc = args.nbox
    if nframe >= 0:
        for i in range(nframe + 1):
            if not xyz_info.restart:
                a = Xyz("output%05d.xyz" % i)
                b = a.parser()
                b.pbc = xyz_info.pbc
                b.step = i
                toPdb(b, "output%05d.pdb" % i)
            # replicate the box using external code (genconf in Gromacs)
            subprocess.Popen([
                "gmx", "genconf", "-f",
                "output%05d.pdb" % i, "-o",
                "s_%05d.pdb" % i, "-nbox",
                "%d" % na,
                "%d" % nb,
                "%d" % nc
            ],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
    subprocess.Popen(["cat s_*.pdb > movie_%d_%d_%d.pdb" % (na, nb, nc)],
                     shell=True)
    # clear up
    o = open("clear.sh", "w")
    o.write("rm output*.xyz\n")
    o.write("rm output*.pdb\n")
    o.write("rm s_*.pdb\n")
    o.close()
    st = os.stat('clear.sh')
    os.chmod('clear.sh', st.st_mode | stat.S_IEXEC)
示例#2
0
文件: e_2_xyz.py 项目: atomsos/simpy
def main(args):
    xyz_info = XyzInfo()

    if args.f:
        fname = args.f[0]
    else:
        fname = "movie.xyz"
        sys.stderr.write("Using default xyz file: movie.xyz\n")

    if args.c:
        a = Xyz(fname)
        b = a.parser()
        if args.pbc:
            b.pbc = args.pbc
        else:
            b.pbc = [20, 20, 23, 90, 90, 90]
        toPdb(b)

    if args.s:
        config = ConfigParser.ConfigParser()
        config.read(args.s[0])
        read_info(xyz_info, config)

    if args.nbox:
        if not args.s:
            sys.stderr.write("No configure file found!\n")
            sys.stderr.write("Prepare a sample configure file (test.ini)\n")
            write_config()
            sys.exit()
        else:
            replicate(xyz_info, args)
示例#3
0
def replicate(xyz_info, args):
    fname = args.f[0]
    nlines = xyz_info.natoms + 2
    nframe = xyzBlock(fname, nlines)

    na, nb, nc = args.nbox
    if nframe >= 0:
        for i in range(nframe+1):
            if not xyz_info.restart:
                a = Xyz("output%05d.xyz"%i)
                b = a.parser()
                b.pbc = xyz_info.pbc
                b.step = i
                toPdb(b, "output%05d.pdb"%i)
            # replicate the box using external code (genconf in Gromacs)
            subprocess.Popen(["genconf", "-f", "output%05d.pdb"%i, 
                              "-o", "s_%05d.pdb"%i, "-nbox",
                                "%d"%na, "%d"%nb, "%d"%nc],
                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    subprocess.Popen(["cat s_*.pdb > movie_%d_%d_%d.pdb"%(na, nb, nc)],
                     shell=True)
    # clear up
    o = open("clear.sh", "w")
    o.write("rm output*.xyz\n")
    o.write("rm output*.pdb\n")
    o.write("rm s_*.pdb\n")
    o.close()
    st = os.stat('clear.sh')
    os.chmod('clear.sh', st.st_mode | stat.S_IEXEC)
示例#4
0
def main(args):
    xyz_info = XyzInfo()

    if args.f:
        fname = args.f[0]
    else:
        fname = "movie.xyz"
        sys.stderr.write("Using default xyz file: movie.xyz\n")

    if args.c:
	a = Xyz(fname)
        b = a.parser()
        b.pbc = [100, 100, 100, 90, 90, 90]
        toPdb(b)

    if args.s:
        config = ConfigParser.ConfigParser() 
        config.read(args.s[0])
        read_info(xyz_info, config)

    if args.nbox:
        if not args.s:
            sys.stderr.write("No configure file found!\n")
            sys.stderr.write("Prepare a sample configure file (test.ini)\n")
            write_config()
            sys.exit()
        else:
            replicate(xyz_info, args)
示例#5
0
""" read the geo file and output to data (LAMMPS), geo and xyz file.
"""
from mytype import System, Molecule, Atom
from xyz import Xyz
from output_conf import toDump
from block import xyzBlock

nframe = xyzBlock("movie.xyz", 194)

if nframe > 1:
    for i in range(nframe):
        a = Xyz("output%05d.xyz"%i)
        b = a.parser()
        b.pbc = [10.739, 11.747, 13.083, 90.00, 95.77, 90.00] 
        b.step = i
        toDump(b, "output%05d.dump"%i)
    o = open("total.dump", "w")
    for i in range(nframe):
        f = open("output%05d.dump"%i, "r")
        for j in f:
            o.write(j)
        f.close()
    o.close()
        
"""
testfile = "out.pdb"
a = Pdb(testfile)
b = a.parser()
toDump(b)
"""