PageRenderTime 57ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/cing/python/cing/PluginCode/x3dna.py

http://cing.googlecode.com/
Python | 673 lines | 654 code | 7 blank | 12 comment | 17 complexity | c06404b64a5fb196b8903dcea8474a50 MD5 | raw file
  1. """
  2. Adds x3dna method to analyze DNA structures. The x3dna program is included as binaries for Mac OSX in the bin directory.
  3. """
  4. import cing
  5. from cing.Libs.NTplot import * #@UnusedWildImport
  6. from cing.Libs.NTutils import * #@UnusedWildImport
  7. from cing.PluginCode.required.reqMatplib import MATPLIB_STR
  8. from cing.PluginCode.required.reqX3dna import * #@UnusedWildImport
  9. from cing.core.classes import Coplanar
  10. from cing.core.classes import CoplanarList
  11. from cing.core.parameters import cingPaths
  12. from cing import plugins
  13. from cing.definitions import validationDirectories
  14. useModule = True
  15. if cing.systemDefinitions.osType == OS_TYPE_MAC: # only installed for mac os currently.
  16. if not os.path.exists(cingPaths.x3dna): # cingPaths.x3dna gets set in __init__ for MAC.
  17. nTdebug("Missing x3dna directory which is a dep for x3dna; currently only tested for mac and disabled for other os")
  18. useModule = False
  19. else:
  20. useModule = False
  21. if not useModule:
  22. raise ImportWarning('x3dna')
  23. contentFile = 'content.xml'
  24. X3DNA_NAN_START = '--' # or that starts with this. sometimes it's 3 sometimes it's 4.
  25. class X3dna(NTdict):
  26. # Dictionary describing the identifier strings in x3dna output file, with shortKeys
  27. outputInfoDict = {
  28. 'baseRmsds':
  29. '''RMSD of the bases (----- for WC bp, + for isolated bp, x for helix change)''',
  30. 'hbondInfo':
  31. '''Detailed H-bond information: atom-name pair and length [ON]''',
  32. 'polygonOverlapArea':
  33. '''
  34. Overlap area in Angstrom^2 between polygons defined by atoms on successive
  35. bases. Polygons projected in the mean plane of the designed base-pair step.
  36. Values in parentheses measure the overlap of base ring atoms only. Those
  37. outside parentheses include exocyclic atoms on the ring. Intra- and
  38. inter-strand overlap is designated according to the following diagram:
  39. i2 3' 5' j2
  40. /|\ |
  41. | |
  42. Strand I | | II
  43. | |
  44. | |
  45. | \|/
  46. i1 5' 3' j1
  47. ''',
  48. 'originAndMNVector':
  49. '''
  50. Origin (Ox, Oy, Oz) and mean normal vector (Nx, Ny, Nz) of each base-pair in
  51. the coordinate system of the given structure
  52. ''',
  53. 'localBPPars':
  54. '''Local base-pair parameters''',
  55. 'localBPStepPars':
  56. '''Local base-pair step parameters''',
  57. 'localBPHelicalPars':
  58. '''Local base-pair helical parameters''',
  59. 'structureClass':
  60. '''Structure classification:''',
  61. 'lambda':
  62. '''
  63. lambda: virtual angle between C1'-YN1 or C1'-RN9 glycosidic bonds and the
  64. base-pair C1'-C1' line
  65. C1'-C1': distance between C1' atoms for each base-pair
  66. RN9-YN1: distance between RN9-YN1 atoms for each base-pair
  67. RC8-YC6: distance between RC8-YC6 atoms for each base-pair
  68. ''',
  69. 'diNucStepClassRHelix':
  70. '''
  71. Classification of each dinucleotide step in a right-handed nucleic acid
  72. structure: A-like; B-like; TA-like; intermediate of A and B, or other cases
  73. ''',
  74. 'grooveWidthsPPDist':
  75. '''
  76. Minor and major groove widths: direct P-P distances and refined P-P distances
  77. which take into account the directions of the sugar-phosphate backbones
  78. (Subtract 5.8 Angstrom from the values to take account of the vdw radii
  79. of the phosphate groups, and for comparison with FreeHelix and Curves.)
  80. Ref: M. A. El Hassan and C. R. Calladine (1998). `Two Distinct Modes of
  81. Protein-induced Bending in DNA.' J. Mol. Biol., v282, pp331-343.
  82. ''',
  83. 'globalHelixAxis':
  84. '''
  85. Global linear helical axis defined by equivalent C1' and RN9/YN1 atom pairs
  86. Deviation from regular linear helix: 2.85(0.76)
  87. ''',
  88. 'mainChainAndChiAngles':
  89. '''
  90. Main chain and chi torsion angles:
  91. Note: alpha: O3'(i-1)-P-O5'-C5'
  92. beta: P-O5'-C5'-C4'
  93. gamma: O5'-C5'-C4'-C3'
  94. delta: C5'-C4'-C3'-O3'
  95. epsilon: C4'-C3'-O3'-P(i+1)
  96. zeta: C3'-O3'-P(i+1)-O5'(i+1)
  97. chi for pyrimidines(Y): O4'-C1'-N1-C2
  98. chi for purines(R): O4'-C1'-N9-C4
  99. ''',
  100. 'sugarConfParameters':
  101. '''
  102. Sugar conformational parameters:
  103. Note: v0: C4'-O4'-C1'-C2'
  104. v1: O4'-C1'-C2'-C3'
  105. v2: C1'-C2'-C3'-C4'
  106. v3: C2'-C3'-C4'-O4'
  107. v4: C3'-C4'-O4'-C1'
  108. tm: amplitude of pseudorotation of the sugar ring
  109. P: phase angle of pseudorotation of the sugar ring
  110. ''',
  111. 'intraStrandDist':
  112. '''Same strand P--P and C1'--C1' virtual bond distances''',
  113. 'helixRadius':
  114. '''
  115. Helix radius (radial displacement of P, O4', and C1' atoms in local helix
  116. frame of each dimer)
  117. ''',
  118. 'diNucStepPosition':
  119. '''
  120. Position (Px, Py, Pz) and local helical axis vector (Hx, Hy, Hz)
  121. for each dinucleotide step
  122. '''
  123. }
  124. def __init__(self, project, parseOnly = False, modelNum = None, **kwds):
  125. NTdict.__init__(self, __CLASS__ = 'X3dna', **kwds)
  126. self.project = project
  127. self.coplanars = project.coplanars
  128. self.molecule = project.molecule # love this one.
  129. self.modelCount = project.molecule.modelCount
  130. def x3dnaPath(self, *args):
  131. """
  132. Return x3dna path from active molecule of project
  133. Creates directory if does not exist
  134. """
  135. return self.project.validationPath(validationDirectories['x3dna'], *args)
  136. def doX3dna(self):
  137. """
  138. Runs x3dna on all models found in the project file.
  139. The input file for X3DNA is a pdbFile
  140. The routine writes all the models found in the project file to separate pdb file, which are analyzed using x3dna:
  141. - x3dna.csh (cingPaths.x3dna) is a shell script that calls the various subroutines of the x3dna package and writes
  142. output files in rootPath:
  143. - find_pair
  144. Return None on error and True on success.
  145. """
  146. if not self.molecule:
  147. nTerror('X3dna: no molecule defined')
  148. return
  149. root = self.project.mkdir(self.project.molecule.name, self.project.moleculeDirectories.x3dna)
  150. rootPath = root
  151. # if not project.molecule.hasDNA():
  152. if not self.project.molecule.hasNucleicAcid():
  153. nTdebug("Not running x3dna for molecule has no DNA")
  154. return True # return true to notify caller that there is no error
  155. x3dnascript = os.path.join(cingPaths.x3dna, 'x3dna.csh')
  156. x3dnaMainDir = os.path.join(cingPaths.x3dna, 'x3dna_MacOS_intel')
  157. appendPathList = [ os.path.join(x3dnaMainDir, 'bin') ]
  158. appendEnvVariableDict = {}
  159. appendEnvVariableDict[ 'X3DNA' ] = x3dnaMainDir
  160. x3dna = ExecuteProgram(pathToProgram = x3dnascript, rootPath = root, redirectOutput = True,
  161. appendPathList = appendPathList, appendEnvVariableDict = appendEnvVariableDict)
  162. # Storage of results for later
  163. self.project.x3dnaStatus.completed = False
  164. self.project.x3dnaStatus.parsed = False
  165. self.project.x3dnaStatus.version = cing.cingVersion
  166. self.project.x3dnaStatus.moleculeName = self.project.molecule.name # just to have it
  167. # project.x3dnaStatus.models = models
  168. # project.x3dnaStatus.baseName = baseName
  169. self.project.x3dnaStatus.path = root
  170. self.project.x3dnaStatus.contentFile = contentFile
  171. self.project.x3dnaStatus.chains = NTlist() # list of (chainNames, outputFile) tuples to be parsed
  172. self.project.x3dnaStatus.keysformat()
  173. # The input file for is a pdb file
  174. skippedAtoms = [] # Keep a list of skipped atoms for later
  175. skippedResidues = []
  176. skippedChains = []
  177. for chain in self.project.molecule.allChains():
  178. skippChain = True
  179. for res in chain.allResidues():
  180. if not res.hasProperties('nucleic'):
  181. skippedResidues.append(res)
  182. for atm in res.allAtoms():
  183. atm.pdbSkipRecord = True
  184. skippedAtoms.append(atm)
  185. #end for
  186. else:
  187. res.x3dna = NTlist()
  188. skippChain = False
  189. #end if
  190. if skippChain:
  191. skippedChains.append(chain)
  192. #end for
  193. #end for
  194. if skippedResidues:
  195. nTmessage('x3dna: non-nucleotides %s will be skipped.', skippedResidues)
  196. # We do not specify any output files, these are set based on the input filename in the x3dna.csh script
  197. # pdbFile=project.molecule.toPDB()
  198. nModels = self.project.molecule.modelCount
  199. name = self.project.molecule.name
  200. if not self.coplanars:
  201. self.coplanars.append(CoplanarList('x3dna-made'))
  202. for modelNum in NTprogressIndicator(range(nModels)):
  203. nTmessage('Running X3DNA on modelNum %i of %s' % (modelNum, name))
  204. baseName = '%s_model_%i' % (name, modelNum)
  205. pdbFilePath = os.path.join(rootPath, baseName + '.pdb')
  206. self.project.molecule.toPDB(pdbFilePath, model = modelNum)
  207. status = x3dna(rootPath, baseName)
  208. if status:
  209. nTerror("Failed to run x3dna for modelNum %d" % modelNum)
  210. return None
  211. fileNameOut = os.path.join(rootPath, baseName + '.out')
  212. if self.parseX3dnaOutput(fileNameOut, modelNum):
  213. nTerror("Failed to parseX3dnaOutput for model id %d" % modelNum)
  214. return None
  215. # end for models
  216. # Restore the 'default' state
  217. for atm in skippedAtoms:
  218. atm.pdbSkipRecord = False
  219. self.project.x3dnaStatus.completed = True
  220. self.project.x3dnaStatus.parsed = True
  221. return True
  222. def parseX3dnaOutput(self, fileName, modelNum):
  223. """
  224. Parse x3dna generated output, we only parse the ".out" file.
  225. Store result in dictionary keyed by 'step' / suite.
  226. Currently, without reading the residue ids this might vary between models. TODO: fix this bug.
  227. """
  228. # Read in the output file, and split into the different parameter blocks
  229. x3dnaOutput = open(fileName, 'r').read()
  230. parameterBlocks = x3dnaOutput.split('****************************************************************************')
  231. for parameterBlock in parameterBlocks:
  232. # identify the parameter block type
  233. # Parse the block
  234. results = self.parseX3dnaParameterBlock(parameterBlock, modelNum)
  235. if results == None: # may be an empty dictionary.
  236. nTerror("Failed to parseX3dnaParameterBlock(parameterBlock) for %s" % parameterBlock)
  237. return True
  238. if self.storeX3dnaParameterBlock(results, modelNum):
  239. nTerror("Failed to parseX3dnaOutput for model id %d" % modelNum)
  240. return None
  241. return None
  242. def identifyParameterBlock(self, block):
  243. # Identify the block by the first line
  244. # print '#',block.split('\n')[1]
  245. found = False
  246. infoText = None # Helping pylint.
  247. parameterBlockId = None
  248. for parameterBlockId, infoText in self.outputInfoDict.iteritems():
  249. # print parameterBlockId, infoText
  250. try:
  251. if block.split('\n')[1].strip() in infoText:
  252. found = True
  253. break
  254. except IndexError:
  255. pass
  256. if found:
  257. return parameterBlockId, infoText
  258. else:
  259. return None, None
  260. def step2bp(self, step):
  261. '''
  262. converts "GA/TC" to "G-C"
  263. '''
  264. return step[0] + '-' + step[-1]
  265. def storeX3dnaParameterBlock(self, results, modelNum):
  266. '''
  267. stores results for one model and one block into CING data model
  268. For now; also link this to the first residues in the molecule; totally wrong but
  269. waiting for correspondence to handle this perfectly correct. TODO: finish correspondence.
  270. '''
  271. # generalized storing mechanism; see Whatif (here there's one level less).
  272. coplanarList = self.coplanars[0]
  273. coplanarIdList = results.keys()
  274. coplanarIdList.sort()
  275. for coplanarIdStr in coplanarIdList:
  276. # nTdebug("Working on coplanarIdStr: %s" % coplanarIdStr)
  277. coplanarId = int(coplanarIdStr) - 1 # should start at zero.
  278. # NB This code assumes that the x3dna analysis is done first and will create the coplanars
  279. # In future look up by residue ids.
  280. if len(coplanarList) <= coplanarId:
  281. coplanar = Coplanar(name = coplanarIdStr)
  282. x3dnaCoplanar = NTdict()
  283. coplanar[X3DNA_STR] = x3dnaCoplanar
  284. # TODO: Fix this.
  285. bogusResidueToLinkForNow = self.molecule.allResidues()[coplanarId]
  286. bogusResidueToLinkForNow[X3DNA_STR] = x3dnaCoplanar
  287. nTdebug("Added coplanar to bogus residue TODO")
  288. coplanarList.append(coplanar)
  289. # end if
  290. # take a short cut name.
  291. x3dnaCoplanar = getDeepByKeys(coplanarList, coplanarId, X3DNA_STR)
  292. for entity in results[coplanarIdStr].keys():
  293. # nTdebug("Working on entity: %s" % entity)
  294. valueList = getDeepByKeysOrDefault(x3dnaCoplanar, nTfill(None, self.modelCount), entity)
  295. valueList[modelNum] = results[coplanarIdStr][entity]
  296. # nTdebug("Set value for coplanarIdStr %s entity %s modelNum: %s to be: %s" % (coplanarIdStr,
  297. #entity, modelNum, valueList[modelNum]))
  298. # end for entity
  299. # end for coplanar
  300. return
  301. def parseX3dnaParameterBlock(self, parameterBlock, modelNum):
  302. '''
  303. Parses various parameter blocks in X3DNA output.
  304. Results are stored on basis of base pairs.
  305. In case of step parameters, the result is stored as an attribute of the first base pair
  306. i.e.
  307. 1 GA/TC -0.86 0.54 2.99 -4.13 2.08 31.35
  308. is stored as in bp "1 G-C"
  309. Example of processed data structure in a dictionary object of class Coplanar:
  310. x3dna.rise : [ 4.73, 3.99 ] for the first and second model.
  311. '''
  312. parameterBlockId, _infoText = self.identifyParameterBlock(parameterBlock) #@UnusedVariable
  313. splitLines = parameterBlock.split('\n')
  314. parseLine = False
  315. results = {}
  316. if parameterBlockId == 'localBPPars':
  317. # bp Shear Stretch Stagger Buckle Propeller Opening
  318. # 1 G-C -0.44 -0.22 -0.62 -2.36 3.15 -3.95
  319. # 2 A-T -0.09 -0.22 -0.19 12.78 -7.95 -0.93
  320. # ......
  321. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  322. # ave. 0.02 -0.24 3.33 0.20 4.00 33.41
  323. # s.d. 0.71 0.90 0.26 3.68 8.17 6.97
  324. for line in splitLines:
  325. wordList = line.split()
  326. if line.strip() == '':
  327. continue
  328. elif wordList[0] == 'bp':
  329. parseLine = True
  330. continue
  331. elif wordList[0] == '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~':
  332. break
  333. elif parseLine == True:
  334. bp = int(wordList[0])
  335. results[bp] = results.get(bp, {})
  336. results[bp].update(dict(
  337. bp_str = wordList[1],
  338. shear = self.parseX3dnaFloat(wordList[2]),
  339. stretch = self.parseX3dnaFloat(wordList[3]),
  340. stagger = self.parseX3dnaFloat(wordList[4]),
  341. buckle = self.parseX3dnaFloat(wordList[5]),
  342. propeller = self.parseX3dnaFloat(wordList[6]),
  343. opening = self.parseX3dnaFloat(wordList[7])
  344. )
  345. )
  346. if parameterBlockId == 'localBPStepPars':
  347. # step Shift Slide Rise Tilt Roll Twist
  348. # 1 GA/TC -0.86 0.54 2.99 -4.13 2.08 31.35
  349. # 2 AA/TT -0.88 -0.27 3.34 -4.59 3.92 39.72
  350. # ......
  351. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  352. # ave. 0.02 -0.24 3.33 0.20 4.00 33.41
  353. # s.d. 0.71 0.90 0.26 3.68 8.17 6.97
  354. for line in splitLines:
  355. wordList = line.split()
  356. if line.strip() == '':
  357. continue
  358. elif wordList[0] == 'step':
  359. parseLine = True
  360. continue
  361. elif wordList[0] == '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~':
  362. break
  363. elif parseLine == True:
  364. step = int(wordList[0])
  365. bp = step
  366. step_str = wordList[1]
  367. bp_str = self.step2bp(step_str)
  368. results[bp] = results.get(bp, {})
  369. results[bp].update(dict(
  370. step = step,
  371. step_str = step_str,
  372. bp_str = bp_str,
  373. shift = self.parseX3dnaFloat(wordList[2]),
  374. slide = self.parseX3dnaFloat(wordList[3]),
  375. rise = self.parseX3dnaFloat(wordList[4]),
  376. tilt = self.parseX3dnaFloat(wordList[5]),
  377. roll = self.parseX3dnaFloat(wordList[6]),
  378. twist = self.parseX3dnaFloat(wordList[7])
  379. )
  380. )
  381. if parameterBlockId == 'grooveWidthsPPDist':
  382. # Minor Groove Major Groove
  383. # P-P Refined P-P Refined
  384. # 1 GA/TC --- --- --- ---
  385. # 2 AA/TT --- --- --- ---
  386. # 3 AT/AT 11.2 --- 15.9 ---
  387. # 4 TT/AA 11.1 11.0 16.1 15.3
  388. # 5 TG/CA 13.2 13.1 18.5 17.5
  389. for line in splitLines:
  390. wordList = line.split()
  391. if line.strip() == '':
  392. continue
  393. elif wordList[0] == 'P-P':
  394. parseLine = True
  395. continue
  396. elif parseLine == True:
  397. # line = line.replace('---', '-0') # watch out these are not zero but NAN
  398. wordList = line.split()
  399. # nTdebug('wordList %r' % wordList)
  400. step = int(wordList[0])
  401. bp = step
  402. step_str = wordList[1]
  403. bp_str = self.step2bp(step_str)
  404. results[bp] = results.get(bp, {})
  405. results[bp].update(dict(
  406. step = step,
  407. step_str = step_str,
  408. bp_str = bp_str,
  409. minPP = self.parseX3dnaFloat(wordList[2]),
  410. minPP_ref = self.parseX3dnaFloat(wordList[3]),
  411. majPP = self.parseX3dnaFloat(wordList[4]),
  412. majPP_ref = self.parseX3dnaFloat(wordList[5])
  413. )
  414. )
  415. if parameterBlockId == 'sugarConfParameters':
  416. # function can be replaced by built in functions in CING except this might
  417. # be nice and easy for puckering amplitude and phase to be harvested.
  418. #Strand I
  419. # base v0 v1 v2 v3 v4 tm P Puckering
  420. # 1 G -39.9 46.9 -36.6 14.9 15.5 46.3 142.2 C1'-exo
  421. # 2 A -36.8 46.6 -38.5 18.5 11.3 45.8 147.3 C2'-endo
  422. # 3 A -25.3 38.1 -36.2 22.8 1.3 38.6 159.4 C2'-endo
  423. #Strand II
  424. # base v0 v1 v2 v3 v4 tm P Puckering
  425. # 1 C -15.9 -11.7 32.7 -42.2 37.6 42.6 39.9 C4'-exo
  426. # 2 T -39.3 30.4 -11.4 -10.8 31.2 38.0 107.4 O4'-endo
  427. # 3 T -40.8 40.2 -24.8 2.1 24.2 41.7 126.5 C1'-exo
  428. pass
  429. if parameterBlockId == 'diNucStepClassRHelix':
  430. # step Xp Yp Zp XpH YpH ZpH Form
  431. # 1 GA/TC -2.80 9.22 -0.29 -2.10 9.21 0.32 B
  432. # 2 AA/TT -2.96 8.85 0.08 -3.60 8.80 0.85 B
  433. # 3 AT/AT -3.26 9.19 -0.04 -5.33 9.19 0.23 B
  434. # 4 TT/AA -3.16 8.94 0.32 -4.07 8.92 0.76 B
  435. # 5 TG/CA -2.87 9.09 0.20 -3.91 8.88 1.92 B
  436. # 6 GT/AC -2.57 9.40 0.01 -2.32 9.36 -0.90 B
  437. # 7 TG/CA -2.15 9.15 0.59 -3.21 9.11 1.13
  438. # 8 GA/TC -2.51 9.25 0.94 -5.66 9.06 2.10
  439. pass
  440. if parameterBlockId == 'baseRmsds':
  441. # Strand I Strand II Helix
  442. # 1 (0.037) ....>A:...1_:[.DG]G-----C[.DC]:..22_:B<.... (0.022) |
  443. # 2 (0.030) ....>A:...2_:[.DA]A-----T[.DT]:..21_:B<.... (0.023) |
  444. pass
  445. if parameterBlockId == 'hbondInfo':
  446. # 1 G-----C [3] N2 - O2 2.80 N1 - N3 2.97 O6 - N4 2.91
  447. # 2 A-----T [2] N1 - N3 2.80 N6 - O4 2.88
  448. # 3 A-----T [2] N1 - N3 2.87 N6 - O4 2.80
  449. pass
  450. if parameterBlockId == 'polygonOverlapArea':
  451. # step i1-i2 i1-j2 j1-i2 j1-j2 sum
  452. # 1 GA/TC 3.94( 0.99) 0.00( 0.00) 0.00( 0.00) 7.62( 2.29) 11.56( 3.28)
  453. # 2 AA/TT 1.42( 0.26) 0.00( 0.00) 0.00( 0.00) 6.89( 1.23) 8.31( 1.49)
  454. pass
  455. if parameterBlockId == 'originAndMNVector':
  456. # bp Ox Oy Oz Nx Ny Nz
  457. # 1 G-C 77.18 44.78 39.96 -0.80 -0.58 -0.16
  458. # 2 A-T 74.85 43.25 38.47 -0.84 -0.51 -0.17
  459. pass
  460. if parameterBlockId == 'localBPHelicalPars':
  461. # step X-disp Y-disp h-Rise Incl. Tip h-Twist
  462. # 1 GA/TC 0.63 0.86 3.11 3.82 7.60 31.68
  463. # 2 AA/TT -0.85 0.75 3.37 5.73 6.71 40.15
  464. pass
  465. if parameterBlockId == 'structureClass':
  466. # This is a right-handed nucleic acid structure
  467. pass
  468. if parameterBlockId == 'lambda':
  469. # bp lambda(I) lambda(II) C1'-C1' RN9-YN1 RC8-YC6
  470. # 1 G-C 49.6 55.2 10.8 9.0 9.8
  471. # 2 A-T 53.5 53.6 10.5 8.8 9.6
  472. pass
  473. if parameterBlockId == 'globalHelixAxis':
  474. # Deviation from regular linear helix: 3.17(0.91)
  475. pass
  476. if parameterBlockId == 'mainChainAndChiAngles':
  477. #Strand I
  478. # base alpha beta gamma delta epsilon zeta chi
  479. # 1 G --- --- 57.6 138.6 -104.4 179.4 -104.7
  480. # 2 A -64.7 125.2 48.1 141.5 -150.0 -149.0 -110.9
  481. #Strand II
  482. # base alpha beta gamma delta epsilon zeta chi
  483. # 1 C -72.7 151.6 50.1 79.4 --- --- -125.3
  484. # 2 T -68.6 168.3 51.7 105.8 -148.7 -91.0 -121.7
  485. pass
  486. if parameterBlockId == 'intraStrandDist':
  487. # Strand I Strand II
  488. # base P--P C1'--C1' base P--P C1'--C1'
  489. # 1 G/A --- 5.1 1 C/T 6.1 4.9
  490. # 2 A/A 6.9 5.2 2 T/T 6.7 5.1
  491. pass
  492. if parameterBlockId == 'diNucStepPosition':
  493. # bp Px Py Pz Hx Hy Hz
  494. # 1 GA/TC 76.62 43.18 39.13 -0.79 -0.54 -0.30
  495. # 2 AA/TT 73.14 42.30 39.01 -0.80 -0.51 -0.31
  496. pass
  497. if parameterBlockId == 'helixRadius':
  498. # Strand I Strand II
  499. # step P O4' C1' P O4' C1'
  500. # 1 GA/TC 10.0 7.3 6.4 8.9 5.6 4.7
  501. # 2 AA/TT 9.7 7.7 6.8 9.4 6.2 5.6
  502. pass
  503. return results
  504. # end def
  505. def parseX3dnaFloat(self, str):
  506. # nTdebug("Found X3dnaFloat wannabe: %s" % str)
  507. if str.startswith(X3DNA_NAN_START):
  508. # nTdebug("Parsed X3dnaFloat as NAN")
  509. return NaN
  510. return float(str)
  511. # end class
  512. def createHtmlX3dna(project, ranges = None):
  513. """ Read out wiPlotList to see what get's created. """
  514. if not getDeepByKeysOrAttributes(plugins, MATPLIB_STR, IS_INSTALLED_STR):
  515. nTdebug('Skipping createHtmlWattos because no matplib installed.')
  516. return
  517. from cing.PluginCode.matplib import MoleculePlotSet #@UnresolvedImport
  518. # The following object will be responsible for creating a (png/pdf) file with
  519. # possibly multiple pages
  520. # Level 1: row
  521. # Level 2: against main or alternative y-axis
  522. # Level 3: plot parameters dictionary (extendible).
  523. keyLoLoL = []
  524. plotAttributesRowMain = NTdict()
  525. plotAttributesRowMain[ KEY_LIST_STR] = [ X3DNA_STR, SHIFT_STR]
  526. plotAttributesRowMain[ KEY_LIST2_STR] = [ X3DNA_STR, SLIDE_STR]
  527. plotAttributesRowMain[ KEY_LIST3_STR] = [ X3DNA_STR, RISE_STR]
  528. plotAttributesRowMain[ YLABEL_STR] = shortNameDict[ SHIFT_STR ]
  529. keyLoLoL.append([ [plotAttributesRowMain] ])
  530. plotAttributesRowMain = NTdict()
  531. plotAttributesRowMain[ KEY_LIST_STR] = [ X3DNA_STR, TILT_STR]
  532. plotAttributesRowMain[ KEY_LIST2_STR] = [ X3DNA_STR, ROLL_STR]
  533. plotAttributesRowMain[ KEY_LIST3_STR] = [ X3DNA_STR, TWIST_STR]
  534. plotAttributesRowMain[ YLABEL_STR] = shortNameDict[ TILT_STR ]
  535. keyLoLoL.append([ [plotAttributesRowMain] ])
  536. plotAttributesRowMain = NTdict()
  537. plotAttributesRowMain[ KEY_LIST_STR] = [ X3DNA_STR, SHEAR_STR]
  538. plotAttributesRowMain[ KEY_LIST2_STR] = [ X3DNA_STR, STRETCH_STR]
  539. plotAttributesRowMain[ KEY_LIST3_STR] = [ X3DNA_STR, STAGGER_STR]
  540. plotAttributesRowMain[ YLABEL_STR] = shortNameDict[ SHEAR_STR ]
  541. keyLoLoL.append([ [plotAttributesRowMain] ])
  542. plotAttributesRowMain = NTdict()
  543. plotAttributesRowMain[ KEY_LIST_STR] = [ X3DNA_STR, BUCKLE_STR]
  544. plotAttributesRowMain[ KEY_LIST2_STR] = [ X3DNA_STR, PROPELLER_STR]
  545. plotAttributesRowMain[ KEY_LIST3_STR] = [ X3DNA_STR, OPENING_STR]
  546. plotAttributesRowMain[ YLABEL_STR] = shortNameDict[ BUCKLE_STR ]
  547. keyLoLoL.append([ [plotAttributesRowMain] ])
  548. plotAttributesRowMain = NTdict()
  549. plotAttributesRowMain[ KEY_LIST_STR] = [ X3DNA_STR, MINPP_STR]
  550. plotAttributesRowMain[ KEY_LIST2_STR] = [ X3DNA_STR, MAJPP_STR]
  551. plotAttributesRowMain[ YLABEL_STR] = shortNameDict[ MINPP_STR ]
  552. plotAttributesRowMain[ USE_ZERO_FOR_MIN_VALUE_STR] = True
  553. plotAttributesRowMain[ USE_MAX_VALUE_STR] = 30.0
  554. keyLoLoL.append([ [plotAttributesRowMain] ])
  555. printLink = project.moleculePath(X3DNA_STR, project.molecule.name + x3dnaPlotList[0][0] + ".pdf")
  556. moleculePlotSet = MoleculePlotSet(project = project, ranges = ranges, keyLoLoL = keyLoLoL)
  557. moleculePlotSet.renderMoleculePlotSet(printLink, createPngCopyToo = True)
  558. #end def
  559. def runX3dna(project, parseOnly = False, modelNum = None):
  560. x3dna = X3dna(project, parseOnly = parseOnly, modelNum = modelNum)
  561. return x3dna.doX3dna()
  562. # register the functions
  563. methods = [(runX3dna, None),
  564. ]
  565. #saves = []
  566. #restores = [
  567. # (restoreX3dna, None),
  568. # ]
  569. #exports = []