allpy

changeset 68:3161cdaf2ff9

add current version of block3d (not integrated)
author boris <bnagaev@gmail.com>
date Fri, 17 Sep 2010 21:52:33 +0400
parents 621fe8e2c1f7
children 056f700b85fe
files blocks3d/AAdict.py blocks3d/AlignmentSeq.py blocks3d/AlignmentSeq_config.py blocks3d/Blocks3D.py blocks3d/Blocks3D_class.py blocks3d/Blocks3D_config.py blocks3d/GeometricalCore_class.py blocks3d/GeometricalCore_config.py blocks3d/Kliki.py blocks3d/clon.py blocks3d/html.htm blocks3d/www/array.js blocks3d/www/blocks.js blocks3d/www/crc32.js blocks3d/www/crc32_color.js blocks3d/www/css.css blocks3d/www/dechex.js blocks3d/www/down.php blocks3d/www/html.php blocks3d/www/json2.js blocks3d/www/mainpanel.js blocks3d/www/screen.js blocks3d/www/top.php
diffstat 23 files changed, 8978 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/blocks3d/AAdict.py	Fri Sep 17 21:52:33 2010 +0400
     1.3 @@ -0,0 +1,2371 @@
     1.4 +AAdict= {
     1.5 +
     1.6 +"CPI":  ('x', 'p', None, None) ,
     1.7 +
     1.8 +"AGM":  ('r', 'p', 'M', None) ,
     1.9 +
    1.10 +"G25":  ('g', 'r', 'M', None) ,
    1.11 +
    1.12 +"CPN":  ('c', 'd', 'M', None) ,
    1.13 +
    1.14 +"MA6":  ('a', 'r', 'M', None) ,
    1.15 +
    1.16 +"NYS":  ('c', 'p', 'M', None) ,
    1.17 +
    1.18 +"CPC":  ('x', 'p', None, None) ,
    1.19 +
    1.20 +"8FG":  ('g', 'd', 'M', None) ,
    1.21 +
    1.22 +"SIC":  ('x', 'p', None, None) ,
    1.23 +
    1.24 +"PQ1":  ('n', 'r', None, None) ,
    1.25 +
    1.26 +"PAS":  ('d', 'p', 'M', None) ,
    1.27 +
    1.28 +"EOV":  ('x', 'p', None, None) ,
    1.29 +
    1.30 +"B2I":  ('i', 'p', 'M', None) ,
    1.31 +
    1.32 +"NYM":  ('n', 'd', None, None) ,
    1.33 +
    1.34 +"URD":  ('u', 'r', 'M', None) ,
    1.35 +
    1.36 +"NYC":  ('x', 'p', None, None) ,
    1.37 +
    1.38 +"AGT":  ('x', 'p', None, None) ,
    1.39 +
    1.40 +"NYG":  ('x', 'p', None, None) ,
    1.41 +
    1.42 +"CPV":  ('x', 'p', None, None) ,
    1.43 +
    1.44 +"TAV":  ('d', 'p', 'M', None) ,
    1.45 +
    1.46 +"S4G":  ('g', 'd', 'M', None) ,
    1.47 +
    1.48 +"MA7":  ('a', 'd', 'M', None) ,
    1.49 +
    1.50 +"S4C":  ('c', 'r', 'M', None) ,
    1.51 +
    1.52 +"UAR":  ('u', 'r', 'M', None) ,
    1.53 +
    1.54 +"SPT":  ('t', 'd', 'M', None) ,
    1.55 +
    1.56 +"S4U":  ('u', 'r', 'M', None) ,
    1.57 +
    1.58 +"TAF":  ('t', 'd', 'M', None) ,
    1.59 +
    1.60 +"5NC":  ('c', 'd', 'M', None) ,
    1.61 +
    1.62 +"CSF":  ('c', 'r', 'M', None) ,
    1.63 +
    1.64 +"0CS":  ('a', 'p', 'M', None) ,
    1.65 +
    1.66 +"B2V":  ('v', 'p', 'M', None) ,
    1.67 +
    1.68 +"TAL":  ('n', 'r', None, None) ,
    1.69 +
    1.70 +"SCY":  ('c', 'p', 'M', None) ,
    1.71 +
    1.72 +"KYQ":  ('k', 'p', 'M', None) ,
    1.73 +
    1.74 +"CS8":  ('n', 'r', None, None) ,
    1.75 +
    1.76 +"TA4":  ('x', 'p', None, None) ,
    1.77 +
    1.78 +"ALN":  ('a', 'p', 'M', None) ,
    1.79 +
    1.80 +"GS":  ('g', 'd', 'M', None) ,
    1.81 +
    1.82 +"2FE":  ('n', 'd', None, None) ,
    1.83 +
    1.84 +"VAL":  ('V', 'p', None, None) ,
    1.85 +
    1.86 +"7DA":  ('a', 'd', 'M', None) ,
    1.87 +
    1.88 +"XPC":  ('x', 'p', None, None) ,
    1.89 +
    1.90 +"VAF":  ('v', 'p', 'M', None) ,
    1.91 +
    1.92 +"VAD":  ('v', 'p', 'M', None) ,
    1.93 +
    1.94 +"BGM":  ('g', 'd', 'M', None) ,
    1.95 +
    1.96 +"P":  ('g', 'd', 'M', None) ,
    1.97 +
    1.98 +"LHU":  ('u', 'r', 'M', None) ,
    1.99 +
   1.100 +"T48":  ('t', 'd', 'M', None) ,
   1.101 +
   1.102 +"2GT":  ('t', 'd', 'M', None) ,
   1.103 +
   1.104 +"HMF":  ('a', 'p', 'M', None) ,
   1.105 +
   1.106 +"BNN":  ('a', 'p', 'M', None) ,
   1.107 +
   1.108 +"AHB":  ('n', 'p', 'M', None) ,
   1.109 +
   1.110 +"NPH":  ('c', 'p', 'M', None) ,
   1.111 +
   1.112 +"SIB":  ('c', 'p', 'M', None) ,
   1.113 +
   1.114 +"SNN":  ('n', 'p', 'M', None) ,
   1.115 +
   1.116 +"AHH":  ('x', 'p', None, None) ,
   1.117 +
   1.118 +"JW5":  ('n', 'r', None, None) ,
   1.119 +
   1.120 +"PBB":  ('c', 'p', 'M', None) ,
   1.121 +
   1.122 +"PTR":  ('y', 'p', 'M', None) ,
   1.123 +
   1.124 +"MAA":  ('a', 'p', 'M', None) ,
   1.125 +
   1.126 +"AHS":  ('x', 'p', None, None) ,
   1.127 +
   1.128 +"AHP":  ('a', 'p', 'M', None) ,
   1.129 +
   1.130 +"MAD":  ('a', 'r', 'M', None) ,
   1.131 +
   1.132 +"AHT":  ('x', 'p', None, None) ,
   1.133 +
   1.134 +"XYG":  ('x', 'p', None, None) ,
   1.135 +
   1.136 +"MAI":  ('r', 'p', 'M', None) ,
   1.137 +
   1.138 +"CP1":  ('c', 'd', 'M', None) ,
   1.139 +
   1.140 +"G2L":  ('g', 'r', 'M', None) ,
   1.141 +
   1.142 +"FFD":  ('n', 'd', None, None) ,
   1.143 +
   1.144 +"CML":  ('c', 'p', 'M', None) ,
   1.145 +
   1.146 +"CMH":  ('c', 'p', 'M', None) ,
   1.147 +
   1.148 +"ZDU":  ('n', 'd', None, None) ,
   1.149 +
   1.150 +"PCS":  ('f', 'p', 'M', None) ,
   1.151 +
   1.152 +"CME":  ('c', 'p', 'M', None) ,
   1.153 +
   1.154 +"CSO":  ('c', 'p', 'M', None) ,
   1.155 +
   1.156 +"193":  ('x', 'p', None, None) ,
   1.157 +
   1.158 +"1TY":  ('y', 'p', 'M', None) ,
   1.159 +
   1.160 +"CB2":  ('c', 'd', 'M', None) ,
   1.161 +
   1.162 +"CS3":  ('c', 'p', 'M', None) ,
   1.163 +
   1.164 +"64T":  ('t', 'd', 'M', None) ,
   1.165 +
   1.166 +"4AC":  ('n', 'r', None, None) ,
   1.167 +
   1.168 +"B3X":  ('n', 'p', 'M', None) ,
   1.169 +
   1.170 +"TST":  ('x', 'p', None, None) ,
   1.171 +
   1.172 +"CMT":  ('c', 'p', 'M', None) ,
   1.173 +
   1.174 +"CMR":  ('c', 'd', 'M', None) ,
   1.175 +
   1.176 +"CSH":  ('x', 'p', None, None) ,
   1.177 +
   1.178 +"VLM":  ('x', 'p', None, None) ,
   1.179 +
   1.180 +"G":  ('G', 'r', None, None) ,
   1.181 +
   1.182 +"C4S":  ('c', 'd', 'M', None) ,
   1.183 +
   1.184 +"U2L":  ('u', 'r', 'M', None) ,
   1.185 +
   1.186 +"LSO":  ('x', 'p', None, None) ,
   1.187 +
   1.188 +"U2N":  ('n', 'd', None, None) ,
   1.189 +
   1.190 +"PLE":  ('l', 'p', 'M', None) ,
   1.191 +
   1.192 +"SIN":  ('x', 'p', None, None) ,
   1.193 +
   1.194 +"M2L":  ('k', 'p', 'M', None) ,
   1.195 +
   1.196 +"I58":  ('k', 'p', 'M', None) ,
   1.197 +
   1.198 +"U2P":  ('u', 'r', 'M', None) ,
   1.199 +
   1.200 +"B2A":  ('a', 'p', 'M', None) ,
   1.201 +
   1.202 +"TTM":  ('t', 'd', 'M', None) ,
   1.203 +
   1.204 +"CSD":  ('c', 'p', 'M', None) ,
   1.205 +
   1.206 +"M2G":  ('g', 'r', 'M', None) ,
   1.207 +
   1.208 +"ASX":  ('x', 'p', None, None) ,
   1.209 +
   1.210 +"AFF":  ('n', 'd', None, None) ,
   1.211 +
   1.212 +"TTD":  ('t', 'd', 'M', None) ,
   1.213 +
   1.214 +"AET":  ('a', 'r', 'M', None) ,
   1.215 +
   1.216 +"C45":  ('c', 'd', 'M', None) ,
   1.217 +
   1.218 +"C46":  ('c', 'd', 'M', None) ,
   1.219 +
   1.220 +"FTR":  ('w', 'p', 'M', None) ,
   1.221 +
   1.222 +"BLY":  ('k', 'p', 'M', None) ,
   1.223 +
   1.224 +"C42":  ('c', 'd', 'M', None) ,
   1.225 +
   1.226 +"C2S":  ('c', 'd', 'M', None) ,
   1.227 +
   1.228 +"FTY":  ('y', 'p', 'M', None) ,
   1.229 +
   1.230 +"CSA":  ('c', 'p', 'M', None) ,
   1.231 +
   1.232 +"I5C":  ('c', 'd', 'M', None) ,
   1.233 +
   1.234 +"ALY":  ('k', 'p', 'M', None) ,
   1.235 +
   1.236 +"P1L":  ('c', 'p', 'M', None) ,
   1.237 +
   1.238 +"C49":  ('c', 'd', 'M', None) ,
   1.239 +
   1.240 +"DSP":  ('d', 'p', 'M', None) ,
   1.241 +
   1.242 +"AFA":  ('n', 'p', 'M', None) ,
   1.243 +
   1.244 +"P1P":  ('n', 'r', None, None) ,
   1.245 +
   1.246 +"U25":  ('u', 'r', 'M', None) ,
   1.247 +
   1.248 +"CHS":  ('x', 'p', None, None) ,
   1.249 +
   1.250 +"BLE":  ('l', 'p', 'M', None) ,
   1.251 +
   1.252 +"DSG":  ('n', 'p', 'M', None) ,
   1.253 +
   1.254 +"DSE":  ('s', 'p', 'M', None) ,
   1.255 +
   1.256 +"S4A":  ('a', 'd', 'M', None) ,
   1.257 +
   1.258 +"DLS":  ('k', 'p', 'M', None) ,
   1.259 +
   1.260 +"4SU":  ('u', 'r', 'M', None) ,
   1.261 +
   1.262 +"MA":  ('a', 'p', 'M', None) ,
   1.263 +
   1.264 +"TRX":  ('w', 'p', 'M', None) ,
   1.265 +
   1.266 +"DC":  ('C', 'd', None, None) ,
   1.267 +
   1.268 +"HLU":  ('l', 'p', 'M', None) ,
   1.269 +
   1.270 +"HSE":  ('s', 'p', 'M', None) ,
   1.271 +
   1.272 +"A5M":  ('c', 'r', 'M', None) ,
   1.273 +
   1.274 +"ALS":  ('a', 'p', 'M', None) ,
   1.275 +
   1.276 +"CBR":  ('c', 'd', 'M', None) ,
   1.277 +
   1.278 +"SHC":  ('c', 'p', 'M', None) ,
   1.279 +
   1.280 +"B2F":  ('f', 'p', 'M', None) ,
   1.281 +
   1.282 +"QUO":  ('g', 'r', 'M', None) ,
   1.283 +
   1.284 +"X4A":  ('n', 'd', None, None) ,
   1.285 +
   1.286 +"BE2":  ('x', 'p', None, None) ,
   1.287 +
   1.288 +"CM0":  ('n', 'r', None, None) ,
   1.289 +
   1.290 +"GLH":  ('q', 'p', 'M', None) ,
   1.291 +
   1.292 +"DOH":  ('d', 'p', 'M', None) ,
   1.293 +
   1.294 +"DON":  ('l', 'p', 'M', None) ,
   1.295 +
   1.296 +"GLM":  ('x', 'p', None, None) ,
   1.297 +
   1.298 +"GLN":  ('Q', 'p', None, None) ,
   1.299 +
   1.300 +"T4S":  ('t', 'd', 'M', None) ,
   1.301 +
   1.302 +"DOC":  ('c', 'd', 'M', None) ,
   1.303 +
   1.304 +"T3P":  ('t', 'd', 'M', None) ,
   1.305 +
   1.306 +"DOA":  ('x', 'p', None, None) ,
   1.307 +
   1.308 +"TOX":  ('w', 'p', 'M', None) ,
   1.309 +
   1.310 +"SMP":  ('a', 'd', 'M', None) ,
   1.311 +
   1.312 +"GLX":  ('x', 'p', None, None) ,
   1.313 +
   1.314 +"GLY":  ('G', 'p', None, None) ,
   1.315 +
   1.316 +"GLZ":  ('g', 'p', 'M', None) ,
   1.317 +
   1.318 +"CTG":  ('t', 'd', 'M', None) ,
   1.319 +
   1.320 +"T38":  ('n', 'r', None, None) ,
   1.321 +
   1.322 +"AKL":  ('d', 'p', 'M', None) ,
   1.323 +
   1.324 +"T36":  ('t', 'd', 'M', None) ,
   1.325 +
   1.326 +"T37":  ('t', 'd', 'M', None) ,
   1.327 +
   1.328 +"4TA":  ('n', 'r', None, None) ,
   1.329 +
   1.330 +"CTH":  ('t', 'p', 'M', None) ,
   1.331 +
   1.332 +"GLU":  ('E', 'p', None, None) ,
   1.333 +
   1.334 +"RCY":  ('c', 'p', 'M', None) ,
   1.335 +
   1.336 +"MDH":  ('x', 'p', None, None) ,
   1.337 +
   1.338 +"MDO":  ('x', 'p', None, None) ,
   1.339 +
   1.340 +"8OG":  ('g', 'd', 'M', None) ,
   1.341 +
   1.342 +"HCS":  ('x', 'p', None, None) ,
   1.343 +
   1.344 +"UD5":  ('u', 'r', 'M', None) ,
   1.345 +
   1.346 +"O2C":  ('n', 'd', None, None) ,
   1.347 +
   1.348 +"5FU":  ('u', 'r', 'M', None) ,
   1.349 +
   1.350 +"SDG":  ('g', 'd', 'M', None) ,
   1.351 +
   1.352 +"MDR":  ('n', 'd', None, None) ,
   1.353 +
   1.354 +"BSE":  ('s', 'p', 'M', None) ,
   1.355 +
   1.356 +"4IN":  ('x', 'p', None, None) ,
   1.357 +
   1.358 +"FCL":  ('f', 'p', 'M', None) ,
   1.359 +
   1.360 +"1SC":  ('c', 'r', 'M', None) ,
   1.361 +
   1.362 +"R7A":  ('c', 'p', 'M', None) ,
   1.363 +
   1.364 +"6IA":  ('a', 'r', 'M', None) ,
   1.365 +
   1.366 +"XTS":  ('g', 'r', 'M', None) ,
   1.367 +
   1.368 +"DFT":  ('n', 'd', None, None) ,
   1.369 +
   1.370 +"FMU":  ('n', 'r', None, None) ,
   1.371 +
   1.372 +"XTY":  ('n', 'd', None, None) ,
   1.373 +
   1.374 +"MVA":  ('v', 'p', 'M', None) ,
   1.375 +
   1.376 +"LTA":  ('x', 'p', None, None) ,
   1.377 +
   1.378 +"01W":  ('x', 'p', None, None) ,
   1.379 +
   1.380 +"DFI":  ('x', 'p', None, None) ,
   1.381 +
   1.382 +"YG":  ('g', 'r', 'M', None) ,
   1.383 +
   1.384 +"FMG":  ('g', 'd', 'M', None) ,
   1.385 +
   1.386 +"DFG":  ('g', 'd', 'M', None) ,
   1.387 +
   1.388 +"XTL":  ('t', 'd', 'M', None) ,
   1.389 +
   1.390 +"DFC":  ('c', 'd', 'M', None) ,
   1.391 +
   1.392 +"XTH":  ('t', 'd', 'M', None) ,
   1.393 +
   1.394 +"NTY":  ('y', 'p', 'M', None) ,
   1.395 +
   1.396 +"EDC":  ('g', 'd', 'M', None) ,
   1.397 +
   1.398 +"T49":  ('t', 'd', 'M', None) ,
   1.399 +
   1.400 +"EDA":  ('a', 'd', 'M', None) ,
   1.401 +
   1.402 +"O12":  ('x', 'p', None, None) ,
   1.403 +
   1.404 +"MMT":  ('t', 'd', 'M', None) ,
   1.405 +
   1.406 +"T41":  ('n', 'r', None, None) ,
   1.407 +
   1.408 +"LMS":  ('n', 'r', None, None) ,
   1.409 +
   1.410 +"0AP":  ('c', 'd', 'M', None) ,
   1.411 +
   1.412 +"ORQ":  ('r', 'p', 'M', None) ,
   1.413 +
   1.414 +"ORN":  ('a', 'p', 'M', None) ,
   1.415 +
   1.416 +"ALM":  ('a', 'p', 'M', None) ,
   1.417 +
   1.418 +"VB1":  ('k', 'p', 'M', None) ,
   1.419 +
   1.420 +"PUY":  ('n', 'r', None, None) ,
   1.421 +
   1.422 +"SBD":  ('s', 'p', 'M', None) ,
   1.423 +
   1.424 +"LPS":  ('s', 'p', 'M', None) ,
   1.425 +
   1.426 +"SC":  ('c', 'd', 'M', None) ,
   1.427 +
   1.428 +"ALT":  ('a', 'p', 'M', None) ,
   1.429 +
   1.430 +"GL3":  ('g', 'p', 'M', None) ,
   1.431 +
   1.432 +"LME":  ('e', 'p', 'M', None) ,
   1.433 +
   1.434 +"SBL":  ('s', 'p', 'M', None) ,
   1.435 +
   1.436 +"ALQ":  ('x', 'p', None, None) ,
   1.437 +
   1.438 +"CAB":  ('a', 'p', 'M', None) ,
   1.439 +
   1.440 +"GPL":  ('k', 'p', 'M', None) ,
   1.441 +
   1.442 +"CAY":  ('c', 'p', 'M', None) ,
   1.443 +
   1.444 +"DPR":  ('p', 'p', 'M', None) ,
   1.445 +
   1.446 +"DPQ":  ('y', 'p', 'M', None) ,
   1.447 +
   1.448 +"DPP":  ('a', 'p', 'M', None) ,
   1.449 +
   1.450 +"CAS":  ('c', 'p', 'M', None) ,
   1.451 +
   1.452 +"NC1":  ('s', 'p', 'M', None) ,
   1.453 +
   1.454 +"IYR":  ('y', 'p', 'M', None) ,
   1.455 +
   1.456 +"CAV":  ('x', 'p', None, None) ,
   1.457 +
   1.458 +"DPY":  ('n', 'd', None, None) ,
   1.459 +
   1.460 +"5AA":  ('a', 'd', 'M', None) ,
   1.461 +
   1.462 +"DPB":  ('t', 'd', 'M', None) ,
   1.463 +
   1.464 +"CAL":  ('x', 'p', None, None) ,
   1.465 +
   1.466 +"DPN":  ('f', 'p', 'M', None) ,
   1.467 +
   1.468 +"BAL":  ('a', 'p', 'M', None) ,
   1.469 +
   1.470 +"DPL":  ('p', 'p', 'M', None) ,
   1.471 +
   1.472 +"CAF":  ('c', 'p', 'M', None) ,
   1.473 +
   1.474 +"DPH":  ('f', 'p', 'M', None) ,
   1.475 +
   1.476 +"HIP":  ('h', 'p', 'M', None) ,
   1.477 +
   1.478 +"LG":  ('g', 'r', 'M', None) ,
   1.479 +
   1.480 +"LA2":  ('k', 'p', 'M', None) ,
   1.481 +
   1.482 +"KOR":  ('m', 'p', 'M', None) ,
   1.483 +
   1.484 +"LC":  ('c', 'r', 'M', None) ,
   1.485 +
   1.486 +"D4M":  ('t', 'd', 'M', None) ,
   1.487 +
   1.488 +"5MD":  ('n', 'd', None, None) ,
   1.489 +
   1.490 +"PGN":  ('g', 'd', 'M', None) ,
   1.491 +
   1.492 +"NHL":  ('e', 'p', 'M', None) ,
   1.493 +
   1.494 +"PGL":  ('x', 'p', None, None) ,
   1.495 +
   1.496 +"TA3":  ('t', 'd', 'M', None) ,
   1.497 +
   1.498 +"XCP":  ('x', 'p', None, None) ,
   1.499 +
   1.500 +"DYS":  ('c', 'p', 'M', None) ,
   1.501 +
   1.502 +"HIA":  ('h', 'p', 'M', None) ,
   1.503 +
   1.504 +"HIC":  ('h', 'p', 'M', None) ,
   1.505 +
   1.506 +"PGP":  ('g', 'r', 'M', None) ,
   1.507 +
   1.508 +"AB7":  ('x', 'p', None, None) ,
   1.509 +
   1.510 +"IIL":  ('i', 'p', 'M', None) ,
   1.511 +
   1.512 +"DYG":  ('x', 'p', None, None) ,
   1.513 +
   1.514 +"PGY":  ('g', 'p', 'M', None) ,
   1.515 +
   1.516 +"A":  ('A', 'r', None, None) ,
   1.517 +
   1.518 +"23F":  ('f', 'p', 'M', None) ,
   1.519 +
   1.520 +"143":  ('c', 'p', 'M', None) ,
   1.521 +
   1.522 +"HIQ":  ('h', 'p', 'M', None) ,
   1.523 +
   1.524 +"THR":  ('T', 'p', None, None) ,
   1.525 +
   1.526 +"PG7":  ('g', 'd', 'M', None) ,
   1.527 +
   1.528 +"ABR":  ('a', 'd', 'M', None) ,
   1.529 +
   1.530 +"HIS":  ('H', 'p', None, None) ,
   1.531 +
   1.532 +"ABT":  ('n', 'd', None, None) ,
   1.533 +
   1.534 +"PG1":  ('s', 'p', 'M', None) ,
   1.535 +
   1.536 +"2LU":  ('l', 'p', 'M', None) ,
   1.537 +
   1.538 +"NZH":  ('h', 'p', 'M', None) ,
   1.539 +
   1.540 +"P5P":  ('a', 'r', 'M', None) ,
   1.541 +
   1.542 +"STY":  ('y', 'p', 'M', None) ,
   1.543 +
   1.544 +"PG9":  ('g', 'p', 'M', None) ,
   1.545 +
   1.546 +"NCX":  ('n', 'd', None, None) ,
   1.547 +
   1.548 +"NCY":  ('x', 'p', None, None) ,
   1.549 +
   1.550 +"CFL":  ('c', 'd', 'M', None) ,
   1.551 +
   1.552 +"3MD":  ('d', 'p', 'M', None) ,
   1.553 +
   1.554 +"1AP":  ('a', 'd', 'M', None) ,
   1.555 +
   1.556 +"TFE":  ('t', 'd', 'M', None) ,
   1.557 +
   1.558 +"D3T":  ('t', 'd', 'M', None) ,
   1.559 +
   1.560 +"TFA":  ('x', 'p', None, None) ,
   1.561 +
   1.562 +"BHD":  ('d', 'p', 'M', None) ,
   1.563 +
   1.564 +"ONL":  ('x', 'p', None, None) ,
   1.565 +
   1.566 +"CFY":  ('x', 'p', None, None) ,
   1.567 +
   1.568 +"QLG":  ('x', 'p', None, None) ,
   1.569 +
   1.570 +"NCB":  ('a', 'p', 'M', None) ,
   1.571 +
   1.572 +"TFQ":  ('f', 'p', 'M', None) ,
   1.573 +
   1.574 +"XXY":  ('x', 'p', None, None) ,
   1.575 +
   1.576 +"23S":  ('x', 'p', None, None) ,
   1.577 +
   1.578 +"0AU":  ('n', 'd', None, None) ,
   1.579 +
   1.580 +"GHP":  ('g', 'p', 'M', None) ,
   1.581 +
   1.582 +"MIA":  ('a', 'r', 'M', None) ,
   1.583 +
   1.584 +"AP7":  ('a', 'd', 'M', None) ,
   1.585 +
   1.586 +"OAD":  ('n', 'r', None, None) ,
   1.587 +
   1.588 +"UDP":  ('n', 'r', None, None) ,
   1.589 +
   1.590 +"GHG":  ('q', 'p', 'M', None) ,
   1.591 +
   1.592 +"ZFB":  ('x', 'p', None, None) ,
   1.593 +
   1.594 +"C38":  ('c', 'd', 'M', None) ,
   1.595 +
   1.596 +"HAQ":  ('x', 'p', None, None) ,
   1.597 +
   1.598 +"C34":  ('c', 'd', 'M', None) ,
   1.599 +
   1.600 +"C37":  ('c', 'd', 'M', None) ,
   1.601 +
   1.602 +"ONE":  ('u', 'r', 'M', None) ,
   1.603 +
   1.604 +"C31":  ('c', 'r', 'M', None) ,
   1.605 +
   1.606 +"HAR":  ('r', 'p', 'M', None) ,
   1.607 +
   1.608 +"TY2":  ('y', 'p', 'M', None) ,
   1.609 +
   1.610 +"TY3":  ('y', 'p', 'M', None) ,
   1.611 +
   1.612 +"RT":  ('n', 'r', None, None) ,
   1.613 +
   1.614 +"4PE":  ('c', 'd', 'M', None) ,
   1.615 +
   1.616 +"4PD":  ('c', 'd', 'M', None) ,
   1.617 +
   1.618 +"4PC":  ('c', 'd', 'M', None) ,
   1.619 +
   1.620 +"SAC":  ('s', 'p', 'M', None) ,
   1.621 +
   1.622 +"PRO":  ('P', 'p', None, None) ,
   1.623 +
   1.624 +"PRN":  ('a', 'd', 'M', None) ,
   1.625 +
   1.626 +"6CL":  ('k', 'p', 'M', None) ,
   1.627 +
   1.628 +"4PH":  ('f', 'p', 'M', None) ,
   1.629 +
   1.630 +"FGL":  ('g', 'p', 'M', None) ,
   1.631 +
   1.632 +"6CT":  ('t', 'd', 'M', None) ,
   1.633 +
   1.634 +"IAS":  ('d', 'p', 'M', None) ,
   1.635 +
   1.636 +"PRS":  ('p', 'p', 'M', None) ,
   1.637 +
   1.638 +"UR3":  ('u', 'r', 'M', None) ,
   1.639 +
   1.640 +"SAR":  ('g', 'p', 'M', None) ,
   1.641 +
   1.642 +"TCY":  ('a', 'd', 'M', None) ,
   1.643 +
   1.644 +"4F3":  ('x', 'p', None, None) ,
   1.645 +
   1.646 +"TPG":  ('g', 'r', 'M', None) ,
   1.647 +
   1.648 +"LAL":  ('a', 'p', 'M', None) ,
   1.649 +
   1.650 +"TPC":  ('c', 'd', 'M', None) ,
   1.651 +
   1.652 +"PPU":  ('a', 'r', 'M', None) ,
   1.653 +
   1.654 +"CHF":  ('x', 'p', None, None) ,
   1.655 +
   1.656 +"BFD":  ('d', 'p', 'M', None) ,
   1.657 +
   1.658 +"TPO":  ('t', 'p', 'M', None) ,
   1.659 +
   1.660 +"H5M":  ('p', 'p', 'M', None) ,
   1.661 +
   1.662 +"AYG":  ('x', 'p', None, None) ,
   1.663 +
   1.664 +"TPL":  ('w', 'p', 'M', None) ,
   1.665 +
   1.666 +"AYA":  ('a', 'p', 'M', None) ,
   1.667 +
   1.668 +"6MC":  ('a', 'r', 'M', None) ,
   1.669 +
   1.670 +"6MA":  ('a', 'r', 'M', None) ,
   1.671 +
   1.672 +"GSR":  ('g', 'd', 'M', None) ,
   1.673 +
   1.674 +"EYS":  ('x', 'p', None, None) ,
   1.675 +
   1.676 +"LPL":  ('x', 'p', None, None) ,
   1.677 +
   1.678 +"6MZ":  ('n', 'r', None, None) ,
   1.679 +
   1.680 +"PR3":  ('c', 'p', 'M', None) ,
   1.681 +
   1.682 +"2ST":  ('t', 'd', 'M', None) ,
   1.683 +
   1.684 +"0NC":  ('a', 'p', 'M', None) ,
   1.685 +
   1.686 +"MRG":  ('g', 'd', 'M', None) ,
   1.687 +
   1.688 +"KYN":  ('a', 'p', 'M', None) ,
   1.689 +
   1.690 +"G2S":  ('g', 'd', 'M', None) ,
   1.691 +
   1.692 +"PYX":  ('c', 'p', 'M', None) ,
   1.693 +
   1.694 +"PYY":  ('n', 'r', None, None) ,
   1.695 +
   1.696 +"TYN":  ('y', 'p', 'M', None) ,
   1.697 +
   1.698 +"TYO":  ('y', 'p', 'M', None) ,
   1.699 +
   1.700 +"KAG":  ('g', 'r', 'M', None) ,
   1.701 +
   1.702 +"IPG":  ('g', 'p', 'M', None) ,
   1.703 +
   1.704 +"GH3":  ('g', 'r', 'M', None) ,
   1.705 +
   1.706 +"APP":  ('x', 'p', None, None) ,
   1.707 +
   1.708 +"IPN":  ('n', 'd', None, None) ,
   1.709 +
   1.710 +"TYB":  ('y', 'p', 'M', None) ,
   1.711 +
   1.712 +"FAG":  ('n', 'd', None, None) ,
   1.713 +
   1.714 +"DBY":  ('y', 'p', 'M', None) ,
   1.715 +
   1.716 +"APK":  ('k', 'p', 'M', None) ,
   1.717 +
   1.718 +"APH":  ('a', 'p', 'M', None) ,
   1.719 +
   1.720 +"API":  ('k', 'p', 'M', None) ,
   1.721 +
   1.722 +"TYX":  ('x', 'p', None, None) ,
   1.723 +
   1.724 +"APO":  ('x', 'p', None, None) ,
   1.725 +
   1.726 +"APM":  ('x', 'p', None, None) ,
   1.727 +
   1.728 +"TYT":  ('y', 'p', 'M', None) ,
   1.729 +
   1.730 +"TYU":  ('n', 'r', None, None) ,
   1.731 +
   1.732 +"DBS":  ('s', 'p', 'M', None) ,
   1.733 +
   1.734 +"DBU":  ('a', 'p', 'M', None) ,
   1.735 +
   1.736 +"TYQ":  ('y', 'p', 'M', None) ,
   1.737 +
   1.738 +"TYR":  ('Y', 'p', None, None) ,
   1.739 +
   1.740 +"APE":  ('x', 'p', None, None) ,
   1.741 +
   1.742 +"BT5":  ('n', 'r', None, None) ,
   1.743 +
   1.744 +"KST":  ('k', 'p', 'M', None) ,
   1.745 +
   1.746 +"2AD":  ('x', 'p', None, None) ,
   1.747 +
   1.748 +"ARG":  ('R', 'p', None, None) ,
   1.749 +
   1.750 +"HDP":  ('n', 'd', None, None) ,
   1.751 +
   1.752 +"CZ2":  ('c', 'p', 'M', None) ,
   1.753 +
   1.754 +"2AO":  ('x', 'p', None, None) ,
   1.755 +
   1.756 +"G33":  ('g', 'd', 'M', None) ,
   1.757 +
   1.758 +"AHO":  ('a', 'p', 'M', None) ,
   1.759 +
   1.760 +"P2U":  ('n', 'd', None, None) ,
   1.761 +
   1.762 +"P2T":  ('t', 'd', 'M', None) ,
   1.763 +
   1.764 +"MG1":  ('g', 'd', 'M', None) ,
   1.765 +
   1.766 +"G32":  ('g', 'd', 'M', None) ,
   1.767 +
   1.768 +"2AR":  ('a', 'd', 'M', None) ,
   1.769 +
   1.770 +"2AS":  ('x', 'p', None, None) ,
   1.771 +
   1.772 +"G46":  ('g', 'r', 'M', None) ,
   1.773 +
   1.774 +"G47":  ('g', 'd', 'M', None) ,
   1.775 +
   1.776 +"G48":  ('g', 'r', 'M', None) ,
   1.777 +
   1.778 +"G49":  ('g', 'd', 'M', None) ,
   1.779 +
   1.780 +"OCS":  ('c', 'p', 'M', None) ,
   1.781 +
   1.782 +"P2Y":  ('p', 'p', 'M', None) ,
   1.783 +
   1.784 +"PHA":  ('f', 'p', 'M', None) ,
   1.785 +
   1.786 +"NLQ":  ('q', 'p', 'M', None) ,
   1.787 +
   1.788 +"NLP":  ('l', 'p', 'M', None) ,
   1.789 +
   1.790 +"MLL":  ('l', 'p', 'M', None) ,
   1.791 +
   1.792 +"CEA":  ('c', 'p', 'M', None) ,
   1.793 +
   1.794 +"HV5":  ('a', 'p', 'M', None) ,
   1.795 +
   1.796 +"HMR":  ('r', 'p', 'M', None) ,
   1.797 +
   1.798 +"HRG":  ('r', 'p', 'M', None) ,
   1.799 +
   1.800 +"CSP":  ('c', 'p', 'M', None) ,
   1.801 +
   1.802 +"FA2":  ('a', 'd', 'M', None) ,
   1.803 +
   1.804 +"BMP":  ('n', 'r', None, None) ,
   1.805 +
   1.806 +"NLE":  ('l', 'p', 'M', None) ,
   1.807 +
   1.808 +"RTP":  ('n', 'r', None, None) ,
   1.809 +
   1.810 +"BMT":  ('t', 'p', 'M', None) ,
   1.811 +
   1.812 +"G38":  ('g', 'd', 'M', None) ,
   1.813 +
   1.814 +"CS4":  ('c', 'p', 'M', None) ,
   1.815 +
   1.816 +"2FI":  ('n', 'd', None, None) ,
   1.817 +
   1.818 +"TTS":  ('y', 'p', 'M', None) ,
   1.819 +
   1.820 +"CS1":  ('c', 'p', 'M', None) ,
   1.821 +
   1.822 +"CS0":  ('c', 'p', 'M', None) ,
   1.823 +
   1.824 +"NLO":  ('l', 'p', 'M', None) ,
   1.825 +
   1.826 +"NLN":  ('l', 'p', 'M', None) ,
   1.827 +
   1.828 +"SHP":  ('g', 'p', 'M', None) ,
   1.829 +
   1.830 +"CSL":  ('c', 'd', 'M', None) ,
   1.831 +
   1.832 +"SHR":  ('k', 'p', 'M', None) ,
   1.833 +
   1.834 +"OXX":  ('d', 'p', 'M', None) ,
   1.835 +
   1.836 +"B3Y":  ('y', 'p', 'M', None) ,
   1.837 +
   1.838 +"DLE":  ('l', 'p', 'M', None) ,
   1.839 +
   1.840 +"PYA":  ('a', 'p', 'M', None) ,
   1.841 +
   1.842 +"CSE":  ('c', 'p', 'M', None) ,
   1.843 +
   1.844 +"5FA":  ('a', 'r', 'M', None) ,
   1.845 +
   1.846 +"GCK":  ('c', 'd', 'M', None) ,
   1.847 +
   1.848 +"5FC":  ('c', 'd', 'M', None) ,
   1.849 +
   1.850 +"GGL":  ('e', 'p', 'M', None) ,
   1.851 +
   1.852 +"B3Q":  ('x', 'p', None, None) ,
   1.853 +
   1.854 +"B3S":  ('s', 'p', 'M', None) ,
   1.855 +
   1.856 +"B3L":  ('x', 'p', None, None) ,
   1.857 +
   1.858 +"A47":  ('a', 'd', 'M', None) ,
   1.859 +
   1.860 +"A44":  ('a', 'r', 'M', None) ,
   1.861 +
   1.862 +"5MU":  ('u', 'r', 'M', None) ,
   1.863 +
   1.864 +"CSY":  ('x', 'p', None, None) ,
   1.865 +
   1.866 +"A43":  ('a', 'd', 'M', None) ,
   1.867 +
   1.868 +"A40":  ('a', 'd', 'M', None) ,
   1.869 +
   1.870 +"B3K":  ('k', 'p', 'M', None) ,
   1.871 +
   1.872 +"B3D":  ('d', 'p', 'M', None) ,
   1.873 +
   1.874 +"B3E":  ('e', 'p', 'M', None) ,
   1.875 +
   1.876 +"DLY":  ('k', 'p', 'M', None) ,
   1.877 +
   1.878 +"MTU":  ('a', 'r', 'M', None) ,
   1.879 +
   1.880 +"B3A":  ('a', 'p', 'M', None) ,
   1.881 +
   1.882 +"CSS":  ('c', 'p', 'M', None) ,
   1.883 +
   1.884 +"CSR":  ('c', 'p', 'M', None) ,
   1.885 +
   1.886 +"CZZ":  ('c', 'p', 'M', None) ,
   1.887 +
   1.888 +"N10":  ('s', 'p', 'M', None) ,
   1.889 +
   1.890 +"MGG":  ('r', 'p', 'M', None) ,
   1.891 +
   1.892 +"A35":  ('a', 'd', 'M', None) ,
   1.893 +
   1.894 +"AFG":  ('g', 'd', 'M', None) ,
   1.895 +
   1.896 +"BTR":  ('w', 'p', 'M', None) ,
   1.897 +
   1.898 +"SSU":  ('u', 'r', 'M', None) ,
   1.899 +
   1.900 +"70U":  ('u', 'r', 'M', None) ,
   1.901 +
   1.902 +"A34":  ('a', 'd', 'M', None) ,
   1.903 +
   1.904 +"MGN":  ('q', 'p', 'M', None) ,
   1.905 +
   1.906 +"XCL":  ('c', 'd', 'M', None) ,
   1.907 +
   1.908 +"G4P":  ('n', 'r', None, None) ,
   1.909 +
   1.910 +"XCS":  ('n', 'd', None, None) ,
   1.911 +
   1.912 +"MGQ":  ('a', 'r', 'M', None) ,
   1.913 +
   1.914 +"ABS":  ('a', 'd', 'M', None) ,
   1.915 +
   1.916 +"BTA":  ('l', 'p', 'M', None) ,
   1.917 +
   1.918 +"MGV":  ('g', 'r', 'M', None) ,
   1.919 +
   1.920 +"XCT":  ('c', 'd', 'M', None) ,
   1.921 +
   1.922 +"TTQ":  ('w', 'p', 'M', None) ,
   1.923 +
   1.924 +"MGY":  ('g', 'p', 'M', None) ,
   1.925 +
   1.926 +"XCY":  ('c', 'd', 'M', None) ,
   1.927 +
   1.928 +"NNH":  ('r', 'p', 'M', None) ,
   1.929 +
   1.930 +"TBG":  ('g', 'p', 'M', None) ,
   1.931 +
   1.932 +"ATD":  ('t', 'd', 'M', None) ,
   1.933 +
   1.934 +"U8U":  ('u', 'r', 'M', None) ,
   1.935 +
   1.936 +"SNC":  ('c', 'p', 'M', None) ,
   1.937 +
   1.938 +"ALG":  ('r', 'p', 'M', None) ,
   1.939 +
   1.940 +"M1G":  ('g', 'd', 'M', None) ,
   1.941 +
   1.942 +"ATL":  ('t', 'd', 'M', None) ,
   1.943 +
   1.944 +"ATM":  ('t', 'd', 'M', None) ,
   1.945 +
   1.946 +"HPC":  ('f', 'p', 'M', None) ,
   1.947 +
   1.948 +"TP1":  ('t', 'd', 'M', None) ,
   1.949 +
   1.950 +"XUG":  ('g', 'd', 'M', None) ,
   1.951 +
   1.952 +"ISO":  ('x', 'p', None, None) ,
   1.953 +
   1.954 +"3MM":  ('x', 'p', None, None) ,
   1.955 +
   1.956 +"175":  ('x', 'p', None, None) ,
   1.957 +
   1.958 +"2TY":  ('y', 'p', 'M', None) ,
   1.959 +
   1.960 +"CSB":  ('c', 'p', 'M', None) ,
   1.961 +
   1.962 +"IT1":  ('k', 'p', 'M', None) ,
   1.963 +
   1.964 +"UN1":  ('x', 'p', None, None) ,
   1.965 +
   1.966 +"UN2":  ('x', 'p', None, None) ,
   1.967 +
   1.968 +"ASP":  ('D', 'p', None, None) ,
   1.969 +
   1.970 +"DTH":  ('t', 'p', 'M', None) ,
   1.971 +
   1.972 +"SER":  ('S', 'p', None, None) ,
   1.973 +
   1.974 +"ASU":  ('n', 'd', None, None) ,
   1.975 +
   1.976 +"SEP":  ('s', 'p', 'M', None) ,
   1.977 +
   1.978 +"LNT":  ('x', 'p', None, None) ,
   1.979 +
   1.980 +"A39":  ('a', 'r', 'M', None) ,
   1.981 +
   1.982 +"DGI":  ('g', 'd', 'M', None) ,
   1.983 +
   1.984 +"DGN":  ('q', 'p', 'M', None) ,
   1.985 +
   1.986 +"DGL":  ('e', 'p', 'M', None) ,
   1.987 +
   1.988 +"SEG":  ('a', 'p', 'M', None) ,
   1.989 +
   1.990 +"ASB":  ('d', 'p', 'M', None) ,
   1.991 +
   1.992 +"ASA":  ('d', 'p', 'M', None) ,
   1.993 +
   1.994 +"SEC":  ('a', 'p', 'M', None) ,
   1.995 +
   1.996 +"SEB":  ('s', 'p', 'M', None) ,
   1.997 +
   1.998 +"0A9":  ('f', 'p', 'M', None) ,
   1.999 +
  1.1000 +"ASK":  ('d', 'p', 'M', None) ,
  1.1001 +
  1.1002 +"PVH":  ('h', 'p', 'M', None) ,
  1.1003 +
  1.1004 +"ASI":  ('d', 'p', 'M', None) ,
  1.1005 +
  1.1006 +"SEL":  ('s', 'p', 'M', None) ,
  1.1007 +
  1.1008 +"ASN":  ('N', 'p', None, None) ,
  1.1009 +
  1.1010 +"ASM":  ('x', 'p', None, None) ,
  1.1011 +
  1.1012 +"ASL":  ('d', 'p', 'M', None) ,
  1.1013 +
  1.1014 +"AS2":  ('d', 'p', 'M', None) ,
  1.1015 +
  1.1016 +"IMC":  ('c', 'd', 'M', None) ,
  1.1017 +
  1.1018 +"A3P":  ('a', 'r', 'M', None) ,
  1.1019 +
  1.1020 +"CLH":  ('k', 'p', 'M', None) ,
  1.1021 +
  1.1022 +"3DR":  ('n', 'd', None, None) ,
  1.1023 +
  1.1024 +"FRD":  ('x', 'p', None, None) ,
  1.1025 +
  1.1026 +"CLD":  ('a', 'p', 'M', None) ,
  1.1027 +
  1.1028 +"CLE":  ('l', 'p', 'M', None) ,
  1.1029 +
  1.1030 +"PDU":  ('n', 'd', None, None) ,
  1.1031 +
  1.1032 +"CLG":  ('k', 'p', 'M', None) ,
  1.1033 +
  1.1034 +"BBC":  ('c', 'p', 'M', None) ,
  1.1035 +
  1.1036 +"TFO":  ('a', 'd', 'M', None) ,
  1.1037 +
  1.1038 +"CLB":  ('a', 'p', 'M', None) ,
  1.1039 +
  1.1040 +"TLC":  ('t', 'd', 'M', None) ,
  1.1041 +
  1.1042 +"2DM":  ('n', 'd', None, None) ,
  1.1043 +
  1.1044 +"A3A":  ('a', 'd', 'M', None) ,
  1.1045 +
  1.1046 +"PDL":  ('x', 'p', None, None) ,
  1.1047 +
  1.1048 +"3DA":  ('a', 'd', 'M', None) ,
  1.1049 +
  1.1050 +"GT9":  ('c', 'p', 'M', None) ,
  1.1051 +
  1.1052 +"CLV":  ('x', 'p', None, None) ,
  1.1053 +
  1.1054 +"PDD":  ('x', 'p', None, None) ,
  1.1055 +
  1.1056 +"1TQ":  ('w', 'p', 'M', None) ,
  1.1057 +
  1.1058 +"SEM":  ('x', 'p', None, None) ,
  1.1059 +
  1.1060 +"TGP":  ('g', 'd', 'M', None) ,
  1.1061 +
  1.1062 +"OMC":  ('c', 'r', 'M', None) ,
  1.1063 +
  1.1064 +"AEA":  ('x', 'p', None, None) ,
  1.1065 +
  1.1066 +"OMG":  ('g', 'r', 'M', None) ,
  1.1067 +
  1.1068 +"H2U":  ('u', 'r', 'M', None) ,
  1.1069 +
  1.1070 +"A38":  ('a', 'd', 'M', None) ,
  1.1071 +
  1.1072 +"DTY":  ('y', 'p', 'M', None) ,
  1.1073 +
  1.1074 +"PVL":  ('x', 'p', None, None) ,
  1.1075 +
  1.1076 +"ABA":  ('a', 'p', 'M', None) ,
  1.1077 +
  1.1078 +"OMU":  ('u', 'r', 'M', None) ,
  1.1079 +
  1.1080 +"OMT":  ('m', 'p', 'M', None) ,
  1.1081 +
  1.1082 +"CRF":  ('x', 'p', None, None) ,
  1.1083 +
  1.1084 +"FPA":  ('f', 'p', 'M', None) ,
  1.1085 +
  1.1086 +"VMS":  ('x', 'p', None, None) ,
  1.1087 +
  1.1088 +"T11":  ('f', 'p', 'M', None) ,
  1.1089 +
  1.1090 +"2MR":  ('r', 'p', 'M', None) ,
  1.1091 +
  1.1092 +"DNE":  ('l', 'p', 'M', None) ,
  1.1093 +
  1.1094 +"5IC":  ('c', 'r', 'M', None) ,
  1.1095 +
  1.1096 +"RC7":  ('x', 'p', None, None) ,
  1.1097 +
  1.1098 +"BPE":  ('c', 'p', 'M', None) ,
  1.1099 +
  1.1100 +"2MT":  ('p', 'p', 'M', None) ,
  1.1101 +
  1.1102 +"2MU":  ('u', 'r', 'M', None) ,
  1.1103 +
  1.1104 +"DG":  ('G', 'd', None, None) ,
  1.1105 +
  1.1106 +"UCL":  ('n', 'd', None, None) ,
  1.1107 +
  1.1108 +"DA":  ('A', 'd', None, None) ,
  1.1109 +
  1.1110 +"AEI":  ('d', 'p', 'M', None) ,
  1.1111 +
  1.1112 +"N5M":  ('c', 'r', 'M', None) ,
  1.1113 +
  1.1114 +"5IU":  ('n', 'd', None, None) ,
  1.1115 +
  1.1116 +"2MG":  ('g', 'r', 'M', None) ,
  1.1117 +
  1.1118 +"AAR":  ('r', 'p', 'M', None) ,
  1.1119 +
  1.1120 +"DT":  ('T', 'd', None, None) ,
  1.1121 +
  1.1122 +"DU":  ('n', 'd', None, None) ,
  1.1123 +
  1.1124 +"HV8":  ('x', 'p', None, None) ,
  1.1125 +
  1.1126 +"MC1":  ('s', 'p', 'M', None) ,
  1.1127 +
  1.1128 +"2FM":  ('m', 'p', 'M', None) ,
  1.1129 +
  1.1130 +"CYS":  ('C', 'p', None, None) ,
  1.1131 +
  1.1132 +"CYR":  ('c', 'p', 'M', None) ,
  1.1133 +
  1.1134 +"BIL":  ('x', 'p', None, None) ,
  1.1135 +
  1.1136 +"PCA":  ('e', 'p', 'M', None) ,
  1.1137 +
  1.1138 +"GYC":  ('x', 'p', None, None) ,
  1.1139 +
  1.1140 +"SMC":  ('c', 'p', 'M', None) ,
  1.1141 +
  1.1142 +"0AC":  ('g', 'p', 'M', None) ,
  1.1143 +
  1.1144 +"BIF":  ('f', 'p', 'M', None) ,
  1.1145 +
  1.1146 +"2BU":  ('a', 'd', 'M', None) ,
  1.1147 +
  1.1148 +"2BT":  ('t', 'd', 'M', None) ,
  1.1149 +
  1.1150 +"5PC":  ('c', 'd', 'M', None) ,
  1.1151 +
  1.1152 +"S2M":  ('t', 'd', 'M', None) ,
  1.1153 +
  1.1154 +"5MC":  ('c', 'r', 'M', None) ,
  1.1155 +
  1.1156 +"S2P":  ('a', 'p', 'M', None) ,
  1.1157 +
  1.1158 +"C1X":  ('k', 'p', 'M', None) ,
  1.1159 +
  1.1160 +"CYG":  ('c', 'p', 'M', None) ,
  1.1161 +
  1.1162 +"CYF":  ('c', 'p', 'M', None) ,
  1.1163 +
  1.1164 +"5PY":  ('t', 'd', 'M', None) ,
  1.1165 +
  1.1166 +"CYJ":  ('x', 'p', None, None) ,
  1.1167 +
  1.1168 +"BIU":  ('i', 'p', 'M', None) ,
  1.1169 +
  1.1170 +"ENP":  ('n', 'r', None, None) ,
  1.1171 +
  1.1172 +"AS9":  ('x', 'p', None, None) ,
  1.1173 +
  1.1174 +"CYM":  ('c', 'p', 'M', None) ,
  1.1175 +
  1.1176 +"CY3":  ('c', 'p', 'M', None) ,
  1.1177 +
  1.1178 +"DHN":  ('v', 'p', 'M', None) ,
  1.1179 +
  1.1180 +"CY1":  ('c', 'p', 'M', None) ,
  1.1181 +
  1.1182 +"CY0":  ('c', 'p', 'M', None) ,
  1.1183 +
  1.1184 +"SLZ":  ('k', 'p', 'M', None) ,
  1.1185 +
  1.1186 +"CY4":  ('c', 'p', 'M', None) ,
  1.1187 +
  1.1188 +"T5S":  ('t', 'd', 'M', None) ,
  1.1189 +
  1.1190 +"SLR":  ('p', 'p', 'M', None) ,
  1.1191 +
  1.1192 +"IML":  ('i', 'p', 'M', None) ,
  1.1193 +
  1.1194 +"32S":  ('x', 'p', None, None) ,
  1.1195 +
  1.1196 +"CSX":  ('c', 'p', 'M', None) ,
  1.1197 +
  1.1198 +"MFC":  ('x', 'p', None, None) ,
  1.1199 +
  1.1200 +"32T":  ('x', 'p', None, None) ,
  1.1201 +
  1.1202 +"TFT":  ('t', 'd', 'M', None) ,
  1.1203 +
  1.1204 +"MLZ":  ('k', 'p', 'M', None) ,
  1.1205 +
  1.1206 +"DHU":  ('u', 'r', 'M', None) ,
  1.1207 +
  1.1208 +"ASQ":  ('d', 'p', 'M', None) ,
  1.1209 +
  1.1210 +"SLA":  ('p', 'p', 'M', None) ,
  1.1211 +
  1.1212 +"DHP":  ('x', 'p', None, None) ,
  1.1213 +
  1.1214 +"E1X":  ('a', 'd', 'M', None) ,
  1.1215 +
  1.1216 +"XGL":  ('g', 'd', 'M', None) ,
  1.1217 +
  1.1218 +"MCL":  ('k', 'p', 'M', None) ,
  1.1219 +
  1.1220 +"TLB":  ('n', 'r', None, None) ,
  1.1221 +
  1.1222 +"MCG":  ('x', 'p', None, None) ,
  1.1223 +
  1.1224 +"OTB":  ('x', 'p', None, None) ,
  1.1225 +
  1.1226 +"FT6":  ('w', 'p', 'M', None) ,
  1.1227 +
  1.1228 +"XGA":  ('n', 'd', None, None) ,
  1.1229 +
  1.1230 +"AA4":  ('a', 'p', 'M', None) ,
  1.1231 +
  1.1232 +"R":  ('a', 'd', 'M', None) ,
  1.1233 +
  1.1234 +"GFL":  ('g', 'd', 'M', None) ,
  1.1235 +
  1.1236 +"10C":  ('c', 'r', 'M', None) ,
  1.1237 +
  1.1238 +"NRQ":  ('x', 'p', None, None) ,
  1.1239 +
  1.1240 +"XGU":  ('g', 'd', 'M', None) ,
  1.1241 +
  1.1242 +"MCS":  ('c', 'p', 'M', None) ,
  1.1243 +
  1.1244 +"D3":  ('n', 'd', None, None) ,
  1.1245 +
  1.1246 +"PAQ":  ('y', 'p', 'M', None) ,
  1.1247 +
  1.1248 +"2PR":  ('g', 'd', 'M', None) ,
  1.1249 +
  1.1250 +"PAT":  ('w', 'p', 'M', None) ,
  1.1251 +
  1.1252 +"PAU":  ('a', 'p', 'M', None) ,
  1.1253 +
  1.1254 +"CH":  ('c', 'r', 'M', None) ,
  1.1255 +
  1.1256 +"GCM":  ('x', 'p', None, None) ,
  1.1257 +
  1.1258 +"CSZ":  ('c', 'p', 'M', None) ,
  1.1259 +
  1.1260 +"GMS":  ('g', 'd', 'M', None) ,
  1.1261 +
  1.1262 +"HBN":  ('h', 'p', 'M', None) ,
  1.1263 +
  1.1264 +"TQQ":  ('w', 'p', 'M', None) ,
  1.1265 +
  1.1266 +"2PI":  ('x', 'p', None, None) ,
  1.1267 +
  1.1268 +"GSU":  ('e', 'p', 'M', None) ,
  1.1269 +
  1.1270 +"CSI":  ('g', 'p', 'M', None) ,
  1.1271 +
  1.1272 +"200":  ('f', 'p', 'M', None) ,
  1.1273 +
  1.1274 +"EXY":  ('l', 'p', 'M', None) ,
  1.1275 +
  1.1276 +"12A":  ('a', 'r', 'M', None) ,
  1.1277 +
  1.1278 +"DCL":  ('x', 'p', None, None) ,
  1.1279 +
  1.1280 +"UNK":  ('x', 'p', None, None) ,
  1.1281 +
  1.1282 +"DCI":  ('x', 'p', None, None) ,
  1.1283 +
  1.1284 +"DCG":  ('g', 'd', 'M', None) ,
  1.1285 +
  1.1286 +"4HT":  ('w', 'p', 'M', None) ,
  1.1287 +
  1.1288 +"CSU":  ('c', 'p', 'M', None) ,
  1.1289 +
  1.1290 +"HSO":  ('h', 'p', 'M', None) ,
  1.1291 +
  1.1292 +"HSL":  ('s', 'p', 'M', None) ,
  1.1293 +
  1.1294 +"TLN":  ('n', 'd', None, None) ,
  1.1295 +
  1.1296 +"TZB":  ('x', 'p', None, None) ,
  1.1297 +
  1.1298 +"BTC":  ('c', 'p', 'M', None) ,
  1.1299 +
  1.1300 +"DCY":  ('c', 'p', 'M', None) ,
  1.1301 +
  1.1302 +"DCT":  ('c', 'd', 'M', None) ,
  1.1303 +
  1.1304 +"4BF":  ('y', 'p', 'M', None) ,
  1.1305 +
  1.1306 +"C2L":  ('c', 'r', 'M', None) ,
  1.1307 +
  1.1308 +"RIA":  ('a', 'r', 'M', None) ,
  1.1309 +
  1.1310 +"IAM":  ('a', 'p', 'M', None) ,
  1.1311 +
  1.1312 +"B1F":  ('f', 'p', 'M', None) ,
  1.1313 +
  1.1314 +"GPN":  ('g', 'd', 'M', None) ,
  1.1315 +
  1.1316 +"C25":  ('c', 'r', 'M', None) ,
  1.1317 +
  1.1318 +"N2C":  ('x', 'p', None, None) ,
  1.1319 +
  1.1320 +"HAC":  ('a', 'p', 'M', None) ,
  1.1321 +
  1.1322 +"MEG":  ('e', 'p', 'M', None) ,
  1.1323 +
  1.1324 +"THO":  ('x', 'p', None, None) ,
  1.1325 +
  1.1326 +"BNO":  ('x', 'p', None, None) ,
  1.1327 +
  1.1328 +"125":  ('u', 'r', 'M', None) ,
  1.1329 +
  1.1330 +"126":  ('u', 'r', 'M', None) ,
  1.1331 +
  1.1332 +"127":  ('u', 'r', 'M', None) ,
  1.1333 +
  1.1334 +"128":  ('n', 'r', None, None) ,
  1.1335 +
  1.1336 +"X":  ('g', 'd', 'M', None) ,
  1.1337 +
  1.1338 +"HS8":  ('h', 'p', 'M', None) ,
  1.1339 +
  1.1340 +"NAM":  ('a', 'p', 'M', None) ,
  1.1341 +
  1.1342 +"THC":  ('t', 'p', 'M', None) ,
  1.1343 +
  1.1344 +"HRP":  ('w', 'p', 'M', None) ,
  1.1345 +
  1.1346 +"MNV":  ('v', 'p', 'M', None) ,
  1.1347 +
  1.1348 +"PHI":  ('f', 'p', 'M', None) ,
  1.1349 +
  1.1350 +"PHM":  ('f', 'p', 'M', None) ,
  1.1351 +
  1.1352 +"PHL":  ('f', 'p', 'M', None) ,
  1.1353 +
  1.1354 +"CSW":  ('c', 'p', 'M', None) ,
  1.1355 +
  1.1356 +"ZAD":  ('a', 'r', 'M', None) ,
  1.1357 +
  1.1358 +"OIC":  ('x', 'p', None, None) ,
  1.1359 +
  1.1360 +"PHE":  ('F', 'p', None, None) ,
  1.1361 +
  1.1362 +"PHD":  ('d', 'p', 'M', None) ,
  1.1363 +
  1.1364 +"SYS":  ('c', 'p', 'M', None) ,
  1.1365 +
  1.1366 +"BG1":  ('s', 'p', 'M', None) ,
  1.1367 +
  1.1368 +"NIY":  ('y', 'p', 'M', None) ,
  1.1369 +
  1.1370 +"MTR":  ('t', 'd', 'M', None) ,
  1.1371 +
  1.1372 +"OAS":  ('s', 'p', 'M', None) ,
  1.1373 +
  1.1374 +"BRU":  ('n', 'd', None, None) ,
  1.1375 +
  1.1376 +"NIT":  ('x', 'p', None, None) ,
  1.1377 +
  1.1378 +"OIP":  ('n', 'd', None, None) ,
  1.1379 +
  1.1380 +"0A0":  ('d', 'p', 'M', None) ,
  1.1381 +
  1.1382 +"0A1":  ('y', 'p', 'M', None) ,
  1.1383 +
  1.1384 +"0A2":  ('k', 'p', 'M', None) ,
  1.1385 +
  1.1386 +"CRQ":  ('x', 'p', None, None) ,
  1.1387 +
  1.1388 +"CRW":  ('x', 'p', None, None) ,
  1.1389 +
  1.1390 +"CRU":  ('e', 'p', 'M', None) ,
  1.1391 +
  1.1392 +"DMH":  ('n', 'p', 'M', None) ,
  1.1393 +
  1.1394 +"PRR":  ('a', 'p', 'M', None) ,
  1.1395 +
  1.1396 +"CRX":  ('x', 'p', None, None) ,
  1.1397 +
  1.1398 +"DMK":  ('d', 'p', 'M', None) ,
  1.1399 +
  1.1400 +"MHL":  ('l', 'p', 'M', None) ,
  1.1401 +
  1.1402 +"LAA":  ('d', 'p', 'M', None) ,
  1.1403 +
  1.1404 +"0ZM":  ('x', 'p', None, None) ,
  1.1405 +
  1.1406 +"DMT":  ('x', 'p', None, None) ,
  1.1407 +
  1.1408 +"CRG":  ('x', 'p', None, None) ,
  1.1409 +
  1.1410 +"0ZJ":  ('x', 'p', None, None) ,
  1.1411 +
  1.1412 +"0ZE":  ('x', 'p', None, None) ,
  1.1413 +
  1.1414 +"CRK":  ('x', 'p', None, None) ,
  1.1415 +
  1.1416 +"TPH":  ('x', 'p', None, None) ,
  1.1417 +
  1.1418 +"1PI":  ('x', 'p', None, None) ,
  1.1419 +
  1.1420 +"CRO":  ('x', 'p', None, None) ,
  1.1421 +
  1.1422 +"0ZC":  ('x', 'p', None, None) ,
  1.1423 +
  1.1424 +"MIS":  ('s', 'p', 'M', None) ,
  1.1425 +
  1.1426 +"C36":  ('c', 'd', 'M', None) ,
  1.1427 +
  1.1428 +"NFA":  ('f', 'p', 'M', None) ,
  1.1429 +
  1.1430 +"PU":  ('a', 'r', 'M', None) ,
  1.1431 +
  1.1432 +"G7M":  ('g', 'r', 'M', None) ,
  1.1433 +
  1.1434 +"S6G":  ('g', 'd', 'M', None) ,
  1.1435 +
  1.1436 +"LDH":  ('k', 'p', 'M', None) ,
  1.1437 +
  1.1438 +"TCP":  ('t', 'd', 'M', None) ,
  1.1439 +
  1.1440 +"TCQ":  ('x', 'p', None, None) ,
  1.1441 +
  1.1442 +"8AN":  ('a', 'r', 'M', None) ,
  1.1443 +
  1.1444 +"BUC":  ('c', 'p', 'M', None) ,
  1.1445 +
  1.1446 +"C32":  ('c', 'd', 'M', None) ,
  1.1447 +
  1.1448 +"7MG":  ('g', 'r', 'M', None) ,
  1.1449 +
  1.1450 +"BUG":  ('l', 'p', 'M', None) ,
  1.1451 +
  1.1452 +"LEU":  ('L', 'p', None, None) ,
  1.1453 +
  1.1454 +"MHO":  ('m', 'p', 'M', None) ,
  1.1455 +
  1.1456 +"C":  ('C', 'r', None, None) ,
  1.1457 +
  1.1458 +"DDX":  ('n', 'd', None, None) ,
  1.1459 +
  1.1460 +"OPR":  ('r', 'p', 'M', None) ,
  1.1461 +
  1.1462 +"FOX":  ('g', 'd', 'M', None) ,
  1.1463 +
  1.1464 +"MTY":  ('y', 'p', 'M', None) ,
  1.1465 +
  1.1466 +"TC1":  ('c', 'd', 'M', None) ,
  1.1467 +
  1.1468 +"FOE":  ('c', 'p', 'M', None) ,
  1.1469 +
  1.1470 +"MF3":  ('x', 'p', None, None) ,
  1.1471 +
  1.1472 +"DDN":  ('n', 'd', None, None) ,
  1.1473 +
  1.1474 +"FME":  ('m', 'p', 'M', None) ,
  1.1475 +
  1.1476 +"EFC":  ('c', 'p', 'M', None) ,
  1.1477 +
  1.1478 +"DDG":  ('g', 'd', 'M', None) ,
  1.1479 +
  1.1480 +"MHS":  ('h', 'p', 'M', None) ,
  1.1481 +
  1.1482 +"DDE":  ('h', 'p', 'M', None) ,
  1.1483 +
  1.1484 +"CR2":  ('x', 'p', None, None) ,
  1.1485 +
  1.1486 +"DSN":  ('s', 'p', 'M', None) ,
  1.1487 +
  1.1488 +"PSH":  ('h', 'p', 'M', None) ,
  1.1489 +
  1.1490 +"6MI":  ('n', 'd', None, None) ,
  1.1491 +
  1.1492 +"CR7":  ('x', 'p', None, None) ,
  1.1493 +
  1.1494 +"0AV":  ('a', 'd', 'M', None) ,
  1.1495 +
  1.1496 +"CR5":  ('g', 'p', 'M', None) ,
  1.1497 +
  1.1498 +"MOR":  ('x', 'p', None, None) ,
  1.1499 +
  1.1500 +"CR8":  ('x', 'p', None, None) ,
  1.1501 +
  1.1502 +"PSA":  ('f', 'p', 'M', None) ,
  1.1503 +
  1.1504 +"ANI":  ('x', 'p', None, None) ,
  1.1505 +
  1.1506 +"NP3":  ('n', 'd', None, None) ,
  1.1507 +
  1.1508 +"DM0":  ('k', 'p', 'M', None) ,
  1.1509 +
  1.1510 +"0AA":  ('v', 'p', 'M', None) ,
  1.1511 +
  1.1512 +"0AB":  ('v', 'p', 'M', None) ,
  1.1513 +
  1.1514 +"FOG":  ('f', 'p', 'M', None) ,
  1.1515 +
  1.1516 +"0AD":  ('g', 'd', 'M', None) ,
  1.1517 +
  1.1518 +"LCC":  ('n', 'd', None, None) ,
  1.1519 +
  1.1520 +"NVA":  ('v', 'p', 'M', None) ,
  1.1521 +
  1.1522 +"0AG":  ('l', 'p', 'M', None) ,
  1.1523 +
  1.1524 +"0AH":  ('s', 'p', 'M', None) ,
  1.1525 +
  1.1526 +"1MA":  ('a', 'r', 'M', None) ,
  1.1527 +
  1.1528 +"0AK":  ('d', 'p', 'M', None) ,
  1.1529 +
  1.1530 +"0AM":  ('a', 'd', 'M', None) ,
  1.1531 +
  1.1532 +"PST":  ('t', 'd', 'M', None) ,
  1.1533 +
  1.1534 +"PSU":  ('u', 'r', 'M', None) ,
  1.1535 +
  1.1536 +"1ZX":  ('x', 'p', None, None) ,
  1.1537 +
  1.1538 +"ILG":  ('e', 'p', 'M', None) ,
  1.1539 +
  1.1540 +"ILE":  ('I', 'p', None, None) ,
  1.1541 +
  1.1542 +"5CM":  ('c', 'd', 'M', None) ,
  1.1543 +
  1.1544 +"D11":  ('t', 'p', 'M', None) ,
  1.1545 +
  1.1546 +"UMS":  ('n', 'd', None, None) ,
  1.1547 +
  1.1548 +"X9Q":  ('x', 'p', None, None) ,
  1.1549 +
  1.1550 +"FGP":  ('s', 'p', 'M', None) ,
  1.1551 +
  1.1552 +"DVA":  ('v', 'p', 'M', None) ,
  1.1553 +
  1.1554 +"5ZA":  ('x', 'p', None, None) ,
  1.1555 +
  1.1556 +"BCC":  ('x', 'p', None, None) ,
  1.1557 +
  1.1558 +"TMB":  ('t', 'p', 'M', None) ,
  1.1559 +
  1.1560 +"3AH":  ('h', 'p', 'M', None) ,
  1.1561 +
  1.1562 +"BCX":  ('c', 'p', 'M', None) ,
  1.1563 +
  1.1564 +"KPI":  ('k', 'p', 'M', None) ,
  1.1565 +
  1.1566 +"A2L":  ('a', 'r', 'M', None) ,
  1.1567 +
  1.1568 +"A2M":  ('a', 'r', 'M', None) ,
  1.1569 +
  1.1570 +"ILX":  ('i', 'p', 'M', None) ,
  1.1571 +
  1.1572 +"PEC":  ('c', 'p', 'M', None) ,
  1.1573 +
  1.1574 +"IGL":  ('g', 'p', 'M', None) ,
  1.1575 +
  1.1576 +"OLE":  ('x', 'p', None, None) ,
  1.1577 +
  1.1578 +"LPG":  ('g', 'p', 'M', None) ,
  1.1579 +
  1.1580 +"DI":  ('n', 'd', None, None) ,
  1.1581 +
  1.1582 +"ALO":  ('t', 'p', 'M', None) ,
  1.1583 +
  1.1584 +"OLT":  ('t', 'p', 'M', None) ,
  1.1585 +
  1.1586 +"TBM":  ('t', 'p', 'M', None) ,
  1.1587 +
  1.1588 +"2AU":  ('u', 'r', 'M', None) ,
  1.1589 +
  1.1590 +"LED":  ('l', 'p', 'M', None) ,
  1.1591 +
  1.1592 +"OLZ":  ('s', 'p', 'M', None) ,
  1.1593 +
  1.1594 +"C6C":  ('c', 'p', 'M', None) ,
  1.1595 +
  1.1596 +"IEY":  ('x', 'p', None, None) ,
  1.1597 +
  1.1598 +"HEU":  ('n', 'd', None, None) ,
  1.1599 +
  1.1600 +"SRA":  ('a', 'r', 'M', None) ,
  1.1601 +
  1.1602 +"ZTH":  ('n', 'r', None, None) ,
  1.1603 +
  1.1604 +"NDN":  ('n', 'd', None, None) ,
  1.1605 +
  1.1606 +"C66":  ('x', 'p', None, None) ,
  1.1607 +
  1.1608 +"6CW":  ('w', 'p', 'M', None) ,
  1.1609 +
  1.1610 +"CR0":  ('x', 'p', None, None) ,
  1.1611 +
  1.1612 +"DBM":  ('n', 'r', None, None) ,
  1.1613 +
  1.1614 +"N":  ('n', 'r', None, None) ,
  1.1615 +
  1.1616 +"N6G":  ('g', 'r', 'M', None) ,
  1.1617 +
  1.1618 +"ALC":  ('a', 'p', 'M', None) ,
  1.1619 +
  1.1620 +"S1H":  ('s', 'p', 'M', None) ,
  1.1621 +
  1.1622 +"FZN":  ('k', 'p', 'M', None) ,
  1.1623 +
  1.1624 +"0SP":  ('a', 'd', 'M', None) ,
  1.1625 +
  1.1626 +"OBS":  ('x', 'p', None, None) ,
  1.1627 +
  1.1628 +"2NT":  ('t', 'd', 'M', None) ,
  1.1629 +
  1.1630 +"K1R":  ('c', 'p', 'M', None) ,
  1.1631 +
  1.1632 +"NMT":  ('t', 'd', 'M', None) ,
  1.1633 +
  1.1634 +"A23":  ('a', 'r', 'M', None) ,
  1.1635 +
  1.1636 +"D1P":  ('n', 'd', None, None) ,
  1.1637 +
  1.1638 +"NMS":  ('t', 'd', 'M', None) ,
  1.1639 +
  1.1640 +"CIR":  ('r', 'p', 'M', None) ,
  1.1641 +
  1.1642 +"CH6":  ('x', 'p', None, None) ,
  1.1643 +
  1.1644 +"BJH":  ('x', 'p', None, None) ,
  1.1645 +
  1.1646 +"YYG":  ('g', 'r', 'M', None) ,
  1.1647 +
  1.1648 +"2MA":  ('a', 'r', 'M', None) ,
  1.1649 +
  1.1650 +"NMC":  ('g', 'p', 'M', None) ,
  1.1651 +
  1.1652 +"0AY":  ('x', 'p', None, None) ,
  1.1653 +
  1.1654 +"UFP":  ('n', 'd', None, None) ,
  1.1655 +
  1.1656 +"SET":  ('s', 'p', 'M', None) ,
  1.1657 +
  1.1658 +"UFR":  ('n', 'd', None, None) ,
  1.1659 +
  1.1660 +"NMM":  ('r', 'p', 'M', None) ,
  1.1661 +
  1.1662 +"UFT":  ('n', 'd', None, None) ,
  1.1663 +
  1.1664 +"0AZ":  ('p', 'p', 'M', None) ,
  1.1665 +
  1.1666 +"5IT":  ('t', 'd', 'M', None) ,
  1.1667 +
  1.1668 +"DIL":  ('i', 'p', 'M', None) ,
  1.1669 +
  1.1670 +"FHL":  ('x', 'p', None, None) ,
  1.1671 +
  1.1672 +"0Z6":  ('x', 'p', None, None) ,
  1.1673 +
  1.1674 +"AR4":  ('e', 'p', 'M', None) ,
  1.1675 +
  1.1676 +"EIT":  ('t', 'd', 'M', None) ,
  1.1677 +
  1.1678 +"SD2":  ('x', 'p', None, None) ,
  1.1679 +
  1.1680 +"CH7":  ('x', 'p', None, None) ,
  1.1681 +
  1.1682 +"N5I":  ('n', 'd', None, None) ,
  1.1683 +
  1.1684 +"5AT":  ('t', 'd', 'M', None) ,
  1.1685 +
  1.1686 +"LOL":  ('x', 'p', None, None) ,
  1.1687 +
  1.1688 +"HYP":  ('p', 'p', 'M', None) ,
  1.1689 +
  1.1690 +"IYT":  ('t', 'p', 'M', None) ,
  1.1691 +
  1.1692 +"LOV":  ('x', 'p', None, None) ,
  1.1693 +
  1.1694 +"LCX":  ('k', 'p', 'M', None) ,
  1.1695 +
  1.1696 +"GND":  ('x', 'p', None, None) ,
  1.1697 +
  1.1698 +"GNE":  ('n', 'd', None, None) ,
  1.1699 +
  1.1700 +"FHU":  ('u', 'r', 'M', None) ,
  1.1701 +
  1.1702 +"C12":  ('x', 'p', None, None) ,
  1.1703 +
  1.1704 +"DIV":  ('v', 'p', 'M', None) ,
  1.1705 +
  1.1706 +"T6A":  ('a', 'r', 'M', None) ,
  1.1707 +
  1.1708 +"DIR":  ('r', 'p', 'M', None) ,
  1.1709 +
  1.1710 +"AIB":  ('a', 'p', 'M', None) ,
  1.1711 +
  1.1712 +"SOC":  ('c', 'p', 'M', None) ,
  1.1713 +
  1.1714 +"NSK":  ('x', 'p', None, None) ,
  1.1715 +
  1.1716 +"LCG":  ('g', 'd', 'M', None) ,
  1.1717 +
  1.1718 +"MT2":  ('m', 'p', 'M', None) ,
  1.1719 +
  1.1720 +"GAU":  ('e', 'p', 'M', None) ,
  1.1721 +
  1.1722 +"PPH":  ('l', 'p', 'M', None) ,
  1.1723 +
  1.1724 +"PPN":  ('f', 'p', 'M', None) ,
  1.1725 +
  1.1726 +"1MG":  ('g', 'r', 'M', None) ,
  1.1727 +
  1.1728 +"GAO":  ('g', 'r', 'M', None) ,
  1.1729 +
  1.1730 +"FAI":  ('n', 'r', None, None) ,
  1.1731 +
  1.1732 +"PPW":  ('g', 'd', 'M', None) ,
  1.1733 +
  1.1734 +"2ML":  ('l', 'p', 'M', None) ,
  1.1735 +
  1.1736 +"MBZ":  ('n', 'd', None, None) ,
  1.1737 +
  1.1738 +"TPN":  ('t', 'd', 'M', None) ,
  1.1739 +
  1.1740 +"SOY":  ('s', 'p', 'M', None) ,
  1.1741 +
  1.1742 +"CBV":  ('c', 'r', 'M', None) ,
  1.1743 +
  1.1744 +"MBQ":  ('y', 'p', 'M', None) ,
  1.1745 +
  1.1746 +"G31":  ('g', 'd', 'M', None) ,
  1.1747 +
  1.1748 +"HTI":  ('c', 'p', 'M', None) ,
  1.1749 +
  1.1750 +"XX1":  ('k', 'p', 'M', None) ,
  1.1751 +
  1.1752 +"6OG":  ('g', 'd', 'M', None) ,
  1.1753 +
  1.1754 +"0AF":  ('w', 'p', 'M', None) ,
  1.1755 +
  1.1756 +"G36":  ('g', 'd', 'M', None) ,
  1.1757 +
  1.1758 +"I":  ('n', 'r', None, None) ,
  1.1759 +
  1.1760 +"YOF":  ('y', 'p', 'M', None) ,
  1.1761 +
  1.1762 +"HPQ":  ('f', 'p', 'M', None) ,
  1.1763 +
  1.1764 +"LCA":  ('a', 'r', 'M', None) ,
  1.1765 +
  1.1766 +"IU":  ('u', 'r', 'M', None) ,
  1.1767 +
  1.1768 +"CYQ":  ('c', 'p', 'M', None) ,
  1.1769 +
  1.1770 +"M0H":  ('c', 'p', 'M', None) ,
  1.1771 +
  1.1772 +"FA5":  ('n', 'r', None, None) ,
  1.1773 +
  1.1774 +"LVG":  ('g', 'p', 'M', None) ,
  1.1775 +
  1.1776 +"HPH":  ('x', 'p', None, None) ,
  1.1777 +
  1.1778 +"IRN":  ('n', 'r', None, None) ,
  1.1779 +
  1.1780 +"Y":  ('a', 'd', 'M', None) ,
  1.1781 +
  1.1782 +"IC":  ('c', 'r', 'M', None) ,
  1.1783 +
  1.1784 +"4DP":  ('w', 'p', 'M', None) ,
  1.1785 +
  1.1786 +"HPE":  ('f', 'p', 'M', None) ,
  1.1787 +
  1.1788 +"PR5":  ('a', 'r', 'M', None) ,
  1.1789 +
  1.1790 +"CDE":  ('x', 'p', None, None) ,
  1.1791 +
  1.1792 +"SDP":  ('s', 'p', 'M', None) ,
  1.1793 +
  1.1794 +"GN7":  ('g', 'd', 'M', None) ,
  1.1795 +
  1.1796 +"ARV":  ('x', 'p', None, None) ,
  1.1797 +
  1.1798 +"2AT":  ('t', 'd', 'M', None) ,
  1.1799 +
  1.1800 +"T66":  ('x', 'p', None, None) ,
  1.1801 +
  1.1802 +"LCK":  ('k', 'p', 'M', None) ,
  1.1803 +
  1.1804 +"EHP":  ('f', 'p', 'M', None) ,
  1.1805 +
  1.1806 +"CHP":  ('g', 'p', 'M', None) ,
  1.1807 +
  1.1808 +"HY3":  ('p', 'p', 'M', None) ,
  1.1809 +
  1.1810 +"THX":  ('n', 'd', None, None) ,
  1.1811 +
  1.1812 +"LCH":  ('n', 'd', None, None) ,
  1.1813 +
  1.1814 +"4MF":  ('n', 'd', None, None) ,
  1.1815 +
  1.1816 +"DTR":  ('w', 'p', 'M', None) ,
  1.1817 +
  1.1818 +"MOD":  ('x', 'p', None, None) ,
  1.1819 +
  1.1820 +"4MM":  ('x', 'p', None, None) ,
  1.1821 +
  1.1822 +"ARO":  ('r', 'p', 'M', None) ,
  1.1823 +
  1.1824 +"GSS":  ('g', 'd', 'M', None) ,
  1.1825 +
  1.1826 +"DRZ":  ('n', 'd', None, None) ,
  1.1827 +
  1.1828 +"CCY":  ('x', 'p', None, None) ,
  1.1829 +
  1.1830 +"TPQ":  ('y', 'p', 'M', None) ,
  1.1831 +
  1.1832 +"5CS":  ('c', 'p', 'M', None) ,
  1.1833 +
  1.1834 +"4OC":  ('c', 'r', 'M', None) ,
  1.1835 +
  1.1836 +"DRP":  ('n', 'd', None, None) ,
  1.1837 +
  1.1838 +"BOR":  ('r', 'p', 'M', None) ,
  1.1839 +
  1.1840 +"DRT":  ('t', 'd', 'M', None) ,
  1.1841 +
  1.1842 +"CCS":  ('c', 'p', 'M', None) ,
  1.1843 +
  1.1844 +"TS":  ('n', 'd', None, None) ,
  1.1845 +
  1.1846 +"MME":  ('m', 'p', 'M', None) ,
  1.1847 +
  1.1848 +"CCL":  ('k', 'p', 'M', None) ,
  1.1849 +
  1.1850 +"GSC":  ('g', 'p', 'M', None) ,
  1.1851 +
  1.1852 +"DRM":  ('n', 'd', None, None) ,
  1.1853 +
  1.1854 +"4FB":  ('p', 'p', 'M', None) ,
  1.1855 +
  1.1856 +"GYS":  ('x', 'p', None, None) ,
  1.1857 +
  1.1858 +"NAL":  ('a', 'p', 'M', None) ,
  1.1859 +
  1.1860 +"6MT":  ('a', 'r', 'M', None) ,
  1.1861 +
  1.1862 +"CCC":  ('c', 'r', 'M', None) ,
  1.1863 +
  1.1864 +"UMP":  ('u', 'r', 'M', None) ,
  1.1865 +
  1.1866 +"ML3":  ('k', 'p', 'M', None) ,
  1.1867 +
  1.1868 +"LPD":  ('p', 'p', 'M', None) ,
  1.1869 +
  1.1870 +"OHI":  ('h', 'p', 'M', None) ,
  1.1871 +
  1.1872 +"LYR":  ('k', 'p', 'M', None) ,
  1.1873 +
  1.1874 +"LYS":  ('K', 'p', None, None) ,
  1.1875 +
  1.1876 +"LYX":  ('k', 'p', 'M', None) ,
  1.1877 +
  1.1878 +"CYA":  ('c', 'p', 'M', None) ,
  1.1879 +
  1.1880 +"LYZ":  ('k', 'p', 'M', None) ,
  1.1881 +
  1.1882 +"ODP":  ('n', 'r', None, None) ,
  1.1883 +
  1.1884 +"C3Y":  ('c', 'p', 'M', None) ,
  1.1885 +
  1.1886 +"POM":  ('p', 'p', 'M', None) ,
  1.1887 +
  1.1888 +"LYM":  ('k', 'p', 'M', None) ,
  1.1889 +
  1.1890 +"LYN":  ('k', 'p', 'M', None) ,
  1.1891 +
  1.1892 +"GLQ":  ('e', 'p', 'M', None) ,
  1.1893 +
  1.1894 +"PIV":  ('x', 'p', None, None) ,
  1.1895 +
  1.1896 +"OHS":  ('d', 'p', 'M', None) ,
  1.1897 +
  1.1898 +"X9A":  ('x', 'p', None, None) ,
  1.1899 +
  1.1900 +"SMT":  ('n', 'r', None, None) ,
  1.1901 +
  1.1902 +"XAR":  ('n', 'd', None, None) ,
  1.1903 +
  1.1904 +"CYD":  ('c', 'p', 'M', None) ,
  1.1905 +
  1.1906 +"SVA":  ('s', 'p', 'M', None) ,
  1.1907 +
  1.1908 +"5HT":  ('t', 'd', 'M', None) ,
  1.1909 +
  1.1910 +"5HU":  ('n', 'd', None, None) ,
  1.1911 +
  1.1912 +"XAL":  ('a', 'd', 'M', None) ,
  1.1913 +
  1.1914 +"T":  ('n', 'd', None, None) ,
  1.1915 +
  1.1916 +"5HP":  ('e', 'p', 'M', None) ,
  1.1917 +
  1.1918 +"4SC":  ('c', 'd', 'M', None) ,
  1.1919 +
  1.1920 +"CQR":  ('x', 'p', None, None) ,
  1.1921 +
  1.1922 +"XAD":  ('a', 'd', 'M', None) ,
  1.1923 +
  1.1924 +"XAE":  ('n', 'd', None, None) ,
  1.1925 +
  1.1926 +"TYI":  ('y', 'p', 'M', None) ,
  1.1927 +
  1.1928 +"VLL":  ('x', 'p', None, None) ,
  1.1929 +
  1.1930 +"2BD":  ('n', 'd', None, None) ,
  1.1931 +
  1.1932 +"IIC":  ('x', 'p', None, None) ,
  1.1933 +
  1.1934 +"A66":  ('x', 'p', None, None) ,
  1.1935 +
  1.1936 +"2EG":  ('g', 'd', 'M', None) ,
  1.1937 +
  1.1938 +"2SA":  ('n', 'r', None, None) ,
  1.1939 +
  1.1940 +"2CO":  ('c', 'p', 'M', None) ,
  1.1941 +
  1.1942 +"TMD":  ('t', 'p', 'M', None) ,
  1.1943 +
  1.1944 +"CXM":  ('m', 'p', 'M', None) ,
  1.1945 +
  1.1946 +"ALA":  ('A', 'p', None, None) ,
  1.1947 +
  1.1948 +"GOM":  ('g', 'r', 'M', None) ,
  1.1949 +
  1.1950 +"2VA":  ('v', 'p', 'M', None) ,
  1.1951 +
  1.1952 +"5BU":  ('u', 'r', 'M', None) ,
  1.1953 +
  1.1954 +"IGU":  ('g', 'd', 'M', None) ,
  1.1955 +
  1.1956 +"MLE":  ('l', 'p', 'M', None) ,
  1.1957 +
  1.1958 +"T39":  ('n', 'r', None, None) ,
  1.1959 +
  1.1960 +"FLT":  ('y', 'p', 'M', None) ,
  1.1961 +
  1.1962 +"U37":  ('u', 'r', 'M', None) ,
  1.1963 +
  1.1964 +"U36":  ('u', 'r', 'M', None) ,
  1.1965 +
  1.1966 +"DHL":  ('x', 'p', None, None) ,
  1.1967 +
  1.1968 +"U33":  ('n', 'd', None, None) ,
  1.1969 +
  1.1970 +"TIH":  ('a', 'p', 'M', None) ,
  1.1971 +
  1.1972 +"SMF":  ('f', 'p', 'M', None) ,
  1.1973 +
  1.1974 +"FLA":  ('a', 'p', 'M', None) ,
  1.1975 +
  1.1976 +"HOB":  ('n', 'd', None, None) ,
  1.1977 +
  1.1978 +"FLE":  ('l', 'p', 'M', None) ,
  1.1979 +
  1.1980 +"VDL":  ('x', 'p', None, None) ,
  1.1981 +
  1.1982 +"A1P":  ('n', 'd', None, None) ,
  1.1983 +
  1.1984 +"0G6":  ('x', 'p', None, None) ,
  1.1985 +
  1.1986 +"LLY":  ('k', 'p', 'M', None) ,
  1.1987 +
  1.1988 +"DHI":  ('h', 'p', 'M', None) ,
  1.1989 +
  1.1990 +"RON":  ('x', 'p', None, None) ,
  1.1991 +
  1.1992 +"PTH":  ('y', 'p', 'M', None) ,
  1.1993 +
  1.1994 +"T32":  ('t', 'd', 'M', None) ,
  1.1995 +
  1.1996 +"LLP":  ('k', 'p', 'M', None) ,
  1.1997 +
  1.1998 +"MNU":  ('u', 'r', 'M', None) ,
  1.1999 +
  1.2000 +"PTA":  ('x', 'p', None, None) ,
  1.2001 +
  1.2002 +"TZO":  ('x', 'p', None, None) ,
  1.2003 +
  1.2004 +"DBZ":  ('a', 'p', 'M', None) ,
  1.2005 +
  1.2006 +"MNL":  ('l', 'p', 'M', None) ,
  1.2007 +
  1.2008 +"APN":  ('a', 'd', 'M', None) ,
  1.2009 +
  1.2010 +"OCY":  ('c', 'p', 'M', None) ,
  1.2011 +
  1.2012 +"BCS":  ('c', 'p', 'M', None) ,
  1.2013 +
  1.2014 +"OSE":  ('s', 'p', 'M', None) ,
  1.2015 +
  1.2016 +"3TY":  ('x', 'p', None, None) ,
  1.2017 +
  1.2018 +"SCS":  ('c', 'p', 'M', None) ,
  1.2019 +
  1.2020 +"TYY":  ('y', 'p', 'M', None) ,
  1.2021 +
  1.2022 +"0A5":  ('n', 'p', 'M', None) ,
  1.2023 +
  1.2024 +"PBT":  ('n', 'd', None, None) ,
  1.2025 +
  1.2026 +"CWR":  ('s', 'p', 'M', None) ,
  1.2027 +
  1.2028 +"TRO":  ('w', 'p', 'M', None) ,
  1.2029 +
  1.2030 +"TRN":  ('w', 'p', 'M', None) ,
  1.2031 +
  1.2032 +"PYO":  ('u', 'r', 'M', None) ,
  1.2033 +
  1.2034 +"ZGU":  ('g', 'r', 'M', None) ,
  1.2035 +
  1.2036 +"TRG":  ('k', 'p', 'M', None) ,
  1.2037 +
  1.2038 +"TRF":  ('w', 'p', 'M', None) ,
  1.2039 +
  1.2040 +"R1F":  ('c', 'p', 'M', None) ,
  1.2041 +
  1.2042 +"M5M":  ('c', 'r', 'M', None) ,
  1.2043 +
  1.2044 +"PBF":  ('f', 'p', 'M', None) ,
  1.2045 +
  1.2046 +"R1B":  ('c', 'p', 'M', None) ,
  1.2047 +
  1.2048 +"DHA":  ('a', 'p', 'M', None) ,
  1.2049 +
  1.2050 +"YCM":  ('c', 'p', 'M', None) ,
  1.2051 +
  1.2052 +"R1A":  ('c', 'p', 'M', None) ,
  1.2053 +
  1.2054 +"TRQ":  ('w', 'p', 'M', None) ,
  1.2055 +
  1.2056 +"TRP":  ('W', 'p', None, None) ,
  1.2057 +
  1.2058 +"T23":  ('n', 'r', None, None) ,
  1.2059 +
  1.2060 +"TRW":  ('w', 'p', 'M', None) ,
  1.2061 +
  1.2062 +"4FW":  ('w', 'p', 'M', None) ,
  1.2063 +
  1.2064 +"IVA":  ('x', 'p', None, None) ,
  1.2065 +
  1.2066 +"VOL":  ('x', 'p', None, None) ,
  1.2067 +
  1.2068 +"6HT":  ('t', 'd', 'M', None) ,
  1.2069 +
  1.2070 +"6HG":  ('g', 'd', 'M', None) ,
  1.2071 +
  1.2072 +"MPJ":  ('x', 'p', None, None) ,
  1.2073 +
  1.2074 +"C43":  ('c', 'r', 'M', None) ,
  1.2075 +
  1.2076 +"MPH":  ('x', 'p', None, None) ,
  1.2077 +
  1.2078 +"AVN":  ('x', 'p', None, None) ,
  1.2079 +
  1.2080 +"M3L":  ('k', 'p', 'M', None) ,
  1.2081 +
  1.2082 +"C5C":  ('c', 'p', 'M', None) ,
  1.2083 +
  1.2084 +"HTR":  ('w', 'p', 'M', None) ,
  1.2085 +
  1.2086 +"MPQ":  ('g', 'p', 'M', None) ,
  1.2087 +
  1.2088 +"ESC":  ('m', 'p', 'M', None) ,
  1.2089 +
  1.2090 +"3ME":  ('n', 'd', None, None) ,
  1.2091 +
  1.2092 +"TYS":  ('y', 'p', 'M', None) ,
  1.2093 +
  1.2094 +"6HA":  ('a', 'd', 'M', None) ,
  1.2095 +
  1.2096 +"KCX":  ('k', 'p', 'M', None) ,
  1.2097 +
  1.2098 +"6HC":  ('c', 'd', 'M', None) ,
  1.2099 +
  1.2100 +"AVC":  ('a', 'r', 'M', None) ,
  1.2101 +
  1.2102 +"GTP":  ('g', 'r', 'M', None) ,
  1.2103 +
  1.2104 +"ACB":  ('d', 'p', 'M', None) ,
  1.2105 +
  1.2106 +"2SI":  ('x', 'p', None, None) ,
  1.2107 +
  1.2108 +"NEM":  ('h', 'p', 'M', None) ,
  1.2109 +
  1.2110 +"N7P":  ('p', 'p', 'M', None) ,
  1.2111 +
  1.2112 +"SUB":  ('x', 'p', None, None) ,
  1.2113 +
  1.2114 +"2AG":  ('g', 'p', 'M', None) ,
  1.2115 +
  1.2116 +"SUN":  ('s', 'p', 'M', None) ,
  1.2117 +
  1.2118 +"SUI":  ('x', 'p', None, None) ,
  1.2119 +
  1.2120 +"ACL":  ('r', 'p', 'M', None) ,
  1.2121 +
  1.2122 +"SUR":  ('u', 'r', 'M', None) ,
  1.2123 +
  1.2124 +"BVP":  ('n', 'd', None, None) ,
  1.2125 +
  1.2126 +"HFA":  ('x', 'p', None, None) ,
  1.2127 +
  1.2128 +"LET":  ('x', 'p', None, None) ,
  1.2129 +
  1.2130 +"0A8":  ('c', 'p', 'M', None) ,
  1.2131 +
  1.2132 +"D4P":  ('x', 'p', None, None) ,
  1.2133 +
  1.2134 +"2OT":  ('t', 'd', 'M', None) ,
  1.2135 +
  1.2136 +"NEP":  ('h', 'p', 'M', None) ,
  1.2137 +
  1.2138 +"PMT":  ('c', 'r', 'M', None) ,
  1.2139 +
  1.2140 +"2DT":  ('t', 'd', 'M', None) ,
  1.2141 +
  1.2142 +"MLY":  ('k', 'p', 'M', None) ,
  1.2143 +
  1.2144 +"AD2":  ('a', 'd', 'M', None) ,
  1.2145 +
  1.2146 +"CGA":  ('e', 'p', 'M', None) ,
  1.2147 +
  1.2148 +"NBQ":  ('y', 'p', 'M', None) ,
  1.2149 +
  1.2150 +"ODS":  ('x', 'p', None, None) ,
  1.2151 +
  1.2152 +"7GU":  ('g', 'd', 'M', None) ,
  1.2153 +
  1.2154 +"SAH":  ('c', 'p', 'M', None) ,
  1.2155 +
  1.2156 +"2DF":  ('n', 'd', None, None) ,
  1.2157 +
  1.2158 +"2DA":  ('a', 'd', 'M', None) ,
  1.2159 +
  1.2160 +"PCC":  ('p', 'p', 'M', None) ,
  1.2161 +
  1.2162 +"ODA":  ('x', 'p', None, None) ,
  1.2163 +
  1.2164 +"2DO":  ('x', 'p', None, None) ,
  1.2165 +
  1.2166 +"CGU":  ('e', 'p', 'M', None) ,
  1.2167 +
  1.2168 +"L2A":  ('x', 'p', None, None) ,
  1.2169 +
  1.2170 +"DNG":  ('l', 'p', 'M', None) ,
  1.2171 +
  1.2172 +"UMA":  ('a', 'p', 'M', None) ,
  1.2173 +
  1.2174 +"PM3":  ('f', 'p', 'M', None) ,
  1.2175 +
  1.2176 +"DNM":  ('l', 'p', 'M', None) ,
  1.2177 +
  1.2178 +"DNL":  ('k', 'p', 'M', None) ,
  1.2179 +
  1.2180 +"GMA":  ('e', 'p', 'M', None) ,
  1.2181 +
  1.2182 +"1LU":  ('l', 'p', 'M', None) ,
  1.2183 +
  1.2184 +"CDV":  ('x', 'p', None, None) ,
  1.2185 +
  1.2186 +"ADX":  ('n', 'r', None, None) ,
  1.2187 +
  1.2188 +"LKC":  ('n', 'd', None, None) ,
  1.2189 +
  1.2190 +"ADD":  ('x', 'p', None, None) ,
  1.2191 +
  1.2192 +"CUC":  ('x', 'p', None, None) ,
  1.2193 +
  1.2194 +"DNP":  ('a', 'p', 'M', None) ,
  1.2195 +
  1.2196 +"DNS":  ('k', 'p', 'M', None) ,
  1.2197 +
  1.2198 +"DNR":  ('c', 'd', 'M', None) ,
  1.2199 +
  1.2200 +"CG1":  ('g', 'r', 'M', None) ,
  1.2201 +
  1.2202 +"Z":  ('c', 'd', 'M', None) ,
  1.2203 +
  1.2204 +"GMU":  ('n', 'd', None, None) ,
  1.2205 +
  1.2206 +"C99":  ('x', 'p', None, None) ,
  1.2207 +
  1.2208 +"GDP":  ('g', 'r', 'M', None) ,
  1.2209 +
  1.2210 +"MED":  ('m', 'p', 'M', None) ,
  1.2211 +
  1.2212 +"GDR":  ('g', 'd', 'M', None) ,
  1.2213 +
  1.2214 +"MEA":  ('f', 'p', 'M', None) ,
  1.2215 +
  1.2216 +"LEF":  ('l', 'p', 'M', None) ,
  1.2217 +
  1.2218 +"LEH":  ('l', 'p', 'M', None) ,
  1.2219 +
  1.2220 +"CHG":  ('x', 'p', None, None) ,
  1.2221 +
  1.2222 +"MEN":  ('n', 'p', 'M', None) ,
  1.2223 +
  1.2224 +"G42":  ('g', 'd', 'M', None) ,
  1.2225 +
  1.2226 +"5CG":  ('g', 'd', 'M', None) ,
  1.2227 +
  1.2228 +"T31":  ('u', 'r', 'M', None) ,
  1.2229 +
  1.2230 +"MEU":  ('g', 'p', 'M', None) ,
  1.2231 +
  1.2232 +"MET":  ('M', 'p', None, None) ,
  1.2233 +
  1.2234 +"U34":  ('u', 'r', 'M', None) ,
  1.2235 +
  1.2236 +"MEQ":  ('q', 'p', 'M', None) ,
  1.2237 +
  1.2238 +"MEP":  ('u', 'r', 'M', None) ,
  1.2239 +
  1.2240 +"B1P":  ('n', 'd', None, None) ,
  1.2241 +
  1.2242 +"IG":  ('g', 'r', 'M', None) ,
  1.2243 +
  1.2244 +"T2S":  ('n', 'r', None, None) ,
  1.2245 +
  1.2246 +"ZHP":  ('n', 'r', None, None) ,
  1.2247 +
  1.2248 +"AZK":  ('k', 'p', 'M', None) ,
  1.2249 +
  1.2250 +"U31":  ('u', 'r', 'M', None) ,
  1.2251 +
  1.2252 +"LTR":  ('w', 'p', 'M', None) ,
  1.2253 +
  1.2254 +"MSU":  ('x', 'p', None, None) ,
  1.2255 +
  1.2256 +"1PA":  ('f', 'p', 'M', None) ,
  1.2257 +
  1.2258 +"MSP":  ('a', 'p', 'M', None) ,
  1.2259 +
  1.2260 +"MSO":  ('m', 'p', 'M', None) ,
  1.2261 +
  1.2262 +"AZY":  ('y', 'p', 'M', None) ,
  1.2263 +
  1.2264 +"ENA":  ('n', 'r', None, None) ,
  1.2265 +
  1.2266 +"MSL":  ('m', 'p', 'M', None) ,
  1.2267 +
  1.2268 +"PF5":  ('f', 'p', 'M', None) ,
  1.2269 +
  1.2270 +"1PR":  ('n', 'r', None, None) ,
  1.2271 +
  1.2272 +"3AR":  ('x', 'p', None, None) ,
  1.2273 +
  1.2274 +"MSE":  ('m', 'p', 'M', None) ,
  1.2275 +
  1.2276 +"AZS":  ('s', 'p', 'M', None) ,
  1.2277 +
  1.2278 +"MSA":  ('g', 'p', 'M', None) ,
  1.2279 +
  1.2280 +"R2P":  ('x', 'p', None, None) ,
  1.2281 +
  1.2282 +"CAR":  ('c', 'd', 'M', None) ,
  1.2283 +
  1.2284 +"DAB":  ('a', 'p', 'M', None) ,
  1.2285 +
  1.2286 +"OTY":  ('y', 'p', 'M', None) ,
  1.2287 +
  1.2288 +"DAL":  ('a', 'p', 'M', None) ,
  1.2289 +
  1.2290 +"DAM":  ('x', 'p', None, None) ,
  1.2291 +
  1.2292 +"TT":  ('n', 'd', None, None) ,
  1.2293 +
  1.2294 +"IOY":  ('f', 'p', 'M', None) ,
  1.2295 +
  1.2296 +"DAH":  ('f', 'p', 'M', None) ,
  1.2297 +
  1.2298 +"8MG":  ('g', 'd', 'M', None) ,
  1.2299 +
  1.2300 +"BZG":  ('n', 'd', None, None) ,
  1.2301 +
  1.2302 +"ARM":  ('r', 'p', 'M', None) ,
  1.2303 +
  1.2304 +"DAR":  ('r', 'p', 'M', None) ,
  1.2305 +
  1.2306 +"DAS":  ('d', 'p', 'M', None) ,
  1.2307 +
  1.2308 +"MCY":  ('c', 'd', 'M', None) ,
  1.2309 +
  1.2310 +"SGB":  ('s', 'p', 'M', None) ,
  1.2311 +
  1.2312 +"YRR":  ('n', 'd', None, None) ,
  1.2313 +
  1.2314 +"NF2":  ('n', 'r', None, None) ,
  1.2315 +
  1.2316 +"CNU":  ('u', 'r', 'M', None) ,
  1.2317 +
  1.2318 +"E":  ('a', 'd', 'M', None) ,
  1.2319 +
  1.2320 +"AA3":  ('a', 'p', 'M', None) ,
  1.2321 +
  1.2322 +"GVL":  ('x', 'p', None, None) ,
  1.2323 +
  1.2324 +"TNR":  ('s', 'p', 'M', None) ,
  1.2325 +
  1.2326 +"HOL":  ('n', 'd', None, None) ,
  1.2327 +
  1.2328 +"PTM":  ('y', 'p', 'M', None) ,
  1.2329 +
  1.2330 +"AS":  ('a', 'd', 'M', None) ,
  1.2331 +
  1.2332 +"U":  ('U', 'r', None, None) ,
  1.2333 +
  1.2334 +"ESB":  ('y', 'p', 'M', None) ,
  1.2335 +
  1.2336 +"DA2":  ('x', 'p', None, None) ,
  1.2337 +
  1.2338 +"TNB":  ('c', 'p', 'M', None) ,
  1.2339 +
  1.2340 +"RMP":  ('a', 'd', 'M', None) ,
  1.2341 +
  1.2342 +"SME":  ('m', 'p', 'M', None) ,
  1.2343 +
  1.2344 +"NDF":  ('f', 'p', 'M', None) ,
  1.2345 +
  1.2346 +"BOE":  ('t', 'd', 'M', None) ,
  1.2347 +
  1.2348 +"LGP":  ('g', 'd', 'M', None) ,
  1.2349 +
  1.2350 +"SCH":  ('c', 'p', 'M', None) ,
  1.2351 +
  1.2352 +"T2T":  ('n', 'd', None, None) ,
  1.2353 +
  1.2354 +"PFF":  ('f', 'p', 'M', None) ,
  1.2355 +
  1.2356 +"PCE":  ('x', 'p', None, None) ,
  1.2357 +
  1.2358 +"DFO":  ('x', 'p', None, None) ,
  1.2359 +
  1.2360 +"DXN":  ('n', 'd', None, None) ,
  1.2361 +
  1.2362 +"KGC":  ('k', 'p', 'M', None) ,
  1.2363 +
  1.2364 +"US1":  ('n', 'd', None, None) ,
  1.2365 +
  1.2366 +"HHK":  ('x', 'p', None, None) ,
  1.2367 +
  1.2368 +"DXD":  ('n', 'd', None, None) ,
  1.2369 +
  1.2370 +"ZCY":  ('c', 'r', 'M', None) ,
  1.2371 +
  1.2372 +"IEL":  ('k', 'p', 'M', None) 
  1.2373 +
  1.2374 +}
  1.2375 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/blocks3d/AlignmentSeq.py	Fri Sep 17 21:52:33 2010 +0400
     2.3 @@ -0,0 +1,490 @@
     2.4 +# -*- coding: cp1251 -*-
     2.5 +
     2.6 +#####################################################################
     2.7 +#  ,    
     2.8 +#####################################################################
     2.9 +
    2.10 +
    2.11 +
    2.12 +
    2.13 +"""
    2.14 +Usage:
    2.15 +
    2.16 +seq_in=[]
    2.17 +seq_in.append("SSNAKIDQLSSDAQTANAKADQASNDANAARSDAQAAKDDAARANQRLDNM")
    2.18 +seq_in.append("NAKADQASSDAQTANAKADQASNDANAARSDAQAAKDDAARANQRADNAA")
    2.19 +l=AlignmentSeq(seq_in)
    2.20 +for t in l.new_sequences:
    2.21 +    print t
    2.22 +    
    2.23 +"""
    2.24 +
    2.25 +
    2.26 +
    2.27 +
    2.28 +import AlignmentSeq_config
    2.29 +
    2.30 +vars().update(vars(AlignmentSeq_config))
    2.31 +
    2.32 +class AlignmentSeq:
    2.33 +
    2.34 +
    2.35 +
    2.36 +
    2.37 +
    2.38 +
    2.39 +
    2.40 +    def __init__(self,sequences):
    2.41 +
    2.42 +        """
    2.43 +          
    2.44 +           
    2.45 +         ,       new_sequences
    2.46 +         { [  ] =>    }    connections
    2.47 +
    2.48 +        self.common -  [] => [ ,   ]
    2.49 +        """
    2.50 +        
    2.51 +
    2.52 +        self.old_sequences = []
    2.53 +        self.new_sequences = []
    2.54 +        self.connections = []
    2.55 +
    2.56 +        for seq in sequences:
    2.57 +            self.old_sequences.append(seq.upper().replace('-','').replace(' ',''))
    2.58 +
    2.59 +
    2.60 +        self.common=[]
    2.61 +
    2.62 +        
    2.63 +        for i in xrange(0,len(self.old_sequences)):
    2.64 +             self.unite(i)
    2.65 +
    2.66 +
    2.67 +        for i in xrange(0,len(self.old_sequences)):
    2.68 +             self.lining(i)          
    2.69 +##        
    2.70 +##        return
    2.71 +##
    2.72 +##        self.correct()
    2.73 +##        
    2.74 +##
    2.75 +##        
    2.76 +##
    2.77 +##        for str1 in self.new_sequences:
    2.78 +##            self.connections.append(self.recount(str1))
    2.79 +
    2.80 +
    2.81 +
    2.82 +
    2.83 +
    2.84 +
    2.85 +   
    2.86 +    def cost(self,a1,a2):
    2.87 +
    2.88 +        """
    2.89 +              
    2.90 +         
    2.91 +        """
    2.92 +
    2.93 +
    2.94 +        global matrix
    2.95 +        global gaps
    2.96 +        
    2.97 +        a1=a1.upper()
    2.98 +        a2=a2.upper()
    2.99 +
   2.100 +        if (matrix.has_key(a1)):
   2.101 +            if (matrix[a1].has_key(a2)):
   2.102 +                return matrix[a1][a2]
   2.103 +
   2.104 +        return gaps[0]
   2.105 +            
   2.106 +        
   2.107 +
   2.108 +
   2.109 +
   2.110 +
   2.111 +
   2.112 +
   2.113 +
   2.114 +   
   2.115 +    def gap_cost(self,int1):
   2.116 +        """
   2.117 +             
   2.118 +         ,      
   2.119 +        """
   2.120 +
   2.121 +
   2.122 +        global gaps
   2.123 +
   2.124 +        
   2.125 +        if (int1 >= len(gaps)):
   2.126 +            return gaps[(len(gaps)-1)]
   2.127 +        else:
   2.128 +            return gaps[int1]
   2.129 +
   2.130 +        
   2.131 +
   2.132 +
   2.133 +
   2.134 +
   2.135 +
   2.136 +
   2.137 +
   2.138 +
   2.139 +
   2.140 +
   2.141 +
   2.142 +
   2.143 +
   2.144 +
   2.145 +    def unite(self,chainN):
   2.146 +
   2.147 +        """
   2.148 +          
   2.149 +
   2.150 +        chainN -  
   2.151 +        """
   2.152 +
   2.153 +
   2.154 +        str1=self.old_sequences[chainN]
   2.155 +        len1=len(str1)
   2.156 +
   2.157 +        
   2.158 +
   2.159 +
   2.160 +        if (not self.common):
   2.161 +            i=0
   2.162 +            while (i<len1):
   2.163 +                aminoacids=[str1[i]]
   2.164 +                chains=[chainN]
   2.165 +                
   2.166 +                self.common.append([aminoacids,chains])
   2.167 +                i+=1
   2.168 +                
   2.169 +            return
   2.170 +
   2.171 +
   2.172 +
   2.173 +
   2.174 +
   2.175 +
   2.176 +        len2=len(self.common)
   2.177 +
   2.178 +
   2.179 +        d=[]
   2.180 +        tip_from=[]
   2.181 +        already_gaps=[]
   2.182 +
   2.183 +
   2.184 +        for i in xrange(0,len1+1):
   2.185 +            d.append([])
   2.186 +            already_gaps.append([])
   2.187 +            tip_from.append([])
   2.188 +            for j in xrange(0,len2+1):
   2.189 +                d[i].append(0)
   2.190 +                already_gaps[i].append([0,0])
   2.191 +                tip_from[i].append(0)
   2.192 +
   2.193 +
   2.194 +##        
   2.195 +##        for i in xrange(1,len1+1):
   2.196 +##            d[i][0] =  0
   2.197 +##            already_gaps[i][0] = [0,1+i]
   2.198 +##
   2.199 +##
   2.200 +##        for j in xrange(1,len2+1):
   2.201 +##            d[0][j] =  0
   2.202 +##            already_gaps[0][j] = [1+j,0]
   2.203 +##        
   2.204 +
   2.205 +
   2.206 +
   2.207 +
   2.208 +
   2.209 +
   2.210 +        for i in xrange(1,len1+1):
   2.211 +            for j in xrange(1,len2+1):
   2.212 +
   2.213 +                costs=[]
   2.214 +                for A in self.common[j-1][0]:
   2.215 +                    costs.append(self.cost(str1[i-1],A))
   2.216 +                cost = max(costs)
   2.217 +
   2.218 +                
   2.219 +                insertion = d[i-1][j]
   2.220 +                if (j != len2): #  
   2.221 +                    insertion += self.gap_cost(already_gaps[i-1][j][1])
   2.222 +
   2.223 +                    
   2.224 +                deletion  = d[i][j-1]
   2.225 +                if (i != len1): #  
   2.226 +                    deletion += self.gap_cost(already_gaps[i][j-1][0])
   2.227 +
   2.228 +                substitution=d[i-1][j-1] + cost
   2.229 +
   2.230 +                max_way= max(insertion,deletion,substitution)
   2.231 +
   2.232 +                d[i][j] = max_way
   2.233 +
   2.234 +
   2.235 +                                 
   2.236 +            
   2.237 +                
   2.238 +                if (max_way==substitution):
   2.239 +                    tip=3   
   2.240 +                if (max_way==deletion):
   2.241 +                    tip=2                
   2.242 +                if (max_way==insertion):
   2.243 +                    tip=1
   2.244 + 
   2.245 +
   2.246 +
   2.247 +                if (tip==1):                             # insertion
   2.248 +                    already_gaps[i][j]=[0, (already_gaps[i-1][j][1]+1) ]
   2.249 +
   2.250 +                    
   2.251 +                if (tip==2):                             # deletion
   2.252 +                    already_gaps[i][j]=[ (already_gaps[i][j-1][0]+1), 0 ]
   2.253 +
   2.254 +                if (tip==3):                             # substitution
   2.255 +                    already_gaps[i][j]=[ 0, 0 ]
   2.256 +                
   2.257 +                tip_from[i][j]=tip
   2.258 +
   2.259 +
   2.260 +##        
   2.261 +##        for d1 in d:
   2.262 +##            for d11 in d1:
   2.263 +##                print d11,
   2.264 +##            print
   2.265 +##
   2.266 +##
   2.267 +##
   2.268 +##                
   2.269 +##        for d1 in tip_from:
   2.270 +##            for d11 in d1:
   2.271 +##                print d11,
   2.272 +##            print
   2.273 +##
   2.274 +##        
   2.275 +##
   2.276 +##        print insertion
   2.277 +##        print deletion
   2.278 +##        print substitution
   2.279 +##
   2.280 +##
   2.281 +##        
   2.282 +##        print already_gaps
   2.283 +##        
   2.284 +
   2.285 +        
   2.286 +
   2.287 +        i=len1
   2.288 +        j=len2
   2.289 +
   2.290 +        common=[]
   2.291 +
   2.292 +        while (i>0 or j>0):
   2.293 +            tip=tip_from[i][j]
   2.294 +            
   2.295 +            if tip==1 or (j==0 and i>0):
   2.296 +
   2.297 +                aminoacids=[(str1[i-1])]
   2.298 +                chains=[chainN]
   2.299 +                
   2.300 +                common.append([aminoacids,chains])
   2.301 +                
   2.302 +                i-=1
   2.303 +
   2.304 +
   2.305 +                
   2.306 +            if tip==2 or (i==0 and j>0):
   2.307 +                
   2.308 +                common.append(self.common[j-1])
   2.309 +                j-=1
   2.310 +
   2.311 +                
   2.312 +            if (tip==3):
   2.313 +                                
   2.314 +                chains=self.common[j-1][1]
   2.315 +                chains.append(chainN)
   2.316 +                
   2.317 +                aminoacids=self.common[j-1][0]
   2.318 +                
   2.319 +                if (not aminoacids.count(str1[i-1])):
   2.320 +                    aminoacids.append(str1[i-1])
   2.321 +
   2.322 +                common.append([aminoacids,chains])
   2.323 +                    
   2.324 +                i-=1
   2.325 +                j-=1
   2.326 +
   2.327 +          
   2.328 +            
   2.329 +        common.reverse()
   2.330 +        
   2.331 +        self.common=common
   2.332 +
   2.333 +
   2.334 +
   2.335 +
   2.336 +
   2.337 +
   2.338 +
   2.339 +
   2.340 +
   2.341 +
   2.342 +
   2.343 +
   2.344 +
   2.345 +
   2.346 +
   2.347 +
   2.348 +
   2.349 +
   2.350 +
   2.351 +
   2.352 +
   2.353 +
   2.354 +
   2.355 +    def lining(self,chainN):
   2.356 +
   2.357 +
   2.358 +        """
   2.359 +            
   2.360 +         self.new_sequences
   2.361 +
   2.362 +        chainN -      
   2.363 +        """
   2.364 +
   2.365 +        str1=self.old_sequences[chainN]
   2.366 +        len1=len(str1)
   2.367 +        
   2.368 +        len2=len(self.common)
   2.369 +
   2.370 +
   2.371 +        new_seq=''
   2.372 +        position_in_old=0
   2.373 +
   2.374 +        for common_1 in self.common:
   2.375 +            if (common_1[1].count(chainN)):
   2.376 +                new_seq = new_seq + str1[position_in_old]
   2.377 +                position_in_old += 1
   2.378 +            else:
   2.379 +                new_seq = new_seq + '-'
   2.380 +
   2.381 +        self.new_sequences.append(new_seq)
   2.382 +
   2.383 +
   2.384 +
   2.385 +
   2.386 +
   2.387 +
   2.388 +
   2.389 +##
   2.390 +##    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
   2.391 +##         ,   
   2.392 +##    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
   2.393 +##    def correct(self):
   2.394 +##
   2.395 +##        new_sequences=[]
   2.396 +##        
   2.397 +##        all_l = len(self.new_sequences[0]) #    
   2.398 +##        for str1 in self.new_sequences:
   2.399 +##            all_l = min (all_l,len(str1))
   2.400 +##
   2.401 +##
   2.402 +##        
   2.403 +##        i=0
   2.404 +##        while (i < all_l):
   2.405 +##            
   2.406 +##            if (i==0):
   2.407 +##                for str1 in self.new_sequences:
   2.408 +##                    new_sequences.append(str1[0])
   2.409 +##                i+=1
   2.410 +##                continue
   2.411 +##
   2.412 +##            
   2.413 +##            all_gaps=1
   2.414 +##            for str1 in self.new_sequences:
   2.415 +##                if (str1[i]!='-'):
   2.416 +##                    all_gaps=0
   2.417 +##                    
   2.418 +##            if (all_gaps==1):
   2.419 +##                i+=1
   2.420 +##                continue
   2.421 +##
   2.422 +##
   2.423 +##            sovmest=1
   2.424 +##            j=-1
   2.425 +##            for str1 in self.new_sequences:
   2.426 +##                j+=1
   2.427 +##                if (str1[i]!='-' and new_sequences[j][-1]!='-'):
   2.428 +##                    sovmest=0
   2.429 +##                    break
   2.430 +##                    
   2.431 +##                   
   2.432 +##
   2.433 +##                           
   2.434 +##            j=-1
   2.435 +##            for str1 in self.new_sequences:
   2.436 +##                j+=1
   2.437 +##
   2.438 +##                if (sovmest==1):
   2.439 +##                    if (str1[i]!='-'):
   2.440 +##                        new_sequences[j] = new_sequences[j][:-1] + str1[i]
   2.441 +##                else:
   2.442 +##                    new_sequences[j] = new_sequences[j] + str1[i]
   2.443 +##            
   2.444 +##
   2.445 +##
   2.446 +##            i+=1
   2.447 +##            continue
   2.448 +##
   2.449 +##        self.new_sequences = new_sequences
   2.450 +
   2.451 +
   2.452 +        
   2.453 +
   2.454 +
   2.455 +
   2.456 +
   2.457 +
   2.458 +
   2.459 +
   2.460 +
   2.461 +
   2.462 +
   2.463 +
   2.464 +
   2.465 +##
   2.466 +##    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
   2.467 +##      : [  ] =>   
   2.468 +##    str1 -  
   2.469 +##       0!
   2.470 +##    """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
   2.471 +##    def recount(self,str1):
   2.472 +##        spisok={}
   2.473 +##                        
   2.474 +##        len1=len(str1)
   2.475 +##        old_nomer = 0
   2.476 +##
   2.477 +##        for i in xrange(0,len1):
   2.478 +##            s=str1[i]
   2.479 +##            if (s != '-'):
   2.480 +##                spisok[i]=old_nomer
   2.481 +##                old_nomer+=1
   2.482 +##
   2.483 +##        return spisok
   2.484 +
   2.485 +
   2.486 +
   2.487 +
   2.488 +
   2.489 +
   2.490 +
   2.491 +
   2.492 +
   2.493 +            
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/blocks3d/AlignmentSeq_config.py	Fri Sep 17 21:52:33 2010 +0400
     3.3 @@ -0,0 +1,28 @@
     3.4 +matrix={
     3.5 +"A": {"A":  4, "R": -1, "N": -2, "D": -2, "C":  0, "Q": -1, "E": -1, "G":  0, "H": -2, "I": -1, "L": -1, "K": -1, "M": -1, "F": -2, "P": -1, "S":  1, "T":  0, "W": -3, "Y": -2, "V":  0, "B": -2, "Z": -1, "X":  0, "*": -4},
     3.6 +"R": {"A": -1, "R":  5, "N":  0, "D": -2, "C": -3, "Q":  1, "E":  0, "G": -2, "H":  0, "I": -3, "L": -2, "K":  2, "M": -1, "F": -3, "P": -2, "S": -1, "T": -1, "W": -3, "Y": -2, "V": -3, "B": -1, "Z":  0, "X": -1, "*": -4},
     3.7 +"N": {"A": -2, "R":  0, "N":  6, "D":  1, "C": -3, "Q":  0, "E":  0, "G":  0, "H":  1, "I": -3, "L": -3, "K":  0, "M": -2, "F": -3, "P": -2, "S":  1, "T":  0, "W": -4, "Y": -2, "V": -3, "B":  3, "Z":  0, "X": -1, "*": -4},
     3.8 +"D": {"A": -2, "R": -2, "N":  1, "D":  6, "C": -3, "Q":  0, "E":  2, "G": -1, "H": -1, "I": -3, "L": -4, "K": -1, "M": -3, "F": -3, "P": -1, "S":  0, "T": -1, "W": -4, "Y": -3, "V": -3, "B":  4, "Z":  1, "X": -1, "*": -4},
     3.9 +"C": {"A":  0, "R": -3, "N": -3, "D": -3, "C":  9, "Q": -3, "E": -4, "G": -3, "H": -3, "I": -1, "L": -1, "K": -3, "M": -1, "F": -2, "P": -3, "S": -1, "T": -1, "W": -2, "Y": -2, "V": -1, "B": -3, "Z": -3, "X": -2, "*": -4},
    3.10 +"Q": {"A": -1, "R":  1, "N":  0, "D":  0, "C": -3, "Q":  5, "E":  2, "G": -2, "H":  0, "I": -3, "L": -2, "K":  1, "M":  0, "F": -3, "P": -1, "S":  0, "T": -1, "W": -2, "Y": -1, "V": -2, "B":  0, "Z":  3, "X": -1, "*": -4},
    3.11 +"E": {"A": -1, "R":  0, "N":  0, "D":  2, "C": -4, "Q":  2, "E":  5, "G": -2, "H":  0, "I": -3, "L": -3, "K":  1, "M": -2, "F": -3, "P": -1, "S":  0, "T": -1, "W": -3, "Y": -2, "V": -2, "B":  1, "Z":  4, "X": -1, "*": -4},
    3.12 +"G": {"A":  0, "R": -2, "N":  0, "D": -1, "C": -3, "Q": -2, "E": -2, "G":  6, "H": -2, "I": -4, "L": -4, "K": -2, "M": -3, "F": -3, "P": -2, "S":  0, "T": -2, "W": -2, "Y": -3, "V": -3, "B": -1, "Z": -2, "X": -1, "*": -4},
    3.13 +"H": {"A": -2, "R":  0, "N":  1, "D": -1, "C": -3, "Q":  0, "E":  0, "G": -2, "H":  8, "I": -3, "L": -3, "K": -1, "M": -2, "F": -1, "P": -2, "S": -1, "T": -2, "W": -2, "Y":  2, "V": -3, "B":  0, "Z":  0, "X": -1, "*": -4},
    3.14 +"I": {"A": -1, "R": -3, "N": -3, "D": -3, "C": -1, "Q": -3, "E": -3, "G": -4, "H": -3, "I":  4, "L":  2, "K": -3, "M":  1, "F":  0, "P": -3, "S": -2, "T": -1, "W": -3, "Y": -1, "V":  3, "B": -3, "Z": -3, "X": -1, "*": -4},
    3.15 +"L": {"A": -1, "R": -2, "N": -3, "D": -4, "C": -1, "Q": -2, "E": -3, "G": -4, "H": -3, "I":  2, "L":  4, "K": -2, "M":  2, "F":  0, "P": -3, "S": -2, "T": -1, "W": -2, "Y": -1, "V":  1, "B": -4, "Z": -3, "X": -1, "*": -4},
    3.16 +"K": {"A": -1, "R":  2, "N":  0, "D": -1, "C": -3, "Q":  1, "E":  1, "G": -2, "H": -1, "I": -3, "L": -2, "K":  5, "M": -1, "F": -3, "P": -1, "S":  0, "T": -1, "W": -3, "Y": -2, "V": -2, "B":  0, "Z":  1, "X": -1, "*": -4},
    3.17 +"M": {"A": -1, "R": -1, "N": -2, "D": -3, "C": -1, "Q":  0, "E": -2, "G": -3, "H": -2, "I":  1, "L":  2, "K": -1, "M":  5, "F":  0, "P": -2, "S": -1, "T": -1, "W": -1, "Y": -1, "V":  1, "B": -3, "Z": -1, "X": -1, "*": -4},
    3.18 +"F": {"A": -2, "R": -3, "N": -3, "D": -3, "C": -2, "Q": -3, "E": -3, "G": -3, "H": -1, "I":  0, "L":  0, "K": -3, "M":  0, "F":  6, "P": -4, "S": -2, "T": -2, "W":  1, "Y":  3, "V": -1, "B": -3, "Z": -3, "X": -1, "*": -4},
    3.19 +"P": {"A": -1, "R": -2, "N": -2, "D": -1, "C": -3, "Q": -1, "E": -1, "G": -2, "H": -2, "I": -3, "L": -3, "K": -1, "M": -2, "F": -4, "P":  7, "S": -1, "T": -1, "W": -4, "Y": -3, "V": -2, "B": -2, "Z": -1, "X": -2, "*": -4},
    3.20 +"S": {"A":  1, "R": -1, "N":  1, "D":  0, "C": -1, "Q":  0, "E":  0, "G":  0, "H": -1, "I": -2, "L": -2, "K":  0, "M": -1, "F": -2, "P": -1, "S":  4, "T":  1, "W": -3, "Y": -2, "V": -2, "B":  0, "Z":  0, "X":  0, "*": -4},
    3.21 +"T": {"A":  0, "R": -1, "N":  0, "D": -1, "C": -1, "Q": -1, "E": -1, "G": -2, "H": -2, "I": -1, "L": -1, "K": -1, "M": -1, "F": -2, "P": -1, "S":  1, "T":  5, "W": -2, "Y": -2, "V":  0, "B": -1, "Z": -1, "X":  0, "*": -4},
    3.22 +"W": {"A": -3, "R": -3, "N": -4, "D": -4, "C": -2, "Q": -2, "E": -3, "G": -2, "H": -2, "I": -3, "L": -2, "K": -3, "M": -1, "F":  1, "P": -4, "S": -3, "T": -2, "W": 11, "Y":  2, "V": -3, "B": -4, "Z": -3, "X": -2, "*": -4},
    3.23 +"Y": {"A": -2, "R": -2, "N": -2, "D": -3, "C": -2, "Q": -1, "E": -2, "G": -3, "H":  2, "I": -1, "L": -1, "K": -2, "M": -1, "F":  3, "P": -3, "S": -2, "T": -2, "W":  2, "Y":  7, "V": -1, "B": -3, "Z": -2, "X": -1, "*": -4},
    3.24 +"V": {"A":  0, "R": -3, "N": -3, "D": -3, "C": -1, "Q": -2, "E": -2, "G": -3, "H": -3, "I":  3, "L":  1, "K": -2, "M":  1, "F": -1, "P": -2, "S": -2, "T":  0, "W": -3, "Y": -1, "V":  4, "B": -3, "Z": -2, "X": -1, "*": -4},
    3.25 +"B": {"A": -2, "R": -1, "N":  3, "D":  4, "C": -3, "Q":  0, "E":  1, "G": -1, "H":  0, "I": -3, "L": -4, "K":  0, "M": -3, "F": -3, "P": -2, "S":  0, "T": -1, "W": -4, "Y": -3, "V": -3, "B":  4, "Z":  0, "X": -1, "*": -4},
    3.26 +"Z": {"A": -1, "R":  0, "N":  0, "D":  1, "C": -3, "Q":  3, "E":  4, "G": -2, "H":  0, "I": -3, "L": -3, "K":  1, "M": -1, "F": -3, "P": -1, "S":  0, "T": -1, "W": -3, "Y": -2, "V": -2, "B":  0, "Z":  4, "X": -1, "*": -4},
    3.27 +"X": {"A":  0, "R": -1, "N": -1, "D": -1, "C": -2, "Q": -1, "E": -1, "G": -1, "H": -1, "I": -1, "L": -1, "K": -1, "M": -1, "F": -1, "P": -2, "S":  0, "T":  0, "W": -2, "Y": -1, "V": -1, "B": -1, "Z": -1, "X": -1, "*": -4},
    3.28 +"*": {"A": -4, "R": -4, "N": -4, "D": -4, "C": -4, "Q": -4, "E": -4, "G": -4, "H": -4, "I": -4, "L": -4, "K": -4, "M": -4, "F": -4, "P": -4, "S": -4, "T": -4, "W": -4, "Y": -4, "V": -4, "B": -4, "Z": -4, "X": -4, "*":  1}
    3.29 +}
    3.30 +
    3.31 +gaps = (-8, -4, -2, -1)
    3.32 \ No newline at end of file
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/blocks3d/Blocks3D.py	Fri Sep 17 21:52:33 2010 +0400
     4.3 @@ -0,0 +1,511 @@
     4.4 +# -*- coding: cp1251 -*-
     4.5 +
     4.6 +
     4.7 +##########################
     4.8 +# Reliable blocks finding
     4.9 +##########################
    4.10 +
    4.11 +
    4.12 +import json
    4.13 +
    4.14 +
    4.15 +import Blocks3D_config
    4.16 +import GeometricalCore_config
    4.17 +from Blocks3D_class import Blocks3D
    4.18 +B3D = Blocks3D()
    4.19 +
    4.20 +
    4.21 +
    4.22 +import sys
    4.23 +
    4.24 +
    4.25 +
    4.26 +# determine html.htm path
    4.27 +if hasattr(Blocks3D_config, 'html_file'):
    4.28 +    html_file = Blocks3D_config.html_file
    4.29 +    
    4.30 +else:
    4.31 +
    4.32 +    if sys.argv[0].replace('/', '') != sys.argv[0]:
    4.33 +        delimiter = '/'
    4.34 +    else:
    4.35 +        delimiter = "\\"
    4.36 +
    4.37 +    path_parts = sys.argv[0].split(delimiter)
    4.38 +    path_parts[-1] = 'html.htm'
    4.39 +    html_file = delimiter.join(path_parts)
    4.40 +
    4.41 +
    4.42 +
    4.43 +
    4.44 +
    4.45 +
    4.46 +
    4.47 +
    4.48 +
    4.49 +import optparse
    4.50 +import os
    4.51 +
    4.52 +
    4.53 +from clon import clon # copy list
    4.54 +
    4.55 +
    4.56 +
    4.57 +
    4.58 +# get options
    4.59 +
    4.60 +parser = optparse.OptionParser()
    4.61 +
    4.62 +
    4.63 +parser.set_defaults(**vars(GeometricalCore_config))
    4.64 +parser.set_defaults(**vars(Blocks3D_config))
    4.65 +
    4.66 +
    4.67 +parser.add_option('-i', help='Input alignment file', dest='alignment_file')
    4.68 +parser.add_option('-c', help='PDB names conformity file', dest='conformity_file')
    4.69 +
    4.70 +
    4.71 +##parser.add_option('--out', help='Output file name (*)', dest='output_file')
    4.72 +##parser.add_option('-f', help='Output file format (msf, fasta, list)', dest='output_format')
    4.73 +
    4.74 +#parser.add_option('-l', help='Output list file', dest='output_list_file')
    4.75 +#parser.add_option('-f', help='Output fasta file', dest='output_fasta_file')
    4.76 +#parser.add_option('-g', help='Output msf file', dest='output_msf_file')
    4.77 +#parser.add_option('-p', help='Output pdb file (+spt script)', dest='output_pdb_file')
    4.78 +
    4.79 +parser.add_option('-H', help='Output html file', dest='output_html_file')
    4.80 +
    4.81 +
    4.82 +
    4.83 +parser.add_option('-d', help='Distance spreading [' + str(GeometricalCore_config.delta) + ']', dest='delta')
    4.84 +
    4.85 +parser.add_option('-m', help='Min block width [' + str(Blocks3D_config.min_width) + ']', dest='min_width')
    4.86 +
    4.87 +
    4.88 +parser.add_option('-t', help='Bron-Kerbosh (couple cores) timeout [' + str(GeometricalCore_config.timeout) + '] (-1 - unlimited)', dest='timeout')
    4.89 +
    4.90 +
    4.91 +parser.add_option('-T', help='Bron-Kerbosh (blocks) timeout [' + str(Blocks3D_config.timeout_2) + '] (-1 - unlimited)', dest='timeout_2')
    4.92 +
    4.93 +
    4.94 +#parser.add_option('-n', help='Alternative core new atoms (%) [' + str(int(GeometricalCore_config.alternative_core_new_atoms * 100)) + ']', dest='new_atoms')
    4.95 +
    4.96 +#parser.add_option('-a', help='Cores count [' + str(GeometricalCore_config.alternative_cores_count) + '] (0 - all)', dest='cores_count')
    4.97 +
    4.98 +
    4.99 +#parser.add_option('-x', help='Superposition core identifier (0 - main core)', dest='Super_core')
   4.100 +
   4.101 +
   4.102 +
   4.103 +parser.add_option('-u', help='PDB url [' + GeometricalCore_config.pdb_url + ']', dest='pdb_url')
   4.104 +parser.add_option('-s', action='store_true', help='Do not save uploaded PDB')
   4.105 +
   4.106 +
   4.107 +
   4.108 +options, args = parser.parse_args()
   4.109 +vars().update(vars(options))
   4.110 +
   4.111 +
   4.112 +
   4.113 +
   4.114 +
   4.115 +
   4.116 +
   4.117 +
   4.118 +
   4.119 +all_right = 1
   4.120 +
   4.121 +
   4.122 +
   4.123 +# check all options
   4.124 +
   4.125 +
   4.126 +try:
   4.127 +
   4.128 +    delta = float(delta)
   4.129 +
   4.130 +    min_width = int(min_width)
   4.131 +
   4.132 +except:
   4.133 +    all_right = 0
   4.134 +    print "Error: bad option"
   4.135 +    
   4.136 +    
   4.137 +
   4.138 +if s:
   4.139 +    save = 0
   4.140 +else:
   4.141 +    save = 1
   4.142 +
   4.143 +
   4.144 +
   4.145 +if timeout:
   4.146 +    try:
   4.147 +        timeout = int(timeout)
   4.148 +    except:
   4.149 +        all_right = 0
   4.150 +        print "Error: bad timeout"
   4.151 +
   4.152 +
   4.153 +
   4.154 +if timeout_2:
   4.155 +    try:
   4.156 +        timeout_2 = int(timeout_2)
   4.157 +    except:
   4.158 +        all_right = 0
   4.159 +        print "Error: bad timeout"
   4.160 +
   4.161 +
   4.162 +
   4.163 +#if not Super_core:
   4.164 +#    Super_core = 0
   4.165 +    
   4.166 +#Super_core = int(Super_core)
   4.167 +
   4.168 +
   4.169 +
   4.170 +
   4.171 +
   4.172 +
   4.173 +
   4.174 +
   4.175 +try:
   4.176 +    if not os.path.exists(alignment_file):
   4.177 +        all_right = 0
   4.178 +        print "Error: can not find input file"
   4.179 +except:
   4.180 +    all_right = 0
   4.181 +    print "Error: can not find input file"    
   4.182 +
   4.183 +
   4.184 +if not (output_html_file):
   4.185 +    all_right = 0
   4.186 +    print "Error: no output file"
   4.187 +
   4.188 +
   4.189 +
   4.190 +
   4.191 +
   4.192 +
   4.193 +
   4.194 +
   4.195 +if conformity_file:
   4.196 +    try:
   4.197 +        if not os.path.exists(conformity_file):
   4.198 +            all_right = 0
   4.199 +            print "Error: can not find conformity file"
   4.200 +    except:
   4.201 +        all_right = all_right
   4.202 +
   4.203 +
   4.204 +
   4.205 +
   4.206 +
   4.207 +
   4.208 +
   4.209 +
   4.210 +
   4.211 +
   4.212 +if not all_right:
   4.213 +
   4.214 +    print ' '
   4.215 +    
   4.216 +    print 'Programm for find blocks of true alignment'
   4.217 +
   4.218 +    print ' '
   4.219 +
   4.220 +    parser.print_help()
   4.221 +
   4.222 +#    print ' '
   4.223 +#    print '* - required options'
   4.224 +
   4.225 +#    print ' '
   4.226 +#    print 'Protein identifiers should not contain ":" symbol'
   4.227 +
   4.228 +    exit()
   4.229 +
   4.230 +
   4.231 +
   4.232 +
   4.233 +# determinate temp fasta file
   4.234 +
   4.235 +#n = 1
   4.236 +
   4.237 +#while 1:
   4.238 +#    GC_temp = 'GC_temp' + str(n) + '.tmp'
   4.239 +#    if not os.path.exists(GC_temp):
   4.240 +#        break
   4.241 +#    n += 1
   4.242 +
   4.243 +GC_temp = 'GC_temp'
   4.244 +
   4.245 +
   4.246 +
   4.247 +
   4.248 +
   4.249 +
   4.250 +
   4.251 +
   4.252 +
   4.253 +
   4.254 +##is_fasta = 0
   4.255 +##fasta_check = open(alignment_file).readlines()
   4.256 +##
   4.257 +##for fasta_line in fasta_check:
   4.258 +##    if len(fasta_line) == 0:
   4.259 +##        continue
   4.260 +##    if fasta_line[0] == '>':
   4.261 +##        is_fasta = 1
   4.262 +##
   4.263 +##
   4.264 +##if is_fasta:
   4.265 +##
   4.266 +##    open(GC_temp, 'w').write(''.join(fasta_check))
   4.267 +##
   4.268 +##
   4.269 +##else:
   4.270 +
   4.271 +
   4.272 +
   4.273 +
   4.274 +
   4.275 +# try to determ is it fasta
   4.276 +
   4.277 +text = ''.join(open(alignment_file).readlines())
   4.278 +
   4.279 +#if text.count("\n>") >= 2:
   4.280 +if text.count("\n>") >= 1:
   4.281 +    # fasta
   4.282 +    
   4.283 +    # write to temp file input fasta alignment
   4.284 +    open(GC_temp, 'w').write(text)
   4.285 +    
   4.286 +else:
   4.287 +
   4.288 +    # not fasta
   4.289 +    
   4.290 +    # convert input file to fasta
   4.291 +
   4.292 +    try:
   4.293 +        os.system('seqret ' + alignment_file + ' ' + GC_temp)
   4.294 +    except:
   4.295 +        print 'Error: can not convert input alignment file to fasta using emboss command seqret'
   4.296 +        exit()
   4.297 +
   4.298 +
   4.299 +
   4.300 +
   4.301 +
   4.302 +
   4.303 +if not os.path.exists(GC_temp):
   4.304 +    print 'Error: can not convert input alignment file to fasta'
   4.305 +    exit()
   4.306 +
   4.307 +
   4.308 +
   4.309 +    
   4.310 +
   4.311 +
   4.312 +
   4.313 +
   4.314 +
   4.315 +
   4.316 +# read fasta
   4.317 +
   4.318 +fasta = open(GC_temp).readlines()
   4.319 +
   4.320 +
   4.321 +fasta_dict = {} # dict. index - fasta identifier. value - sequence without line breaks
   4.322 +
   4.323 +#fasta_order = [] # list of IDs, in order as in input file
   4.324 +
   4.325 +current_id = '' # current fasta identifier
   4.326 +
   4.327 +for fasta_string in fasta:
   4.328 +    
   4.329 +    fasta_string = fasta_string.strip()
   4.330 +    
   4.331 +    if not len(fasta_string):
   4.332 +        continue
   4.333 +
   4.334 +    if fasta_string[0] == '>':
   4.335 +        current_id = fasta_string[1:].split()[0]
   4.336 +        #fasta_order.append(current_id)
   4.337 +        fasta_dict[current_id] = ''
   4.338 +    else:
   4.339 +        if not current_id:
   4.340 +            print 'Bad Fasta file: line "' + fasta_string + '"'
   4.341 +            exit()
   4.342 +        fasta_dict[current_id] += fasta_string.replace(' ', '')
   4.343 +
   4.344 +
   4.345 +
   4.346 +
   4.347 +
   4.348 +# read conformity file
   4.349 +
   4.350 +
   4.351 +conformity_dict = {} # Key - fasta_id. Value - list [pdb_code, pdb_chain] 
   4.352 +
   4.353 +
   4.354 +if conformity_file:
   4.355 +    conformity = open(conformity_file).readlines()
   4.356 +
   4.357 +    for conformity_string in conformity:
   4.358 +        
   4.359 +        if len(conformity_string) < 8:
   4.360 +            continue
   4.361 +
   4.362 +        conformity_list = conformity_string.split()
   4.363 +
   4.364 +        if len(conformity_list) != 2:
   4.365 +            print 'Error: can not read line "' + conformity_string + '" in conformity file'
   4.366 +            exit()
   4.367 +
   4.368 +        fasta_id = conformity_list[0]
   4.369 +        
   4.370 +##        if not fasta_dict.has_key(fasta_id):
   4.371 +##            print 'Error: unknown fasta identifier "' + fasta_id + '" in conformity file'
   4.372 +##            exit()            
   4.373 +
   4.374 +                                  
   4.375 +        conformity_pdb = conformity_list[1]
   4.376 +
   4.377 +#        if len(conformity_pdb) != 2:
   4.378 +#            print 'Error: can not read PDB code and chain "' + conformity_list[1] + '" in conformity file'
   4.379 +#            exit()
   4.380 +
   4.381 +#        if len(conformity_pdb[0]) != 4 or len(conformity_pdb[1]) != 1:
   4.382 +#            print 'Error: can not read PDB code and chain "' + conformity_list[1] + '" in conformity file'
   4.383 +#            exit()
   4.384 +
   4.385 +       
   4.386 +        conformity_dict[fasta_id] = conformity_pdb
   4.387 +
   4.388 +
   4.389 +
   4.390 +
   4.391 +# get PDB names and chains
   4.392 +
   4.393 +block = [] # block to give it to GeometricalCore_class
   4.394 +
   4.395 +# ID_user[ID] = ID, entered by user
   4.396 +ID_user = {}
   4.397 +
   4.398 +    
   4.399 +for fasta_id, sequence in fasta_dict.items():
   4.400 +    
   4.401 +    if conformity_dict.has_key(fasta_id):
   4.402 +        fasta_id = conformity_dict[fasta_id]
   4.403 +        
   4.404 +    
   4.405 +    pdb = B3D.from_ID(fasta_id)
   4.406 +    
   4.407 +    
   4.408 +
   4.409 +    if not pdb:
   4.410 +        print 'Error: sequence identifier "' + fasta_id + '" in not valid'
   4.411 +#        exit()
   4.412 +        continue
   4.413 +
   4.414 +    pdb_code, pdb_chain, model = pdb
   4.415 +
   4.416 +    block.append([pdb_code, pdb_chain, sequence, model])
   4.417 +    
   4.418 +    # save ID, entered by user
   4.419 +    ID = B3D.to_ID(pdb_code, pdb_chain, model)
   4.420 +    ID_user[ID] = fasta_id
   4.421 +
   4.422 +
   4.423 +if len(block) < 2:
   4.424 +    print 'Error: there are not enough sequences (less than 2)'
   4.425 +    exit()
   4.426 +
   4.427 +
   4.428 +
   4.429 +
   4.430 +
   4.431 +
   4.432 +
   4.433 +##############################################
   4.434 +# run GeometricalCore_class to make core
   4.435 +##############################################
   4.436 +
   4.437 +  
   4.438 +    
   4.439 +B3D.min_width = min_width
   4.440 +B3D.timeout_2 = timeout_2
   4.441 +
   4.442 +B3D.delta = delta
   4.443 +B3D.save = save
   4.444 +B3D.min_size = min_width
   4.445 +B3D.alternative_core_new_atoms = alternative_core_new_atoms
   4.446 +B3D.alternative_cores_count = alternative_cores_count
   4.447 +B3D.timeout = timeout
   4.448 +B3D.pdb_url = pdb_url
   4.449 +
   4.450 +    
   4.451 +# blocks is object with result
   4.452 +blocks = B3D.find_blocks(block)
   4.453 +
   4.454 +# remake IDs as user enter
   4.455 +blocks_1 = []
   4.456 +
   4.457 +
   4.458 +for block in blocks:
   4.459 +
   4.460 +    IDs_1 = []
   4.461 +    
   4.462 +    for ID in block['IDs']:
   4.463 +    
   4.464 +        IDs_1.append(ID_user[ID])
   4.465 +    
   4.466 +    block['IDs'] = IDs_1
   4.467 +    
   4.468 +    blocks_1.append(block)
   4.469 +
   4.470 +
   4.471 +
   4.472 +
   4.473 +
   4.474 +if output_html_file:
   4.475 +    # produce HTML
   4.476 +    
   4.477 +    t = ''
   4.478 +    
   4.479 +    
   4.480 +    t += "blocks = json('" + json.dumps(blocks_1) + "');"
   4.481 +    t += "fasta_dict = json('" + json.dumps(fasta_dict) + "');"
   4.482 +    
   4.483 +#    t += "try{blocks_init();}catch(e){}"
   4.484 +    
   4.485 +    
   4.486 +    
   4.487 +    html = ''.join(open(html_file).readlines())
   4.488 +    
   4.489 +    # insert out code instead of "self_js_text"
   4.490 +    html = html.replace('self_js_text', t)
   4.491 +    
   4.492 +    
   4.493 +    open(output_html_file, 'w').write(html)
   4.494 +    
   4.495 +
   4.496 +
   4.497 +
   4.498 +
   4.499 +
   4.500 +
   4.501 +
   4.502 +
   4.503 +
   4.504 +
   4.505 +
   4.506 +os.remove(GC_temp)
   4.507 +
   4.508 +print 'Task is complete'
   4.509 +
   4.510 +
   4.511 +
   4.512 +
   4.513 +
   4.514 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/blocks3d/Blocks3D_class.py	Fri Sep 17 21:52:33 2010 +0400
     5.3 @@ -0,0 +1,751 @@
     5.4 +# -*- coding: cp1251 -*-
     5.5 +
     5.6 +################################
     5.7 +# Find blocks or true alignment
     5.8 +################################
     5.9 +
    5.10 +
    5.11 +"""
    5.12 +
    5.13 +"""
    5.14 +
    5.15 +
    5.16 +
    5.17 +#import json #temp
    5.18 +
    5.19 +
    5.20 +
    5.21 +import GeometricalCore_class # for find cores
    5.22 +
    5.23 +import Blocks3D_config # default class options
    5.24 +
    5.25 +GC = GeometricalCore_class.GeometricalCore
    5.26 +
    5.27 +from Kliki import Kliki
    5.28 +
    5.29 +
    5.30 +from clon import clon # copy list
    5.31 +
    5.32 +
    5.33 +class Blocks3D(GC):
    5.34 +
    5.35 +    """
    5.36 +    Self data:
    5.37 +
    5.38 +
    5.39 +
    5.40 +    User parameters:
    5.41 +
    5.42 +    
    5.43 +    """
    5.44 +
    5.45 +
    5.46 +
    5.47 +
    5.48 +    
    5.49 +    def __init__(self):
    5.50 +
    5.51 +        """
    5.52 +        Create new copy of class
    5.53 +        """
    5.54 +        
    5.55 +        GC.__init__(self)
    5.56 +        
    5.57 +        vars(self).update(vars(Blocks3D_config))
    5.58 +        
    5.59 +        
    5.60 +        
    5.61 +
    5.62 +
    5.63 +
    5.64 +    def find_blocks(self, alignment):
    5.65 +        """
    5.66 +        Find all blocks
    5.67 +
    5.68 +        Arguments:
    5.69 +            alignment - list.
    5.70 +                It's element - list like ["1jcc", "A", "SSNAKIDQLSSDAQ", None]
    5.71 +                    SSNAKIDQLSSDAQ - part of alignment block sequence
    5.72 +                    Last parameter - model or None
    5.73 +                    
    5.74 +
    5.75 +        Result:
    5.76 +            returns list of blocks
    5.77 +
    5.78 +            block is dict:
    5.79 +                start: integer
    5.80 +                end: integer
    5.81 +                IDs: list of IDs
    5.82 +        """
    5.83 +        
    5.84 +#        # list of IDs
    5.85 +        IDs = []
    5.86 +
    5.87 +        for pdb_code, pdb_chain, seq_part, model in alignment:
    5.88 +
    5.89 +            ID = self.to_ID(pdb_code, pdb_chain, model)
    5.90 +            IDs.append(ID)
    5.91 +        
    5.92 +        self.IDs = IDs
    5.93 +        
    5.94 +
    5.95 +        # build couple cores:
    5.96 +        
    5.97 +        # CORES = <list of cores>
    5.98 +        # core is list of positions
    5.99 +#        CORES = []
   5.100 +        
   5.101 +        
   5.102 +        
   5.103 +        # couple_core_parts[ID_1][ID_2] = <list of parts>
   5.104 +        # part = {'core': core_number, 'start': start_posotion, 'end': end_position}
   5.105 +        couple_core_parts = {}
   5.106 +        
   5.107 +        
   5.108 +            
   5.109 +
   5.110 +        for protein_1 in alignment:
   5.111 +            pdb_code_1, pdb_chain_1, seq_part_1, model_1 = protein_1
   5.112 +            ID_1 = self.to_ID(pdb_code_1, pdb_chain_1, model_1)
   5.113 +
   5.114 +            couple_core_parts[ID_1] = {}
   5.115 +            
   5.116 +            for protein_2 in alignment:
   5.117 +                pdb_code_2, pdb_chain_2, seq_part_2, model_2 = protein_2
   5.118 +                ID_2 = self.to_ID(pdb_code_2, pdb_chain_2, model_2)
   5.119 +                
   5.120 +                if ID_1 == ID_2:
   5.121 +                    break
   5.122 +                
   5.123 +                
   5.124 +                cores = self.check_block([protein_1, protein_2])
   5.125 +                
   5.126 +#                print ' '
   5.127 +                
   5.128 +#                print cores
   5.129 +                
   5.130 +                
   5.131 +                couple_core_parts[ID_1][ID_2] = []
   5.132 +                
   5.133 +                all_cores = [] # list of positions of all cores
   5.134 +                
   5.135 +                for core in cores:
   5.136 +                
   5.137 +                    parts = self.splice_to_continued(core, (ID_1, ID_2))
   5.138 +                    
   5.139 +                    for part in parts:
   5.140 +                        
   5.141 +                        if len(part) >= self.min_width:
   5.142 +                        
   5.143 +                            all_cores.extend(clon(part))
   5.144 +                    
   5.145 +                all_cores = list(set(all_cores)) # unical elements
   5.146 +                
   5.147 +                all_cores.sort()
   5.148 +                    
   5.149 +                
   5.150 +                parts = self.splice_to_continued(all_cores, (ID_1, ID_2))
   5.151 +                    
   5.152 +                for part in parts:
   5.153 +                
   5.154 +                    if len(part) < self.min_width:
   5.155 +                        continue
   5.156 +                        
   5.157 +                    couple_core_parts[ID_1][ID_2].append(clon({
   5.158 +                    'start': part[0], 'end': part[-1]}))
   5.159 +
   5.160 +                couple_core_parts[ID_2][ID_1] = couple_core_parts[ID_1][ID_2]
   5.161 +                
   5.162 +#                CORES.append(clon(core))
   5.163 +            
   5.164 +        
   5.165 +        
   5.166 +#        exit()
   5.167 +        
   5.168 +        # list of elements of blocks graph
   5.169 +        # element is (ID, pos)
   5.170 +        graph_elements = []
   5.171 +        
   5.172 +        # reverse dict to graph_elements
   5.173 +        graph_elements_1 = {}
   5.174 +        
   5.175 +        
   5.176 +        # graph[i][j] == 1, if these elements are connected, or i == j
   5.177 +        # i and j are indexes from list "graph_elements"
   5.178 +        graph = {}
   5.179 +        
   5.180 +        
   5.181 +        # same as graph, but include lists of cores n
   5.182 +#        graph_cores = {}
   5.183 +        
   5.184 +        
   5.185 +        
   5.186 +        # is_boundary[ID][pos] == 1, if pos is boundary of some part in ID
   5.187 +        is_boundary = {}
   5.188 +        
   5.189 +        
   5.190 +        
   5.191 +        for ID_1 in IDs:
   5.192 +            
   5.193 +            
   5.194 +            # find boundaries
   5.195 +            is_boundary[ID_1] = {}
   5.196 +            for ID_2 in IDs:
   5.197 +                if ID_2 == ID_1:
   5.198 +                    continue
   5.199 +                for part in couple_core_parts[ID_1][ID_2]:
   5.200 +                    is_boundary[ID_1][part['start']] = 1
   5.201 +                    is_boundary[ID_1][part['end']] = 1
   5.202 +                
   5.203 +
   5.204 +        
   5.205 +        
   5.206 +            for ID_2 in IDs:
   5.207 +                
   5.208 +                if ID_1 == ID_2:
   5.209 +                    break
   5.210 +                    
   5.211 +                
   5.212 +                
   5.213 +                
   5.214 +                
   5.215 +                for part in couple_core_parts[ID_1][ID_2]:
   5.216 +                    
   5.217 +                    start = part['start']
   5.218 +                    end = part['end']
   5.219 +                    
   5.220 +                    # elements of graph like (ID, pos)
   5.221 +                    elements = []
   5.222 +                    
   5.223 +                    for pos in xrange(start, end + 1):
   5.224 +                        
   5.225 +                        if not is_boundary[ID_1].has_key(pos) and not is_boundary[ID_2].has_key(pos):
   5.226 +                            continue
   5.227 +                    
   5.228 +                        for ID in (ID_1, ID_2):
   5.229 +                            if not graph_elements_1.has_key((ID, pos)):
   5.230 +                                L = len(graph_elements)
   5.231 +                                graph_elements_1[(ID, pos)] = L
   5.232 +                                graph[L] = {}
   5.233 +#                                graph_cores[L] = {}
   5.234 +                                
   5.235 +                                graph_elements.append((ID, pos))
   5.236 +                                
   5.237 +
   5.238 +                            elements.append(graph_elements_1[(ID, pos)])
   5.239 +                            
   5.240 +                    
   5.241 +                    for element_1 in elements:
   5.242 +                        for element_2 in elements:
   5.243 +                            graph[element_1][element_2] = 1
   5.244 +                            
   5.245 +#                            # add information about cores
   5.246 +#                            if not graph_cores[element_1].has_key(element_2):
   5.247 +#                                graph_cores[element_1][element_2] = []
   5.248 +#                            graph_cores[element_1][element_2].append(part['core'])
   5.249 +                            
   5.250 +                            
   5.251 +        
   5.252 +        L = len(graph_elements)
   5.253 +        
   5.254 +        for element_1 in xrange(0, L):
   5.255 +            for element_2 in xrange(0, L):
   5.256 +                if not graph[element_1].has_key(element_2):
   5.257 +                    graph[element_1][element_2] = 0
   5.258 +        
   5.259 +        
   5.260 +        
   5.261 +        kliki_1 = Kliki(graph, min_size=0, timeout=self.timeout_2).kliki
   5.262 +        
   5.263 +        
   5.264 +#        
   5.265 +#        
   5.266 +#        # graf illustration
   5.267 +#        for i in graph.keys():
   5.268 +#            t = ''
   5.269 +#            for j in graph[i].keys():
   5.270 +#                if graph[i][j]:
   5.271 +#                    t += '1'
   5.272 +#                else:
   5.273 +#                    t += ' '
   5.274 +#            print t
   5.275 +#        
   5.276 +#        
   5.277 +        
   5.278 +        
   5.279 +        alignment_len = len(alignment[0][2])
   5.280 +        
   5.281 +        
   5.282 +        
   5.283 +        # occupied alignment elements
   5.284 +        occupied = {}
   5.285 +        
   5.286 +        for ID in IDs:
   5.287 +            
   5.288 +            occupied[ID] = [0] * alignment_len
   5.289 +            
   5.290 +        # 00000000
   5.291 +        occupied_current0 = clon(occupied)
   5.292 +        
   5.293 +        
   5.294 +        
   5.295 +        
   5.296 +        
   5.297 +        
   5.298 +        
   5.299 +#        print graph
   5.300 +        
   5.301 +#        print kliki_1
   5.302 +        
   5.303 +        
   5.304 +        rectangles = []
   5.305 +        
   5.306 +        for klika in kliki_1:
   5.307 +        
   5.308 +            if self.rectangles_type == 'out':
   5.309 +                
   5.310 +                # transitivity 
   5.311 +                
   5.312 +                IDs_dict = {}
   5.313 +                start = alignment_len
   5.314 +                end = 0
   5.315 +                
   5.316 +                for element in klika:
   5.317 +                    
   5.318 +                    ID, pos = graph_elements[element]
   5.319 +                    
   5.320 +                    IDs_dict[ID] = 1
   5.321 +                    
   5.322 +                    start = min(start, pos)
   5.323 +                    end = max(end, pos)
   5.324 +                
   5.325 +                IDs = IDs_dict.keys()
   5.326 +                
   5.327 +                
   5.328 +                rectangles.append({'IDs': IDs, 'start': start, 'end': end})
   5.329 +                
   5.330 +            else:
   5.331 +                
   5.332 +                ID_start = {}
   5.333 +                ID_end = {}
   5.334 +                
   5.335 +                for element in klika:
   5.336 +                    
   5.337 +                    ID, pos = graph_elements[element]
   5.338 +                    
   5.339 +                    
   5.340 +                    if not ID_start.has_key(ID):
   5.341 +                        ID_start[ID] = pos
   5.342 +                        ID_end[ID] = pos
   5.343 +                    else:
   5.344 +                        ID_start[ID] = min(ID_start[ID], pos)
   5.345 +                        ID_end[ID] = max(ID_end[ID], pos)
   5.346 +                
   5.347 +                
   5.348 +                # empty table
   5.349 +                occupied_current = clon(occupied_current0)
   5.350 +                
   5.351 +                
   5.352 +                
   5.353 +                for ID, start in ID_start.items():
   5.354 +                    end = ID_end[ID]
   5.355 +                    
   5.356 +                    for pos in xrange(start, end + 1):
   5.357 +                        occupied_current[ID][pos] = 1
   5.358 +                
   5.359 +                
   5.360 +                rectangles.extend(self.splice_to_rect(occupied_current))
   5.361 +        
   5.362 +        
   5.363 +        
   5.364 +        # sort by height and then by width
   5.365 +        
   5.366 +        rectangles.sort(self.rectangles_compare)
   5.367 +        
   5.368 +        
   5.369 +        
   5.370 +        
   5.371 +        
   5.372 +        
   5.373 +        
   5.374 +        
   5.375 +        
   5.376 +        rectangles_2 = []
   5.377 +        
   5.378 +        
   5.379 +        for rectangle in rectangles:
   5.380 +            
   5.381 +            # empty table
   5.382 +            occupied_current = clon(occupied_current0)
   5.383 +            
   5.384 +            for ID in rectangle['IDs']:
   5.385 +                
   5.386 +                for pos in xrange(rectangle['start'], rectangle['end'] + 1):
   5.387 +                
   5.388 +                    if not occupied[ID][pos]:
   5.389 +                    
   5.390 +                        occupied_current[ID][pos] = 1
   5.391 +            
   5.392 +            rectangles_current = self.splice_to_rect(occupied_current)
   5.393 +            
   5.394 +            
   5.395 +            
   5.396 +            rectangles_2.extend(rectangles_current)
   5.397 +            
   5.398 +            for rectangle in rectangles_current:
   5.399 +                
   5.400 +#                if len(rectangle['IDs']) ==2 and rectangle['IDs'][1] == '1bw5_A_4':
   5.401 +#                    print occupied_current, rectangles
   5.402 +                    
   5.403 +                    
   5.404 +                for ID in rectangle['IDs']:
   5.405 +                    for pos in xrange(rectangle['start'], rectangle['end'] + 1):
   5.406 +                        occupied[ID][pos] = 1
   5.407 +            
   5.408 +        
   5.409 +        
   5.410 +        rectangles = clon(rectangles_2)
   5.411 +        
   5.412 +        
   5.413 +        
   5.414 +        
   5.415 +        
   5.416 +        # delete blocks, including 1 sequence
   5.417 +        
   5.418 +        rectangles = filter(self.rectangle_filter, rectangles)
   5.419 +        
   5.420 +        
   5.421 +        return rectangles
   5.422 +            
   5.423 +        
   5.424 +        
   5.425 +#        
   5.426 +#    # transitivity 
   5.427 +#    def splice_to_outrect(self, occupied_current, occupied):
   5.428 +#        """
   5.429 +#        Splice multitude of alignment elements to rectangles
   5.430 +#        
   5.431 +#        Returns:
   5.432 +#            new occupied_current (out rectangle) \ occupied
   5.433 +#                
   5.434 +#        """
   5.435 +#        
   5.436 +#        width = len(occupied_current.values()[0])
   5.437 +#        
   5.438 +#        start = width # the most right position
   5.439 +#        end = 0 # the most left position
   5.440 +#        
   5.441 +#        IDs_dict = {}
   5.442 +#        
   5.443 +#        for ID, line in occupied_current.items():
   5.444 +#            
   5.445 +#            for pos, condition in enumerate(line):
   5.446 +#                
   5.447 +#                if condition:
   5.448 +#                    
   5.449 +#                    IDs_dict[ID] = 1
   5.450 +#                    start = min(start, pos)
   5.451 +#                    end = max(end, pos)
   5.452 +#            
   5.453 +#        IDs = IDs_dict.keys()
   5.454 +#        
   5.455 +#        
   5.456 +#        
   5.457 +#        occupied_current_1 = {}
   5.458 +#        
   5.459 +#        
   5.460 +#        
   5.461 +#        for ID in IDs:
   5.462 +#            
   5.463 +#            occupied_current_1[ID] = [0] * width
   5.464 +#            
   5.465 +#            for pos in xrange(start, end + 1):
   5.466 +#
   5.467 +#                if not occupied[ID][pos]:
   5.468 +#
   5.469 +#                    occupied_current_1[ID][pos] = 1
   5.470 +#            
   5.471 +#        return occupied_current_1
   5.472 +#        
   5.473 +#        
   5.474 +        
   5.475 +        
   5.476 +    def rectangles_compare(self, x, y):
   5.477 +        
   5.478 +        height_x = len(x['IDs'])
   5.479 +        height_y = len(y['IDs'])
   5.480 +        
   5.481 +        if height_x > height_y:
   5.482 +            return -1
   5.483 +        if height_x < height_y:
   5.484 +            return 1
   5.485 +            
   5.486 +        # same heights
   5.487 +        
   5.488 +        width_x = x['end'] - x['start'] + 1
   5.489 +        width_y = y['end'] - y['start'] + 1
   5.490 +        
   5.491 +        if width_x > width_y:
   5.492 +            return -1
   5.493 +        if width_x < width_y:
   5.494 +            return 1
   5.495 +        
   5.496 +        return 0
   5.497 +    
   5.498 +    
   5.499 +    
   5.500 +    
   5.501 +    def rectangle_filter(self, rectangle):
   5.502 +        
   5.503 +        height = len(rectangle['IDs'])
   5.504 +        
   5.505 +        width = rectangle['end'] - rectangle['start'] + 1
   5.506 +        
   5.507 +        if height >= 2 and width >= self.min_width:
   5.508 +            return True
   5.509 +        else:
   5.510 +            return False
   5.511 +        
   5.512 +        
   5.513 +        
   5.514 +        
   5.515 +    def splice_to_rect(self, occupied_current):
   5.516 +        """
   5.517 +        Splice multitude of alignment elements to rectangles
   5.518 +        
   5.519 +        Returns list of rectangles:
   5.520 +            rectangle is dict:
   5.521 +                'start'
   5.522 +                'end'
   5.523 +                'IDs' - list
   5.524 +                
   5.525 +        """
   5.526 +        
   5.527 +#        occupied_current_1 = splice_to_outrect(occupied_current, occupied)
   5.528 +
   5.529 +        occupied_current_1 = clon(occupied_current)
   5.530 +        
   5.531 +        width = len(occupied_current_1.values()[0])
   5.532 +        
   5.533 +        
   5.534 +        rectangles = []
   5.535 +        
   5.536 +        rectangles_count = 0
   5.537 +        
   5.538 +        
   5.539 +        while 1: 
   5.540 +            
   5.541 +            excluded_IDs = {}
   5.542 +            
   5.543 +            while 1:
   5.544 +                
   5.545 +                IDs_occupied = {} # is ID occupied
   5.546 +                
   5.547 +                height = {} # this position height
   5.548 +                
   5.549 +                for pos in xrange(0, width):
   5.550 +                    
   5.551 +                    height[pos] = 0
   5.552 +                    
   5.553 +                    for ID, e in occupied_current_1.items():
   5.554 +                        
   5.555 +                        if excluded_IDs.has_key(ID):
   5.556 +                            continue
   5.557 +                        
   5.558 +                        if  e[pos]:
   5.559 +                            height[pos] += 1
   5.560 +                            
   5.561 +                            IDs_occupied[ID] = 1
   5.562 +                
   5.563 +                
   5.564 +                max_height = len(IDs_occupied.keys())
   5.565 +                
   5.566 +                
   5.567 +                if max_height <= 1:
   5.568 +                    break
   5.569 +                
   5.570 +                
   5.571 +                
   5.572 +                max_height_positions = []
   5.573 +                
   5.574 +                for pos in xrange(0, width):
   5.575 +                    if height[pos] == max_height:
   5.576 +                        max_height_positions.append(pos)
   5.577 +                        
   5.578 +                
   5.579 +                parts = self.splice_to_continued(max_height_positions, IDs_occupied.keys())
   5.580 +
   5.581 +                
   5.582 +                ok = 0
   5.583 +                
   5.584 +                for part in parts:
   5.585 +                    
   5.586 +                    if len(part) >= self.min_width:
   5.587 +                        
   5.588 +                        # It is block!
   5.589 +                        
   5.590 +                        IDs = IDs_occupied.keys()
   5.591 +                        start = part[0]
   5.592 +                        end = part[-1]
   5.593 +                        
   5.594 +                        
   5.595 +                        rectangles.append(clon({'IDs': IDs, 'start': start, 'end': end, 'cores':[]}))
   5.596 +                        
   5.597 +                        
   5.598 +                        # exclude elements
   5.599 +                        
   5.600 +                        for ID in IDs:
   5.601 +                            for pos in xrange(start, end + 1):
   5.602 +                                occupied_current_1[ID][pos] = 0
   5.603 +                        
   5.604 +                        
   5.605 +                
   5.606 +                        ok = 1
   5.607 +                        
   5.608 +                if ok:
   5.609 +                    continue
   5.610 +                    
   5.611 +                
   5.612 +                
   5.613 +                
   5.614 +                # find the shortest sequence
   5.615 +                
   5.616 +                
   5.617 +                max_width_dict = {}
   5.618 +                
   5.619 +                for ID, e in occupied_current_1.items():
   5.620 +                    
   5.621 +                    if excluded_IDs.has_key(ID):
   5.622 +                        continue
   5.623 +                    
   5.624 +                    positions = []
   5.625 +                    
   5.626 +                    for pos in xrange(0, width):
   5.627 +                        
   5.628 +                        if height[pos] <= 1:
   5.629 +                            # "bad" position
   5.630 +                            continue
   5.631 +                        
   5.632 +                        if e[pos]:
   5.633 +                            positions.append(pos)
   5.634 +                    
   5.635 +                    if len(positions) == 0:
   5.636 +                        continue
   5.637 +                        
   5.638 +                    parts = self.splice_to_continued(positions, [ID])
   5.639 +                    
   5.640 +                    max_part_len = 0
   5.641 +                    
   5.642 +                    for part in parts:
   5.643 +                        max_part_len = max(len(part), max_part_len)
   5.644 +                    
   5.645 +                    max_width_dict[ID] = max_part_len
   5.646 +                    
   5.647 +                
   5.648 +                if len(max_width_dict.values()):
   5.649 +                    min_width = min(max_width_dict.values())
   5.650 +                else:
   5.651 +                    break
   5.652 +                
   5.653 +                # exclude these sequences
   5.654 +                
   5.655 +                for ID, e in occupied_current_1.items():
   5.656 +                    
   5.657 +                    if max_width_dict.has_key(ID):
   5.658 +                        #if max_width_dict[ID] == min_width:
   5.659 +                        if max_width_dict[ID] <= min_width:
   5.660 +                            
   5.661 +                            excluded_IDs[ID] = 1
   5.662 +                            
   5.663 +#                            for pos in xrange(0, width):
   5.664 +#                                occupied_current_1[ID][pos] = 0
   5.665 +
   5.666 +            
   5.667 +#            print rectangles_count
   5.668 +            
   5.669 +            if len(rectangles) == rectangles_count:
   5.670 +                break
   5.671 +                
   5.672 +            rectangles_count = len(rectangles)
   5.673 +            
   5.674 +#            print rectangles_count
   5.675 +            
   5.676 +                        
   5.677 +        return rectangles
   5.678 +        
   5.679 +        
   5.680 +        
   5.681 +        
   5.682 +        
   5.683 +        
   5.684 +        
   5.685 +        
   5.686 +        
   5.687 +        
   5.688 +    
   5.689 +    
   5.690 +    
   5.691 +    
   5.692 +    
   5.693 +    
   5.694 +    
   5.695 +    
   5.696 +    
   5.697 +    
   5.698 +    
   5.699 +    
   5.700 +    
   5.701 +    
   5.702 +    
   5.703 +    def splice_to_continued(self, LIST, IDs):
   5.704 +        """
   5.705 +        LIST is a list of positions of alignment
   5.706 +        
   5.707 +        returns list of continued lists, constituted source LIST
   5.708 +        """
   5.709 +        
   5.710 +        LIST.sort()
   5.711 +
   5.712 +
   5.713 +        # list of continuing parts of this core
   5.714 +        parts = [[]]
   5.715 +
   5.716 +        for pos in LIST:
   5.717 +
   5.718 +            if len(parts[-1]):
   5.719 +                
   5.720 +                if pos - parts[-1][-1] == 1:
   5.721 +                    
   5.722 +                    parts[-1].append(pos)
   5.723 +                    
   5.724 +                else:
   5.725 +                    
   5.726 +                    # check omited sequence
   5.727 +                    
   5.728 +                    gappes = 1 # all omited sequence is gaps
   5.729 +                    
   5.730 +                    for x in xrange(parts[-1][-1] + 1, pos):
   5.731 +                        
   5.732 +                        for ID in IDs:
   5.733 +                            if self.structure1[ID][x]:
   5.734 +                                gappes = 0
   5.735 +                                break
   5.736 +                                
   5.737 +                        if gappes == 0:
   5.738 +                            break
   5.739 +                            
   5.740 +                    if not gappes:
   5.741 +                    
   5.742 +                        # There are not only gapes
   5.743 +                        parts.append([pos])
   5.744 +                    
   5.745 +            else: 
   5.746 +                # first element
   5.747 +                
   5.748 +                parts[-1].append(pos)
   5.749 +                            
   5.750 +        
   5.751 +        return clon(parts)
   5.752 +
   5.753 +
   5.754 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/blocks3d/Blocks3D_config.py	Fri Sep 17 21:52:33 2010 +0400
     6.3 @@ -0,0 +1,20 @@
     6.4 +# -*- coding: cp1251 -*-
     6.5 +
     6.6 +#################
     6.7 +# CLASS VARS
     6.8 +#################
     6.9 +
    6.10 +import sys
    6.11 +
    6.12 +
    6.13 +min_width = 3
    6.14 +
    6.15 +timeout_2 = 10
    6.16 +
    6.17 +
    6.18 +# in this file should be HTM text. string "self_js_text" will be replaced to variable code
    6.19 +# html_file = "../../html.htm"
    6.20 +
    6.21 +
    6.22 +rectangles_type = 'out'
    6.23 +
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/blocks3d/GeometricalCore_class.py	Fri Sep 17 21:52:33 2010 +0400
     7.3 @@ -0,0 +1,1008 @@
     7.4 +# -*- coding: cp1251 -*-
     7.5 +
     7.6 +##############################################
     7.7 +# Geometrical core finding - alignment check
     7.8 +##############################################
     7.9 +
    7.10 +
    7.11 +"""
    7.12 +Example:
    7.13 +
    7.14 +    import GeometricalCore_class
    7.15 +
    7.16 +    l = GeometricalCore_class.GeometricalCore()
    7.17 +
    7.18 +
    7.19 +    print l.check_block([
    7.20 +        ['1jcc', 'A', 'NAKIDQLSSDAQTANAKADQASNDANAARSDAQAAKDDAARANQRLDNM', None],
    7.21 +        ['1jcd', 'A', 'NAKADQASSDAQTANAKADQASNDANAARSDAQAAKDDAARANQRADNA', None],
    7.22 +        ])
    7.23 +
    7.24 +    print l.check_block([
    7.25 +        ['1jcc', 'A', 'NAKIDQLSSDAQTANAKADQASNDANAARSDAQAAKDDAARANQRLDNM', None],
    7.26 +        ['1jcd', 'A', 'NAKADQASSDAQTANAKADQASNDANAARSDAQAAKDDAARANQRADNA', None],
    7.27 +        ])
    7.28 +
    7.29 +
    7.30 +Run method check_block() for each alignment block
    7.31 +
    7.32 +Structures will be uploaded automatically.
    7.33 +Programm takes them from folder /pdb (/pdb/1jcc.ent), if they are there
    7.34 +
    7.35 +In this example we control biological truth of alignment
    7.36 +    NAKIDQLSSDAQTANAKADQASNDANAARSDAQAAKDDAARANQRLDNM
    7.37 +    NAKADQASSDAQTANAKADQASNDANAARSDAQAAKDDAARANQRADNA
    7.38 +
    7.39 +We controled with delta 1 and 2 angstrom
    7.40 +Delta is max allowed alterity between max and min distance between atoms
    7.41 +
    7.42 +We got list of core alignment positions (first is 0)
    7.43 +
    7.44 +"""
    7.45 +
    7.46 +
    7.47 +
    7.48 +
    7.49 +
    7.50 +
    7.51 +import os # to control file existence 
    7.52 +
    7.53 +import urllib2 # to upload PDB from Internet
    7.54 +
    7.55 +import re # regulas expression
    7.56 +
    7.57 +
    7.58 +from Kliki import Kliki # algorithm to find core(s) from graph 
    7.59 +
    7.60 +import AAdict # dict to convert 3-N code to 1-N
    7.61 +import AlignmentSeq # sequense alignment class
    7.62 +
    7.63 +
    7.64 +import GeometricalCore_config # default class options
    7.65 +
    7.66 +
    7.67 +
    7.68 +
    7.69 +AAdict = AAdict.AAdict
    7.70 +
    7.71 +
    7.72 +class GeometricalCore:
    7.73 +
    7.74 +    """
    7.75 +    Self data:
    7.76 +
    7.77 +    self.structure
    7.78 +        3d Coordinates of CA atoms of each structure
    7.79 +        
    7.80 +        Formation:
    7.81 +            self.structure[structure name][atom identifier] = list [x,y,z]
    7.82 +            where:
    7.83 +                structure name - string like "1jcc:A"
    7.84 +                atom identifier - number of residue i PDB file, first is 0
    7.85 +                x,y,x - Coordinates of CA atoms in PDB
    7.86 +        
    7.87 +
    7.88 +    self.seq
    7.89 +        sequences of each structures
    7.90 +
    7.91 +        Formation:
    7.92 +            self.seq[structure name] = string like "SSNAKIDQLSSDAQ"
    7.93 +                where: structure name - string like "1jcc:A"
    7.94 +    
    7.95 +    self.structure1 - same as self.structure, but atom identifier is number in block
    7.96 +    
    7.97 +    self.d - distances
    7.98 +        self.d[ID][i][j] = distance between i and j atoms in structure ID  
    7.99 +
   7.100 +
   7.101 +
   7.102 +
   7.103 +
   7.104 +    User parameters:
   7.105 +
   7.106 +        self.max_absent - max part of positions without PDB info in one structure
   7.107 +
   7.108 +        self.save - should programm save PDB to folder pbd/ (0 - do not save, 1 - save)
   7.109 +
   7.110 +        self.min_size - min size of each core
   7.111 +
   7.112 +        self.alternative_core_new_atoms - part of new atoms in alternative core
   7.113 +
   7.114 +        self.alternative_cores_count - max number of cores (including main core)
   7.115 +    
   7.116 +    """
   7.117 +
   7.118 +
   7.119 +
   7.120 +
   7.121 +    
   7.122 +    def __init__(self):
   7.123 +
   7.124 +        """
   7.125 +        Create new copy of class
   7.126 +
   7.127 +        Creates self vars self.structure and self.seq
   7.128 +        """
   7.129 +        
   7.130 +        vars(self).update(vars(GeometricalCore_config))
   7.131 +
   7.132 +
   7.133 +        self.structure = {}
   7.134 +        self.structure1 = {}
   7.135 +        self.d = {}
   7.136 +        
   7.137 +        
   7.138 +        self.seq = {}
   7.139 +        self.pdb_text = {} # there will be PDB texts in this dict. key - string like "1jcc"
   7.140 +        
   7.141 +        
   7.142 +        
   7.143 +        
   7.144 +
   7.145 +
   7.146 +
   7.147 +
   7.148 +
   7.149 +    def change_block_boundary(self):
   7.150 +        """
   7.151 +        If you use at first one boundaries (in positions) of block in some PDB file,
   7.152 +        and then decide to change them, run this method before running check_block method
   7.153 +        """
   7.154 +    
   7.155 +        self.structure1 = {}
   7.156 +        self.d = {}
   7.157 +
   7.158 +
   7.159 +
   7.160 +#
   7.161 +#
   7.162 +#    def change_parameters(self, delta=None, save=None, min_size=None,
   7.163 +#                alternative_core_new_atoms=None,
   7.164 +#                alternative_cores_count=None, timeout=None):
   7.165 +#        """
   7.166 +#        Changes self parameters
   7.167 +#
   7.168 +#        description of parameters - see class description
   7.169 +#        """
   7.170 +#
   7.171 +#        if delta != None:
   7.172 +#            self.delta = delta
   7.173 +#
   7.174 +#
   7.175 +#        if save != None:
   7.176 +#            self.save = save
   7.177 +#
   7.178 +#        if min_size != None:
   7.179 +#            self.min_size = min_size
   7.180 +#
   7.181 +#        if alternative_core_new_atoms != None:
   7.182 +#            self.alternative_core_new_atoms = alternative_core_new_atoms
   7.183 +#
   7.184 +#
   7.185 +#        if alternative_cores_count != None:
   7.186 +#            self.alternative_cores_count = alternative_cores_count            
   7.187 +#
   7.188 +#        if timeout != None:
   7.189 +#            self.timeout = timeout            
   7.190 +#
   7.191 +#
   7.192 +#
   7.193 +
   7.194 +
   7.195 +
   7.196 +    
   7.197 +    def to_ID(self, pdb_code, pdb_chain, model):
   7.198 +    
   7.199 +        """
   7.200 +        Makes standart ID for structure from pdb_code, chain and model
   7.201 +        """
   7.202 +    
   7.203 +        ID = pdb_code + '_'
   7.204 +        
   7.205 +        if pdb_chain:
   7.206 +            ID = ID + pdb_chain.upper().strip()
   7.207 +
   7.208 +        if model:
   7.209 +            ID = ID + '_' + model
   7.210 +            
   7.211 +        return ID
   7.212 +        
   7.213 +        
   7.214 +        
   7.215 +        
   7.216 +        
   7.217 +        
   7.218 +    def from_ID(self, ID):
   7.219 +    
   7.220 +        """
   7.221 +        Parse standart ID to pdb_code, chain and model
   7.222 +        """
   7.223 +        
   7.224 +        
   7.225 +        if not hasattr(self, 're1'):
   7.226 +        
   7.227 +        
   7.228 +            # makes compiled regular expressions
   7.229 +            
   7.230 +            # for pdb-codes
   7.231 +            self.re1 = re.compile(r"(^|[^a-z0-9])([0-9][0-9a-z]{3})([^a-z0-9]([0-9a-z ]?)([^a-z0-9]([0-9]{1,3}))?)?($|[^a-z0-9])")
   7.232 +            
   7.233 +            # for files
   7.234 +            self.re2 = re.compile(r"(^)([^^]+\.(ent|pdb))([^a-zA-Z0-9]([0-9A-Za-z ]?)([^a-zA-Z0-9]([0-9]{1,3}))?)?$")
   7.235 +            
   7.236 +            
   7.237 +            self.from_ID_dict = {}
   7.238 +            
   7.239 +            
   7.240 +                
   7.241 +        
   7.242 +        if self.from_ID_dict.has_key(ID):
   7.243 +            return self.from_ID_dict[ID]
   7.244 +            
   7.245 +        
   7.246 +        if ID.lower().find('.ent') != -1 or ID.lower().find('.pdb') != -1:
   7.247 +            # it is file
   7.248 +            parseO = self.re2.search(ID) # files
   7.249 +        else:
   7.250 +            parseO = self.re1.search(ID.lower()) # pdb codes
   7.251 +        
   7.252 +            
   7.253 +        if not parseO:
   7.254 +            return None
   7.255 +            
   7.256 +        parse = parseO.groups()
   7.257 +        
   7.258 +        
   7.259 +        if len(parse) < 2:
   7.260 +            return None
   7.261 +            
   7.262 +        
   7.263 +        code = parse[1]
   7.264 +        
   7.265 +#        if not file:
   7.266 +#            code = code.lower()
   7.267 +        
   7.268 +        chain = ''
   7.269 +        model = None
   7.270 +        
   7.271 +        if len(parse) >= 4:
   7.272 +            chain = parse[3]
   7.273 +            
   7.274 +            if chain:
   7.275 +                chain = chain.upper()
   7.276 +        
   7.277 +            if len(parse) >= 6:
   7.278 +                if parse[5]:
   7.279 +                    model = parse[5]
   7.280 +                
   7.281 +        
   7.282 +        
   7.283 +        self.from_ID_dict[ID] = (code, chain, model) # save parsing results
   7.284 +        
   7.285 +        return code, chain, model
   7.286 +        
   7.287 +        
   7.288 +
   7.289 +
   7.290 +
   7.291 +
   7.292 +    def check_block(self, block):
   7.293 +        """
   7.294 +        Outside opened method (from main programm)
   7.295 +
   7.296 +
   7.297 +        Arguments:
   7.298 +            block - list.
   7.299 +                It's element - list like ["1jcc", "A", "SSNAKIDQLSSDAQ", None]
   7.300 +                    SSNAKIDQLSSDAQ - part of alignment block sequence
   7.301 +                    Last parameter - model or None
   7.302 +                    
   7.303 +
   7.304 +        Result:
   7.305 +            returns list of core atom identifiers (first is 0)
   7.306 +
   7.307 +            Example: [0,1,2,3,4,6]
   7.308 +        """
   7.309 +        
   7.310 +        
   7.311 +
   7.312 +
   7.313 +        # check lendth of input sequences
   7.314 +        L0 = len(block[0][2])
   7.315 +
   7.316 +        for pdb_code, pdb_chain, seq_part, model in block:
   7.317 +            if len(seq_part) != L0:
   7.318 +                #print seq_part, block[0][2]
   7.319 +                print 'Sequences must have equal lengths'
   7.320 +                print 'Task was aborted!'
   7.321 +                return
   7.322 +        
   7.323 +
   7.324 +
   7.325 +        
   7.326 +
   7.327 +
   7.328 +        
   7.329 +        pdb_list = [] # list of uploading PDB names
   7.330 +
   7.331 +        for pdb_code, pdb_chain, seq_part, model in block:
   7.332 +
   7.333 +            ID = self.to_ID(pdb_code, pdb_chain, model)
   7.334 +
   7.335 +            if not self.seq.has_key(ID) or not self.structure.has_key(ID):
   7.336 +            
   7.337 +#                pdb_code = pdb_code.lower()
   7.338 +                
   7.339 +                if pdb_chain:
   7.340 +                    pdb_chain = pdb_chain.upper()
   7.341 +                    
   7.342 +                pdb_list.append((pdb_code, pdb_chain, model))
   7.343 +
   7.344 +
   7.345 +
   7.346 +        if len(pdb_list) != 0:
   7.347 +            self.load_pdb(pdb_list) # If it is required, get PDBs
   7.348 +
   7.349 +
   7.350 +
   7.351 +        for pdb_code, pdb_chain, seq_part, model in block:
   7.352 +
   7.353 +            ID = self.to_ID(pdb_code, pdb_chain, model)
   7.354 +            
   7.355 +            
   7.356 +
   7.357 +
   7.358 +
   7.359 +            if not self.seq.has_key(ID) or not self.structure.has_key(ID): # no structure :(
   7.360 +                print 'Undefined structuce ' + ID
   7.361 +                print 'Task was aborted!'
   7.362 +                return            
   7.363 +
   7.364 +            if not self.seq[ID] or not self.structure[ID]: # no structure :(
   7.365 +                print 'Undefined structuce ' + ID
   7.366 +                print 'Task was aborted!'
   7.367 +                return
   7.368 +        
   7.369 +
   7.370 +
   7.371 +
   7.372 +        
   7.373 +
   7.374 +#        absent = {} # [position identifier] = 1, if some structure has not this atom       
   7.375 +
   7.376 +#        structure = {} # [structure name][position in block] = list [x,y,z]
   7.377 +        
   7.378 +        IDs = []
   7.379 +        
   7.380 +        for pdb_code, pdb_chain, seq_part, model in block:
   7.381 +
   7.382 +            ID = self.to_ID(pdb_code, pdb_chain, model)
   7.383 +            
   7.384 +            IDs.append(ID)
   7.385 +
   7.386 +            if self.structure1.has_key(ID):
   7.387 +                continue
   7.388 +            
   7.389 +
   7.390 +            # alignment part of sequence with full sequence
   7.391 +            connections = self.find_sequence_piece(self.seq[ID], seq_part)
   7.392 +
   7.393 +
   7.394 +            # add atoms coordinates
   7.395 +
   7.396 +            self.structure1[ID] = []
   7.397 +
   7.398 +
   7.399 +            
   7.400 +            for i in xrange(0, len(connections)):
   7.401 +                if connections[i] == '-': # there is not required position in PDB
   7.402 +                    self.structure1[ID].append(None)
   7.403 +#                    absent[i] = 1
   7.404 +                else:
   7.405 +                    self.structure1[ID].append(self.structure[ID][connections[i]])
   7.406 +
   7.407 +#
   7.408 +#
   7.409 +#        # how many positions absent in some structures
   7.410 +#        if len(absent) / float(len(block[0][2])) > self.max_absent:
   7.411 +#            print 'There are too many positions without PDB structure,', len(absent), 'of', len(block[0][2])
   7.412 +#
   7.413 +#
   7.414 +
   7.415 +
   7.416 +        # now we know coordinates of each atom of each structure
   7.417 +
   7.418 +
   7.419 +
   7.420 +        # calculate atom distances
   7.421 +        self.make_d()
   7.422 +
   7.423 +
   7.424 +        # make alignment graph
   7.425 +        graf, cost = self.make_graf(IDs)
   7.426 +
   7.427 +##        self.cost = cost
   7.428 +
   7.429 +
   7.430 +        # find cores
   7.431 +        cores = Kliki(graf, cost, min_size=self.min_size, timeout=self.timeout).kliki
   7.432 +
   7.433 +
   7.434 +        # sort cores and return real alternative cores (with high difference)
   7.435 +        cores = self.find_alternative_cores(cores)
   7.436 +
   7.437 +
   7.438 +#
   7.439 +#        # save CA atom coordinates
   7.440 +#        self.structure1 = structure 
   7.441 +#
   7.442 +        
   7.443 +        return cores
   7.444 +
   7.445 +
   7.446 +
   7.447 +
   7.448 +    
   7.449 +
   7.450 +
   7.451 +
   7.452 +    def load_pdb(self, pdb_list):
   7.453 +
   7.454 +        """
   7.455 +        This method is runned to get PDB files and reading them structures
   7.456 +
   7.457 +        Argument:
   7.458 +            pdb_list - list of lists [pdb_code, chain]
   7.459 +
   7.460 +        Result:
   7.461 +            Adds structure data to self vars self.structure and self.seq
   7.462 +        """
   7.463 +
   7.464 +
   7.465 +
   7.466 +
   7.467 +
   7.468 +        codes = [] # list of PDB codes
   7.469 +
   7.470 +        # get texts of each PDB
   7.471 +        
   7.472 +        for pdb_code, pdb_chain, model in pdb_list:
   7.473 +            if not codes.count(pdb_code):
   7.474 +                codes.append(pdb_code)
   7.475 +
   7.476 +
   7.477 +        for pdb_code in codes:
   7.478 +
   7.479 +
   7.480 +            # check PDB file existance in folder ./pdb/
   7.481 +            
   7.482 +            fname = 'pdb/' + pdb_code
   7.483 +            
   7.484 +            if pdb_code.lower().find('.ent') == -1 and pdb_code.lower().find('.pdb') == -1:
   7.485 +                # pdb code
   7.486 +                fname += '.ent'
   7.487 +            
   7.488 +            
   7.489 +            if os.path.exists(fname):
   7.490 +                self.pdb_text[pdb_code] = open(fname).readlines()
   7.491 +            else:
   7.492 +                # try to upload from Internet 
   7.493 +                try:
   7.494 +
   7.495 +                    url = self.pdb_url.replace('XXXX', pdb_code)
   7.496 +                    
   7.497 +                    self.pdb_text[pdb_code] = urllib2.urlopen(url).readlines()
   7.498 +
   7.499 +                    
   7.500 +                except:
   7.501 +                    self.pdb_text[pdb_code] = ''
   7.502 +                    
   7.503 +                    
   7.504 +                if self.save:
   7.505 +                    # save information
   7.506 +                    
   7.507 +                    try:
   7.508 +                    
   7.509 +                    
   7.510 +                        # check folder "/pdb" existance
   7.511 +                        
   7.512 +                        if not os.path.exists('pdb'):
   7.513 +                        
   7.514 +                            # make folder
   7.515 +                            os.mkdir('pdb');
   7.516 +                        
   7.517 +                        
   7.518 +                        pdbfile_to_save = open('pdb/' + pdb_code + '.ent', 'w')
   7.519 +                        pdbfile_to_save.write(''.join(self.pdb_text[pdb_code]))
   7.520 +                        pdbfile_to_save.close()
   7.521 +                        
   7.522 +                        print 'PDB structure saved to file pdb/' + pdb_code + '.ent'
   7.523 +					
   7.524 +                    except:
   7.525 +                        
   7.526 +                        print 'Can not write file pdb/' + pdb_code + '.ent'
   7.527 +                    
   7.528 +
   7.529 +            if not self.pdb_text[pdb_code]:
   7.530 +                #print self.pdb_url.replace('XXXX', pdb_code)
   7.531 +                print 'Can not get text of PDB', pdb_code
   7.532 +                return
   7.533 +
   7.534 +
   7.535 +        # We have all PDB texts
   7.536 +
   7.537 +
   7.538 +        # read all texts and get CA atoms coordinates 
   7.539 +
   7.540 +        for pdb_code, pdb_chain, model in pdb_list:
   7.541 +        
   7.542 +            ID = self.to_ID(pdb_code, pdb_chain, model)
   7.543 +            
   7.544 +            S = self.read_pdb(pdb_code, pdb_chain, self.pdb_text[pdb_code], model)
   7.545 +            self.structure[ID], self.seq[ID] = S
   7.546 +
   7.547 +
   7.548 +            if not self.seq[ID]:
   7.549 +                print 'Can not find sequence for "' + ID + '"'
   7.550 +                return 
   7.551 +         
   7.552 +
   7.553 +
   7.554 +
   7.555 +        
   7.556 +
   7.557 +    def read_pdb(self, pdb_code, pdb_chain, pdb_text, model):
   7.558 +        """
   7.559 +        Reads pdb_text
   7.560 +        
   7.561 +        Returns (structure, sequence)
   7.562 +            structure (key - string like "1jcc:A")
   7.563 +                This element is dict with [x,y,z] coordinates of each aa
   7.564 +            sequence
   7.565 +        """
   7.566 +
   7.567 +       
   7.568 +
   7.569 +        structure = [] # dict with coordinates list
   7.570 +        seq = ''  # sequense (string)
   7.571 +        
   7.572 +        
   7.573 +        Model_already = 0 # is it our model now
   7.574 +        
   7.575 +        if not model:
   7.576 +            Model_already = 1
   7.577 +
   7.578 +
   7.579 +
   7.580 +
   7.581 +
   7.582 +        for currentline in pdb_text:
   7.583 +        
   7.584 +        
   7.585 +            if not Model_already:
   7.586 +                if currentline[0:5] == 'MODEL':
   7.587 +                    if currentline[10:14].strip() == model:
   7.588 +                        Model_already = 1
   7.589 +                        continue
   7.590 +                        
   7.591 +                continue
   7.592 +                
   7.593 +                
   7.594 +            
   7.595 +            if currentline[0:6] == 'ENDMDL':
   7.596 +                break
   7.597 +
   7.598 +
   7.599 +            if len(currentline) < 54:
   7.600 +                continue
   7.601 +            
   7.602 +            
   7.603 +
   7.604 +            if currentline[0:4] != "ATOM":
   7.605 +                continue
   7.606 +                
   7.607 +            
   7.608 +            atomType = currentline[12:16].strip()
   7.609 +
   7.610 +            if atomType != "CA":
   7.611 +                continue
   7.612 +                
   7.613 +            
   7.614 +            thisChain = currentline[21].strip()
   7.615 +
   7.616 +            if thisChain != pdb_chain:
   7.617 +                continue
   7.618 +                
   7.619 +            
   7.620 +            alterCode = currentline[16] # Alter code
   7.621 +                
   7.622 +            if alterCode != ' ' and alterCode != 'A':
   7.623 +                continue
   7.624 +
   7.625 +            
   7.626 +            thisAminoAcid = currentline[17:20].strip()
   7.627 +
   7.628 +                      
   7.629 +            thisX = float(currentline[30:38].strip())
   7.630 +            thisY = float(currentline[38:46].strip())
   7.631 +            thisZ = float(currentline[46:54].strip())
   7.632 +
   7.633 +
   7.634 +            # add atom coornates
   7.635 +            structure.append((thisX,thisY,thisZ))
   7.636 +
   7.637 +
   7.638 +            # prolong sequense
   7.639 +            if (AAdict.has_key(thisAminoAcid)):
   7.640 +                seq = seq + AAdict[thisAminoAcid][0]
   7.641 +            else:
   7.642 +                seq = seq + 'x'
   7.643 +        
   7.644 +        return (structure, seq)
   7.645 +
   7.646 +
   7.647 +
   7.648 +
   7.649 +
   7.650 +
   7.651 +###     
   7.652 +###     
   7.653 +###     
   7.654 +###         def add_pdb(self, pdb_code, pdb_chain, pdb_text, model):
   7.655 +###     
   7.656 +###             """
   7.657 +###             Method read PDB and get coordinates of CA atoms
   7.658 +###     
   7.659 +###             Arguments:
   7.660 +###                 pdb_code - PDB name, for example "1jcc"
   7.661 +###                 pdb_chain - chain, for example "A"
   7.662 +###                 pdb_text - PDB file strings
   7.663 +###     
   7.664 +###     
   7.665 +###             Result:
   7.666 +###                 New element will be added in dict self.structure (key - string like "1jcc:A")
   7.667 +###                 This element is dict with [x,y,z] coordinates of each aa
   7.668 +###     
   7.669 +###             """
   7.670 +###             
   7.671 +###             ID = self.to_ID(pdb_code, pdb_chain, model)
   7.672 +###             
   7.673 +###             self.structure[ID], self.seq[ID] = read_pdb(pdb_code, pdb_chain, pdb_text, model)
   7.674 +###             
   7.675 +###     
   7.676 +###             
   7.677 +
   7.678 +
   7.679 +        
   7.680 +
   7.681 +
   7.682 +
   7.683 +
   7.684 +
   7.685 +
   7.686 +
   7.687 +
   7.688 +
   7.689 +
   7.690 +
   7.691 +
   7.692 +
   7.693 +
   7.694 +
   7.695 +        
   7.696 +            
   7.697 +
   7.698 +
   7.699 +
   7.700 +
   7.701 +
   7.702 +
   7.703 +
   7.704 +
   7.705 +
   7.706 +
   7.707 +
   7.708 +
   7.709 +
   7.710 +    def find_sequence_piece (self, seq_all, seq_part):
   7.711 +        """
   7.712 +        Method for search subsequence in sequnce
   7.713 +
   7.714 +        Arguments:
   7.715 +            seq_all - full sequence (from PDB)
   7.716 +            seq_part - subsequence (from alignment block), can contain gapes
   7.717 +
   7.718 +        Result:
   7.719 +        retuns list with conformity list
   7.720 +                key - subsequence position (in seq_part)
   7.721 +                value - full sequence position (in seq_all)
   7.722 +
   7.723 +                First is 0
   7.724 +
   7.725 +                If no position from PDB meets subsequence position,
   7.726 +                value is '-', programm makes warning
   7.727 +
   7.728 +        """
   7.729 +        seq_alignment = AlignmentSeq.AlignmentSeq([seq_part, seq_all]).new_sequences
   7.730 +
   7.731 +##        print seq_alignment[0]
   7.732 +##        print seq_alignment[1]
   7.733 +
   7.734 +
   7.735 +        # At first, calculate conformity without gapes
   7.736 +        
   7.737 +        connections0 = [] # key - seq_part position, value - position in seq_part without gapes
   7.738 +        part_usage = 0 # how many aa from seqpart were used
   7.739 +        
   7.740 +        for i in xrange(0, len(seq_part)):
   7.741 +            s = seq_part[i]
   7.742 +            if s == '-':
   7.743 +                connections0.append('-')
   7.744 +            else:
   7.745 +                connections0.append(part_usage)
   7.746 +                part_usage += 1
   7.747 +            
   7.748 +        
   7.749 +
   7.750 +
   7.751 +
   7.752 +
   7.753 +
   7.754 +
   7.755 +        
   7.756 +
   7.757 +        connections1 = []
   7.758 +
   7.759 +        all_usage = 0 # how many aa from full sequence were used
   7.760 +
   7.761 +        for i in xrange(0, len(seq_alignment[0])):
   7.762 +            AA_part = seq_alignment[0][i]
   7.763 +            AA_all  = seq_alignment[1][i]
   7.764 +
   7.765 +            if AA_all != '-':
   7.766 +                all_usage += 1
   7.767 +
   7.768 +            if AA_part == '-':
   7.769 +                continue
   7.770 +
   7.771 +            if AA_all == '-':
   7.772 +                connections1.append('-')
   7.773 +#                print 'Can not find', AA_part, len(connections1), 'of', seq_part, 'in', seq_all
   7.774 +                continue
   7.775 +        
   7.776 +
   7.777 +            connections1.append(all_usage - 1)
   7.778 +
   7.779 +
   7.780 +
   7.781 +        connections = []
   7.782 +
   7.783 +
   7.784 +        for i in connections0:
   7.785 +            if i == '-':
   7.786 +                connections.append('-')
   7.787 +            else:
   7.788 +                connections.append(connections1[i])
   7.789 +
   7.790 +        return connections
   7.791 +
   7.792 +
   7.793 +
   7.794 +        
   7.795 +            
   7.796 +            
   7.797 +            
   7.798 +
   7.799 +
   7.800 +
   7.801 +
   7.802 +
   7.803 +
   7.804 +
   7.805 +
   7.806 +
   7.807 +    def make_d(self):
   7.808 +
   7.809 +        """
   7.810 +        Calculates distances
   7.811 +        
   7.812 +        adds new elements to self.d
   7.813 +        """
   7.814 +
   7.815 +
   7.816 +        # Atom count
   7.817 +        aton_count = len(self.structure1.values()[0])
   7.818 +        
   7.819 +        for ID, structure in self.structure1.items():
   7.820 +            
   7.821 +            if self.d.has_key(ID):
   7.822 +                continue # already done
   7.823 +                
   7.824 +            self.d[ID] = []
   7.825 +
   7.826 +
   7.827 +            # create distance matrix 
   7.828 +            for atom1 in xrange(0, aton_count):
   7.829 +                self.d[ID].append([])
   7.830 +                for atom2 in xrange(0, aton_count):
   7.831 +                    self.d[ID][atom1].append(None)
   7.832 +
   7.833 +
   7.834 +            # done distance matrix 
   7.835 +            
   7.836 +            for atom1 in xrange(0, aton_count):
   7.837 +                for atom2 in xrange(0, aton_count):
   7.838 +
   7.839 +                    if atom2 == atom1:
   7.840 +                        break
   7.841 +                        
   7.842 +                    if structure[atom1] and structure[atom2]:
   7.843 +
   7.844 +                        dist = 0
   7.845 +
   7.846 +                        for xyz in xrange(0, 3):
   7.847 +                           
   7.848 +                            dist += (structure[atom1][xyz] - structure[atom2][xyz]) ** 2
   7.849 +
   7.850 +                        dist = dist ** 0.5
   7.851 +
   7.852 +                        self.d[ID][atom1][atom2] = dist
   7.853 +                        self.d[ID][atom2][atom1] = dist
   7.854 +         
   7.855 +            
   7.856 +
   7.857 +
   7.858 +
   7.859 +
   7.860 +
   7.861 +
   7.862 +
   7.863 +
   7.864 +    def make_graf(self, IDs):
   7.865 +
   7.866 +        """
   7.867 +        Make alignment core graph
   7.868 +
   7.869 +        Arguments:
   7.870 +            IDs - list of IDs to study
   7.871 +            
   7.872 +            
   7.873 +        Result:
   7.874 +        returns [alignment core graph, cost graf]
   7.875 +
   7.876 +        
   7.877 +            alignment core graph example:
   7.878 +            graf[0][1] = 1    0 and 1 positions are connected
   7.879 +            graf[0][1] = 0    0 and 1 positions are not connected
   7.880 +        """
   7.881 +
   7.882 +        # Atom count
   7.883 +        aton_count = len(self.structure1.values()[0])
   7.884 +
   7.885 +
   7.886 +        graf = {}
   7.887 +
   7.888 +        cost = {} # distance spreading 
   7.889 +
   7.890 +        
   7.891 +        
   7.892 +        
   7.893 +        
   7.894 +        for atom1 in xrange(0, aton_count):
   7.895 +
   7.896 +            
   7.897 +            graf[atom1] = {}
   7.898 +
   7.899 +            cost[atom1] = {}
   7.900 +            
   7.901 +            for atom2 in xrange(0, aton_count):
   7.902 +
   7.903 +
   7.904 +                if atom1 == atom2:
   7.905 +                    graf[atom1][atom2] = 1
   7.906 +                    break
   7.907 +
   7.908 +                
   7.909 +                distances = []
   7.910 +                
   7.911 +                for ID in IDs:
   7.912 +                    distances.append(self.d[ID][atom1][atom2])
   7.913 +
   7.914 +                
   7.915 +                if distances.count(None):
   7.916 +                    graf[atom1][atom2] = 0
   7.917 +                    graf[atom2][atom1] = 0
   7.918 +
   7.919 +                else:
   7.920 +                    
   7.921 +                    spreading = max(distances) - min(distances)
   7.922 +
   7.923 +                    if spreading > self.delta:
   7.924 +                    
   7.925 +                        graf[atom1][atom2] = 0
   7.926 +                        graf[atom2][atom1] = 0
   7.927 +                        
   7.928 +                    else:
   7.929 +                        graf[atom1][atom2] = 1
   7.930 +                        graf[atom2][atom1] = 1
   7.931 +
   7.932 +                        cost[atom1][atom2] = -spreading
   7.933 +                        cost[atom2][atom1] = -spreading
   7.934 +
   7.935 +                        
   7.936 +
   7.937 +        return [graf, cost]
   7.938 +
   7.939 +
   7.940 +
   7.941 +
   7.942 +
   7.943 +
   7.944 +
   7.945 +    def find_alternative_cores(self, cores):
   7.946 +        """
   7.947 +        gather different cores and returns it
   7.948 +
   7.949 +        Arguments:
   7.950 +            cores - list of lists of core atoms
   7.951 +
   7.952 +        Result:
   7.953 +            returns list with real different cores
   7.954 +        """
   7.955 +
   7.956 +        new_cores = [] # list with added cores
   7.957 +
   7.958 +        for core in cores:
   7.959 +
   7.960 +            if self.alternative_cores_count:
   7.961 +                if len(new_cores) >= self.alternative_cores_count:
   7.962 +                    break # there are enough cores :)
   7.963 +
   7.964 +
   7.965 +
   7.966 +
   7.967 +            ok = 1
   7.968 +
   7.969 +            if self.alternative_core_new_atoms:
   7.970 +
   7.971 +                # compare this core with all added cores
   7.972 +            
   7.973 +                for one_core in new_cores:
   7.974 +                    new_atoms = 0
   7.975 +
   7.976 +                    for atom in core:
   7.977 +                        if one_core.count(atom) == 0:
   7.978 +                            new_atoms += 1
   7.979 +
   7.980 +                    if new_atoms / float(len(core)) < self.alternative_core_new_atoms:
   7.981 +                        ok = 0
   7.982 +                        break
   7.983 +
   7.984 +
   7.985 +            # if this core is good
   7.986 +            if ok == 1:            
   7.987 +                new_cores.append(core)
   7.988 +
   7.989 +
   7.990 +
   7.991 +        return new_cores
   7.992 +                
   7.993 +            
   7.994 +            
   7.995 +
   7.996 +
   7.997 +
   7.998 +
   7.999 +
  7.1000 +
  7.1001 +
  7.1002 +
  7.1003 +
  7.1004 +
  7.1005 +
  7.1006 +
  7.1007 +
  7.1008 +
  7.1009 +
  7.1010 +
  7.1011 +
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/blocks3d/GeometricalCore_config.py	Fri Sep 17 21:52:33 2010 +0400
     8.3 @@ -0,0 +1,52 @@
     8.4 +# -*- coding: cp1251 -*-
     8.5 +
     8.6 +#################
     8.7 +# CLASS VARS
     8.8 +#################
     8.9 +
    8.10 +
    8.11 +#  -     
    8.12 +delta = 2.0
    8.13 +
    8.14 +
    8.15 +
    8.16 +#        pdb/
    8.17 +save = 1
    8.18 +
    8.19 +
    8.20 +
    8.21 +# min size of returning cores
    8.22 +min_size = 20
    8.23 +
    8.24 +
    8.25 +
    8.26 +# min part or new atoms in new alternative core
    8.27 +alternative_core_new_atoms = 0.5
    8.28 +
    8.29 +
    8.30 +# max number of cores (including main core)
    8.31 +alternative_cores_count = 5
    8.32 +
    8.33 +
    8.34 +
    8.35 +#     ,         PDB
    8.36 +# !!! can be changed only in this file !!!
    8.37 +max_absent = 0.15
    8.38 +
    8.39 +
    8.40 +# pdb download url (XXXX is pdb code place)
    8.41 +pdb_url = 'http://www.pdb.org/pdb/files/XXXX.pdb'
    8.42 +
    8.43 +# time in sec. for BRON-KERBOSH algorithm
    8.44 +timeout = 10
    8.45 +
    8.46 +
    8.47 +#####################
    8.48 +# PROGRAMM VARS
    8.49 +#####################
    8.50 +
    8.51 +
    8.52 +# output file format (msf, fasta, list)
    8.53 +# output_format = 'msf'
    8.54 +
    8.55 +
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/blocks3d/Kliki.py	Fri Sep 17 21:52:33 2010 +0400
     9.3 @@ -0,0 +1,567 @@
     9.4 +# -*- coding: cp1251 -*-
     9.5 +
     9.6 +#########################################################################
     9.7 +#  -:   /
     9.8 +#########################################################################
     9.9 +
    9.10 +
    9.11 +
    9.12 +
    9.13 +"""
    9.14 +        
    9.15 +
    9.16 +Usage:
    9.17 +
    9.18 +from Kliki import Kliki
    9.19 +l = Kliki(graf)
    9.20 +l.kliki #   
    9.21 +"""
    9.22 +
    9.23 +
    9.24 +import time
    9.25 +from clon import clon
    9.26 +
    9.27 +
    9.28 +
    9.29 +class Kliki:
    9.30 +
    9.31 +
    9.32 +
    9.33 +    """
    9.34 +    graf[1][2] = 1 -  , 0 -  
    9.35 +
    9.36 +    kliki -  ,  -   ,    
    9.37 +
    9.38 +    compsub -     
    9.39 +    """
    9.40 +            
    9.41 +
    9.42 +        
    9.43 +
    9.44 +
    9.45 +
    9.46 +
    9.47 +    
    9.48 +    def __init__ (self, graf, cost = None, limit_count=0, min_size=0, timeout=10):
    9.49 +
    9.50 +        """
    9.51 +          
    9.52 +
    9.53 +        graf -  .
    9.54 +             graf[1][2] == 1,  1   2
    9.55 +             graf[1][2] == 0,  1    2
    9.56 +
    9.57 +            graf[N][N] = 1   N
    9.58 +
    9.59 +        cost -   graf ()
    9.60 +                .
    9.61 +              ,     
    9.62 +              fast_algorithm    
    9.63 +            
    9.64 +
    9.65 +        limit_count -   ,  
    9.66 +              0,    
    9.67 +
    9.68 +        min_size - min size of returning klika
    9.69 +
    9.70 +        timeout - time in sec. for BRON-KERBOSH algorithm
    9.71 +            
    9.72 +        """
    9.73 +
    9.74 +        
    9.75 +
    9.76 +        self.graf = graf
    9.77 +        self.cost = cost
    9.78 +
    9.79 +        
    9.80 +        self.kliki = []
    9.81 +
    9.82 +        self.timeout = timeout
    9.83 +
    9.84 +
    9.85 +
    9.86 +        connections = {} # index - atom, value - count of connections
    9.87 +
    9.88 +        for atom in self.graf.keys():
    9.89 +            connections[atom] = self.graf[atom].values().count(1)
    9.90 +
    9.91 +
    9.92 +
    9.93 +
    9.94 +
    9.95 +        # delete atoms which have not enough number of connections
    9.96 +        deleted = 1
    9.97 +
    9.98 +        while deleted:
    9.99 +
   9.100 +            deleted = 0
   9.101 +            
   9.102 +            for atom, c in connections.items():
   9.103 +                
   9.104 +                if c < min_size:
   9.105 +                    
   9.106 +                    del connections[atom]
   9.107 +                    
   9.108 +                    for atom1, connect in graf[atom].items():
   9.109 +                        if connect == 1 and connections.has_key(atom1):
   9.110 +                            connections[atom1] -= 1
   9.111 +                            deleted = 1
   9.112 +
   9.113 +                
   9.114 +                        
   9.115 +        
   9.116 +
   9.117 +        bank_l = {}
   9.118 +        
   9.119 +        for atom, c in connections.items():
   9.120 +            
   9.121 +            if not bank_l.has_key(c):
   9.122 +                bank_l[c] = []
   9.123 +                
   9.124 +            bank_l[c].append(atom)
   9.125 +
   9.126 +
   9.127 +        keys = []            
   9.128 +        
   9.129 +        if len(bank_l.keys()):
   9.130 +            for c in xrange(min(bank_l.keys()), max(bank_l.keys())+1):
   9.131 +                if bank_l.has_key(c):
   9.132 +                    keys.extend(bank_l[c])
   9.133 +            
   9.134 +            
   9.135 +
   9.136 +
   9.137 +        # RUN BRON-KERBOSH
   9.138 +
   9.139 +        if self.timeout != 0:
   9.140 +
   9.141 +            self.bron_kerbosh(keys[:])
   9.142 +
   9.143 +        if len(self.kliki) == 0:
   9.144 +            self.fast_algorithm(keys[:]) # run fast algorithm
   9.145 +
   9.146 +
   9.147 +        
   9.148 +
   9.149 +
   9.150 +        #         
   9.151 +
   9.152 +
   9.153 +
   9.154 +
   9.155 +
   9.156 +##        max_l=0                  #  
   9.157 +##        min_l=len(self.kliki[0]) #  
   9.158 +
   9.159 +        bank_l = {}
   9.160 +        
   9.161 +        for klika in self.kliki:
   9.162 +            klika.sort()
   9.163 +            l = len(klika) #   
   9.164 +
   9.165 +            if l >= min_size:
   9.166 +##                max_l = max(max_l,len(klika))
   9.167 +##                min_l = min(min_l,len(klika))
   9.168 +
   9.169 +                if not bank_l.has_key(l):
   9.170 +                    bank_l[l] = []
   9.171 +
   9.172 +                bank_l[l].append(klika)
   9.173 +
   9.174 +
   9.175 +
   9.176 +        kliki=[]
   9.177 +
   9.178 +        #print self.cost
   9.179 +        
   9.180 +        if len(bank_l.keys()):
   9.181 +            
   9.182 +            r = range(min(bank_l.keys()), max(bank_l.keys())+1)
   9.183 +            r.reverse()
   9.184 +            
   9.185 +            for l in r:
   9.186 +                if (bank_l.has_key(l)):
   9.187 +
   9.188 +                    k = bank_l[l] #    l
   9.189 +
   9.190 +
   9.191 +                    if self.cost:
   9.192 +
   9.193 +    ##                    print l
   9.194 +
   9.195 +                        #       cost
   9.196 +
   9.197 +                       
   9.198 +
   9.199 +                        costs = []
   9.200 +
   9.201 +                        for klika in k:
   9.202 +
   9.203 +                            c = 0
   9.204 +
   9.205 +                            for i in klika:
   9.206 +                                
   9.207 +                                if not self.cost.has_key(i):
   9.208 +                                    continue
   9.209 +
   9.210 +                                for j in klika:
   9.211 +
   9.212 +                                    if j == i:
   9.213 +                                        break
   9.214 +
   9.215 +                                    
   9.216 +                                    if not self.cost[i].has_key(j):
   9.217 +                                        continue
   9.218 +
   9.219 +                                    c += self.cost[i][j]
   9.220 +
   9.221 +                            costs.append(c)
   9.222 +
   9.223 +                        costs1 = costs[:]
   9.224 +
   9.225 +                        costs1.sort(reverse=1)
   9.226 +
   9.227 +                        k1 = []
   9.228 +
   9.229 +                        for c in costs1:
   9.230 +
   9.231 +                            n = costs.index(c)
   9.232 +
   9.233 +                            k1.append(k[n][:])
   9.234 +
   9.235 +                            del k[n]
   9.236 +                            del costs[n]
   9.237 +
   9.238 +                        k = k1
   9.239 +                    
   9.240 +                    kliki.extend(k)
   9.241 +                
   9.242 +##        kliki.reverse()
   9.243 +
   9.244 +        if limit_count:
   9.245 +            if len(kliki) > limit_count: #     
   9.246 +                kliki = kliki[:limit_count]
   9.247 +            
   9.248 +
   9.249 +        self.kliki = kliki[:]
   9.250 +
   9.251 +
   9.252 +
   9.253 +
   9.254 +
   9.255 +        
   9.256 +            
   9.257 +
   9.258 +    
   9.259 +
   9.260 +    def bron_kerbosh (self, keys):
   9.261 +
   9.262 +        """
   9.263 +         -    
   9.264 +        http://ru.wikipedia.org/wiki/___
   9.265 +
   9.266 +        compsub -   
   9.267 +        candidates -     
   9.268 +        used -      
   9.269 +        """
   9.270 +
   9.271 +        depth = 0 #  ""
   9.272 +        list_candidates = [keys] #   candidates  ""
   9.273 +        list_used = [[]] #  used  ""
   9.274 +
   9.275 +        compsub = [] #  compsub
   9.276 +
   9.277 +
   9.278 +        print 'Bron and Kerbosh algorithm started'
   9.279 +        
   9.280 +        start_time = time.time()
   9.281 +    
   9.282 +        # ...
   9.283 +        while 1:
   9.284 +
   9.285 +            if depth == -1:
   9.286 +                break # Ѩ!   () 
   9.287 +
   9.288 +
   9.289 +
   9.290 +            
   9.291 +
   9.292 +            #  candidates  used  
   9.293 +
   9.294 +            #print depth
   9.295 +            
   9.296 +            candidates = list_candidates[depth][:]
   9.297 +            used = list_used[depth][:]          
   9.298 +
   9.299 +
   9.300 +
   9.301 +
   9.302 +            #  candidates  
   9.303 +            if len(candidates)==0:
   9.304 +                depth -= 1
   9.305 +
   9.306 +                if compsub:
   9.307 +                    compsub.pop()                
   9.308 +                continue
   9.309 +
   9.310 +                       
   9.311 +
   9.312 +
   9.313 +            
   9.314 +            
   9.315 +            #  used   ,      candidates
   9.316 +            # (  used      1  candidates)
   9.317 +
   9.318 +            used_candidates = 0
   9.319 +        
   9.320 +            for used1 in used:
   9.321 +                for candidates1 in candidates:
   9.322 +                    if self.graf[used1][candidates1] == 0:
   9.323 +                        break
   9.324 +                else:
   9.325 +                    used_candidates = 1             
   9.326 +
   9.327 +            if used_candidates:
   9.328 +                depth -= 1
   9.329 +
   9.330 +                if compsub:
   9.331 +                    compsub.pop()
   9.332 +                continue
   9.333 +                
   9.334 +       
   9.335 +
   9.336 +
   9.337 +
   9.338 +
   9.339 +
   9.340 +            #   v  candidates     compsub
   9.341 +            v = candidates[0]
   9.342 +            compsub.append(v)
   9.343 +
   9.344 +
   9.345 +
   9.346 +
   9.347 +            
   9.348 +            #  new_candidates  new_used,   candidates  used ,    v
   9.349 +            # ( ,     v)
   9.350 +            new_candidates = []
   9.351 +            for candidates1 in candidates:
   9.352 +                if self.graf[candidates1][v] == 1 and candidates1 != v:
   9.353 +                    new_candidates.append(candidates1)
   9.354 +
   9.355 +                                                            
   9.356 +            new_used = []
   9.357 +            for used1 in used:
   9.358 +                if self.graf[used1][v] == 1 and used1 != v:
   9.359 +                    new_used.append(used1)
   9.360 +
   9.361 +
   9.362 +
   9.363 +
   9.364 +            #  v  candidates    used                   
   9.365 +            del list_candidates[depth][0]
   9.366 +            list_used[depth].append(v)
   9.367 +
   9.368 +
   9.369 +            #  new_candidates  new_used 
   9.370 +            if len(new_candidates) == 0 and len(new_used) == 0:
   9.371 +                # compsub  
   9.372 +                self.kliki.append(compsub[:])
   9.373 +                
   9.374 +            else:
   9.375 +                #    bron_kerbosh(new_candidates, new_used)
   9.376 +
   9.377 +                depth += 1
   9.378 +                
   9.379 +
   9.380 +                # TIMEOUT check start
   9.381 +                if self.timeout != -1:
   9.382 +                    
   9.383 +                    if time.time() - start_time > self.timeout:
   9.384 +
   9.385 +                        self.kliki = []
   9.386 +                        return
   9.387 +                # TIMEOUT check end
   9.388 +
   9.389 +                    
   9.390 +                    
   9.391 +                
   9.392 +                if depth >= len(list_candidates):
   9.393 +                    list_candidates.append([])
   9.394 +                    list_used.append([])
   9.395 +
   9.396 +                
   9.397 +                list_candidates[depth] = new_candidates[:]
   9.398 +                list_used[depth] = new_used[:]
   9.399 +                
   9.400 +                continue
   9.401 +
   9.402 +
   9.403 +            #  v  compsub
   9.404 +            if compsub:
   9.405 +                compsub.pop()
   9.406 +
   9.407 +
   9.408 +
   9.409 +
   9.410 +
   9.411 +
   9.412 +
   9.413 +
   9.414 +
   9.415 +
   9.416 +    def fast_algorithm (self, keys):
   9.417 +
   9.418 +        """
   9.419 +        Fast algorithm
   9.420 +        """
   9.421 +
   9.422 +
   9.423 +        self.kliki = []
   9.424 +
   9.425 +        print 'Fast algorithm started'
   9.426 +
   9.427 +
   9.428 +
   9.429 +        while 1:
   9.430 +            # try find new klika
   9.431 +
   9.432 +
   9.433 +            # exclude previous klika atoms
   9.434 +            excluded = {}
   9.435 +
   9.436 +            for klika in self.kliki:
   9.437 +
   9.438 +                for i in klika:
   9.439 +
   9.440 +                    excluded[i] = 1
   9.441 +
   9.442 +            keys1 = []
   9.443 +
   9.444 +            for i in keys:
   9.445 +
   9.446 +                if not excluded.has_key(i):
   9.447 +                    keys1.append(i)
   9.448 +                
   9.449 +            if len(keys1) == 0:
   9.450 +                break
   9.451 +
   9.452 +            while 1:
   9.453 +
   9.454 +                # exclude some atoms
   9.455 +
   9.456 +
   9.457 +                connections = {} # index - atom, value -  connections value
   9.458 +
   9.459 +                for i in keys1:
   9.460 +                    
   9.461 +                    connections[i] = 0
   9.462 +                    
   9.463 +                    for j in keys1:
   9.464 +
   9.465 +                        if i != j and self.graf[i][j]:
   9.466 +                            connections[i] += 1
   9.467 +
   9.468 +
   9.469 +                if max(connections.values()) == min(connections.values()):
   9.470 +                    # all atoms are equal
   9.471 +                    break
   9.472 +                
   9.473 +                                                    
   9.474 +                exclude_connect = min(connections.values()) # excluded atoms connections
   9.475 +
   9.476 +
   9.477 +                if self.cost:
   9.478 +
   9.479 +
   9.480 +                    cost_sum = {} # index - atom, value - cost sum
   9.481 +
   9.482 +                    for i in keys1:
   9.483 +
   9.484 +                        cost_sum[i] = 0
   9.485 +                        
   9.486 +                        if connections[i] == exclude_connect:
   9.487 +
   9.488 +                            for j in keys1:
   9.489 +
   9.490 +                                if i != j and self.graf[i][j]:
   9.491 +
   9.492 +                                    cost_sum[i] += self.cost[i][j]
   9.493 +
   9.494 +                    exclude_cost = min(cost_sum.values()) # excluded atoms cost sum
   9.495 +
   9.496 +
   9.497 +
   9.498 +                    keys2 = []
   9.499 +
   9.500 +                    for i in keys1:
   9.501 +                        
   9.502 +                        if connections[i] == exclude_connect:
   9.503 +
   9.504 +                            if cost_sum[i] == exclude_cost:
   9.505 +
   9.506 +                                continue
   9.507 +                        
   9.508 +                        keys2.append(i)
   9.509 +
   9.510 +                    keys1 = clon(keys2)
   9.511 +
   9.512 +                else:
   9.513 +
   9.514 +                    keys2 = []
   9.515 +
   9.516 +                    for i in keys1:
   9.517 +                        
   9.518 +                        if connections[i] == exclude_connect:
   9.519 +
   9.520 +                            continue
   9.521 +                        
   9.522 +                        keys2.append(i)
   9.523 +
   9.524 +                    keys1 = clon(keys2)
   9.525 +
   9.526 +
   9.527 +
   9.528 +            # try add other atoms
   9.529 +
   9.530 +
   9.531 +            while 1:
   9.532 +
   9.533 +
   9.534 +                for i in keys:
   9.535 +
   9.536 +                    if i in keys1:
   9.537 +                        continue
   9.538 +
   9.539 +
   9.540 +                    for j in keys1:
   9.541 +
   9.542 +
   9.543 +                        if not self.graf[i][j]:
   9.544 +                            break
   9.545 +
   9.546 +                    else:
   9.547 +                        # add atom i
   9.548 +                        keys1.append(i)
   9.549 +
   9.550 +
   9.551 +                        break
   9.552 +                        
   9.553 +                    
   9.554 +                else:
   9.555 +                    # no new atoms
   9.556 +                    break
   9.557 +                    
   9.558 +            
   9.559 +
   9.560 +            # keys1 is klika
   9.561 +
   9.562 +            self.kliki.append(keys1[:])
   9.563 +
   9.564 +            
   9.565 +
   9.566 +            
   9.567 +                
   9.568 +                
   9.569 +
   9.570 +        
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/blocks3d/clon.py	Fri Sep 17 21:52:33 2010 +0400
    10.3 @@ -0,0 +1,38 @@
    10.4 +# -*- coding: cp1251 -*-
    10.5 +
    10.6 +####################################
    10.7 +#   Create new clon of list or dict
    10.8 +####################################
    10.9 +
   10.10 +
   10.11 +def clon (obj):
   10.12 +    t = type(obj)
   10.13 +
   10.14 +
   10.15 +    if t == list or t == tuple:
   10.16 +        
   10.17 +        r = []
   10.18 +        
   10.19 +        for i in obj:
   10.20 +            r.append(clon(i))
   10.21 +
   10.22 +        if t == tuple:
   10.23 +            r = tuple(r)
   10.24 +
   10.25 +        return r
   10.26 +
   10.27 +
   10.28 +    if t == dict:
   10.29 +        
   10.30 +        r = {}
   10.31 +        
   10.32 +        for key, value in obj.items():
   10.33 +            r[key] = clon(value)
   10.34 +
   10.35 +
   10.36 +        return r
   10.37 +
   10.38 +    return obj
   10.39 +
   10.40 +            
   10.41 +    
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/blocks3d/html.htm	Fri Sep 17 21:52:33 2010 +0400
    11.3 @@ -0,0 +1,1590 @@
    11.4 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    11.5 +<html>
    11.6 +<head>
    11.7 +
    11.8 +<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    11.9 +
   11.10 +<title>Blocks</title>
   11.11 +
   11.12 +<style type="text/css"> 
   11.13 +<!--
   11.14 +
   11.15 +
   11.16 +
   11.17 +
   11.18 +
   11.19 +body
   11.20 +{
   11.21 +    font: 14px 'Arial', Tahoma, Arial;
   11.22 +    cursor: default;
   11.23 +}
   11.24 +A
   11.25 +{ 
   11.26 +    font: 14px 'Arial', Tahoma, Arial;
   11.27 +    color: blue;
   11.28 +    text-decoration: none;
   11.29 +    cursor: pointer;
   11.30 +}
   11.31 +A:hover
   11.32 +{
   11.33 +    color: black;
   11.34 +    font-family: 'Arial' , Tahoma, Arial;
   11.35 +    text-decoration: underline;
   11.36 +}
   11.37 +
   11.38 +h1
   11.39 +{
   11.40 +    font: bold 19px 'Arial' , Tahoma, Arial;
   11.41 +    color: #004080;
   11.42 +}
   11.43 +
   11.44 +h2
   11.45 +{
   11.46 +    font: bold 17px 'Arial' , Tahoma, Arial;
   11.47 +    color: #784080;
   11.48 +}
   11.49 +
   11.50 +h3
   11.51 +{
   11.52 +    font: bold 15px 'Arial' , Tahoma, Arial;
   11.53 +    color: #000000;
   11.54 +}
   11.55 +
   11.56 +TD
   11.57 +{
   11.58 +    font: 14px 'Arial', Tahoma, Arial;
   11.59 +}
   11.60 +
   11.61 +
   11.62 +table
   11.63 +{
   11.64 +    border-color: black;
   11.65 +    border-Collapse: collapse;
   11.66 +    border-width: 1px;
   11.67 +}
   11.68 +
   11.69 +
   11.70 +
   11.71 +img
   11.72 +{
   11.73 +    border:none;
   11.74 +}
   11.75 +
   11.76 +
   11.77 +
   11.78 +
   11.79 +
   11.80 +
   11.81 +
   11.82 +#mainpanel
   11.83 +{
   11.84 +    overflow: auto;
   11.85 +}
   11.86 +
   11.87 +#h1_header
   11.88 +{
   11.89 +    overflow: hidden;
   11.90 +}
   11.91 +
   11.92 +
   11.93 +#legend, #IDs
   11.94 +{
   11.95 +    overflow: hidden;
   11.96 +}
   11.97 +
   11.98 +#alignment
   11.99 +{
  11.100 +    overflow: auto;
  11.101 +}
  11.102 +
  11.103 +
  11.104 +
  11.105 +
  11.106 +-->
  11.107 +</style>
  11.108 +
  11.109 +
  11.110 +
  11.111 +</head>
  11.112 +
  11.113 + 
  11.114 +<body onload=blocks_init()>
  11.115 +
  11.116 +
  11.117 +    
  11.118 +<table width=100% cellpadding=0 cellspacing=0>
  11.119 +    
  11.120 +
  11.121 +
  11.122 +    <tr align=left valign=top>
  11.123 +        
  11.124 +        <td colspan=2>
  11.125 +            <div id="h1_header"><h1>Reliable blocks finding</h1></div>
  11.126 +        </td>
  11.127 +
  11.128 +
  11.129 +    
  11.130 +    <tr align=left valign=top>
  11.131 +        
  11.132 +        <td colspan=2>
  11.133 +            <div id="mainpanel"> Enable Javascript!</div>
  11.134 +        </td>
  11.135 +
  11.136 +    <tr align=left valign=top>
  11.137 +        
  11.138 +        <td>
  11.139 +        </td>
  11.140 +        
  11.141 +        <td>
  11.142 +            <div id="legend"></div>
  11.143 +        </td>
  11.144 +        
  11.145 +    <tr align=left valign=top>
  11.146 +        
  11.147 +        <td>
  11.148 +            <div id="IDs"></div>
  11.149 +        </td>
  11.150 +        
  11.151 +        <td>
  11.152 +            <div id="alignment" onscroll="alignment_onscroll()"></div>
  11.153 +        </td>
  11.154 +    
  11.155 +</table>
  11.156 +
  11.157 +
  11.158 +<script type="text/javascript">
  11.159 +//<!--
  11.160 +
  11.161 +
  11.162 +
  11.163 +
  11.164 +//////////////////////////
  11.165 +// скопировать массив :)
  11.166 +//////////////////////////
  11.167 +
  11.168 +
  11.169 +function array_clon(obj)
  11.170 +{
  11.171 +    if (typeof(obj) == 'object')
  11.172 +    {
  11.173 +        
  11.174 +        if (typeof(obj.length) === 'undefined')
  11.175 +        {
  11.176 +            var obj1 = {}; // хэш
  11.177 +        }
  11.178 +        else
  11.179 +        {
  11.180 +            var obj1 = []; // массив
  11.181 +        }
  11.182 +        
  11.183 +        
  11.184 +        for (var i in obj)
  11.185 +        {
  11.186 +            obj1[i] = array_clon(obj[i]);
  11.187 +        }
  11.188 +        
  11.189 +        return obj1;
  11.190 +    }  
  11.191 +    else
  11.192 +    {
  11.193 +        return obj;
  11.194 +    }
  11.195 +}
  11.196 +
  11.197 +
  11.198 +
  11.199 +
  11.200 +
  11.201 +/////////////////////////////////////
  11.202 +// взять элемент массива без ошибок
  11.203 +/////////////////////////////////////
  11.204 +
  11.205 +function ae(obj, indexes)
  11.206 +{
  11.207 +    if (typeof(indexes) != 'object')
  11.208 +    {
  11.209 +        indexes = [indexes];
  11.210 +    }
  11.211 +    
  11.212 +    var index;
  11.213 +    var r = obj;
  11.214 +    
  11.215 +    var i;
  11.216 +    
  11.217 +    for (i = 0; i < indexes.length; i++)
  11.218 +    {
  11.219 +        try
  11.220 +        {
  11.221 +            index = indexes[i];
  11.222 +            r = r[index];
  11.223 +        }
  11.224 +        catch(e)
  11.225 +        {
  11.226 +            return 0;
  11.227 +        }
  11.228 +    
  11.229 +    }
  11.230 +    
  11.231 +    if (!r)
  11.232 +    {
  11.233 +        return 0;
  11.234 +    }
  11.235 +    
  11.236 +    return r;
  11.237 +}
  11.238 +
  11.239 +
  11.240 +
  11.241 +
  11.242 +
  11.243 +
  11.244 +
  11.245 +
  11.246 +
  11.247 +///////////////////
  11.248 +// поиск в массиве 
  11.249 +///////////////////
  11.250 +// где, что
  11.251 +function indexOf (input, elt /*, from*/)
  11.252 +{
  11.253 +    
  11.254 +    var r;
  11.255 +    
  11.256 +    try
  11.257 +    {
  11.258 +        return input.indexOf(elt /*, from*/);
  11.259 +    }
  11.260 +    catch(e)
  11.261 +    {
  11.262 +        var len = input.length >>> 0;
  11.263 +
  11.264 +        var from = Number(arguments[1]) || 0;
  11.265 +        from = (from < 0)
  11.266 +             ? Math.ceil(from)
  11.267 +             : Math.floor(from);
  11.268 +        if (from < 0)
  11.269 +          from += len;
  11.270 +
  11.271 +        for (; from < len; from++)
  11.272 +        {
  11.273 +          if (from in input &&
  11.274 +              input[from] === elt)
  11.275 +            return from;
  11.276 +        }
  11.277 +        return -1;
  11.278 +    }
  11.279 +}
  11.280 +
  11.281 +//  
  11.282 +//  
  11.283 +//  if (!Array.prototype.indexOf)
  11.284 +//  {
  11.285 +//    Array.prototype.indexOf = function(elt /*, from*/)
  11.286 +//    {
  11.287 +//      var len = this.length >>> 0;
  11.288 +//  
  11.289 +//      var from = Number(arguments[1]) || 0;
  11.290 +//      from = (from < 0)
  11.291 +//           ? Math.ceil(from)
  11.292 +//           : Math.floor(from);
  11.293 +//      if (from < 0)
  11.294 +//        from += len;
  11.295 +//  
  11.296 +//      for (; from < len; from++)
  11.297 +//      {
  11.298 +//        if (from in this &&
  11.299 +//            this[from] === elt)
  11.300 +//          return from;
  11.301 +//      }
  11.302 +//      return -1;
  11.303 +//    };
  11.304 +//  }
  11.305 +//  
  11.306 +//  
  11.307 +
  11.308 +
  11.309 +
  11.310 +
  11.311 +
  11.312 +
  11.313 +function sortNumber(a, b)
  11.314 +{
  11.315 +    return a - b;
  11.316 +}
  11.317 +
  11.318 +
  11.319 +// возвращает список ключей словаря
  11.320 +function array_keys(arr)
  11.321 +{
  11.322 +    var keys = [];
  11.323 +    
  11.324 +    var key;
  11.325 +    
  11.326 +    for (key in arr)
  11.327 +    {
  11.328 +        keys.push(key);
  11.329 +    }
  11.330 +    
  11.331 +    return keys;
  11.332 +}
  11.333 +
  11.334 +
  11.335 +
  11.336 +
  11.337 +// возвращает список значений словаря
  11.338 +function array_values(arr)
  11.339 +{
  11.340 +    var values = [];
  11.341 +    
  11.342 +    var key;
  11.343 +    
  11.344 +    for (key in arr)
  11.345 +    {
  11.346 +        values.push(arr[key]);
  11.347 +    }
  11.348 +    
  11.349 +    return values;
  11.350 +}
  11.351 +
  11.352 +
  11.353 +
  11.354 +
  11.355 +
  11.356 +
  11.357 +/*
  11.358 +    http://www.JSON.org/json2.js
  11.359 +    2009-06-29
  11.360 +
  11.361 +    Public Domain.
  11.362 +
  11.363 +    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
  11.364 +
  11.365 +    See http://www.JSON.org/js.html
  11.366 +
  11.367 +    This file creates a global JSON object containing two methods: stringify
  11.368 +    and parse.
  11.369 +
  11.370 +        JSON.stringify(value, replacer, space)
  11.371 +            value       any JavaScript value, usually an object or array.
  11.372 +
  11.373 +            replacer    an optional parameter that determines how object
  11.374 +                        values are stringified for objects. It can be a
  11.375 +                        function or an array of strings.
  11.376 +
  11.377 +            space       an optional parameter that specifies the indentation
  11.378 +                        of nested structures. If it is omitted, the text will
  11.379 +                        be packed without extra whitespace. If it is a number,
  11.380 +                        it will specify the number of spaces to indent at each
  11.381 +                        level. If it is a string (such as '\t' or '&nbsp;'),
  11.382 +                        it contains the characters used to indent at each level.
  11.383 +
  11.384 +            This method produces a JSON text from a JavaScript value.
  11.385 +
  11.386 +            When an object value is found, if the object contains a toJSON
  11.387 +            method, its toJSON method will be called and the result will be
  11.388 +            stringified. A toJSON method does not serialize: it returns the
  11.389 +            value represented by the name/value pair that should be serialized,
  11.390 +            or undefined if nothing should be serialized. The toJSON method
  11.391 +            will be passed the key associated with the value, and this will be
  11.392 +            bound to the object holding the key.
  11.393 +
  11.394 +            For example, this would serialize Dates as ISO strings.
  11.395 +
  11.396 +                Date.prototype.toJSON = function (key) {
  11.397 +                    function f(n) {
  11.398 +                        // Format integers to have at least two digits.
  11.399 +                        return n < 10 ? '0' + n : n;
  11.400 +                    }
  11.401 +
  11.402 +                    return this.getUTCFullYear()   + '-' +
  11.403 +                         f(this.getUTCMonth() + 1) + '-' +
  11.404 +                         f(this.getUTCDate())      + 'T' +
  11.405 +                         f(this.getUTCHours())     + ':' +
  11.406 +                         f(this.getUTCMinutes())   + ':' +
  11.407 +                         f(this.getUTCSeconds())   + 'Z';
  11.408 +                };
  11.409 +
  11.410 +            You can provide an optional replacer method. It will be passed the
  11.411 +            key and value of each member, with this bound to the containing
  11.412 +            object. The value that is returned from your method will be
  11.413 +            serialized. If your method returns undefined, then the member will
  11.414 +            be excluded from the serialization.
  11.415 +
  11.416 +            If the replacer parameter is an array of strings, then it will be
  11.417 +            used to select the members to be serialized. It filters the results
  11.418 +            such that only members with keys listed in the replacer array are
  11.419 +            stringified.
  11.420 +
  11.421 +            Values that do not have JSON representations, such as undefined or
  11.422 +            functions, will not be serialized. Such values in objects will be
  11.423 +            dropped; in arrays they will be replaced with null. You can use
  11.424 +            a replacer function to replace those with JSON values.
  11.425 +            JSON.stringify(undefined) returns undefined.
  11.426 +
  11.427 +            The optional space parameter produces a stringification of the
  11.428 +            value that is filled with line breaks and indentation to make it
  11.429 +            easier to read.
  11.430 +
  11.431 +            If the space parameter is a non-empty string, then that string will
  11.432 +            be used for indentation. If the space parameter is a number, then
  11.433 +            the indentation will be that many spaces.
  11.434 +
  11.435 +            Example:
  11.436 +
  11.437 +            text = JSON.stringify(['e', {pluribus: 'unum'}]);
  11.438 +            // text is '["e",{"pluribus":"unum"}]'
  11.439 +
  11.440 +
  11.441 +            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
  11.442 +            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
  11.443 +
  11.444 +            text = JSON.stringify([new Date()], function (key, value) {
  11.445 +                return this[key] instanceof Date ?
  11.446 +                    'Date(' + this[key] + ')' : value;
  11.447 +            });
  11.448 +            // text is '["Date(---current time---)"]'
  11.449 +
  11.450 +
  11.451 +        JSON.parse(text, reviver)
  11.452 +            This method parses a JSON text to produce an object or array.
  11.453 +            It can throw a SyntaxError exception.
  11.454 +
  11.455 +            The optional reviver parameter is a function that can filter and
  11.456 +            transform the results. It receives each of the keys and values,
  11.457 +            and its return value is used instead of the original value.
  11.458 +            If it returns what it received, then the structure is not modified.
  11.459 +            If it returns undefined then the member is deleted.
  11.460 +
  11.461 +            Example:
  11.462 +
  11.463 +            // Parse the text. Values that look like ISO date strings will
  11.464 +            // be converted to Date objects.
  11.465 +
  11.466 +            myData = JSON.parse(text, function (key, value) {
  11.467 +                var a;
  11.468 +                if (typeof value === 'string') {
  11.469 +                    a =
  11.470 +/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
  11.471 +                    if (a) {
  11.472 +                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
  11.473 +                            +a[5], +a[6]));
  11.474 +                    }
  11.475 +                }
  11.476 +                return value;
  11.477 +            });
  11.478 +
  11.479 +            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
  11.480 +                var d;
  11.481 +                if (typeof value === 'string' &&
  11.482 +                        value.slice(0, 5) === 'Date(' &&
  11.483 +                        value.slice(-1) === ')') {
  11.484 +                    d = new Date(value.slice(5, -1));
  11.485 +                    if (d) {
  11.486 +                        return d;
  11.487 +                    }
  11.488 +                }
  11.489 +                return value;
  11.490 +            });
  11.491 +
  11.492 +
  11.493 +    This is a reference implementation. You are free to copy, modify, or
  11.494 +    redistribute.
  11.495 +
  11.496 +    This code should be minified before deployment.
  11.497 +    See http://javascript.crockford.com/jsmin.html
  11.498 +
  11.499 +    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
  11.500 +    NOT CONTROL.
  11.501 +*/
  11.502 +
  11.503 +/*jslint evil: true */
  11.504 +
  11.505 +/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
  11.506 +    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
  11.507 +    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
  11.508 +    lastIndex, length, parse, prototype, push, replace, slice, stringify,
  11.509 +    test, toJSON, toString, valueOf
  11.510 +*/
  11.511 +
  11.512 +// Create a JSON object only if one does not already exist. We create the
  11.513 +// methods in a closure to avoid creating global variables.
  11.514 +
  11.515 +var JSON = JSON || {};
  11.516 +
  11.517 +(function () {
  11.518 +
  11.519 +    function f(n) {
  11.520 +        // Format integers to have at least two digits.
  11.521 +        return n < 10 ? '0' + n : n;
  11.522 +    }
  11.523 +
  11.524 +    if (typeof Date.prototype.toJSON !== 'function') {
  11.525 +
  11.526 +        Date.prototype.toJSON = function (key) {
  11.527 +
  11.528 +            return isFinite(this.valueOf()) ?
  11.529 +                   this.getUTCFullYear()   + '-' +
  11.530 +                 f(this.getUTCMonth() + 1) + '-' +
  11.531 +                 f(this.getUTCDate())      + 'T' +
  11.532 +                 f(this.getUTCHours())     + ':' +
  11.533 +                 f(this.getUTCMinutes())   + ':' +
  11.534 +                 f(this.getUTCSeconds())   + 'Z' : null;
  11.535 +        };
  11.536 +
  11.537 +        String.prototype.toJSON =
  11.538 +        Number.prototype.toJSON =
  11.539 +        Boolean.prototype.toJSON = function (key) {
  11.540 +            return this.valueOf();
  11.541 +        };
  11.542 +    }
  11.543 +
  11.544 +    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
  11.545 +        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
  11.546 +        gap,
  11.547 +        indent,
  11.548 +        meta = {    // table of character substitutions
  11.549 +            '\b': '\\b',
  11.550 +            '\t': '\\t',
  11.551 +            '\n': '\\n',
  11.552 +            '\f': '\\f',
  11.553 +            '\r': '\\r',
  11.554 +            '"' : '\\"',
  11.555 +            '\\': '\\\\'
  11.556 +        },
  11.557 +        rep;
  11.558 +
  11.559 +
  11.560 +    function quote(string) {
  11.561 +
  11.562 +// If the string contains no control characters, no quote characters, and no
  11.563 +// backslash characters, then we can safely slap some quotes around it.
  11.564 +// Otherwise we must also replace the offending characters with safe escape
  11.565 +// sequences.
  11.566 +
  11.567 +        escapable.lastIndex = 0;
  11.568 +        return escapable.test(string) ?
  11.569 +            '"' + string.replace(escapable, function (a) {
  11.570 +                var c = meta[a];
  11.571 +                return typeof c === 'string' ? c :
  11.572 +                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
  11.573 +            }) + '"' :
  11.574 +            '"' + string + '"';
  11.575 +    }
  11.576 +
  11.577 +
  11.578 +    function str(key, holder) {
  11.579 +
  11.580 +// Produce a string from holder[key].
  11.581 +
  11.582 +        var i,          // The loop counter.
  11.583 +            k,          // The member key.
  11.584 +            v,          // The member value.
  11.585 +            length,
  11.586 +            mind = gap,
  11.587 +            partial,
  11.588 +            value = holder[key];
  11.589 +
  11.590 +// If the value has a toJSON method, call it to obtain a replacement value.
  11.591 +
  11.592 +        if (value && typeof value === 'object' &&
  11.593 +                typeof value.toJSON === 'function') {
  11.594 +            value = value.toJSON(key);
  11.595 +        }
  11.596 +
  11.597 +// If we were called with a replacer function, then call the replacer to
  11.598 +// obtain a replacement value.
  11.599 +
  11.600 +        if (typeof rep === 'function') {
  11.601 +            value = rep.call(holder, key, value);
  11.602 +        }
  11.603 +
  11.604 +// What happens next depends on the value's type.
  11.605 +
  11.606 +        switch (typeof value) {
  11.607 +        case 'string':
  11.608 +            return quote(value);
  11.609 +
  11.610 +        case 'number':
  11.611 +
  11.612 +// JSON numbers must be finite. Encode non-finite numbers as null.
  11.613 +
  11.614 +            return isFinite(value) ? String(value) : 'null';
  11.615 +
  11.616 +        case 'boolean':
  11.617 +        case 'null':
  11.618 +
  11.619 +// If the value is a boolean or null, convert it to a string. Note:
  11.620 +// typeof null does not produce 'null'. The case is included here in
  11.621 +// the remote chance that this gets fixed someday.
  11.622 +
  11.623 +            return String(value);
  11.624 +
  11.625 +// If the type is 'object', we might be dealing with an object or an array or
  11.626 +// null.
  11.627 +
  11.628 +        case 'object':
  11.629 +
  11.630 +// Due to a specification blunder in ECMAScript, typeof null is 'object',
  11.631 +// so watch out for that case.
  11.632 +
  11.633 +            if (!value) {
  11.634 +                return 'null';
  11.635 +            }
  11.636 +
  11.637 +// Make an array to hold the partial results of stringifying this object value.
  11.638 +
  11.639 +            gap += indent;
  11.640 +            partial = [];
  11.641 +
  11.642 +// Is the value an array?
  11.643 +
  11.644 +            if (Object.prototype.toString.apply(value) === '[object Array]') {
  11.645 +
  11.646 +// The value is an array. Stringify every element. Use null as a placeholder
  11.647 +// for non-JSON values.
  11.648 +
  11.649 +                length = value.length;
  11.650 +                for (i = 0; i < length; i += 1) {
  11.651 +                    partial[i] = str(i, value) || 'null';
  11.652 +                }
  11.653 +
  11.654 +// Join all of the elements together, separated with commas, and wrap them in
  11.655 +// brackets.
  11.656 +
  11.657 +                v = partial.length === 0 ? '[]' :
  11.658 +                    gap ? '[\n' + gap +
  11.659 +                            partial.join(',\n' + gap) + '\n' +
  11.660 +                                mind + ']' :
  11.661 +                          '[' + partial.join(',') + ']';
  11.662 +                gap = mind;
  11.663 +                return v;
  11.664 +            }
  11.665 +
  11.666 +// If the replacer is an array, use it to select the members to be stringified.
  11.667 +
  11.668 +            if (rep && typeof rep === 'object') {
  11.669 +                length = rep.length;
  11.670 +                for (i = 0; i < length; i += 1) {
  11.671 +                    k = rep[i];
  11.672 +                    if (typeof k === 'string') {
  11.673 +                        v = str(k, value);
  11.674 +                        if (v) {
  11.675 +                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
  11.676 +                        }
  11.677 +                    }
  11.678 +                }
  11.679 +            } else {
  11.680 +
  11.681 +// Otherwise, iterate through all of the keys in the object.
  11.682 +
  11.683 +                for (k in value) {
  11.684 +                    if (Object.hasOwnProperty.call(value, k)) {
  11.685 +                        v = str(k, value);
  11.686 +                        if (v) {
  11.687 +                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
  11.688 +                        }
  11.689 +                    }
  11.690 +                }
  11.691 +            }
  11.692 +
  11.693 +// Join all of the member texts together, separated with commas,
  11.694 +// and wrap them in braces.
  11.695 +
  11.696 +            v = partial.length === 0 ? '{}' :
  11.697 +                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
  11.698 +                        mind + '}' : '{' + partial.join(',') + '}';
  11.699 +            gap = mind;
  11.700 +            return v;
  11.701 +        }
  11.702 +    }
  11.703 +
  11.704 +// If the JSON object does not yet have a stringify method, give it one.
  11.705 +
  11.706 +    if (typeof JSON.stringify !== 'function') {
  11.707 +        JSON.stringify = function (value, replacer, space) {
  11.708 +
  11.709 +// The stringify method takes a value and an optional replacer, and an optional
  11.710 +// space parameter, and returns a JSON text. The replacer can be a function
  11.711 +// that can replace values, or an array of strings that will select the keys.
  11.712 +// A default replacer method can be provided. Use of the space parameter can
  11.713 +// produce text that is more easily readable.
  11.714 +
  11.715 +            var i;
  11.716 +            gap = '';
  11.717 +            indent = '';
  11.718 +
  11.719 +// If the space parameter is a number, make an indent string containing that
  11.720 +// many spaces.
  11.721 +
  11.722 +            if (typeof space === 'number') {
  11.723 +                for (i = 0; i < space; i += 1) {
  11.724 +                    indent += ' ';
  11.725 +                }
  11.726 +
  11.727 +// If the space parameter is a string, it will be used as the indent string.
  11.728 +
  11.729 +            } else if (typeof space === 'string') {
  11.730 +                indent = space;
  11.731 +            }
  11.732 +
  11.733 +// If there is a replacer, it must be a function or an array.
  11.734 +// Otherwise, throw an error.
  11.735 +
  11.736 +            rep = replacer;
  11.737 +            if (replacer && typeof replacer !== 'function' &&
  11.738 +                    (typeof replacer !== 'object' ||
  11.739 +                     typeof replacer.length !== 'number')) {
  11.740 +                throw new Error('JSON.stringify');
  11.741 +            }
  11.742 +
  11.743 +// Make a fake root object containing our value under the key of ''.
  11.744 +// Return the result of stringifying the value.
  11.745 +
  11.746 +            return str('', {'': value});
  11.747 +        };
  11.748 +    }
  11.749 +
  11.750 +
  11.751 +// If the JSON object does not yet have a parse method, give it one.
  11.752 +
  11.753 +    if (typeof JSON.parse !== 'function') {
  11.754 +        JSON.parse = function (text, reviver) {
  11.755 +
  11.756 +// The parse method takes a text and an optional reviver function, and returns
  11.757 +// a JavaScript value if the text is a valid JSON text.
  11.758 +
  11.759 +            var j;
  11.760 +
  11.761 +            function walk(holder, key) {
  11.762 +
  11.763 +// The walk method is used to recursively walk the resulting structure so
  11.764 +// that modifications can be made.
  11.765 +
  11.766 +                var k, v, value = holder[key];
  11.767 +                if (value && typeof value === 'object') {
  11.768 +                    for (k in value) {
  11.769 +                        if (Object.hasOwnProperty.call(value, k)) {
  11.770 +                            v = walk(value, k);
  11.771 +                            if (v !== undefined) {
  11.772 +                                value[k] = v;
  11.773 +                            } else {
  11.774 +                                delete value[k];
  11.775 +                            }
  11.776 +                        }
  11.777 +                    }
  11.778 +                }
  11.779 +                return reviver.call(holder, key, value);
  11.780 +            }
  11.781 +
  11.782 +
  11.783 +// Parsing happens in four stages. In the first stage, we replace certain
  11.784 +// Unicode characters with escape sequences. JavaScript handles many characters
  11.785 +// incorrectly, either silently deleting them, or treating them as line endings.
  11.786 +
  11.787 +            cx.lastIndex = 0;
  11.788 +            if (cx.test(text)) {
  11.789 +                text = text.replace(cx, function (a) {
  11.790 +                    return '\\u' +
  11.791 +                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
  11.792 +                });
  11.793 +            }
  11.794 +
  11.795 +// In the second stage, we run the text against regular expressions that look
  11.796 +// for non-JSON patterns. We are especially concerned with '()' and 'new'
  11.797 +// because they can cause invocation, and '=' because it can cause mutation.
  11.798 +// But just to be safe, we want to reject all unexpected forms.
  11.799 +
  11.800 +// We split the second stage into 4 regexp operations in order to work around
  11.801 +// crippling inefficiencies in IE's and Safari's regexp engines. First we
  11.802 +// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
  11.803 +// replace all simple value tokens with ']' characters. Third, we delete all
  11.804 +// open brackets that follow a colon or comma or that begin the text. Finally,
  11.805 +// we look to see that the remaining characters are only whitespace or ']' or
  11.806 +// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
  11.807 +
  11.808 +            if (/^[\],:{}\s]*$/.
  11.809 +test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
  11.810 +replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
  11.811 +replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
  11.812 +
  11.813 +// In the third stage we use the eval function to compile the text into a
  11.814 +// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
  11.815 +// in JavaScript: it can begin a block or an object literal. We wrap the text
  11.816 +// in parens to eliminate the ambiguity.
  11.817 +
  11.818 +                j = eval('(' + text + ')');
  11.819 +
  11.820 +// In the optional fourth stage, we recursively walk the new structure, passing
  11.821 +// each name/value pair to a reviver function for possible transformation.
  11.822 +
  11.823 +                return typeof reviver === 'function' ?
  11.824 +                    walk({'': j}, '') : j;
  11.825 +            }
  11.826 +
  11.827 +// If the text is not JSON parseable, then a SyntaxError is thrown.
  11.828 +
  11.829 +            throw new SyntaxError('JSON.parse');
  11.830 +        };
  11.831 +    }
  11.832 +}());
  11.833 +
  11.834 +
  11.835 +
  11.836 +
  11.837 +// JSON
  11.838 +function json(obj7)
  11.839 +{
  11.840 +    if (typeof(obj7) == 'string')
  11.841 +    {
  11.842 +        // раскодируем
  11.843 +        
  11.844 +        return JSON.parse(obj7);
  11.845 +    }
  11.846 +    else
  11.847 +    {
  11.848 +        // кодируем
  11.849 +        return JSON.stringify(obj7);
  11.850 +    }
  11.851 +}
  11.852 +
  11.853 +
  11.854 +
  11.855 +
  11.856 +
  11.857 +
  11.858 +/////////////////////////////////////////
  11.859 +// Функции упрощают общение с mainpanel
  11.860 +/////////////////////////////////////////
  11.861 +
  11.862 +
  11.863 +
  11.864 +
  11.865 +
  11.866 +/////////////////////////////////
  11.867 +// добавить текст в mainpanel
  11.868 +/////////////////////////////////
  11.869 +
  11.870 +function mp_add(str)
  11.871 +{
  11.872 +    $('mainpanel').innerHTML += str;
  11.873 +}
  11.874 +
  11.875 +
  11.876 +
  11.877 +
  11.878 +////////////////////////////////////
  11.879 +// устанавливает текст в mainpanel
  11.880 +////////////////////////////////////
  11.881 +
  11.882 +function mp_set(str)
  11.883 +{
  11.884 +    $('mainpanel').innerHTML = str;
  11.885 +}
  11.886 +
  11.887 +
  11.888 +
  11.889 +
  11.890 +////////////////////////////////////
  11.891 +// пишет текст в status line
  11.892 +////////////////////////////////////
  11.893 +
  11.894 +function sl_set(str)
  11.895 +{
  11.896 +    $('statusline').innerHTML = str;
  11.897 +}
  11.898 +
  11.899 +
  11.900 +
  11.901 +///////////////////////////////////////
  11.902 +// Возвращает document.getElementById
  11.903 +///////////////////////////////////////
  11.904 +
  11.905 +function $(str)
  11.906 +{
  11.907 +    return document.getElementById(str);
  11.908 +}
  11.909 +
  11.910 +
  11.911 +
  11.912 +
  11.913 +///////////////////////
  11.914 +// узнать развер окна
  11.915 +///////////////////////
  11.916 +
  11.917 +function get_ww()
  11.918 +{
  11.919 +    var frameWidth = 800;
  11.920 +    
  11.921 +    if (self.innerWidth)
  11.922 +    {
  11.923 +        frameWidth = self.innerWidth;
  11.924 +    }
  11.925 +    else if (document.documentElement && document.documentElement.clientWidth)
  11.926 +    {
  11.927 +        frameWidth = document.documentElement.clientWidth;
  11.928 +    }
  11.929 +    else if (document.body)
  11.930 +    {
  11.931 +        frameWidth = document.body.clientWidth;
  11.932 +    }
  11.933 +    
  11.934 +    return frameWidth;
  11.935 +}
  11.936 +
  11.937 +
  11.938 +function get_wh()
  11.939 +{
  11.940 +    var frameHeight = 640;
  11.941 +    
  11.942 +    if (self.innerHeight)
  11.943 +    {
  11.944 +        frameHeight = self.innerHeight;
  11.945 +    }
  11.946 +    else if (document.documentElement && document.documentElement.clientHeight)
  11.947 +    {
  11.948 +        frameHeight = document.documentElement.clientHeight;
  11.949 +    }
  11.950 +    else if (document.body)
  11.951 +    {
  11.952 +        frameHeight = document.body.clientHeight;
  11.953 +    }
  11.954 +    
  11.955 +    return frameHeight;
  11.956 +} 
  11.957 +
  11.958 +
  11.959 +
  11.960 +
  11.961 +
  11.962 +// выдает цвет в зависимости от something (это должна быть строка)
  11.963 +function crc32_color(something)
  11.964 +{
  11.965 +    var crc = crc32(something);
  11.966 +    var rgb = []; // [r, g, b] (берутся последние 3 байте подписи)
  11.967 +    
  11.968 +    rgb[0] = crc & 0xFF;
  11.969 +    rgb[1] = (crc >> 8) & 0xFF;
  11.970 +    rgb[2] = (crc >> 16) & 0xFF;
  11.971 +    
  11.972 +    var j;
  11.973 +    
  11.974 +    // подсветлим цвета
  11.975 +    for (j = 0; j < 3; j++)
  11.976 +    {
  11.977 +        if (rgb[j] & 96 == 96)
  11.978 +        {
  11.979 +            // 2 и 3 биты ненулевые
  11.980 +            rgb[j] &= 63; // второй бит 0
  11.981 +        }
  11.982 +        if (rgb[j] & 96 == 0)
  11.983 +        {
  11.984 +            // 2 и 3 биты нулевые
  11.985 +            rgb[j] |= 64; // второй бит 1
  11.986 +        }
  11.987 +        
  11.988 +        
  11.989 +        rgb[j] |= 128; // первый бит 1
  11.990 +    }
  11.991 +    
  11.992 +    for (j = 0; j < 3; j++)
  11.993 +    {
  11.994 +        rgb[j] = dechex(rgb[j]);
  11.995 +        
  11.996 +        if (rgb[j].length == 1)
  11.997 +        {
  11.998 +            rgb[j] = '0' + rgb[j];
  11.999 +        }
 11.1000 +    }
 11.1001 +    
 11.1002 +    return '#' + rgb.join('');
 11.1003 +}
 11.1004 +
 11.1005 +
 11.1006 +
 11.1007 +function crc32 ( str ) 
 11.1008 +{
 11.1009 +    // http://kevin.vanzonneveld.net
 11.1010 +    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
 11.1011 +    // +   improved by: T0bsn
 11.1012 +    // -    depends on: utf8_encode
 11.1013 +    // *     example 1: crc32('Kevin van Zonneveld');
 11.1014 +    // *     returns 1: 1249991249
 11.1015 +
 11.1016 +    //str = this.utf8_encode(str);
 11.1017 +   
 11.1018 +    var table = [0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D];
 11.1019 +
 11.1020 +    var crc = 0;
 11.1021 +    var x = 0;
 11.1022 +    var y = 0;
 11.1023 +
 11.1024 +    crc = crc ^ (-1);
 11.1025 +    for (var i = 0, iTop = str.length; i < iTop; i++) {
 11.1026 +        y = ( crc ^ str.charCodeAt( i ) ) & 0xFF;
 11.1027 +        x = table[y];
 11.1028 +        crc = ( crc >>> 8 ) ^ x;
 11.1029 +    }
 11.1030 +
 11.1031 +    return crc ^ (-1);
 11.1032 +}
 11.1033 +
 11.1034 +
 11.1035 +
 11.1036 +
 11.1037 +function dechex (number) {
 11.1038 +    // http://kevin.vanzonneveld.net
 11.1039 +    // +   original by: Philippe Baumann
 11.1040 +    // +   bugfixed by: Onno Marsman
 11.1041 +    // +   improved by: http://stackoverflow.com/questions/57803/how-to-convert-decimal-to-hex-in-javascript
 11.1042 +    // +   input by: pilus
 11.1043 +    // *     example 1: dechex(10);
 11.1044 +    // *     returns 1: 'a'
 11.1045 +    // *     example 2: dechex(47);
 11.1046 +    // *     returns 2: '2f'
 11.1047 +    // *     example 3: dechex(-1415723993);
 11.1048 +    // *     returns 3: 'ab9dc427'
 11.1049 +    if (number < 0) {
 11.1050 +        number = 0xFFFFFFFF + number + 1;
 11.1051 +    }
 11.1052 +    return parseInt(number, 10).toString(16);
 11.1053 +}
 11.1054 +
 11.1055 +
 11.1056 +
 11.1057 +
 11.1058 +/*
 11.1059 +список блоков
 11.1060 +блок - это словарь:
 11.1061 +    start: integer
 11.1062 +    end: integer
 11.1063 +    IDs: list of IDs
 11.1064 +    //cores: number of all continued part of cores, taking part in klika 
 11.1065 +*/
 11.1066 +
 11.1067 +var blocks = {};
 11.1068 +
 11.1069 +// fasta_dict[ID] = текст последовательности
 11.1070 +var fasta_dict = {};
 11.1071 +
 11.1072 +
 11.1073 +/////////////////////////////////
 11.1074 +// пользовательские параметры
 11.1075 +/////////////////////////////////
 11.1076 +
 11.1077 +var h1_height = 50; // высота ячейки с заголовком
 11.1078 +var mainpanel_height = 100; // высота полосы управления
 11.1079 +var legend_interval = 10; // через сколько позиций делать подпись
 11.1080 +
 11.1081 +
 11.1082 +var letter_width = 9; // ширина буковок
 11.1083 +var letter_height = 17; // высота буковок
 11.1084 +var scroller_height_width = 16; // ширина = высота полос прокрутки
 11.1085 +
 11.1086 +var boundary = 70; // запас до границы экрана
 11.1087 +
 11.1088 +
 11.1089 +
 11.1090 +
 11.1091 +
 11.1092 +//////////////////////////////////////////////
 11.1093 +// последующие переменные генерируются сами
 11.1094 +//////////////////////////////////////////////
 11.1095 +
 11.1096 +
 11.1097 +var selected_block_i; // какой блок был щелкнут
 11.1098 +var ID_order = []; // порядок следования ID на экране
 11.1099 +
 11.1100 +var ID_order_now = []; // ID_order, примененный при текущем посторении
 11.1101 +
 11.1102 +var max_ID_length; // максимальная длина названия
 11.1103 +var seq_length; // длина последовательности
 11.1104 +var IDs_count; // сколько у нас всего последовательнотей
 11.1105 +
 11.1106 +// alignment_strings[ID] = строчка с последовательностью ак для <pre>
 11.1107 +var alignment_strings = {};
 11.1108 +
 11.1109 +
 11.1110 +//useful_positions[ID][position] = номер блока, 
 11.1111 +//если этот элемент входит в состав хотябы одного блока.
 11.1112 +var useful_positions = {};
 11.1113 +
 11.1114 +
 11.1115 +var blocks_inited = 0;
 11.1116 +
 11.1117 +
 11.1118 +
 11.1119 +// стартует весь процесс
 11.1120 +function blocks_init()
 11.1121 +{
 11.1122 +    if (blocks_inited)
 11.1123 +    {
 11.1124 +        return;
 11.1125 +    }
 11.1126 +    
 11.1127 +    blocks_inited = 1;
 11.1128 +    
 11.1129 +    
 11.1130 +    var ID, block;
 11.1131 +    var i, j, k;
 11.1132 +    var t = '';
 11.1133 +    
 11.1134 +    var seq;
 11.1135 +    
 11.1136 +    // вычислим max_ID_length
 11.1137 +    
 11.1138 +    
 11.1139 +    max_ID_length = 0;
 11.1140 +    
 11.1141 +    for (ID in fasta_dict)
 11.1142 +    {
 11.1143 +        max_ID_length = Math.max(max_ID_length, ID.length);
 11.1144 +    }
 11.1145 +    
 11.1146 +    
 11.1147 +    // длина последовательности
 11.1148 +    
 11.1149 +    for (ID in fasta_dict)
 11.1150 +    {
 11.1151 +        seq_length = fasta_dict[ID].length;
 11.1152 +        break;
 11.1153 +    }
 11.1154 +    
 11.1155 +    
 11.1156 +    // сколько у нас всего последовательнотей
 11.1157 +    IDs_count = array_keys(fasta_dict).length;
 11.1158 +    
 11.1159 +    
 11.1160 +
 11.1161 +    
 11.1162 +    ///////////////////////////////////////
 11.1163 +    // придумаем цвет для каждого блока
 11.1164 +    ///////////////////////////////////////
 11.1165 +    
 11.1166 +    for (i = 0; i < blocks.length; i++)
 11.1167 +    {
 11.1168 +        blocks[i].color = crc32_color(json(blocks[i]));
 11.1169 +    }
 11.1170 +    
 11.1171 +    
 11.1172 +    
 11.1173 +    
 11.1174 +    
 11.1175 +    
 11.1176 +    
 11.1177 +    
 11.1178 +    
 11.1179 +    
 11.1180 +    ////////////////////////////////////////////////////////////
 11.1181 +    // Отметим позиции, которые нам может потребоваться красить
 11.1182 +    ////////////////////////////////////////////////////////////
 11.1183 +    
 11.1184 +    useful_positions = {};
 11.1185 +    
 11.1186 +    for (ID in fasta_dict)
 11.1187 +    {
 11.1188 +        useful_positions[ID] = [];
 11.1189 +    }
 11.1190 +    
 11.1191 +    for (i = 0; i < blocks.length; i++)
 11.1192 +    {
 11.1193 +        block = blocks[i];
 11.1194 +        
 11.1195 +        for (k = 0; k < block.IDs.length; k++)
 11.1196 +        {
 11.1197 +            ID = block.IDs[k];
 11.1198 +            
 11.1199 +            for (j = block.start; j <= block.end; j++)
 11.1200 +            {
 11.1201 +                useful_positions[ID][j] = i;
 11.1202 +            }
 11.1203 +        }
 11.1204 +        
 11.1205 +    }
 11.1206 +    
 11.1207 +    
 11.1208 +    
 11.1209 +    
 11.1210 +    
 11.1211 +    // вычислим строчки для <pre>, чтобы каждый раз не считать
 11.1212 +    
 11.1213 +    alignment_strings = {};
 11.1214 +    
 11.1215 +    
 11.1216 +    var block_i;
 11.1217 +    
 11.1218 +    for (ID in fasta_dict)
 11.1219 +    {
 11.1220 +        t = '';
 11.1221 +        
 11.1222 +        seq = fasta_dict[ID];
 11.1223 +        
 11.1224 +        for (j = 0; j < seq_length; j++)
 11.1225 +        {
 11.1226 +            block_i = useful_positions[ID][j];
 11.1227 +            
 11.1228 +            if (block_i || block_i === 0)
 11.1229 +            {
 11.1230 +                // этот элемент входит в состав блока
 11.1231 +                
 11.1232 +                t += '<font ';
 11.1233 +                //t += ' id="a_' + ID + '_' + j + '" ';
 11.1234 +                t += ' style="background:' + blocks[block_i].color + '; cursor:pointer;" ' ;
 11.1235 +                t += ' onclick=letter_click("' + ID + '",' + j + ') ' ;
 11.1236 +                t += '>';
 11.1237 +            }
 11.1238 +
 11.1239 +            t += seq.charAt(j);
 11.1240 +
 11.1241 +            if (block_i || block_i === 0)
 11.1242 +            {
 11.1243 +                t += '</font>';
 11.1244 +            }
 11.1245 +            
 11.1246 +        }
 11.1247 +        
 11.1248 +        alignment_strings[ID] = t;
 11.1249 +        
 11.1250 +        
 11.1251 +    }
 11.1252 +    
 11.1253 +    
 11.1254 +    
 11.1255 +    
 11.1256 +    ////////////////////////////
 11.1257 +    // займемся форматированием
 11.1258 +    ////////////////////////////
 11.1259 +    
 11.1260 +    set_table_width_height();
 11.1261 +    
 11.1262 +    
 11.1263 +    
 11.1264 +    ///////////////////////////////////////
 11.1265 +    // заполним шкалу с номерами позиций
 11.1266 +    ///////////////////////////////////////
 11.1267 +    
 11.1268 +    t = '';
 11.1269 +    
 11.1270 +    var legend_l = 0; // длина легенды
 11.1271 +    
 11.1272 +    var c = Math.floor(seq_length / legend_interval); // число подписей
 11.1273 +    var number; // текущее число
 11.1274 +    
 11.1275 +    for (i = 1; i <= c; i++)
 11.1276 +    {
 11.1277 +        number = i * legend_interval;
 11.1278 +        number = '' + number; // перевод в строку
 11.1279 +        
 11.1280 +        legend_l += 1;
 11.1281 +        
 11.1282 +        for (j = 0; j < legend_interval - number.length; j++)
 11.1283 +        {
 11.1284 +            t += '&nbsp;';
 11.1285 +            legend_l += 1;
 11.1286 +        }
 11.1287 +        
 11.1288 +        t += number;
 11.1289 +        
 11.1290 +    }
 11.1291 +    
 11.1292 +    for (j = 0; j < seq_length - legend_l; j++)
 11.1293 +    {
 11.1294 +        t += '&nbsp;';
 11.1295 +    }
 11.1296 +    
 11.1297 +    t = '<pre><nobr>' + t + '</nobr></pre>';
 11.1298 +    
 11.1299 +    $('legend').innerHTML = t;
 11.1300 +    
 11.1301 +    
 11.1302 +    
 11.1303 +    
 11.1304 +    
 11.1305 +    
 11.1306 +    
 11.1307 +    
 11.1308 +    ////////////////////////
 11.1309 +    // теперь всё запустим
 11.1310 +    ////////////////////////
 11.1311 +    
 11.1312 +    
 11.1313 +    ID_order = array_keys(fasta_dict);
 11.1314 +    
 11.1315 +    blocks_show();
 11.1316 +    
 11.1317 +}
 11.1318 +
 11.1319 +
 11.1320 +
 11.1321 +
 11.1322 +
 11.1323 +
 11.1324 +// вычисляет высоту и ширину элемнтов таблицы
 11.1325 +function set_table_width_height()
 11.1326 +{
 11.1327 +    /*
 11.1328 +    В <pre> всегда вставляется переход на следующую строчку в самом начале и в самом конце
 11.1329 +    */
 11.1330 +    
 11.1331 +    
 11.1332 +    
 11.1333 +    
 11.1334 +    $('mainpanel').style.height = mainpanel_height + 'px';
 11.1335 +    $('h1_header').style.height = h1_height + 'px';
 11.1336 +    
 11.1337 +    
 11.1338 +    $('legend').style.height = (letter_height * 2) + 'px';
 11.1339 +    
 11.1340 +    
 11.1341 +    var screen_width = get_ww();
 11.1342 +    var screen_height = get_wh();
 11.1343 +    
 11.1344 +    // ширина панельки с названиями: (длина названия + 3 символа (" : ")) * ширина символа (9)
 11.1345 +    var IDs_panel_width = (max_ID_length + 3) * letter_width;
 11.1346 +    $('IDs').style.width = IDs_panel_width + 'px';
 11.1347 +    
 11.1348 +    
 11.1349 +    
 11.1350 +    
 11.1351 +    // возьмем все, что осталось
 11.1352 +    var width_1 = screen_width - IDs_panel_width - boundary;
 11.1353 +    
 11.1354 +    // сколько он сам занимает по максимуму
 11.1355 +    var width_2 = letter_width * seq_length;
 11.1356 +    
 11.1357 +    var width = Math.min(width_1, width_2);
 11.1358 +    
 11.1359 +    
 11.1360 +    // возьмем все, что осталось
 11.1361 +    var height_1 = screen_height - h1_height - mainpanel_height - letter_height * 2 - boundary;
 11.1362 +    
 11.1363 +    // сколько он сам занимает по максимуму
 11.1364 +    var height_2 = letter_height * (IDs_count + 2);
 11.1365 +    
 11.1366 +    var height = Math.min(height_1, height_2);
 11.1367 +    
 11.1368 +    
 11.1369 +    
 11.1370 +    
 11.1371 +    
 11.1372 +    
 11.1373 +    $('legend').style.width = width + 'px';
 11.1374 +    
 11.1375 +    if (height != height_2)
 11.1376 +    {
 11.1377 +        // добавим размер полос прокрутки
 11.1378 +        width += scroller_height_width;
 11.1379 +    }
 11.1380 +    
 11.1381 +    $('alignment').style.width = width + 'px';
 11.1382 +    
 11.1383 +    
 11.1384 +    
 11.1385 +    
 11.1386 +    
 11.1387 +    
 11.1388 +    
 11.1389 +    $('IDs').style.height = height + 'px';
 11.1390 +    
 11.1391 +    if (width != width_2)
 11.1392 +    {
 11.1393 +        // добавим размер полос прокрутки
 11.1394 +        height += scroller_height_width;
 11.1395 +    }    
 11.1396 +    
 11.1397 +    $('alignment').style.height = height + 'px';
 11.1398 +    
 11.1399 +    
 11.1400 +}
 11.1401 +
 11.1402 +
 11.1403 +
 11.1404 +
 11.1405 +
 11.1406 +
 11.1407 +
 11.1408 +
 11.1409 +
 11.1410 +
 11.1411 +
 11.1412 +
 11.1413 +// срабатывает про прокрутке окошка с выравниванием
 11.1414 +function alignment_onscroll()
 11.1415 +{
 11.1416 +    
 11.1417 +    $('legend').scrollLeft = $('alignment').scrollLeft;
 11.1418 +    
 11.1419 +    $('IDs').scrollTop = $('alignment').scrollTop;
 11.1420 +    
 11.1421 +}
 11.1422 +
 11.1423 +
 11.1424 +
 11.1425 +
 11.1426 +
 11.1427 +
 11.1428 +
 11.1429 +
 11.1430 +
 11.1431 +
 11.1432 +
 11.1433 +
 11.1434 +
 11.1435 +
 11.1436 +
 11.1437 +
 11.1438 +
 11.1439 +
 11.1440 +
 11.1441 +
 11.1442 +// выводит на экран pre с выравниванием, если это требуется
 11.1443 +function blocks_make_pre()
 11.1444 +{
 11.1445 +    if (json(ID_order) == json(ID_order_now))
 11.1446 +    {
 11.1447 +        return; // ничего не поменялось
 11.1448 +    }
 11.1449 +    
 11.1450 +    var ID, block;
 11.1451 +    var i, j;
 11.1452 +    var t = '';
 11.1453 +    
 11.1454 +    
 11.1455 +    
 11.1456 +    /////////////////
 11.1457 +    // Alignment
 11.1458 +    /////////////////
 11.1459 +    
 11.1460 +    t = '';
 11.1461 +    
 11.1462 +    t += "<pre>";
 11.1463 +    
 11.1464 +    for (i = 0; i < ID_order.length; i++)
 11.1465 +    {
 11.1466 +        ID = ID_order[i];
 11.1467 +        
 11.1468 +        t += alignment_strings[ID];
 11.1469 +        
 11.1470 +        if (i != ID_order.length - 1)
 11.1471 +        {
 11.1472 +            t += "\n";
 11.1473 +        }
 11.1474 +    }
 11.1475 +    
 11.1476 +    t += "</pre>\n";
 11.1477 +    
 11.1478 +    $('alignment').innerHTML = t;
 11.1479 +    
 11.1480 +    
 11.1481 +    
 11.1482 +    
 11.1483 +    //////////////////////
 11.1484 +    // Панель названий
 11.1485 +    //////////////////////
 11.1486 +    
 11.1487 +    
 11.1488 +    t = '';
 11.1489 +    
 11.1490 +    t += "<pre>";
 11.1491 +    
 11.1492 +    for (i = 0; i < ID_order.length; i++)
 11.1493 +    {
 11.1494 +        ID = ID_order[i];
 11.1495 +        
 11.1496 +        // добавим пробелов
 11.1497 +        for (j = 0; j < max_ID_length - ID.length; j++)
 11.1498 +        {
 11.1499 +            t += ' ';
 11.1500 +        }
 11.1501 +        
 11.1502 +        // название
 11.1503 +        t += ID + ' : ';
 11.1504 +        
 11.1505 +        t += "\n";
 11.1506 +    }
 11.1507 +    
 11.1508 +    t += "</pre>\n";
 11.1509 +    
 11.1510 +    $('IDs').innerHTML = t;
 11.1511 +    
 11.1512 +    
 11.1513 +    ID_order_now = array_clon(ID_order);
 11.1514 +}
 11.1515 +
 11.1516 +
 11.1517 +
 11.1518 +
 11.1519 +
 11.1520 +// клик по букве - перестави этот блок повыше
 11.1521 +function letter_click(ID, pos)
 11.1522 +{
 11.1523 +    selected_block_i = useful_positions[ID][pos];
 11.1524 +    
 11.1525 +    // добавим последовательности, входящие в блок
 11.1526 +    ID_order = array_clon(blocks[selected_block_i].IDs);
 11.1527 +    
 11.1528 +    // а теперь все остальные
 11.1529 +    for (ID in fasta_dict)
 11.1530 +    {
 11.1531 +        if (indexOf(ID_order, ID) == -1)
 11.1532 +        {
 11.1533 +            ID_order.push(ID);
 11.1534 +        }
 11.1535 +    }
 11.1536 +    
 11.1537 +    blocks_show();
 11.1538 +}
 11.1539 +
 11.1540 +
 11.1541 +
 11.1542 +
 11.1543 +
 11.1544 +
 11.1545 +function blocks_show()
 11.1546 +{
 11.1547 +    var t = '';
 11.1548 +    
 11.1549 +    if (selected_block_i || selected_block_i === 0)
 11.1550 +    {
 11.1551 +        t += 'Block ' + selected_block_i + '. ';
 11.1552 +        
 11.1553 +        //t += 'Include cores: ' + blocks[selected_block_i].cores.join(', ');
 11.1554 +        
 11.1555 +        
 11.1556 +    }
 11.1557 +    
 11.1558 +    
 11.1559 +    
 11.1560 +    mp_set(t);
 11.1561 +    
 11.1562 +    blocks_make_pre();
 11.1563 +}
 11.1564 +
 11.1565 +
 11.1566 +
 11.1567 +
 11.1568 +
 11.1569 +
 11.1570 +
 11.1571 +
 11.1572 +
 11.1573 +
 11.1574 +
 11.1575 +
 11.1576 +
 11.1577 +
 11.1578 +
 11.1579 +
 11.1580 +
 11.1581 +
 11.1582 +
 11.1583 +
 11.1584 +self_js_text
 11.1585 +
 11.1586 +
 11.1587 +//-->
 11.1588 +</script>
 11.1589 +
 11.1590 +
 11.1591 +</body>
 11.1592 +</html>
 11.1593 +
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/blocks3d/www/array.js	Fri Sep 17 21:52:33 2010 +0400
    12.3 @@ -0,0 +1,190 @@
    12.4 +
    12.5 +//////////////////////////
    12.6 +// скопировать массив :)
    12.7 +//////////////////////////
    12.8 +
    12.9 +
   12.10 +function array_clon(obj)
   12.11 +{
   12.12 +    if (typeof(obj) == 'object')
   12.13 +    {
   12.14 +        
   12.15 +        if (typeof(obj.length) === 'undefined')
   12.16 +        {
   12.17 +            var obj1 = {}; // хэш
   12.18 +        }
   12.19 +        else
   12.20 +        {
   12.21 +            var obj1 = []; // массив
   12.22 +        }
   12.23 +        
   12.24 +        
   12.25 +        for (var i in obj)
   12.26 +        {
   12.27 +            obj1[i] = array_clon(obj[i]);
   12.28 +        }
   12.29 +        
   12.30 +        return obj1;
   12.31 +    }  
   12.32 +    else
   12.33 +    {
   12.34 +        return obj;
   12.35 +    }
   12.36 +}
   12.37 +
   12.38 +
   12.39 +
   12.40 +
   12.41 +
   12.42 +/////////////////////////////////////
   12.43 +// взять элемент массива без ошибок
   12.44 +/////////////////////////////////////
   12.45 +
   12.46 +function ae(obj, indexes)
   12.47 +{
   12.48 +    if (typeof(indexes) != 'object')
   12.49 +    {
   12.50 +        indexes = [indexes];
   12.51 +    }
   12.52 +    
   12.53 +    var index;
   12.54 +    var r = obj;
   12.55 +    
   12.56 +    var i;
   12.57 +    
   12.58 +    for (i = 0; i < indexes.length; i++)
   12.59 +    {
   12.60 +        try
   12.61 +        {
   12.62 +            index = indexes[i];
   12.63 +            r = r[index];
   12.64 +        }
   12.65 +        catch(e)
   12.66 +        {
   12.67 +            return 0;
   12.68 +        }
   12.69 +    
   12.70 +    }
   12.71 +    
   12.72 +    if (!r)
   12.73 +    {
   12.74 +        return 0;
   12.75 +    }
   12.76 +    
   12.77 +    return r;
   12.78 +}
   12.79 +
   12.80 +
   12.81 +
   12.82 +
   12.83 +
   12.84 +
   12.85 +
   12.86 +
   12.87 +
   12.88 +///////////////////
   12.89 +// поиск в массиве 
   12.90 +///////////////////
   12.91 +// где, что
   12.92 +function indexOf (input, elt /*, from*/)
   12.93 +{
   12.94 +    
   12.95 +    var r;
   12.96 +    
   12.97 +    try
   12.98 +    {
   12.99 +        return input.indexOf(elt /*, from*/);
  12.100 +    }
  12.101 +    catch(e)
  12.102 +    {
  12.103 +        var len = input.length >>> 0;
  12.104 +
  12.105 +        var from = Number(arguments[1]) || 0;
  12.106 +        from = (from < 0)
  12.107 +             ? Math.ceil(from)
  12.108 +             : Math.floor(from);
  12.109 +        if (from < 0)
  12.110 +          from += len;
  12.111 +
  12.112 +        for (; from < len; from++)
  12.113 +        {
  12.114 +          if (from in input &&
  12.115 +              input[from] === elt)
  12.116 +            return from;
  12.117 +        }
  12.118 +        return -1;
  12.119 +    }
  12.120 +}
  12.121 +
  12.122 +//  
  12.123 +//  
  12.124 +//  if (!Array.prototype.indexOf)
  12.125 +//  {
  12.126 +//    Array.prototype.indexOf = function(elt /*, from*/)
  12.127 +//    {
  12.128 +//      var len = this.length >>> 0;
  12.129 +//  
  12.130 +//      var from = Number(arguments[1]) || 0;
  12.131 +//      from = (from < 0)
  12.132 +//           ? Math.ceil(from)
  12.133 +//           : Math.floor(from);
  12.134 +//      if (from < 0)
  12.135 +//        from += len;
  12.136 +//  
  12.137 +//      for (; from < len; from++)
  12.138 +//      {
  12.139 +//        if (from in this &&
  12.140 +//            this[from] === elt)
  12.141 +//          return from;
  12.142 +//      }
  12.143 +//      return -1;
  12.144 +//    };
  12.145 +//  }
  12.146 +//  
  12.147 +//  
  12.148 +
  12.149 +
  12.150 +
  12.151 +
  12.152 +
  12.153 +
  12.154 +function sortNumber(a, b)
  12.155 +{
  12.156 +    return a - b;
  12.157 +}
  12.158 +
  12.159 +
  12.160 +// возвращает список ключей словаря
  12.161 +function array_keys(arr)
  12.162 +{
  12.163 +    var keys = [];
  12.164 +    
  12.165 +    var key;
  12.166 +    
  12.167 +    for (key in arr)
  12.168 +    {
  12.169 +        keys.push(key);
  12.170 +    }
  12.171 +    
  12.172 +    return keys;
  12.173 +}
  12.174 +
  12.175 +
  12.176 +
  12.177 +
  12.178 +// возвращает список значений словаря
  12.179 +function array_values(arr)
  12.180 +{
  12.181 +    var values = [];
  12.182 +    
  12.183 +    var key;
  12.184 +    
  12.185 +    for (key in arr)
  12.186 +    {
  12.187 +        values.push(arr[key]);
  12.188 +    }
  12.189 +    
  12.190 +    return values;
  12.191 +}
  12.192 +
  12.193 +
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/blocks3d/www/blocks.js	Fri Sep 17 21:52:33 2010 +0400
    13.3 @@ -0,0 +1,511 @@
    13.4 +
    13.5 +/*
    13.6 + 
    13.7 + -  :
    13.8 +    start: integer
    13.9 +    end: integer
   13.10 +    IDs: list of IDs
   13.11 +    //cores: number of all continued part of cores, taking part in klika 
   13.12 +*/
   13.13 +
   13.14 +var blocks = {};
   13.15 +
   13.16 +// fasta_dict[ID] =  
   13.17 +var fasta_dict = {};
   13.18 +
   13.19 +
   13.20 +/////////////////////////////////
   13.21 +//  
   13.22 +/////////////////////////////////
   13.23 +
   13.24 +var h1_height = 50; //    
   13.25 +var mainpanel_height = 100; //   
   13.26 +var legend_interval = 10; //     
   13.27 +
   13.28 +
   13.29 +var letter_width = 9; //  
   13.30 +var letter_height = 17; //  
   13.31 +var scroller_height_width = 16; //  =   
   13.32 +
   13.33 +var boundary = 70; //    
   13.34 +
   13.35 +
   13.36 +
   13.37 +
   13.38 +
   13.39 +//////////////////////////////////////////////
   13.40 +//    
   13.41 +//////////////////////////////////////////////
   13.42 +
   13.43 +
   13.44 +var selected_block_i; //    
   13.45 +var ID_order = []; //   ID  
   13.46 +
   13.47 +var ID_order_now = []; // ID_order,    
   13.48 +
   13.49 +var max_ID_length; //   
   13.50 +var seq_length; //  
   13.51 +var IDs_count; //     
   13.52 +
   13.53 +// alignment_strings[ID] =      <pre>
   13.54 +var alignment_strings = {};
   13.55 +
   13.56 +
   13.57 +//useful_positions[ID][position] =  , 
   13.58 +//        .
   13.59 +var useful_positions = {};
   13.60 +
   13.61 +
   13.62 +var blocks_inited = 0;
   13.63 +
   13.64 +
   13.65 +
   13.66 +//   
   13.67 +function blocks_init()
   13.68 +{
   13.69 +    if (blocks_inited)
   13.70 +    {
   13.71 +        return;
   13.72 +    }
   13.73 +    
   13.74 +    blocks_inited = 1;
   13.75 +    
   13.76 +    
   13.77 +    var ID, block;
   13.78 +    var i, j, k;
   13.79 +    var t = '';
   13.80 +    
   13.81 +    var seq;
   13.82 +    
   13.83 +    //  max_ID_length
   13.84 +    
   13.85 +    
   13.86 +    max_ID_length = 0;
   13.87 +    
   13.88 +    for (ID in fasta_dict)
   13.89 +    {
   13.90 +        max_ID_length = Math.max(max_ID_length, ID.length);
   13.91 +    }
   13.92 +    
   13.93 +    
   13.94 +    //  
   13.95 +    
   13.96 +    for (ID in fasta_dict)
   13.97 +    {
   13.98 +        seq_length = fasta_dict[ID].length;
   13.99 +        break;
  13.100 +    }
  13.101 +    
  13.102 +    
  13.103 +    //     
  13.104 +    IDs_count = array_keys(fasta_dict).length;
  13.105 +    
  13.106 +    
  13.107 +
  13.108 +    
  13.109 +    ///////////////////////////////////////
  13.110 +    //     
  13.111 +    ///////////////////////////////////////
  13.112 +    
  13.113 +    for (i = 0; i < blocks.length; i++)
  13.114 +    {
  13.115 +        blocks[i].color = crc32_color(json(blocks[i]));
  13.116 +    }
  13.117 +    
  13.118 +    
  13.119 +    
  13.120 +    
  13.121 +    
  13.122 +    
  13.123 +    
  13.124 +    
  13.125 +    
  13.126 +    
  13.127 +    ////////////////////////////////////////////////////////////
  13.128 +    //  ,     
  13.129 +    ////////////////////////////////////////////////////////////
  13.130 +    
  13.131 +    useful_positions = {};
  13.132 +    
  13.133 +    for (ID in fasta_dict)
  13.134 +    {
  13.135 +        useful_positions[ID] = [];
  13.136 +    }
  13.137 +    
  13.138 +    for (i = 0; i < blocks.length; i++)
  13.139 +    {
  13.140 +        block = blocks[i];
  13.141 +        
  13.142 +        for (k = 0; k < block.IDs.length; k++)
  13.143 +        {
  13.144 +            ID = block.IDs[k];
  13.145 +            
  13.146 +            for (j = block.start; j <= block.end; j++)
  13.147 +            {
  13.148 +                useful_positions[ID][j] = i;
  13.149 +            }
  13.150 +        }
  13.151 +        
  13.152 +    }
  13.153 +    
  13.154 +    
  13.155 +    
  13.156 +    
  13.157 +    
  13.158 +    //    <pre>,     
  13.159 +    
  13.160 +    alignment_strings = {};
  13.161 +    
  13.162 +    
  13.163 +    var block_i;
  13.164 +    
  13.165 +    for (ID in fasta_dict)
  13.166 +    {
  13.167 +        t = '';
  13.168 +        
  13.169 +        seq = fasta_dict[ID];
  13.170 +        
  13.171 +        for (j = 0; j < seq_length; j++)
  13.172 +        {
  13.173 +            block_i = useful_positions[ID][j];
  13.174 +            
  13.175 +            if (block_i || block_i === 0)
  13.176 +            {
  13.177 +                //      
  13.178 +                
  13.179 +                t += '<font ';
  13.180 +                //t += ' id="a_' + ID + '_' + j + '" ';
  13.181 +                t += ' style="background:' + blocks[block_i].color + '; cursor:pointer;" ' ;
  13.182 +                t += ' onclick=letter_click("' + ID + '",' + j + ') ' ;
  13.183 +                t += '>';
  13.184 +            }
  13.185 +
  13.186 +            t += seq.charAt(j);
  13.187 +
  13.188 +            if (block_i || block_i === 0)
  13.189 +            {
  13.190 +                t += '</font>';
  13.191 +            }
  13.192 +            
  13.193 +        }
  13.194 +        
  13.195 +        alignment_strings[ID] = t;
  13.196 +        
  13.197 +        
  13.198 +    }
  13.199 +    
  13.200 +    
  13.201 +    
  13.202 +    
  13.203 +    ////////////////////////////
  13.204 +    //  
  13.205 +    ////////////////////////////
  13.206 +    
  13.207 +    set_table_width_height();
  13.208 +    
  13.209 +    
  13.210 +    
  13.211 +    ///////////////////////////////////////
  13.212 +    //     
  13.213 +    ///////////////////////////////////////
  13.214 +    
  13.215 +    t = '';
  13.216 +    
  13.217 +    var c = Math.floor(seq_length / legend_interval); //  
  13.218 +    var number; //  
  13.219 +    
  13.220 +    for (i = 1; i <= c; i++)
  13.221 +    {
  13.222 +        number = i * legend_interval;
  13.223 +        number = '' + number; //   
  13.224 +        
  13.225 +        for (j = 0; j < legend_interval - number.length; j++)
  13.226 +        {
  13.227 +            t += '&nbsp;';
  13.228 +        }
  13.229 +        
  13.230 +        t += number;
  13.231 +        
  13.232 +    }
  13.233 +    
  13.234 +    t = '<pre><nobr>' + t + '</nobr></pre>';
  13.235 +    
  13.236 +    $('legend').innerHTML = t;
  13.237 +    
  13.238 +    
  13.239 +    
  13.240 +    
  13.241 +    
  13.242 +    
  13.243 +    
  13.244 +    
  13.245 +    ////////////////////////
  13.246 +    //   
  13.247 +    ////////////////////////
  13.248 +    
  13.249 +    
  13.250 +    ID_order = array_keys(fasta_dict);
  13.251 +    
  13.252 +    blocks_show();
  13.253 +    
  13.254 +}
  13.255 +
  13.256 +
  13.257 +
  13.258 +
  13.259 +
  13.260 +
  13.261 +//      
  13.262 +function set_table_width_height()
  13.263 +{
  13.264 +    /*
  13.265 +     <pre>             
  13.266 +    */
  13.267 +    
  13.268 +    
  13.269 +    
  13.270 +    
  13.271 +    $('mainpanel').style.height = mainpanel_height + 'px';
  13.272 +    $('h1_header').style.height = h1_height + 'px';
  13.273 +    
  13.274 +    
  13.275 +    $('legend').style.height = (letter_height * 2) + 'px';
  13.276 +    
  13.277 +    
  13.278 +    var screen_width = get_ww();
  13.279 +    var screen_height = get_wh();
  13.280 +    
  13.281 +    //    : (  + 3  (" : ")) *   (9)
  13.282 +    var IDs_panel_width = (max_ID_length + 3) * letter_width;
  13.283 +    $('IDs').style.width = IDs_panel_width + 'px';
  13.284 +    
  13.285 +    
  13.286 +    
  13.287 +    
  13.288 +    //  ,  
  13.289 +    var width_1 = screen_width - IDs_panel_width - boundary;
  13.290 +    
  13.291 +    //      
  13.292 +    var width_2 = letter_width * seq_length;
  13.293 +    
  13.294 +    var width = Math.min(width_1, width_2);
  13.295 +    
  13.296 +    
  13.297 +    //  ,  
  13.298 +    var height_1 = screen_height - h1_height - mainpanel_height - letter_height * 2 - boundary;
  13.299 +    
  13.300 +    //      
  13.301 +    var height_2 = letter_height * (IDs_count + 2);
  13.302 +    
  13.303 +    var height = Math.min(height_1, height_2);
  13.304 +    
  13.305 +    
  13.306 +    
  13.307 +    
  13.308 +    
  13.309 +    
  13.310 +    $('legend').style.width = width + 'px';
  13.311 +    
  13.312 +    if (height != height_2)
  13.313 +    {
  13.314 +        //    
  13.315 +        width += scroller_height_width;
  13.316 +    }
  13.317 +    
  13.318 +    $('alignment').style.width = width + 'px';
  13.319 +    
  13.320 +    
  13.321 +    
  13.322 +    
  13.323 +    
  13.324 +    
  13.325 +    
  13.326 +    $('IDs').style.height = height + 'px';
  13.327 +    
  13.328 +    if (width != width_2)
  13.329 +    {
  13.330 +        //    
  13.331 +        height += scroller_height_width;
  13.332 +    }    
  13.333 +    
  13.334 +    $('alignment').style.height = height + 'px';
  13.335 +    
  13.336 +    
  13.337 +}
  13.338 +
  13.339 +
  13.340 +
  13.341 +
  13.342 +
  13.343 +
  13.344 +
  13.345 +
  13.346 +
  13.347 +
  13.348 +
  13.349 +
  13.350 +//      
  13.351 +function alignment_onscroll()
  13.352 +{
  13.353 +    
  13.354 +    $('legend').scrollLeft = $('alignment').scrollLeft;
  13.355 +    
  13.356 +    $('IDs').scrollTop = $('alignment').scrollTop;
  13.357 +    
  13.358 +}
  13.359 +
  13.360 +
  13.361 +
  13.362 +
  13.363 +
  13.364 +
  13.365 +
  13.366 +
  13.367 +
  13.368 +
  13.369 +
  13.370 +
  13.371 +
  13.372 +
  13.373 +
  13.374 +
  13.375 +
  13.376 +
  13.377 +
  13.378 +
  13.379 +//    pre  ,   
  13.380 +function blocks_make_pre()
  13.381 +{
  13.382 +    if (json(ID_order) == json(ID_order_now))
  13.383 +    {
  13.384 +        return; //   
  13.385 +    }
  13.386 +    
  13.387 +    var ID, block;
  13.388 +    var i, j;
  13.389 +    var t = '';
  13.390 +    
  13.391 +    
  13.392 +    
  13.393 +    /////////////////
  13.394 +    // Alignment
  13.395 +    /////////////////
  13.396 +    
  13.397 +    t = '';
  13.398 +    
  13.399 +    t += "<pre>";
  13.400 +    
  13.401 +    for (i = 0; i < ID_order.length; i++)
  13.402 +    {
  13.403 +        ID = ID_order[i];
  13.404 +        
  13.405 +        t += alignment_strings[ID];
  13.406 +        
  13.407 +        if (i != ID_order.length - 1)
  13.408 +        {
  13.409 +            t += "\n";
  13.410 +        }
  13.411 +    }
  13.412 +    
  13.413 +    t += "</pre>\n";
  13.414 +    
  13.415 +    $('alignment').innerHTML = t;
  13.416 +    
  13.417 +    
  13.418 +    
  13.419 +    
  13.420 +    //////////////////////
  13.421 +    //  
  13.422 +    //////////////////////
  13.423 +    
  13.424 +    
  13.425 +    t = '';
  13.426 +    
  13.427 +    t += "<pre>";
  13.428 +    
  13.429 +    for (i = 0; i < ID_order.length; i++)
  13.430 +    {
  13.431 +        ID = ID_order[i];
  13.432 +        
  13.433 +        //  
  13.434 +        for (j = 0; j < max_ID_length - ID.length; j++)
  13.435 +        {
  13.436 +            t += ' ';
  13.437 +        }
  13.438 +        
  13.439 +        // 
  13.440 +        t += ID + ' : ';
  13.441 +        
  13.442 +        t += "\n";
  13.443 +    }
  13.444 +    
  13.445 +    t += "</pre>\n";
  13.446 +    
  13.447 +    $('IDs').innerHTML = t;
  13.448 +    
  13.449 +    
  13.450 +    ID_order_now = array_clon(ID_order);
  13.451 +}
  13.452 +
  13.453 +
  13.454 +
  13.455 +
  13.456 +
  13.457 +//    -    
  13.458 +function letter_click(ID, pos)
  13.459 +{
  13.460 +    selected_block_i = useful_positions[ID][pos];
  13.461 +    
  13.462 +    //  ,   
  13.463 +    ID_order = array_clon(blocks[selected_block_i].IDs);
  13.464 +    
  13.465 +    //    
  13.466 +    for (ID in fasta_dict)
  13.467 +    {
  13.468 +        if (indexOf(ID_order, ID) == -1)
  13.469 +        {
  13.470 +            ID_order.push(ID);
  13.471 +        }
  13.472 +    }
  13.473 +    
  13.474 +    blocks_show();
  13.475 +}
  13.476 +
  13.477 +
  13.478 +
  13.479 +
  13.480 +
  13.481 +
  13.482 +function blocks_show()
  13.483 +{
  13.484 +    var t = '';
  13.485 +    
  13.486 +    if (selected_block_i || selected_block_i === 0)
  13.487 +    {
  13.488 +        t += 'Block ' + selected_block_i + '. ';
  13.489 +        
  13.490 +        //t += 'Include cores: ' + blocks[selected_block_i].cores.join(', ');
  13.491 +        
  13.492 +        
  13.493 +    }
  13.494 +    
  13.495 +    
  13.496 +    
  13.497 +    mp_set(t);
  13.498 +    
  13.499 +    blocks_make_pre();
  13.500 +}
  13.501 +
  13.502 +
  13.503 +
  13.504 +
  13.505 +
  13.506 +
  13.507 +
  13.508 +
  13.509 +
  13.510 +
  13.511 +
  13.512 +
  13.513 +
  13.514 +
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/blocks3d/www/crc32.js	Fri Sep 17 21:52:33 2010 +0400
    14.3 @@ -0,0 +1,25 @@
    14.4 +function crc32 ( str ) {
    14.5 +    // http://kevin.vanzonneveld.net
    14.6 +    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    14.7 +    // +   improved by: T0bsn
    14.8 +    // -    depends on: utf8_encode
    14.9 +    // *     example 1: crc32('Kevin van Zonneveld');
   14.10 +    // *     returns 1: 1249991249
   14.11 +
   14.12 +    //str = this.utf8_encode(str);
   14.13 +    
   14.14 +    var table = "00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D";
   14.15 +
   14.16 +    var crc = 0;
   14.17 +    var x = 0;
   14.18 +    var y = 0;
   14.19 +
   14.20 +    crc = crc ^ (-1);
   14.21 +    for (var i = 0, iTop = str.length; i < iTop; i++) {
   14.22 +        y = ( crc ^ str.charCodeAt( i ) ) & 0xFF;
   14.23 +        x = "0x" + table.substr( y * 9, 8 );
   14.24 +        crc = ( crc >>> 8 ) ^ x;
   14.25 +    }
   14.26 +
   14.27 +    return crc ^ (-1);
   14.28 +}
   14.29 \ No newline at end of file
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/blocks3d/www/crc32_color.js	Fri Sep 17 21:52:33 2010 +0400
    15.3 @@ -0,0 +1,32 @@
    15.4 +
    15.5 +
    15.6 +// выдает цвет в зависимости от something (это должна быть строка)
    15.7 +function crc32_color(something)
    15.8 +{
    15.9 +    var crc = crc32(something);
   15.10 +    var rgb = []; // [r, g, b] (берутся последние 3 байте подписи)
   15.11 +    
   15.12 +    rgb[0] = crc & 0xFF;
   15.13 +    rgb[1] = (crc >> 8) & 0xFF;
   15.14 +    rgb[2] = (crc >> 16) & 0xFF;
   15.15 +    
   15.16 +    var j;
   15.17 +    
   15.18 +    // подсветлим цвета
   15.19 +    for (j = 0; j < 3; j++)
   15.20 +    {
   15.21 +        rgb[j] |= 128;
   15.22 +    }
   15.23 +    
   15.24 +    for (j = 0; j < 3; j++)
   15.25 +    {
   15.26 +        rgb[j] = dechex(rgb[j]);
   15.27 +        
   15.28 +        if (rgb[j].length == 1)
   15.29 +        {
   15.30 +            rgb[j] = '0' + rgb[j];
   15.31 +        }
   15.32 +    }
   15.33 +    
   15.34 +    return '#' + rgb.join('');
   15.35 +}
   15.36 \ No newline at end of file
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/blocks3d/www/css.css	Fri Sep 17 21:52:33 2010 +0400
    16.3 @@ -0,0 +1,84 @@
    16.4 +
    16.5 +body
    16.6 +{
    16.7 +    font: 14px 'Arial', Tahoma, Arial;
    16.8 +    cursor: default;
    16.9 +}
   16.10 +A
   16.11 +{ 
   16.12 +    font: 14px 'Arial', Tahoma, Arial;
   16.13 +    color: blue;
   16.14 +    text-decoration: none;
   16.15 +    cursor: pointer;
   16.16 +}
   16.17 +A:hover
   16.18 +{
   16.19 +    color: black;
   16.20 +    font-family: 'Arial' , Tahoma, Arial;
   16.21 +    text-decoration: underline;
   16.22 +}
   16.23 +
   16.24 +h1
   16.25 +{
   16.26 +    font: bold 19px 'Arial' , Tahoma, Arial;
   16.27 +    color: #004080;
   16.28 +}
   16.29 +
   16.30 +h2
   16.31 +{
   16.32 +    font: bold 17px 'Arial' , Tahoma, Arial;
   16.33 +    color: #784080;
   16.34 +}
   16.35 +
   16.36 +h3
   16.37 +{
   16.38 +    font: bold 15px 'Arial' , Tahoma, Arial;
   16.39 +    color: #000000;
   16.40 +}
   16.41 +
   16.42 +TD
   16.43 +{
   16.44 +    font: 14px 'Arial', Tahoma, Arial;
   16.45 +}
   16.46 +
   16.47 +
   16.48 +table
   16.49 +{
   16.50 +    border-color: black;
   16.51 +    border-Collapse: collapse;
   16.52 +    border-width: 1px;
   16.53 +}
   16.54 +
   16.55 +
   16.56 +
   16.57 +img
   16.58 +{
   16.59 +    border:none;
   16.60 +}
   16.61 +
   16.62 +
   16.63 +
   16.64 +
   16.65 +
   16.66 +
   16.67 +
   16.68 +#mainpanel
   16.69 +{
   16.70 +    overflow: auto;
   16.71 +}
   16.72 +
   16.73 +#h1_header
   16.74 +{
   16.75 +    overflow: hidden;
   16.76 +}
   16.77 +
   16.78 +
   16.79 +#legend, #IDs
   16.80 +{
   16.81 +    overflow: hidden;
   16.82 +}
   16.83 +
   16.84 +#alignment
   16.85 +{
   16.86 +    overflow: auto;
   16.87 +}
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/blocks3d/www/dechex.js	Fri Sep 17 21:52:33 2010 +0400
    17.3 @@ -0,0 +1,17 @@
    17.4 +function dechex (number) {
    17.5 +    // http://kevin.vanzonneveld.net
    17.6 +    // +   original by: Philippe Baumann
    17.7 +    // +   bugfixed by: Onno Marsman
    17.8 +    // +   improved by: http://stackoverflow.com/questions/57803/how-to-convert-decimal-to-hex-in-javascript
    17.9 +    // +   input by: pilus
   17.10 +    // *     example 1: dechex(10);
   17.11 +    // *     returns 1: 'a'
   17.12 +    // *     example 2: dechex(47);
   17.13 +    // *     returns 2: '2f'
   17.14 +    // *     example 3: dechex(-1415723993);
   17.15 +    // *     returns 3: 'ab9dc427'
   17.16 +    if (number < 0) {
   17.17 +        number = 0xFFFFFFFF + number + 1;
   17.18 +    }
   17.19 +    return parseInt(number, 10).toString(16);
   17.20 +}
   17.21 \ No newline at end of file
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/blocks3d/www/down.php	Fri Sep 17 21:52:33 2010 +0400
    18.3 @@ -0,0 +1,2 @@
    18.4 +</body>
    18.5 +</html>
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/blocks3d/www/html.php	Fri Sep 17 21:52:33 2010 +0400
    19.3 @@ -0,0 +1,34 @@
    19.4 +<?
    19.5 +
    19.6 +[inc]top.php
    19.7 +
    19.8 +?>
    19.9 +
   19.10 +<script type="text/javascript">
   19.11 +//<!--
   19.12 +
   19.13 +[inc_js]array.js
   19.14 +[inc_js]json2.js
   19.15 +[inc_js]mainpanel.js
   19.16 +[inc_js]screen.js
   19.17 +[inc_js]crc32_color.js
   19.18 +[inc_js]crc32.js
   19.19 +[inc_js]dechex.js
   19.20 +[inc_js]blocks.js
   19.21 +
   19.22 +
   19.23 +
   19.24 +
   19.25 +
   19.26 +self_js_text
   19.27 +
   19.28 +
   19.29 +//-->
   19.30 +</script>
   19.31 +
   19.32 +
   19.33 +<?
   19.34 +
   19.35 +[inc]down.php
   19.36 +
   19.37 +?>
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/blocks3d/www/json2.js	Fri Sep 17 21:52:33 2010 +0400
    20.3 @@ -0,0 +1,496 @@
    20.4 +/*
    20.5 +    http://www.JSON.org/json2.js
    20.6 +    2009-06-29
    20.7 +
    20.8 +    Public Domain.
    20.9 +
   20.10 +    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
   20.11 +
   20.12 +    See http://www.JSON.org/js.html
   20.13 +
   20.14 +    This file creates a global JSON object containing two methods: stringify
   20.15 +    and parse.
   20.16 +
   20.17 +        JSON.stringify(value, replacer, space)
   20.18 +            value       any JavaScript value, usually an object or array.
   20.19 +
   20.20 +            replacer    an optional parameter that determines how object
   20.21 +                        values are stringified for objects. It can be a
   20.22 +                        function or an array of strings.
   20.23 +
   20.24 +            space       an optional parameter that specifies the indentation
   20.25 +                        of nested structures. If it is omitted, the text will
   20.26 +                        be packed without extra whitespace. If it is a number,
   20.27 +                        it will specify the number of spaces to indent at each
   20.28 +                        level. If it is a string (such as '\t' or '&nbsp;'),
   20.29 +                        it contains the characters used to indent at each level.
   20.30 +
   20.31 +            This method produces a JSON text from a JavaScript value.
   20.32 +
   20.33 +            When an object value is found, if the object contains a toJSON
   20.34 +            method, its toJSON method will be called and the result will be
   20.35 +            stringified. A toJSON method does not serialize: it returns the
   20.36 +            value represented by the name/value pair that should be serialized,
   20.37 +            or undefined if nothing should be serialized. The toJSON method
   20.38 +            will be passed the key associated with the value, and this will be
   20.39 +            bound to the object holding the key.
   20.40 +
   20.41 +            For example, this would serialize Dates as ISO strings.
   20.42 +
   20.43 +                Date.prototype.toJSON = function (key) {
   20.44 +                    function f(n) {
   20.45 +                        // Format integers to have at least two digits.
   20.46 +                        return n < 10 ? '0' + n : n;
   20.47 +                    }
   20.48 +
   20.49 +                    return this.getUTCFullYear()   + '-' +
   20.50 +                         f(this.getUTCMonth() + 1) + '-' +
   20.51 +                         f(this.getUTCDate())      + 'T' +
   20.52 +                         f(this.getUTCHours())     + ':' +
   20.53 +                         f(this.getUTCMinutes())   + ':' +
   20.54 +                         f(this.getUTCSeconds())   + 'Z';
   20.55 +                };
   20.56 +
   20.57 +            You can provide an optional replacer method. It will be passed the
   20.58 +            key and value of each member, with this bound to the containing
   20.59 +            object. The value that is returned from your method will be
   20.60 +            serialized. If your method returns undefined, then the member will
   20.61 +            be excluded from the serialization.
   20.62 +
   20.63 +            If the replacer parameter is an array of strings, then it will be
   20.64 +            used to select the members to be serialized. It filters the results
   20.65 +            such that only members with keys listed in the replacer array are
   20.66 +            stringified.
   20.67 +
   20.68 +            Values that do not have JSON representations, such as undefined or
   20.69 +            functions, will not be serialized. Such values in objects will be
   20.70 +            dropped; in arrays they will be replaced with null. You can use
   20.71 +            a replacer function to replace those with JSON values.
   20.72 +            JSON.stringify(undefined) returns undefined.
   20.73 +
   20.74 +            The optional space parameter produces a stringification of the
   20.75 +            value that is filled with line breaks and indentation to make it
   20.76 +            easier to read.
   20.77 +
   20.78 +            If the space parameter is a non-empty string, then that string will
   20.79 +            be used for indentation. If the space parameter is a number, then
   20.80 +            the indentation will be that many spaces.
   20.81 +
   20.82 +            Example:
   20.83 +
   20.84 +            text = JSON.stringify(['e', {pluribus: 'unum'}]);
   20.85 +            // text is '["e",{"pluribus":"unum"}]'
   20.86 +
   20.87 +
   20.88 +            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
   20.89 +            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
   20.90 +
   20.91 +            text = JSON.stringify([new Date()], function (key, value) {
   20.92 +                return this[key] instanceof Date ?
   20.93 +                    'Date(' + this[key] + ')' : value;
   20.94 +            });
   20.95 +            // text is '["Date(---current time---)"]'
   20.96 +
   20.97 +
   20.98 +        JSON.parse(text, reviver)
   20.99 +            This method parses a JSON text to produce an object or array.
  20.100 +            It can throw a SyntaxError exception.
  20.101 +
  20.102 +            The optional reviver parameter is a function that can filter and
  20.103 +            transform the results. It receives each of the keys and values,
  20.104 +            and its return value is used instead of the original value.
  20.105 +            If it returns what it received, then the structure is not modified.
  20.106 +            If it returns undefined then the member is deleted.
  20.107 +
  20.108 +            Example:
  20.109 +
  20.110 +            // Parse the text. Values that look like ISO date strings will
  20.111 +            // be converted to Date objects.
  20.112 +
  20.113 +            myData = JSON.parse(text, function (key, value) {
  20.114 +                var a;
  20.115 +                if (typeof value === 'string') {
  20.116 +                    a =
  20.117 +/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
  20.118 +                    if (a) {
  20.119 +                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
  20.120 +                            +a[5], +a[6]));
  20.121 +                    }
  20.122 +                }
  20.123 +                return value;
  20.124 +            });
  20.125 +
  20.126 +            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
  20.127 +                var d;
  20.128 +                if (typeof value === 'string' &&
  20.129 +                        value.slice(0, 5) === 'Date(' &&
  20.130 +                        value.slice(-1) === ')') {
  20.131 +                    d = new Date(value.slice(5, -1));
  20.132 +                    if (d) {
  20.133 +                        return d;
  20.134 +                    }
  20.135 +                }
  20.136 +                return value;
  20.137 +            });
  20.138 +
  20.139 +
  20.140 +    This is a reference implementation. You are free to copy, modify, or
  20.141 +    redistribute.
  20.142 +
  20.143 +    This code should be minified before deployment.
  20.144 +    See http://javascript.crockford.com/jsmin.html
  20.145 +
  20.146 +    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
  20.147 +    NOT CONTROL.
  20.148 +*/
  20.149 +
  20.150 +/*jslint evil: true */
  20.151 +
  20.152 +/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
  20.153 +    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
  20.154 +    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
  20.155 +    lastIndex, length, parse, prototype, push, replace, slice, stringify,
  20.156 +    test, toJSON, toString, valueOf
  20.157 +*/
  20.158 +
  20.159 +// Create a JSON object only if one does not already exist. We create the
  20.160 +// methods in a closure to avoid creating global variables.
  20.161 +
  20.162 +var JSON = JSON || {};
  20.163 +
  20.164 +(function () {
  20.165 +
  20.166 +    function f(n) {
  20.167 +        // Format integers to have at least two digits.
  20.168 +        return n < 10 ? '0' + n : n;
  20.169 +    }
  20.170 +
  20.171 +    if (typeof Date.prototype.toJSON !== 'function') {
  20.172 +
  20.173 +        Date.prototype.toJSON = function (key) {
  20.174 +
  20.175 +            return isFinite(this.valueOf()) ?
  20.176 +                   this.getUTCFullYear()   + '-' +
  20.177 +                 f(this.getUTCMonth() + 1) + '-' +
  20.178 +                 f(this.getUTCDate())      + 'T' +
  20.179 +                 f(this.getUTCHours())     + ':' +
  20.180 +                 f(this.getUTCMinutes())   + ':' +
  20.181 +                 f(this.getUTCSeconds())   + 'Z' : null;
  20.182 +        };
  20.183 +
  20.184 +        String.prototype.toJSON =
  20.185 +        Number.prototype.toJSON =
  20.186 +        Boolean.prototype.toJSON = function (key) {
  20.187 +            return this.valueOf();
  20.188 +        };
  20.189 +    }
  20.190 +
  20.191 +    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
  20.192 +        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
  20.193 +        gap,
  20.194 +        indent,
  20.195 +        meta = {    // table of character substitutions
  20.196 +            '\b': '\\b',
  20.197 +            '\t': '\\t',
  20.198 +            '\n': '\\n',
  20.199 +            '\f': '\\f',
  20.200 +            '\r': '\\r',
  20.201 +            '"' : '\\"',
  20.202 +            '\\': '\\\\'
  20.203 +        },
  20.204 +        rep;
  20.205 +
  20.206 +
  20.207 +    function quote(string) {
  20.208 +
  20.209 +// If the string contains no control characters, no quote characters, and no
  20.210 +// backslash characters, then we can safely slap some quotes around it.
  20.211 +// Otherwise we must also replace the offending characters with safe escape
  20.212 +// sequences.
  20.213 +
  20.214 +        escapable.lastIndex = 0;
  20.215 +        return escapable.test(string) ?
  20.216 +            '"' + string.replace(escapable, function (a) {
  20.217 +                var c = meta[a];
  20.218 +                return typeof c === 'string' ? c :
  20.219 +                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
  20.220 +            }) + '"' :
  20.221 +            '"' + string + '"';
  20.222 +    }
  20.223 +
  20.224 +
  20.225 +    function str(key, holder) {
  20.226 +
  20.227 +// Produce a string from holder[key].
  20.228 +
  20.229 +        var i,          // The loop counter.
  20.230 +            k,          // The member key.
  20.231 +            v,          // The member value.
  20.232 +            length,
  20.233 +            mind = gap,
  20.234 +            partial,
  20.235 +            value = holder[key];
  20.236 +
  20.237 +// If the value has a toJSON method, call it to obtain a replacement value.
  20.238 +
  20.239 +        if (value && typeof value === 'object' &&
  20.240 +                typeof value.toJSON === 'function') {
  20.241 +            value = value.toJSON(key);
  20.242 +        }
  20.243 +
  20.244 +// If we were called with a replacer function, then call the replacer to
  20.245 +// obtain a replacement value.
  20.246 +
  20.247 +        if (typeof rep === 'function') {
  20.248 +            value = rep.call(holder, key, value);
  20.249 +        }
  20.250 +
  20.251 +// What happens next depends on the value's type.
  20.252 +
  20.253 +        switch (typeof value) {
  20.254 +        case 'string':
  20.255 +            return quote(value);
  20.256 +
  20.257 +        case 'number':
  20.258 +
  20.259 +// JSON numbers must be finite. Encode non-finite numbers as null.
  20.260 +
  20.261 +            return isFinite(value) ? String(value) : 'null';
  20.262 +
  20.263 +        case 'boolean':
  20.264 +        case 'null':
  20.265 +
  20.266 +// If the value is a boolean or null, convert it to a string. Note:
  20.267 +// typeof null does not produce 'null'. The case is included here in
  20.268 +// the remote chance that this gets fixed someday.
  20.269 +
  20.270 +            return String(value);
  20.271 +
  20.272 +// If the type is 'object', we might be dealing with an object or an array or
  20.273 +// null.
  20.274 +
  20.275 +        case 'object':
  20.276 +
  20.277 +// Due to a specification blunder in ECMAScript, typeof null is 'object',
  20.278 +// so watch out for that case.
  20.279 +
  20.280 +            if (!value) {
  20.281 +                return 'null';
  20.282 +            }
  20.283 +
  20.284 +// Make an array to hold the partial results of stringifying this object value.
  20.285 +
  20.286 +            gap += indent;
  20.287 +            partial = [];
  20.288 +
  20.289 +// Is the value an array?
  20.290 +
  20.291 +            if (Object.prototype.toString.apply(value) === '[object Array]') {
  20.292 +
  20.293 +// The value is an array. Stringify every element. Use null as a placeholder
  20.294 +// for non-JSON values.
  20.295 +
  20.296 +                length = value.length;
  20.297 +                for (i = 0; i < length; i += 1) {
  20.298 +                    partial[i] = str(i, value) || 'null';
  20.299 +                }
  20.300 +
  20.301 +// Join all of the elements together, separated with commas, and wrap them in
  20.302 +// brackets.
  20.303 +
  20.304 +                v = partial.length === 0 ? '[]' :
  20.305 +                    gap ? '[\n' + gap +
  20.306 +                            partial.join(',\n' + gap) + '\n' +
  20.307 +                                mind + ']' :
  20.308 +                          '[' + partial.join(',') + ']';
  20.309 +                gap = mind;
  20.310 +                return v;
  20.311 +            }
  20.312 +
  20.313 +// If the replacer is an array, use it to select the members to be stringified.
  20.314 +
  20.315 +            if (rep && typeof rep === 'object') {
  20.316 +                length = rep.length;
  20.317 +                for (i = 0; i < length; i += 1) {
  20.318 +                    k = rep[i];
  20.319 +                    if (typeof k === 'string') {
  20.320 +                        v = str(k, value);
  20.321 +                        if (v) {
  20.322 +                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
  20.323 +                        }
  20.324 +                    }
  20.325 +                }
  20.326 +            } else {
  20.327 +
  20.328 +// Otherwise, iterate through all of the keys in the object.
  20.329 +
  20.330 +                for (k in value) {
  20.331 +                    if (Object.hasOwnProperty.call(value, k)) {
  20.332 +                        v = str(k, value);
  20.333 +                        if (v) {
  20.334 +                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
  20.335 +                        }
  20.336 +                    }
  20.337 +                }
  20.338 +            }
  20.339 +
  20.340 +// Join all of the member texts together, separated with commas,
  20.341 +// and wrap them in braces.
  20.342 +
  20.343 +            v = partial.length === 0 ? '{}' :
  20.344 +                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
  20.345 +                        mind + '}' : '{' + partial.join(',') + '}';
  20.346 +            gap = mind;
  20.347 +            return v;
  20.348 +        }
  20.349 +    }
  20.350 +
  20.351 +// If the JSON object does not yet have a stringify method, give it one.
  20.352 +
  20.353 +    if (typeof JSON.stringify !== 'function') {
  20.354 +        JSON.stringify = function (value, replacer, space) {
  20.355 +
  20.356 +// The stringify method takes a value and an optional replacer, and an optional
  20.357 +// space parameter, and returns a JSON text. The replacer can be a function
  20.358 +// that can replace values, or an array of strings that will select the keys.
  20.359 +// A default replacer method can be provided. Use of the space parameter can
  20.360 +// produce text that is more easily readable.
  20.361 +
  20.362 +            var i;
  20.363 +            gap = '';
  20.364 +            indent = '';
  20.365 +
  20.366 +// If the space parameter is a number, make an indent string containing that
  20.367 +// many spaces.
  20.368 +
  20.369 +            if (typeof space === 'number') {
  20.370 +                for (i = 0; i < space; i += 1) {
  20.371 +                    indent += ' ';
  20.372 +                }
  20.373 +
  20.374 +// If the space parameter is a string, it will be used as the indent string.
  20.375 +
  20.376 +            } else if (typeof space === 'string') {
  20.377 +                indent = space;
  20.378 +            }
  20.379 +
  20.380 +// If there is a replacer, it must be a function or an array.
  20.381 +// Otherwise, throw an error.
  20.382 +
  20.383 +            rep = replacer;
  20.384 +            if (replacer && typeof replacer !== 'function' &&
  20.385 +                    (typeof replacer !== 'object' ||
  20.386 +                     typeof replacer.length !== 'number')) {
  20.387 +                throw new Error('JSON.stringify');
  20.388 +            }
  20.389 +
  20.390 +// Make a fake root object containing our value under the key of ''.
  20.391 +// Return the result of stringifying the value.
  20.392 +
  20.393 +            return str('', {'': value});
  20.394 +        };
  20.395 +    }
  20.396 +
  20.397 +
  20.398 +// If the JSON object does not yet have a parse method, give it one.
  20.399 +
  20.400 +    if (typeof JSON.parse !== 'function') {
  20.401 +        JSON.parse = function (text, reviver) {
  20.402 +
  20.403 +// The parse method takes a text and an optional reviver function, and returns
  20.404 +// a JavaScript value if the text is a valid JSON text.
  20.405 +
  20.406 +            var j;
  20.407 +
  20.408 +            function walk(holder, key) {
  20.409 +
  20.410 +// The walk method is used to recursively walk the resulting structure so
  20.411 +// that modifications can be made.
  20.412 +
  20.413 +                var k, v, value = holder[key];
  20.414 +                if (value && typeof value === 'object') {
  20.415 +                    for (k in value) {
  20.416 +                        if (Object.hasOwnProperty.call(value, k)) {
  20.417 +                            v = walk(value, k);
  20.418 +                            if (v !== undefined) {
  20.419 +                                value[k] = v;
  20.420 +                            } else {
  20.421 +                                delete value[k];
  20.422 +                            }
  20.423 +                        }
  20.424 +                    }
  20.425 +                }
  20.426 +                return reviver.call(holder, key, value);
  20.427 +            }
  20.428 +
  20.429 +
  20.430 +// Parsing happens in four stages. In the first stage, we replace certain
  20.431 +// Unicode characters with escape sequences. JavaScript handles many characters
  20.432 +// incorrectly, either silently deleting them, or treating them as line endings.
  20.433 +
  20.434 +            cx.lastIndex = 0;
  20.435 +            if (cx.test(text)) {
  20.436 +                text = text.replace(cx, function (a) {
  20.437 +                    return '\\u' +
  20.438 +                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
  20.439 +                });
  20.440 +            }
  20.441 +
  20.442 +// In the second stage, we run the text against regular expressions that look
  20.443 +// for non-JSON patterns. We are especially concerned with '()' and 'new'
  20.444 +// because they can cause invocation, and '=' because it can cause mutation.
  20.445 +// But just to be safe, we want to reject all unexpected forms.
  20.446 +
  20.447 +// We split the second stage into 4 regexp operations in order to work around
  20.448 +// crippling inefficiencies in IE's and Safari's regexp engines. First we
  20.449 +// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
  20.450 +// replace all simple value tokens with ']' characters. Third, we delete all
  20.451 +// open brackets that follow a colon or comma or that begin the text. Finally,
  20.452 +// we look to see that the remaining characters are only whitespace or ']' or
  20.453 +// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
  20.454 +
  20.455 +            if (/^[\],:{}\s]*$/.
  20.456 +test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
  20.457 +replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
  20.458 +replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
  20.459 +
  20.460 +// In the third stage we use the eval function to compile the text into a
  20.461 +// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
  20.462 +// in JavaScript: it can begin a block or an object literal. We wrap the text
  20.463 +// in parens to eliminate the ambiguity.
  20.464 +
  20.465 +                j = eval('(' + text + ')');
  20.466 +
  20.467 +// In the optional fourth stage, we recursively walk the new structure, passing
  20.468 +// each name/value pair to a reviver function for possible transformation.
  20.469 +
  20.470 +                return typeof reviver === 'function' ?
  20.471 +                    walk({'': j}, '') : j;
  20.472 +            }
  20.473 +
  20.474 +// If the text is not JSON parseable, then a SyntaxError is thrown.
  20.475 +
  20.476 +            throw new SyntaxError('JSON.parse');
  20.477 +        };
  20.478 +    }
  20.479 +}());
  20.480 +
  20.481 +
  20.482 +
  20.483 +
  20.484 +// JSON
  20.485 +function json(obj7)
  20.486 +{
  20.487 +    if (typeof(obj7) == 'string')
  20.488 +    {
  20.489 +        // раскодируем
  20.490 +        
  20.491 +        return JSON.parse(obj7);
  20.492 +    }
  20.493 +    else
  20.494 +    {
  20.495 +        // кодируем
  20.496 +        return JSON.stringify(obj7);
  20.497 +    }
  20.498 +}
  20.499 +
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/blocks3d/www/mainpanel.js	Fri Sep 17 21:52:33 2010 +0400
    21.3 @@ -0,0 +1,52 @@
    21.4 +
    21.5 +/////////////////////////////////////////
    21.6 +//     mainpanel
    21.7 +/////////////////////////////////////////
    21.8 +
    21.9 +
   21.10 +
   21.11 +
   21.12 +
   21.13 +/////////////////////////////////
   21.14 +//    mainpanel
   21.15 +/////////////////////////////////
   21.16 +
   21.17 +function mp_add(str)
   21.18 +{
   21.19 +    $('mainpanel').innerHTML += str;
   21.20 +}
   21.21 +
   21.22 +
   21.23 +
   21.24 +
   21.25 +////////////////////////////////////
   21.26 +//    mainpanel
   21.27 +////////////////////////////////////
   21.28 +
   21.29 +function mp_set(str)
   21.30 +{
   21.31 +    $('mainpanel').innerHTML = str;
   21.32 +}
   21.33 +
   21.34 +
   21.35 +
   21.36 +
   21.37 +////////////////////////////////////
   21.38 +//    status line
   21.39 +////////////////////////////////////
   21.40 +
   21.41 +function sl_set(str)
   21.42 +{
   21.43 +    $('statusline').innerHTML = str;
   21.44 +}
   21.45 +
   21.46 +
   21.47 +
   21.48 +///////////////////////////////////////
   21.49 +//  document.getElementById
   21.50 +///////////////////////////////////////
   21.51 +
   21.52 +function $(str)
   21.53 +{
   21.54 +    return document.getElementById(str);
   21.55 +}
   21.56 \ No newline at end of file
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/blocks3d/www/screen.js	Fri Sep 17 21:52:33 2010 +0400
    22.3 @@ -0,0 +1,45 @@
    22.4 +
    22.5 +///////////////////////
    22.6 +//   
    22.7 +///////////////////////
    22.8 +
    22.9 +function get_ww()
   22.10 +{
   22.11 +    var frameWidth = 800;
   22.12 +    
   22.13 +    if (self.innerWidth)
   22.14 +    {
   22.15 +        frameWidth = self.innerWidth;
   22.16 +    }
   22.17 +    else if (document.documentElement && document.documentElement.clientWidth)
   22.18 +    {
   22.19 +        frameWidth = document.documentElement.clientWidth;
   22.20 +    }
   22.21 +    else if (document.body)
   22.22 +    {
   22.23 +        frameWidth = document.body.clientWidth;
   22.24 +    }
   22.25 +    
   22.26 +    return frameWidth;
   22.27 +}
   22.28 +
   22.29 +
   22.30 +function get_wh()
   22.31 +{
   22.32 +    var frameHeight = 640;
   22.33 +    
   22.34 +    if (self.innerHeight)
   22.35 +    {
   22.36 +        frameHeight = self.innerHeight;
   22.37 +    }
   22.38 +    else if (document.documentElement && document.documentElement.clientHeight)
   22.39 +    {
   22.40 +        frameHeight = document.documentElement.clientHeight;
   22.41 +    }
   22.42 +    else if (document.body)
   22.43 +    {
   22.44 +        frameHeight = document.body.clientHeight;
   22.45 +    }
   22.46 +    
   22.47 +    return frameHeight;
   22.48 +} 
   22.49 \ No newline at end of file
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/blocks3d/www/top.php	Fri Sep 17 21:52:33 2010 +0400
    23.3 @@ -0,0 +1,64 @@
    23.4 +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    23.5 +<html>
    23.6 +<head>
    23.7 +
    23.8 +<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    23.9 +
   23.10 +<title>Blocks</title>
   23.11 +
   23.12 +<style type="text/css"> 
   23.13 +<!--
   23.14 +
   23.15 +
   23.16 +[inc_css]css.css
   23.17 +
   23.18 +-->
   23.19 +</style>
   23.20 +
   23.21 +
   23.22 +
   23.23 +</head>
   23.24 +
   23.25 + 
   23.26 +<body onload=blocks_init()>
   23.27 +
   23.28 +
   23.29 +    
   23.30 +<table width=100% cellpadding=0 cellspacing=0>
   23.31 +    
   23.32 +
   23.33 +
   23.34 +    <tr align=left valign=top>
   23.35 +        
   23.36 +        <td colspan=2>
   23.37 +            <div id="h1_header"><h1>Reliable blocks finding</h1></div>
   23.38 +        </td>
   23.39 +
   23.40 +
   23.41 +    
   23.42 +    <tr align=left valign=top>
   23.43 +        
   23.44 +        <td colspan=2>
   23.45 +            <div id="mainpanel"> Enable Javascript!</div>
   23.46 +        </td>
   23.47 +
   23.48 +    <tr align=left valign=top>
   23.49 +        
   23.50 +        <td>
   23.51 +        </td>
   23.52 +        
   23.53 +        <td>
   23.54 +            <div id="legend"></div>
   23.55 +        </td>
   23.56 +        
   23.57 +    <tr align=left valign=top>
   23.58 +        
   23.59 +        <td>
   23.60 +            <div id="IDs"></div>
   23.61 +        </td>
   23.62 +        
   23.63 +        <td>
   23.64 +            <div id="alignment" onscroll="alignment_onscroll()"></div>
   23.65 +        </td>
   23.66 +    
   23.67 +</table>