def main(): ## trjconv -f 2LZM_wt.trr -o 2LZM_wt_trjconv.pdb -s 2LZM_wt_MD.tpr -skip 10 -sep fd = open('2lzm.pdb', 'r') lines1 = fd.readlines() fd.close() lines2 = [] for line in lines1: record = line[:6].strip() if record in [ 'HELIX', 'TURN', 'SHEET', ]: lines2 += [line] for i in range(50): fd = open('%i.pdb' % (i), 'r') lines = fd.readlines() fd.close() lines = lines2 + lines fd = open('nma%i.pdb' % (i), 'w') fd.writelines(lines) fd.close() stop import sys, os, numpy sys.path.append('/home/people/tc/svn/tc_sandbox/quakes/') import phipsi_comparison sys.path.append('/home/people/tc/svn/tc_sandbox/misc/') import phipsi_plot sys.path.append('/home/people/tc/svn/Protool/') import geometry instance_geometry = geometry.geometry() d_residues = { 'ALA': 'A', 'CYS': 'C', 'ASP': 'D', 'GLU': 'E', 'PHE': 'F', 'GLY': 'G', 'HIS': 'H', 'ILE': 'I', 'LYS': 'K', 'LEU': 'L', 'MET': 'M', 'ASN': 'N', 'PRO': 'P', 'GLN': 'Q', 'ARG': 'R', 'SER': 'S', 'THR': 'T', 'VAL': 'V', 'TRP': 'W', 'TYR': 'Y', } d_max = {} d_ramachandran = {} for res in d_residues.values(): d_ramachandran[res] = {} for phi in range(-180, 180): d_ramachandran[res][phi] = {} for psi in range(-180, 180): d_ramachandran[res][phi][psi] = 0 d_ramachandran = phipsi_comparison.parse_dihedrals(d_residues) ## slow ## d_ramachandran[res][phi][psi] = 1 for res in d_ramachandran.keys(): max = 0 for phi in d_ramachandran[res].keys(): for psi in d_ramachandran[res][phi].keys(): count = d_ramachandran[res][phi][psi] if count > max: max = count d_max[res] = max option = 'gromacs' option = 'pdbs' if option == 'frames': l = range(50) elif option == 'pdbs': l = [ '150l', ] chain = 'D' elif option == 'gromacs': l = [] for i in range(101): l += ['2LZM_wt_trjconv_%i' % (i)] chain = ' ' fd = open('2LZM_wt_trjconv_0.pdb', 'r') lines = fd.readlines() fd.close() l_coords_ref = [] for line in lines: record = line[:6].strip() if record == 'ATOM': atom_name = line[12:16].strip() if atom_name == 'CA': x = float(line[30:38]) y = float(line[38:46]) z = float(line[46:54]) coord = numpy.array([ x, y, z, ]) l_coords_ref += [coord] d_transformations = {} for pdb in l: if pdb == '2LZM_wt_trjconv_0.pdb': continue fd = open('%s.pdb' % (pdb), 'r') lines = fd.readlines() fd.close() l_coords = [] for line in lines: record = line[:6].strip() if record == 'ATOM': atom_name = line[12:16].strip() if atom_name == 'CA' and line[21] == chain: x = float(line[30:38]) y = float(line[38:46]) z = float(line[46:54]) coord = numpy.array([ x, y, z, ]) l_coords += [coord] l_coords_ref = l_coords_ref[:len(l_coords)] rmsd = instance_geometry.superpose(l_coords_ref, l_coords) tv1 = instance_geometry.fitcenter rm = instance_geometry.rotation tv2 = instance_geometry.refcenter d_transformations[pdb] = [ tv1, rm, tv2, ] for pdb in l: print pdb if option == 'gromacs': ## i = int(pdb[pdb.rindex('_')+1:]) prefix = 'rasmol%s' % (i) else: prefix = 'rasmol%s' % (pdb) lines_rotated = [] ## write rasmol script lines_rasmol = [ 'rasmol -nodisplay %s_rotated.pdb << EOF\n' % (pdb), 'cartoon\n', 'wireframe 0\n', ] d_phipsi, lines_gnuplot = phipsi_plot.calculate_phipsi(pdb, chain=chain) fd = open('%s.pdb' % (pdb)) lines1 = fd.readlines() fd.close() for line1 in lines1: record = line1[:6].strip() if record in [ 'HELIX', 'TURN', 'SHEET', ]: lines_rotated += [line1] if record != 'ATOM': continue if line1[21] != chain: continue atom_name = line1[12:16].strip() ## if atom_name != 'CA': ## continue if atom_name not in [ 'N', 'CA', 'C', 'O', ]: continue bfactor = float(line1[60:66]) res_no = int(line1[22:26]) res_name = line1[17:20].strip() if res_no not in d_phipsi.keys(): bfactor = 50. continue else: phi = int(d_phipsi[res_no][0]) psi = int(d_phipsi[res_no][1]) if phi == 180.: phi = -180. if psi == 180.: psi = -180. bfactor = (100 * d_ramachandran[d_residues[res_name]][phi][psi] / float(d_max[d_residues[res_name]])) x = float(line1[30:38]) y = float(line1[38:46]) z = float(line1[46:54]) coordinate = numpy.array([ x, y, z, ]) if pdb != '2LZM_wt_trjconv_0': tv1 = d_transformations[pdb][0] rm = d_transformations[pdb][1] tv2 = d_transformations[pdb][2] coordinate = numpy.dot(coordinate - tv1, rm) + tv2 lines_rotated += [ '%s%8.3f%8.3f%8.3f%s%6.2f%s' % (line1[:30], coordinate[0], coordinate[1], coordinate[2], line1[54:60], bfactor, line1[66:]) ] h = 159. + 80 * bfactor / 100. s = 240. l = 120. + 120. * (50 - abs(bfactor - 50)) / 50. r, g, b = hsl2rgb( h, s, l, ) lines_rasmol += [ 'select %i\n' % (res_no), 'color [%i,%i,%i]\n' % ( r, g, b, ) ] fd = open('%s_rotated.pdb' % (pdb), 'w') fd.writelines(lines_rotated) fd.close() lines_rasmol += [ ## 'ribbons\n', 'rotate x 100\n', 'rotate z 30\n', 'rotate x 100\n', 'rotate z 90\n', 'rotate x 40\n', 'rotate y -20\n', 'write %s.ppm\n' % (prefix), 'exit\n', ] ## write rasmol script to file fd = open('%srasmol.src' % (prefix), 'w') fd.writelines(lines_rasmol) fd.close() ## execute rasmol script os.system('source %srasmol.src > %srasmol.log' % (prefix, prefix)) ## convert rasmol output ## os.system('convert %s.ppm -resize x80 %s.gif' %(prefix,prefix)) os.system('convert %s.ppm %s.gif' % (prefix, prefix)) ## clean up os.remove('%s.ppm' % (prefix)) os.remove('%srasmol.log' % (prefix)) os.remove('%srasmol.src' % (prefix)) ## os.remove('frame%s.pdb' %(str(i).zfill(2))) if option == 'gromacs': line = 'convert ' for i in range(101): ## 0 to 100 line += 'rasmol%s.gif ' % (i) for i in range(101 - 1 - 1, -1 + 1, -1): ## 99 to 1 line += 'rasmol%s.gif ' % (i) line += '-loop 0 2lzm_MD.gif' print line os.system(line) ## for frame in range(50): ## os.remove('rasmol%s.gif' %(i)) return
def main(): ## trjconv -f 2LZM_wt.trr -o 2LZM_wt_trjconv.pdb -s 2LZM_wt_MD.tpr -skip 10 -sep fd = open('2lzm.pdb','r') lines1 = fd.readlines() fd.close() lines2 = [] for line in lines1: record = line[:6].strip() if record in ['HELIX','TURN','SHEET',]: lines2 += [line] for i in range(50): fd = open('%i.pdb' %(i),'r') lines = fd.readlines() fd.close() lines = lines2+lines fd = open('nma%i.pdb' %(i),'w') fd.writelines(lines) fd.close() stop import sys, os, numpy sys.path.append('/home/people/tc/svn/tc_sandbox/quakes/') import phipsi_comparison sys.path.append('/home/people/tc/svn/tc_sandbox/misc/') import phipsi_plot sys.path.append('/home/people/tc/svn/Protool/') import geometry instance_geometry = geometry.geometry() d_residues = { 'ALA':'A','CYS':'C','ASP':'D','GLU':'E','PHE':'F', 'GLY':'G','HIS':'H','ILE':'I','LYS':'K','LEU':'L', 'MET':'M','ASN':'N','PRO':'P','GLN':'Q','ARG':'R', 'SER':'S','THR':'T','VAL':'V','TRP':'W','TYR':'Y', } d_max = {} d_ramachandran = {} for res in d_residues.values(): d_ramachandran[res] = {} for phi in range(-180,180): d_ramachandran[res][phi] = {} for psi in range(-180,180): d_ramachandran[res][phi][psi] = 0 d_ramachandran = phipsi_comparison.parse_dihedrals(d_residues) ## slow ## d_ramachandran[res][phi][psi] = 1 for res in d_ramachandran.keys(): max = 0 for phi in d_ramachandran[res].keys(): for psi in d_ramachandran[res][phi].keys(): count = d_ramachandran[res][phi][psi] if count > max: max = count d_max[res] = max option = 'gromacs' option = 'pdbs' if option == 'frames': l = range(50) elif option == 'pdbs': l = ['150l',] chain = 'D' elif option == 'gromacs': l = [] for i in range(101): l += ['2LZM_wt_trjconv_%i' %(i)] chain = ' ' fd = open('2LZM_wt_trjconv_0.pdb','r') lines = fd.readlines() fd.close() l_coords_ref = [] for line in lines: record = line[:6].strip() if record == 'ATOM': atom_name = line[12:16].strip() if atom_name == 'CA': x = float(line[30:38]) y = float(line[38:46]) z = float(line[46:54]) coord = numpy.array([x,y,z,]) l_coords_ref += [coord] d_transformations = {} for pdb in l: if pdb == '2LZM_wt_trjconv_0.pdb': continue fd = open('%s.pdb' %(pdb),'r') lines = fd.readlines() fd.close() l_coords = [] for line in lines: record = line[:6].strip() if record == 'ATOM': atom_name = line[12:16].strip() if atom_name == 'CA' and line[21] == chain: x = float(line[30:38]) y = float(line[38:46]) z = float(line[46:54]) coord = numpy.array([x,y,z,]) l_coords += [coord] l_coords_ref = l_coords_ref[:len(l_coords)] rmsd = instance_geometry.superpose(l_coords_ref,l_coords) tv1 = instance_geometry.fitcenter rm = instance_geometry.rotation tv2 = instance_geometry.refcenter d_transformations[pdb] = [tv1,rm,tv2,] for pdb in l: print pdb if option == 'gromacs': ## i = int(pdb[pdb.rindex('_')+1:]) prefix = 'rasmol%s' %(i) else: prefix = 'rasmol%s' %(pdb) lines_rotated = [] ## write rasmol script lines_rasmol = [ 'rasmol -nodisplay %s_rotated.pdb << EOF\n' %(pdb), 'cartoon\n', 'wireframe 0\n', ] d_phipsi, lines_gnuplot = phipsi_plot.calculate_phipsi(pdb, chain = chain) fd = open('%s.pdb' %(pdb)) lines1 = fd.readlines() fd.close() for line1 in lines1: record = line1[:6].strip() if record in ['HELIX','TURN','SHEET',]: lines_rotated += [line1] if record != 'ATOM': continue if line1[21] != chain: continue atom_name = line1[12:16].strip() ## if atom_name != 'CA': ## continue if atom_name not in ['N','CA','C','O',]: continue bfactor = float(line1[60:66]) res_no = int(line1[22:26]) res_name = line1[17:20].strip() if res_no not in d_phipsi.keys(): bfactor = 50. continue else: phi = int(d_phipsi[res_no][0]) psi = int(d_phipsi[res_no][1]) if phi == 180.: phi = -180. if psi == 180.: psi = -180. bfactor = ( 100 *d_ramachandran[d_residues[res_name]][phi][psi] /float(d_max[d_residues[res_name]]) ) x = float(line1[30:38]) y = float(line1[38:46]) z = float(line1[46:54]) coordinate = numpy.array([x,y,z,]) if pdb != '2LZM_wt_trjconv_0': tv1 = d_transformations[pdb][0] rm = d_transformations[pdb][1] tv2 = d_transformations[pdb][2] coordinate = numpy.dot(coordinate-tv1,rm)+tv2 lines_rotated += ['%s%8.3f%8.3f%8.3f%s%6.2f%s' %( line1[:30], coordinate[0],coordinate[1],coordinate[2], line1[54:60],bfactor,line1[66:] )] h = 159.+80*bfactor/100. s = 240. l = 120.+120.*(50-abs(bfactor-50))/50. r,g,b = hsl2rgb(h,s,l,) lines_rasmol += [ 'select %i\n' %(res_no), 'color [%i,%i,%i]\n' %( r, g, b, ) ] fd = open('%s_rotated.pdb' %(pdb),'w') fd.writelines(lines_rotated) fd.close() lines_rasmol += [ ## 'ribbons\n', 'rotate x 100\n', 'rotate z 30\n', 'rotate x 100\n', 'rotate z 90\n', 'rotate x 40\n', 'rotate y -20\n', 'write %s.ppm\n' %(prefix), 'exit\n', ] ## write rasmol script to file fd = open('%srasmol.src' %(prefix),'w') fd.writelines(lines_rasmol) fd.close() ## execute rasmol script os.system('source %srasmol.src > %srasmol.log' %(prefix,prefix)) ## convert rasmol output ## os.system('convert %s.ppm -resize x80 %s.gif' %(prefix,prefix)) os.system('convert %s.ppm %s.gif' %(prefix,prefix)) ## clean up os.remove('%s.ppm' %(prefix)) os.remove('%srasmol.log' %(prefix)) os.remove('%srasmol.src' %(prefix)) ## os.remove('frame%s.pdb' %(str(i).zfill(2))) if option == 'gromacs': line = 'convert ' for i in range(101): ## 0 to 100 line += 'rasmol%s.gif ' %(i) for i in range(101-1-1,-1+1,-1): ## 99 to 1 line += 'rasmol%s.gif ' %(i) line += '-loop 0 2lzm_MD.gif' print line os.system(line) ## for frame in range(50): ## os.remove('rasmol%s.gif' %(i)) return
def morph( self, eigenvectors_all_modes, nframes, chains, d_coordinates, atoms_hessian, matrix_hessian, job, ): '''This function puts in frames between the maximum amplitudes of a movement given by eigenvectors. The values of the diagonal elements of the hessian matrix are used for B factors to make coloring during simulation possible.''' sys.path.append('/home/people/tc/svn/tc_sandbox/quakes/') import phipsi_comparison sys.path.append('/home/people/tc/svn/tc_sandbox/misc/') import phipsi d_residues = { 'ALA':'A','CYS':'C','ASP':'D','GLU':'E','PHE':'F', 'GLY':'G','HIS':'H','ILE':'I','LYS':'K','LEU':'L', 'MET':'M','ASN':'N','PRO':'P','GLN':'Q','ARG':'R', 'SER':'S','THR':'T','VAL':'V','TRP':'W','TYR':'Y', } ##d_ramachandran = phipsi_comparison.parse_dihedrals(d_residues) d_ramachandran = {} for res in d_residues.values(): d_ramachandran[res] = {} for phi in range(-180,180): d_ramachandran[res][phi] = {} for psi in range(-180,180): d_ramachandran[res][phi][psi] = 0 d_ramachandran = phipsi_comparison.parse_dihedrals(d_residues) ## slow d_max = {} for res in d_ramachandran.keys(): max = 0 for phi in d_ramachandran[res].keys(): for psi in d_ramachandran[res][phi].keys(): count = d_ramachandran[res][phi][psi] if count > max: max = count d_max[res] = max ## print 'visualize the two extreme projections along a trajectory and interpolate n frames between them' fd = open('/oxygenase_local/data/pdb/lz/pdb2lzm.ent','r') lines = fd.readlines() fd.close() ss_lines = [] for line in lines: record = line[:6].strip() if record in ['HELIX','TURN','SHEET',]: ss_lines += [line] for mode in range(6,min(12,len(matrix_hessian))): print mode eigenvectors = eigenvectors_all_modes[mode] ## eigenvectors = length_adjustment(mode, eigenvectors) output_vmd = ['REMARK color by connectivity (b-factor) or squared displacement (temperature factor)\n'] for frame in range(nframes): lines_rasmol = [ 'rasmol -nodisplay NMAframe%s.pdb << EOF\n' %(str(frame).zfill(2)), 'cartoon\n', 'wireframe 0\n', ] prefix = 'NMA%s' %(frame) ## write rasmol script lines = [ 'rasmol -nodisplay NMAframe%s.pdb << EOF\n' %(str(frame).zfill(2)), 'cartoon\n', 'wireframe 0\n', ## 'ribbons\n', ## 'color temperature\n', ] d_colors = {} print mode,frame output_rasmol = [] output_rasmol = list(ss_lines) output_vmd.append('HEADER frame t= %4.3f\nMODEL 0\n' %(frame)) for chain in chains: res_nos = d_coordinates['chains'][chain]['residues'].keys() res_nos.sort() for i_res_no in range(1,len(res_nos)-1): res_no = res_nos[i_res_no] for iCode in d_coordinates['chains'][chain]['residues'][res_no]['iCodes'].keys(): for altloc in d_coordinates['chains'][chain]['residues'][res_no]['iCodes'][iCode]['altlocs'].keys(): res_name = d_coordinates['chains'][chain]['residues'][res_no]['iCodes'][iCode]['altlocs'][altloc]['res_name'] ## for atom_name in ['C','CA','N','O',]: ## for atom_name in d_coordinates['chains'][chain]['residues'][res_no]['iCodes'][iCode]['altlocs'][altloc]['atoms'].keys(): ## if 'hessian' in d_coordinates['chains'][chain]['residues'][res_no]['iCodes'][iCode]['altlocs'][altloc]['atoms'][atom_name].keys(): C = d_coordinates['chains'][chain]['residues'][res_no]['iCodes'][iCode]['altlocs'][altloc]['atoms']['C']['coordinate'] CA = d_coordinates['chains'][chain]['residues'][res_no]['iCodes'][iCode]['altlocs'][altloc]['atoms']['CA']['coordinate'] N = d_coordinates['chains'][chain]['residues'][res_no]['iCodes'][iCode]['altlocs'][altloc]['atoms']['N']['coordinate'] O = d_coordinates['chains'][chain]['residues'][res_no]['iCodes'][iCode]['altlocs'][altloc]['atoms']['O']['coordinate'] vx_C = 64*eigenvectors[4*3*(i_res_no)+0] vy_C = 64*eigenvectors[4*3*(i_res_no)+1] vz_C = 64*eigenvectors[4*3*(i_res_no)+2] vx_CA = 64*eigenvectors[4*3*(i_res_no)+3] vy_CA = 64*eigenvectors[4*3*(i_res_no)+4] vz_CA = 64*eigenvectors[4*3*(i_res_no)+5] vx_N = 64*eigenvectors[4*3*(i_res_no)+6] vy_N = 64*eigenvectors[4*3*(i_res_no)+7] vz_N = 64*eigenvectors[4*3*(i_res_no)+8] vx_O = 64*eigenvectors[4*3*(i_res_no)+9] vy_O = 64*eigenvectors[4*3*(i_res_no)+10] vz_O = 64*eigenvectors[4*3*(i_res_no)+11] x2_C = C[0]+(1-2*float(frame)/float(nframes))*vx_C y2_C = C[1]+(1-2*float(frame)/float(nframes))*vy_C z2_C = C[2]+(1-2*float(frame)/float(nframes))*vz_C x2_CA = CA[0]+(1-2*float(frame)/float(nframes))*vx_CA y2_CA = CA[1]+(1-2*float(frame)/float(nframes))*vy_CA z2_CA = CA[2]+(1-2*float(frame)/float(nframes))*vz_CA x2_N = N[0]+(1-2*float(frame)/float(nframes))*vx_N y2_N = N[1]+(1-2*float(frame)/float(nframes))*vy_N z2_N = N[2]+(1-2*float(frame)/float(nframes))*vz_N x2_O = O[0]+(1-2*float(frame)/float(nframes))*vx_O y2_O = O[1]+(1-2*float(frame)/float(nframes))*vy_O z2_O = O[2]+(1-2*float(frame)/float(nframes))*vz_O C2 = [x2_C,y2_C,z2_C,] CA2 = [x2_CA,y2_CA,z2_CA,] N2 = [x2_N,y2_N,z2_N,] O2 = [x2_O,y2_O,z2_O,] C_prev = d_coordinates['chains'][chain]['residues'][res_no-1]['iCodes'][iCode]['altlocs'][altloc]['atoms']['C']['coordinate'] vx_C_prev = 64*eigenvectors[4*3*(i_res_no-1)+0] vy_C_prev = 64*eigenvectors[4*3*(i_res_no-1)+1] vz_C_prev = 64*eigenvectors[4*3*(i_res_no-1)+2] x2_C_prev = C_prev[0]+(1-2*float(frame)/float(nframes))*vx_C_prev y2_C_prev = C_prev[1]+(1-2*float(frame)/float(nframes))*vy_C_prev z2_C_prev = C_prev[2]+(1-2*float(frame)/float(nframes))*vz_C_prev C_prev2 = [x2_C_prev,y2_C_prev,z2_C_prev,] phi = int(self.dihedral(C_prev2,N2,CA2,C2,)) N_next = d_coordinates['chains'][chain]['residues'][res_no+1]['iCodes'][iCode]['altlocs'][altloc]['atoms']['N']['coordinate'] vx_N_next = 64*eigenvectors[4*3*(i_res_no+1)+0] vy_N_next = 64*eigenvectors[4*3*(i_res_no+1)+1] vz_N_next = 64*eigenvectors[4*3*(i_res_no+1)+2] x2_N_next = N_next[0]+(1-2*float(frame)/float(nframes))*vx_N_next y2_N_next = N_next[1]+(1-2*float(frame)/float(nframes))*vy_N_next z2_N_next = N_next[2]+(1-2*float(frame)/float(nframes))*vz_N_next N_next2 = [x2_N_next,y2_N_next,z2_N_next,] psi = int(self.dihedral(N2,CA2,C2,N_next2,)) bfactor = ( 100 *d_ramachandran[d_residues[res_name]][phi][psi] /float(d_max[d_residues[res_name]]) ) ## index = int(100*bfactor/d_factors[mode][0]) ## ## if index > 100 or index < 0: ## print index,bfactor ## stop h = 159.+80*bfactor/100. s = 240. l = 120.+120.*(50-abs(bfactor-50))/50. r,g,b = self.hsl2rgb(h,s,l,) lines_rasmol += [ 'select %i\n' %(res_no), 'color [%i,%i,%i]\n' %( r, g, b, ) ] line_out = 'ATOM %3s%s%3s %1s%4i%1s %8.3f%8.3f%8.3f%6.2f%6.2f\n' %( 'C ', altloc, res_name, chain, int(res_no), iCode, x2_C,y2_C,z2_C, bfactor, bfactor, ) output_rasmol += [line_out] line_out = 'ATOM %3s%s%3s %1s%4i%1s %8.3f%8.3f%8.3f%6.2f%6.2f\n' %( 'CA ', altloc, res_name, chain, int(res_no), iCode, x2_CA,y2_CA,z2_CA, bfactor, bfactor, ) output_rasmol += [line_out] line_out = 'ATOM %3s%s%3s %1s%4i%1s %8.3f%8.3f%8.3f%6.2f%6.2f\n' %( 'N ', altloc, res_name, chain, int(res_no), iCode, x2_N,y2_N,z2_N, bfactor, bfactor, ) output_rasmol += [line_out] line_out = 'ATOM %3s%s%3s %1s%4i%1s %8.3f%8.3f%8.3f%6.2f%6.2f\n' %( 'O ', altloc, res_name, chain, int(res_no), iCode, x2_O,y2_O,z2_O, bfactor, bfactor, ) output_rasmol += [line_out] fd = open('NMAframe%s.pdb' %(str(frame).zfill(2)),'w') fd.writelines(output_rasmol) fd.close() output_vmd.append('TER\nENDMDL\n') lines_rasmol += [ ## 'ribbons\n', 'rotate x 100\n', 'rotate z 30\n', 'rotate x 100\n', 'rotate z 90\n', 'rotate x 40\n', 'rotate y -20\n', 'write %s.ppm\n' %(prefix), 'exit\n', ] ## write rasmol script to file fd = open('%srasmol.src' %(prefix),'w') fd.writelines(lines_rasmol) fd.close() ## execute rasmol script os.system('source %srasmol.src > %srasmol.log' %(prefix,prefix)) ## convert rasmol output ## os.system('convert %s.ppm -resize x80 %s.gif' %(prefix,prefix)) os.system('convert %s.ppm %s.gif' %(prefix,prefix)) ## clean up os.remove('%s.ppm' %(prefix)) os.remove('%srasmol.log' %(prefix)) os.remove('%srasmol.src' %(prefix)) ## os.remove('NMAframe%s.pdb' %(str(frame).zfill(2))) line = 'convert ' for frame in range(50): line += 'NMA%s.gif ' %(frame) for frame in range(50-1-1,-1+1,-1): line += 'NMA%s.gif ' %(frame) line += '-loop 0 mode%s.gif' %(mode) print line os.system(line) for frame in range(50): os.remove('NMA%s.gif' %(frame)) fd = open(job+'_mode'+str(mode+1).zfill(2)+'.pdb', 'w') ## implicit path fd.writelines(output_vmd) fd.close() return