properties.ts 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /**
  2. * Copyright (c) 2017-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. * @author Panagiotis Tourlas <panagiot_tourlov@hotmail.com>
  6. *
  7. * Adapted from MolQL project
  8. */
  9. import { MolScriptBuilder } from '../../../mol-script/language/builder';
  10. const B = MolScriptBuilder;
  11. import { PropertyDict } from '../types';
  12. const reFloat = /[-+]?[0-9]*\.?[0-9]+/;
  13. const rePosInt = /[+]?[0-9]+/;
  14. const reInt = /[-+]?[0-9]+/;
  15. function str(x: string) { return x; }
  16. export const sstrucDict: { [key: string]: string } = {
  17. T: 'turn', // Turn
  18. E: 'sheet', // Extended conformation ($\beta$ sheets)
  19. B: 'strand', // Isolated bridge
  20. H: 'alpha', // Alpha helix
  21. G: '3-10', // 3-10 helix
  22. I: 'pi', // Pi helix
  23. C: 'none', // Coil
  24. };
  25. export function sstrucMap(x: string) {
  26. return B.struct.type.secondaryStructureFlags(
  27. [sstrucDict[x.toUpperCase()] || 'none']
  28. );
  29. }
  30. export const properties: PropertyDict = {
  31. name: {
  32. '@desc': 'str atom name',
  33. '@examples': ['name CA'],
  34. regex: /[a-zA-Z0-9]+/, map: B.atomName,
  35. level: 'atom-test', property: B.ammp('label_atom_id')
  36. },
  37. type: {
  38. '@desc': 'str atom type',
  39. '@examples': ['type C3'],
  40. isUnsupported: true,
  41. regex: /[a-zA-Z0-9]+/, map: str,
  42. level: 'atom-test'
  43. },
  44. index: {
  45. '@desc': 'num the atom number, starting at 0',
  46. '@examples': ['index 10'],
  47. isNumeric: true,
  48. regex: rePosInt, map: x => (parseInt(x) - 1),
  49. level: 'atom-test', property: B.ammp('id')
  50. },
  51. serial: {
  52. '@desc': 'num the atom number, starting at 1',
  53. '@examples': ['serial 11'],
  54. isNumeric: true,
  55. regex: rePosInt, map: x => parseInt(x),
  56. level: 'atom-test', property: B.ammp('id')
  57. },
  58. atomicnumber: {
  59. '@desc': 'num atomic number (0 if undefined)',
  60. '@examples': ['atomicnumber 13'],
  61. isNumeric: true,
  62. regex: rePosInt, map: x => parseInt(x),
  63. level: 'atom-test', property: B.acp('atomicNumber')
  64. },
  65. element: {
  66. '@desc': 'str atomic element symbol string ("X" if undefined)',
  67. '@examples': ['element N'],
  68. regex: /[a-zA-Z0-9]{1,3}/, map: x => B.es(x),
  69. level: 'atom-test', property: B.acp('elementSymbol')
  70. },
  71. altloc: {
  72. '@desc': 'str alternate location/conformation identifier',
  73. '@examples': ['altloc C'],
  74. regex: /[a-zA-Z0-9]+/, map: str,
  75. level: 'atom-test', property: B.ammp('label_alt_id')
  76. },
  77. chain: {
  78. '@desc': 'str the one-character chain identifier',
  79. '@examples': ['chain A'],
  80. regex: /[a-zA-Z0-9]+/, map: str,
  81. level: 'residue-test', property: B.ammp('auth_asym_id')
  82. },
  83. residue: {
  84. '@desc': 'num a set of connected atoms with the same residue number',
  85. '@examples': ['residue < 11', 'residue 11'],
  86. isNumeric: true,
  87. regex: reInt, map: x => parseInt(x),
  88. level: 'residue-test', property: B.ammp('auth_seq_id')
  89. },
  90. fragment: {
  91. '@desc': 'num a set of connected residues',
  92. '@examples': ['fragment 42'],
  93. isUnsupported: true,
  94. isNumeric: true,
  95. regex: reInt, map: x => parseInt(x),
  96. level: 'residue-test'
  97. },
  98. pfrag: {
  99. '@desc': 'num a set of connected protein residues',
  100. '@examples': ['pfrag 42'],
  101. isUnsupported: true,
  102. isNumeric: true,
  103. regex: reInt, map: x => parseInt(x),
  104. level: 'residue-test'
  105. },
  106. nfrag: {
  107. '@desc': 'num a set of connected nucleic residues',
  108. '@examples': ['nfrag 42'],
  109. isUnsupported: true,
  110. isNumeric: true,
  111. regex: reInt, map: x => parseInt(x),
  112. level: 'residue-test'
  113. },
  114. sequence: {
  115. '@desc': 'str a sequence given by one letter names',
  116. '@examples': ['sequence PGATTACA'],
  117. isUnsupported: true,
  118. regex: /[a-zA-Z0-9]+/, map: str,
  119. level: 'residue-test'
  120. },
  121. numbonds: {
  122. '@desc': 'num number of bonds',
  123. '@examples': ['numbonds = 2', 'numbonds >= 3'],
  124. isNumeric: true,
  125. regex: rePosInt, map: x => parseInt(x),
  126. level: 'atom-test', property: B.acp('bondCount')
  127. },
  128. resname: {
  129. '@desc': 'str residue name',
  130. '@examples': ['resname ALA'],
  131. regex: /[a-zA-Z0-9]+/, map: str,
  132. level: 'residue-test', property: B.ammp('auth_comp_id')
  133. },
  134. resid: {
  135. '@desc': 'num residue id',
  136. '@examples': ['resid 42'],
  137. isNumeric: true,
  138. regex: reInt, map: x => parseInt(x),
  139. level: 'residue-test', property: B.ammp('auth_seq_id')
  140. },
  141. segname: {
  142. '@desc': 'str segment name',
  143. '@examples': ['segname B'],
  144. regex: /[a-zA-Z0-9]+/, map: str,
  145. level: 'residue-test', property: B.ammp('label_asym_id')
  146. },
  147. x: {
  148. '@desc': 'float x coordinate',
  149. '@examples': ['x 42'],
  150. isNumeric: true,
  151. regex: reFloat, map: x => parseFloat(x),
  152. level: 'atom-test', property: B.acp('x')
  153. },
  154. y: {
  155. '@desc': 'float y coordinate',
  156. '@examples': ['y > 1.7'],
  157. isNumeric: true,
  158. regex: reFloat, map: x => parseFloat(x),
  159. level: 'atom-test', property: B.acp('y')
  160. },
  161. z: {
  162. '@desc': 'float z coordinate',
  163. '@examples': ['z < 11', 'z > -21'],
  164. isNumeric: true,
  165. regex: reFloat, map: x => parseFloat(x),
  166. level: 'atom-test', property: B.acp('z')
  167. },
  168. radius: {
  169. '@desc': 'float atomic radius',
  170. '@examples': ['radius > 1.3'],
  171. isNumeric: true,
  172. regex: reFloat, map: x => parseFloat(x),
  173. level: 'atom-test', property: B.acp('vdw')
  174. },
  175. mass: {
  176. '@desc': 'float atomic mass',
  177. '@examples': ['mass > 2'],
  178. isNumeric: true,
  179. regex: reFloat, map: x => parseFloat(x),
  180. level: 'atom-test', property: B.acp('mass')
  181. },
  182. charge: {
  183. '@desc': 'float atomic charge',
  184. '@examples': ['charge > 0', 'charge 1'],
  185. isNumeric: true,
  186. regex: reFloat, map: x => parseFloat(x),
  187. level: 'atom-test', property: B.ammp('pdbx_formal_charge')
  188. },
  189. beta: {
  190. '@desc': 'float temperature factor',
  191. '@examples': ['beta < 20', 'beta > 35'],
  192. isNumeric: true,
  193. regex: reFloat, map: x => parseFloat(x),
  194. level: 'atom-test', property: B.ammp('B_iso_or_equiv')
  195. },
  196. occupancy: {
  197. '@desc': 'float occupancy',
  198. '@examples': ['occupancy 1', 'occupancy < 1'],
  199. isNumeric: true,
  200. regex: reFloat, map: x => parseFloat(x),
  201. level: 'atom-test', property: B.ammp('occupancy')
  202. },
  203. user: {
  204. '@desc': 'float time-varying user-specified value',
  205. '@examples': ['user < 0.1'],
  206. isUnsupported: true,
  207. isNumeric: true,
  208. regex: reFloat, map: x => parseFloat(x),
  209. level: 'atom-test'
  210. },
  211. rasmol: {
  212. '@desc': 'str translates Rasmol selection string to VMD',
  213. '@examples': ["rasmol 'all'"],
  214. isUnsupported: true,
  215. regex: /[^']*/, map: str,
  216. level: 'atom-test'
  217. },
  218. structure: {
  219. '@desc': 'str single letter name for the secondary structure',
  220. '@examples': ['structure H', 'structure H E'],
  221. regex: /T|E|B|H|G|I|C/i, map: sstrucMap,
  222. level: 'atom-test', property: B.ammp('secondaryStructureFlags')
  223. },
  224. phi: {
  225. '@desc': 'float phi backbone conformational angles',
  226. '@examples': ['phi < 160'],
  227. isUnsupported: true,
  228. isNumeric: true,
  229. regex: reFloat, map: x => parseFloat(x),
  230. level: 'residue-test'
  231. },
  232. psi: {
  233. '@desc': 'float psi backbone conformational angles',
  234. '@examples': ['psi < 160'],
  235. isUnsupported: true,
  236. isNumeric: true,
  237. regex: reFloat, map: x => parseFloat(x),
  238. level: 'residue-test'
  239. },
  240. ufx: {
  241. '@desc': 'num force to apply in the x coordinate',
  242. '@examples': ['ufx 1'],
  243. isUnsupported: true,
  244. isNumeric: true,
  245. regex: reFloat, map: x => parseInt(x),
  246. level: 'atom-test'
  247. },
  248. ufy: {
  249. '@desc': 'num force to apply in the y coordinate',
  250. '@examples': ['ufy 1'],
  251. isUnsupported: true,
  252. isNumeric: true,
  253. regex: reFloat, map: x => parseInt(x),
  254. level: 'atom-test'
  255. },
  256. ufz: {
  257. '@desc': 'num force to apply in the z coordinate',
  258. '@examples': ['ufz 1'],
  259. isUnsupported: true,
  260. isNumeric: true,
  261. regex: reFloat, map: x => parseInt(x),
  262. level: 'atom-test'
  263. },
  264. };