コード例 #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)