Bjoern Olausson

order_parameters-popc.py PDF Print E-mail
  
Thursday, 14 May 2009 14:56

  1.  
  2. <p>
  3. #!/usr/bin/python
  4. # -*- coding: utf-8 -*-
  5. #
  6. import sys, os, subprocess, glob, linecache, string
  7.  
  8. # CHARMM executable
  9. CHARMM = "/home/blub/.soft/usr/local/bin/charmm.xxlarge"
  10. # Number of C Atom to start with
  11. Cs = 2
  12. # Number of last C Atom
  13. Cl = 16
  14. # Number of trajectory (DCD) files
  15. N = 1
  16. # Filename to store the final average S over all C-D
  17. S = 'S.dat'
  18. # trajectory files to read. Will be extended with "$N.dcd"
  19. # Link all your dcd files into . and name the links membrane_npgt{1..N}.dcd
  20. T = 'membrane_npgt'
  21. # Directory to store results in
  22. D = 'scd_proper'
  23. # Edit the CHARMM config below to fit your needs
  24. # Do not edit the "DIR" and "dcdname" var it is set via python var above
  25.  
  26. CHARMMcfg_form ='''
  27. ! the axial avg order parameter for an input C no.;
  28. ! N: Trajectory files -- C: chain carbon number @C
  29. ! http://www.charmm.org/ubbthreads/showflat.php?Cat=0&amp;Number=6581&amp;page=0&amp;vc=1
  30.  
  31. ! dcdname: membrane_npgt (will be extendet with "@K.dcd" --> This e-mail address is being protected from spambots. You need JavaScript enabled to view it )
  32. ! segid: SEGID of the Lipids
  33. ! nsteps: number of Steps in the trajectory
  34. ! nlipids: Number of Lipids
  35. ! DIR: dir to store output in
  36. ! MinResid: First resid of POPC (71)
  37. ! MaxResid: Last resid of POPC (98)
  38. ! charmm N:40 C:2 < order_parameters.inp >&amp; scd/v2.out
  39.  
  40. set DIR $DT
  41. set dcdname $TT
  42. set nsteps 101000
  43. set MinResidUP 15
  44. set MaxResidUP 42
  45. set MinResidLO 71
  46. set MaxResidLO 98
  47.  
  48. calc nlipidsUP @MaxResidUP - @MinResidUP + 1
  49. calc nlipidsLO @MaxResidLO - @MinResidLO + 1
  50. calc nlipids @nlipidsUP + @nlipidsLO
  51.  
  52. set segid MEMB
  53.  
  54. bomblev -2
  55. ! Read in Topology and Parameter files
  56.  
  57. open unit 1 card read name top_all27_prot_lipid.rtf
  58. read RTF card unit 1
  59. close unit 1
  60.  
  61. open unit 1 card read name par_all27_prot_lipid.prm
  62. read PARA card unit 1
  63. close unit 1
  64.  
  65. stream toppar_all27_lipid_cholesterol.str
  66.  
  67. !Read PSF &amp; COOR
  68. open read card unit 10 name step5_assembly.psf
  69. read psf card unit 10
  70.  
  71.  
  72. calc mxa @nlipids * 6 * 4
  73. calc mxs 10 + @nlipids * 2 * 4
  74. calc mxt @nsteps * @N
  75.  
  76. correl maxtim @MXT maxa @MXA maxs @MXS
  77. enter sx zero
  78. enter sy dupl sx
  79. enter axy dupl sx
  80.  
  81.  
  82. set resid @MinResidUP
  83. set k 1
  84. ! TRAILING LETTERS IN THE 'H' ATOM NAMES REQUIRE @{C}, NOT @C
  85. ! ENTEr name VECT [X,Y,Z,R,XYZ] repeat(2x(atom-spec))
  86. ! atom-spec = segid resid atom-name
  87. label elpUP
  88. ! C3* == PALMITOYL
  89. enter y@K vect z @segid @resid H@{C}X @segid @resid C3@C
  90. enter c@K vect r @segid @resid H@{C}X @segid @resid C3@C
  91. enter z@K vect z @segid @resid H@{C}Y @segid @resid C3@C
  92. enter d@K vect r @segid @resid H@{C}Y @segid @resid C3@C
  93. incr k by 1
  94. incr resid by 1
  95. if @k le @nlipidsUP goto elpUP
  96.  
  97. set resid @MinResidLO
  98. ! TRAILING LETTERS IN THE 'H' ATOM NAMES REQUIRE @{C}, NOT @C
  99. ! ENTEr name VECT [X,Y,Z,R,XYZ] repeat(2x(atom-spec))
  100. ! atom-spec = segid resid atom-name
  101. label elpLO
  102. ! C3* == PALMITOYL
  103. enter y@K vect z @segid @resid H@{C}X @segid @resid C3@C
  104. enter c@K vect r @segid @resid H@{C}X @segid @resid C3@C
  105. enter z@K vect z @segid @resid H@{C}Y @segid @resid C3@C
  106. enter d@K vect r @segid @resid H@{C}Y @segid @resid C3@C
  107. incr k by 1
  108. incr resid by 1
  109. if @k le @nlipids goto elpLO
  110.  
  111. set k 1
  112. label klp
  113. calc u @K + 7
  114. open unit @U file read name @{dcdname}@K.dcd
  115. incr k by 1
  116. if @k .le. @N goto klp
  117.  
  118. traj firstu 8 nunit @N
  119.  
  120. ! LOOP OVER LIPIDS; NORM, CALC SCD, ACCUM
  121. ! S(CD) = (3*(z/r)**2 - 1)/2
  122. ! sr = (1.5*(w@K / a@K)**2 - 0.5) * (1 / @nlipids)
  123. ! S=0,5(3cos**2TETA-1)
  124. ! cosTETA = Z/R = w@K/a@K
  125.  
  126. calc rLIPIDS 1. / @nlipids
  127.  
  128. set k 1
  129. label clp
  130. ! C3* == PALMITOYL
  131. mantim y@K ratio c@K
  132. mantim y@K squa
  133. mantim y@K mult 1.5
  134. mantim y@K shift -0.5
  135. mantim y@K mult @rLIPIDS
  136. mantim sx add y@K
  137. mantim z@K ratio d@K
  138. mantim z@K squa
  139. mantim z@K mult 1.5
  140. mantim z@K shift -0.5
  141. mantim z@K mult @rLIPIDS
  142. mantim sy add z@K
  143. incr k by 1
  144. if @k le @nlipids goto clp
  145.  
  146.  
  147.  
  148. ! Average both H
  149. mantime axy add sx
  150. mantime axy add sy
  151. mantime axy mult 0.5
  152. set averxy ?aver
  153.  
  154. edit sx veccod 3 delta 0.001 skip 1000 offset 1.
  155.  
  156. ! MIXED CASE IS IGNORED; @C IS THE CHAIN CARBON NO.
  157. open write unit 1 card name @{DIR}/ This e-mail address is being protected from spambots. You need JavaScript enabled to view it
  158. write sx unit 1 dumb time
  159. * dumb
  160. *
  161.  
  162. end
  163.  
  164. open write unit 1 card name @{DIR}/ This e-mail address is being protected from spambots. You need JavaScript enabled to view it
  165. write title unit 1
  166. *PALMITOYL C:@C
  167. *@averxy
  168. *
  169. stop
  170. '''
  171. CHARMMcfg_template=string.Template(CHARMMcfg_form)
  172. # Define all substitutable strings in the template
  173. CHARMMcfg = CHARMMcfg_template.substitute(DT=D, TT=T)
  174.  
  175. open("S.inp", "w").write(CHARMMcfg)
  176.  
  177. try:
  178. os.mkdir(D, 0755)
  179. except OSError:
  180. print >>sys.stderr, "Dir exists, using existing dir."
  181.  
  182. runs = Cs
  183. while runs <= Cl:
  184. print "Processing C%s" % (runs,)
  185. runCHARMM = subprocess.Popen([CHARMM, "N:%s" % (N,), "C:%s" % (runs,)], stdin=open("S.inp", "r"), stderr=open( "%s/C%s.err.out" % (D, runs,), "w"), stdout = open("%s/C%s.out" % (D, runs,), "w"))
  186. runCHARMM.communicate(CHARMMcfg)
  187. #remove empty err files
  188. err = open("%s/C%s.err.out" % (D, runs,)).read()
  189. if err == '':
  190. os.remove("%s/C%s.err.out" % (D, runs,))
  191. runs = runs + 1
  192.  
  193. os.remove("S.inp")
  194.  
  195. values = []
  196. for file in glob.glob(D+'/a*'):
  197. values.append( float(linecache.getline(file, 2).strip()) )
  198. linecache.clearcache()
  199.  
  200. Sav = sum(values) / len(values)
  201. print "Average Palmitoyl Order Parameter", Sav
  202. open(D+"/"+S, 'w').write(str(Sav))
  203.  
  204.  

Attachments:
FileFile sizeLast Modified
Download this file (order_parameters-popc.py)order_parameters-popc.py4 Kb07/29/09 12:30
Last Updated ( Wednesday, 29 July 2009 12:29 )
 

Add comment


Security code
Refresh

6M Pixel

Banner

www. is deprecated

Banner

Play OGG

Banner