Path2xyz.py

From Docswiki
Revision as of 11:07, 13 May 2019 by Adk44 (talk | contribs) (Created page with "Script useful for AMBER9 and NAB users ''path.info'' file can be converted to xyz format using Python program presented below. To do this save the code in ''path2xyz.py'' fi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Script useful for AMBER9 and NAB users


path.info file can be converted to xyz format using Python program presented below. To do this save the code in path2xyz.py file, change privileges of the file:

chmod 755 path2xyz.py

and type:

./path2xyz.py





#!/usr/bin/env python

import sys
import string

###############################################################
##                                                            #
## Edyta Malolepsza                                           #
## David Wales' group, University of Cambridge                #
## in case of problems please send email: em427@cam.ac.uk     #
##                                                            #
###############################################################
##
## transform path.info into path_all.xyz
## ./path2xyz.py
##
###############################################################

prmtop = open("coords.prmtop").read()
f = string.split(prmtop, "\n")

q0 = f.index("%FLAG POINTERS                                                                  ")
q1 = f.index("%FLAG ATOM_NAME                                                                 ")
q2 = f.index("%FLAG RESIDUE_LABEL                                                             ")
q3 = f.index("%FLAG RESIDUE_POINTER                                                           ")

## names of tables are related to names in prmtop file

atomNumber = int(string.split(f[q0+2])[0])

atomName = []
residueLabel = []

an = 0
line = 0
while (an<atomNumber):
  for j in range(20):
    if (an<atomNumber):
      an = an+1
      atomName.append(f[q1+2+line][j*4:(j+1)*4].strip())
    else:
      break
  line = line+1

for i in range(q3-q2-2):
  for j in range((len(f[q2+2+i])+1)/4):
    residueLabel.append(string.strip(f[q2+2+i][j*4:4*(j+1)]))

info = open("path.info").read()
ff = string.split(info, "\n")

xyz = open('path_all.xyz','w')

for i in range(len(ff)/(2+2*atomNumber)):
    m = atomNumber*2+2     # number of lines for each stationary points
    l = atomNumber+2       # number of lines before coordinates
#    xyz.write("%d\n%s %s\n" % (atomNumber, ff[m*i], ff[m*i+1])) # energy and symmetry
    xyz.write("%d\n%s\n" % (atomNumber, ff[m*i])) # energy
    for j in range(atomNumber):
        xyz.write("%-4s %s\n" % (atomName[j], ff[m*i+l+j]))

xyz.write("\n")
xyz.close()


Note: this script works when path.info file was obtain without NOFRQS keyword. If NOFRQS was used, please, change values of two variables:

    m = atomNumber+2     # number of lines for each stationary points
    l = 2                # number of lines before coordinates