#calculate average structure from a trajectory, use conformations with high secondary structure content ifbox = 0 # if the trajectory file contain box information begin = 1 # from begin_th snap (included) end = 2 # to end_the snap (included) interval = 1 # do calculation on every interval steps fstr_out = "output" # output file to store your result fstr_pdb = "sample.pdb" # specify a PDB file trajlist = ["sample.traj"] # the trajectory file(s) import sys '''initialize a PDB instance, and count snapshot volume information''' from tom import PDB pdb = PDB(fstr_pdb) natoms = pdb.numberOfAtoms() nl,size_snap = pdb.numberOfLinesInSnap(ifbox) fout = open(fstr_out,"w") import Numeric as N crd = N.zeros((natoms*3,),N.Float) from tom import DSSP snaplist = [] for traj in trajlist: '''open trajectory file, skip the first line and the unwanted snaps''' trajin = open(traj) print "\nopen %s" %traj trajin.readline() trajin.read((begin-1)*size_snap) sys.stdout.write(".................................. % 0") for snap in range(begin,end+1,interval): sys.stdout.write("\b\b\b\b%4.1f" %(float(snap)/end*100)) sys.stdout.flush() trajin.read((interval-1)*size_snap) #skip unwanted (interval) snapshots crdstr = trajin.read(size_snap).replace('\n','') if(crdstr == ''): trajin.close() print crdstr break pdb.newpdb(crdstr) dssp = DSSP("outpdb").secArray for i in range(0,len(dssp)): fout.write("%d\t%d\t%s\n" %(snap,i+1,dssp[i])) sys.stdout.write('\n') fout.close()