2013-06-10 22:59:55 +08:00
|
|
|
#!/usr/bin/env python
|
2008-04-01 06:28:11 +08:00
|
|
|
|
|
|
|
# Script: dump2pdb.py
|
|
|
|
# Purpose: convert a LAMMPS dump file to PDB format
|
2008-04-01 06:39:55 +08:00
|
|
|
# Syntax: dump2pdb.py dumpfile Nid Ntype Nx Ny Nz pdbfile template
|
2008-04-01 06:28:11 +08:00
|
|
|
# dumpfile = LAMMPS dump file in native LAMMPS format
|
|
|
|
# Nid,Ntype,Nx,Ny,Nz = columns #s for ID,type,x,y,z
|
|
|
|
# (usually 1,2,3,4,5)
|
|
|
|
# pdbfile = new PDB file
|
2008-04-01 06:39:55 +08:00
|
|
|
# template = PDB file to use as template for creating new PDB file
|
|
|
|
# this arg is optional, if not used a generic PDB file is created
|
2008-04-01 06:28:11 +08:00
|
|
|
# Author: Steve Plimpton (Sandia), sjplimp at sandia.gov
|
|
|
|
|
|
|
|
import sys,os
|
|
|
|
path = os.environ["LAMMPS_PYTHON_TOOLS"]
|
|
|
|
sys.path.append(path)
|
|
|
|
from dump import dump
|
|
|
|
from pdbfile import pdbfile
|
|
|
|
|
2008-04-01 06:39:55 +08:00
|
|
|
if len(sys.argv) != 8 and len(sys.argv) != 9:
|
|
|
|
raise StandardError, "Syntax: dump2pdb.py dumpfile Nid Ntype Nx Ny Nz pdbfile template"
|
2008-04-01 06:28:11 +08:00
|
|
|
|
|
|
|
dumpfile = sys.argv[1]
|
|
|
|
nid = int(sys.argv[2])
|
|
|
|
ntype = int(sys.argv[3])
|
|
|
|
nx = int(sys.argv[4])
|
|
|
|
ny = int(sys.argv[5])
|
|
|
|
nz = int(sys.argv[6])
|
|
|
|
pfile = sys.argv[7]
|
2008-04-01 06:39:55 +08:00
|
|
|
if len(sys.argv) == 9: template = sys.argv[8]
|
|
|
|
else: template = ""
|
2008-04-01 06:28:11 +08:00
|
|
|
|
|
|
|
d = dump(dumpfile)
|
|
|
|
d.map(nid,"id",ntype,"type",nx,"x",ny,"y",nz,"z")
|
2008-04-01 06:39:55 +08:00
|
|
|
if template: p = pdbfile(template,d)
|
|
|
|
else: p = pdbfile(d)
|
2008-04-01 06:28:11 +08:00
|
|
|
p.one(pfile)
|