Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/rev/61e5d8e146c7
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 01:17:43 2012
Кодировка:
allpy: 61e5d8e146c7

allpy

changeset 806:61e5d8e146c7

WARNING! Changed EOL formatting to UNIX everywhere! WARNING! To avoid such nasty commits in the future, add the following lines to your ~/.hgrc: [extensions] hgext.eol = Note: kodomo has this setting on by default. Please also note .hgeol file, that has rules for EOL conversion.
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Thu, 14 Jul 2011 14:28:32 +0400
parents b894c8421a60
children 3312472eb920
files .hgeol allpy/data/blossum62.py allpy/homology.py blocks3d/wt/files/js/jquery.countdown.pack.js blocks3d/www/input/blocks.js blocks3d/www/input/crc32.js blocks3d/www/input/crc32_color.js blocks3d/www/input/dechex.js blocks3d/www/input/index.txt blocks3d/www/input/json2.js sandbox/bufferedcanvas.py sandbox/gl.py sandbox/ttk.py sandbox/wx-dc.py sandbox/wx-textctrl.py test/1jcc_in.fasta utils/make_homologies.py utils/make_homology.py
diffstat 18 files changed, 2143 insertions(+), 2128 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/.hgeol	Thu Jul 14 14:28:32 2011 +0400
     1.3 @@ -0,0 +1,15 @@
     1.4 +[patterns]
     1.5 +**.py = native
     1.6 +**.txt = native
     1.7 +**.html = native
     1.8 +**.css = native
     1.9 +**.js = native
    1.10 +**.fasta = native
    1.11 +**.rst = native
    1.12 +**.tcl = native
    1.13 +**.C = native
    1.14 +**.h = native
    1.15 +debian/** = native
    1.16 +Makefile = native
    1.17 +README* = native
    1.18 +NEWS = native
     2.1 --- a/allpy/data/blossum62.py	Thu Jul 14 14:05:39 2011 +0400
     2.2 +++ b/allpy/data/blossum62.py	Thu Jul 14 14:28:32 2011 +0400
     2.3 @@ -1,28 +1,28 @@
     2.4 -matrix = {
     2.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},
     2.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},
     2.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},
     2.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},
     2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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},
    2.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}
    2.29 -}
    2.30 -
    2.31 -gaps = (-8, -4, -2, -1)
    2.32 +matrix = {
    2.33 +"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},
    2.34 +"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},
    2.35 +"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},
    2.36 +"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},
    2.37 +"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},
    2.38 +"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},
    2.39 +"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},
    2.40 +"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},
    2.41 +"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},
    2.42 +"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},
    2.43 +"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},
    2.44 +"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},
    2.45 +"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},
    2.46 +"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},
    2.47 +"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},
    2.48 +"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},
    2.49 +"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},
    2.50 +"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},
    2.51 +"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},
    2.52 +"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},
    2.53 +"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},
    2.54 +"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},
    2.55 +"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},
    2.56 +"*": {"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}
    2.57 +}
    2.58 +
    2.59 +gaps = (-8, -4, -2, -1)
     3.1 --- a/allpy/homology.py	Thu Jul 14 14:05:39 2011 +0400
     3.2 +++ b/allpy/homology.py	Thu Jul 14 14:28:32 2011 +0400
     3.3 @@ -1,485 +1,485 @@
     3.4 -from allpy import protein
     3.5 -from allpy import markups
     3.6 -
     3.7 -
     3.8 -
     3.9 -
    3.10 -class  MonomerHomology(object):
    3.11 -    """ Essentially, alignment is a set of monomer homology classes.
    3.12 -    Object of type MonomerHomology desribes an alignment  in terms of monomer homology. 
    3.13 -    Each monomer of any sequence from an alignment must be contained in a homology class
    3.14 -
    3.15 -    Homology of nonequal monomers of the same sequence is allowed (formally) in attributes, 
    3.16 -        but there is no implemented methods to deal with 
    3.17 -
    3.18 -    DATA:
    3.19 -        monomer_ids = {monomer_id:class_id}
    3.20 -            monomer_id = (sequence_name, monomer_number)
    3.21 -                monomer_number is a number of the monomer in the sequence
    3.22 -            class_id = string 
    3.23 -        classes     = {class_id:[monomer_id1, monomer_id2,...], ...}
    3.24 -        columns = {class_id:column_number}
    3.25 -        blocks_data = [block_data, ...]
    3.26 -        block_data = (sequence_names,class_ids)
    3.27 -            sequence_names = set( [sequence_1_name,...] )
    3.28 -            class_ids = = set( [class_1_id, ...] )
    3.29 -
    3.30 -     block_data contain identifiers of objects only, alignment object is not needed.
    3.31 -     block_data may be converted to bloks of an alignment by appropriate method
    3.32 -
    3.33 -    METHODS:
    3.34 -       + .read(file_name, columns = True)
    3.35 -               Reads file of monomer homology format into MonomerHomology object.
    3.36 -       + .write_monomer(file,monomer_id,monomer_homology_class_id, column_number = column_number)   STATIC
    3.37 -       + .write_class(file,list_of_monomer_ids,monomer_homology_class_id,column_number = column_number)  STATIC
    3.38 -       + .write_block(file, alignment, block)
    3.39 -       + .add_monomer(monomer_id,class_id,column_number)
    3.40 -       + .add_class(monomer_ids,class_id, column_number)
    3.41 -       + .add_block(alignment, block)
    3.42 -       + .compare_with(class)
    3.43 -           + .two_vs_one(classes_one, classes_two)  STATIC
    3.44 -       + .highest_blocks()
    3.45 -       + .alignment_blocks(alignment)
    3.46 -       + .case_homology(in_file_name,out_file_name, case)  STATIC
    3.47 -    """
    3.48 -    def __init__(self, next_class_id = 1):
    3.49 -         self.classes = {}
    3.50 -         self.monomer_ids = {}
    3.51 -         self.columns = {}
    3.52 -         self.blocks_data = []
    3.53 -         self.next_class_id = next_class_id
    3.54 -
    3.55 -################################################################
    3.56 -
    3.57 -    def read(self, file_name, columns = False):
    3.58 -        """
    3.59 -        Monomer_homology file format is as follows
    3.60 -           One line corresponds to one monomer. 
    3.61 -               Thus, number of lines with information is equal to the sum of all sequences lengths
    3.62 -           Three obligatory fields are in each line:
    3.63 -               - homology_class_id   (string)  arbitrary
    3.64 -               - sequence_id         (string)  sequence.name is used as sequence id    
    3.65 -               - monomer_number      (integer) number in the sequence, 1, 2, ...
    3.66 -           If columns:
    3.67 -               - column_number
    3.68 -        Everything from "#" to the line end is ignored
    3.69 -        Fields are delimited by white spaces
    3.70 -        Empty lines (only white speces in the line) are skipped
    3.71 -
    3.72 -        RETURN total number of monomers
    3.73 -        """ 
    3.74 -        try:
    3.75 -            f = open(file_name)
    3.76 -        except:
    3.77 -            raise Exception("Failed to open file %s" % file_name) 
    3.78 -            exit()
    3.79 -
    3.80 -        monomers_count = 0
    3.81 -
    3.82 -        for line in f:
    3.83 -            line = line.strip()
    3.84 -            if len(line) == 0:
    3.85 -                continue
    3.86 -            line = line.split('#')[0]
    3.87 -            if len(line) == 0:
    3.88 -                continue
    3.89 -            line_split = line.split()
    3.90 -
    3.91 -            try:
    3.92 -                class_id = line_split[0]
    3.93 -                sequence_id = line_split[1]
    3.94 -                monomer_number = int(line_split[2])
    3.95 -                if columns:
    3.96 -                    column_number = int(line_split[3])
    3.97 -            except:
    3.98 -                raise Exception("Wrong format in line %s of file %s! Line skipped" % (line, file_name))
    3.99 -                continue
   3.100 -
   3.101 -            self.monomer_ids[(sequence_id,monomer_number)] = class_id 
   3.102 -
   3.103 -            if class_id in self.classes:
   3.104 -                self.classes[class_id].append( (sequence_id,monomer_number) )
   3.105 -            else:
   3.106 -                self.classes[class_id] = [(sequence_id,monomer_number)]
   3.107 -
   3.108 -            if columns:
   3.109 -                if not (class_id in self.columns):
   3.110 -                    self.columns[class_id] = column_number
   3.111 -                    
   3.112 -            monomers_count += 1
   3.113 -        f.close()
   3.114 -        return monomers_count 
   3.115 -
   3.116 -################################################################
   3.117 -
   3.118 -    @staticmethod
   3.119 -    def  two_vs_one(classes_one, classes_two):
   3.120 -        """ Computes weighted average number of mistakes of classes_two with respect to classes_one 
   3.121 -        May be used as external function
   3.122 -        See compare_with help for more details
   3.123 -        Actually, sizes of intersections are computed and store in class_one_splits but not used
   3.124 -        """
   3.125 -        classes_one_size = len(classes_one.monomer_ids)
   3.126 -        classes_two_size = len(classes_two.monomer_ids)
   3.127 -
   3.128 -
   3.129 -        if classes_one_size !=  classes_two_size:
   3.130 -            raise Exception("Comparing sets of monomers are not equal! Check input data.")
   3.131 -            exit()           
   3.132 -
   3.133 -        weighted_mistakes = 0.0 
   3.134 -
   3.135 -
   3.136 -        for class_one in classes_one.classes:
   3.137 -
   3.138 -            class_one_size = len(classes_one.classes[class_one])
   3.139 -            class_one_splits = {}
   3.140 -
   3.141 -            class_one_monomer_ids = classes_one.classes[class_one]
   3.142 -
   3.143 -       
   3.144 -            for monomer_id in class_one_monomer_ids:
   3.145 -
   3.146 -
   3.147 -                 try:
   3.148 -                     class_two_id = classes_two.monomer_ids[monomer_id]
   3.149 -                 except:
   3.150 -                     raise Exception("Comparing sets of monomers are not equal!! Check input data.")
   3.151 -                     exit()
   3.152 -
   3.153 -                 if class_two_id in class_one_splits:
   3.154 -                     class_one_splits[class_two_id] += 1
   3.155 -                 else:
   3.156 -                     class_one_splits[class_two_id] = 1
   3.157 -            splitting_number = len(class_one_splits)
   3.158 -            weighted_mistakes += float(splitting_number-1)* float(class_one_size)/float(classes_one_size)
   3.159 -
   3.160 -        return weighted_mistakes
   3.161 -
   3.162 -    
   3.163 -    def compare_with(self,other): 
   3.164 -        """Compares two monomer homology classes made on the same set of sequences: self and other 
   3.165 -        Both sets of classes MUST contain isomorfic sets of monomer_ids 
   3.166 -       
   3.167 -        RETURN two weighted averege number of mistakes: other vs self and self vs other
   3.168 -            Number of mistakes other vs self in a homology class of self is
   3.169 -                number of classes of other intersecting with the class of self minus one
   3.170 -                In other words, one mistake of other is splitting a class of self 
   3.171 -                    (believed to be true monomer homology class) into two classes
   3.172 -           Wieght of a class of self is size of the class divided by total number of monomeres.
   3.173 -       
   3.174 -        Different mesures and outputs may be implemented later.
   3.175 -        """
   3.176 -
   3.177 -        mistakes_two_vs_one = MonomerHomology.two_vs_one(self, other) # mistakes are splitting self by intersections with other
   3.178 -        mistakes_one_vs_two = MonomerHomology.two_vs_one(other, self) # mistakes are splitting other by intersections with self
   3.179 -
   3.180 -        return (mistakes_two_vs_one, mistakes_one_vs_two)
   3.181 -
   3.182 -################################################################
   3.183 -
   3.184 -    @staticmethod
   3.185 -    def write_class(file,monomer_ids,class_id, column_number = False):
   3.186 -        """ Writes list of monomer_ids forming one homology_class
   3.187 -        """
   3.188 -        for monomer_id in monomer_ids:
   3.189 -            MonomerHomology.write_monomer(file,monomer_id,class_id, column_number = column_number)
   3.190 -
   3.191 -
   3.192 -    def add_class(self,monomer_ids,class_id, column_number):
   3.193 -        """ Adds list of monomer_ids forming one homology_class
   3.194 -        """
   3.195 -        for monomer_id in monomer_ids:
   3.196 -            self.add_monomer(monomer_id,class_id, column_number)
   3.197 -
   3.198 -
   3.199 -
   3.200 -
   3.201 -#################################################################      
   3.202 -
   3.203 -    def add_monomer(self,monomer_id,class_id,column_number):
   3.204 -        """ Add one monomer to Homology 
   3.205 -        """
   3.206 -        if len(monomer_id) != 2:
   3.207 -            raise Exception("wrong parameters given for Monomer_homology.write_monomer: len(monomer_id) is not 2!") 
   3.208 -            exit()
   3.209 -        self.monomer_ids[monomer_id] = class_id
   3.210 -
   3.211 -        if class_id in self.classes:
   3.212 -             self.classes[class_id].append(monomer_id) 
   3.213 -        else:
   3.214 -             self.classes[class_id] = [monomer_id]
   3.215 -
   3.216 -        self.columns[class_id] = column_number
   3.217 -
   3.218 -    @staticmethod
   3.219 -    def write_monomer(file, monomer_id, class_id, column_number = False):
   3.220 -        """ Write a line "class_id sequence_id  monome number \n"  into file
   3.221 -        """
   3.222 -        if len(monomer_id) != 2:
   3.223 -            raise Exception("wrong parameters given for Monomer_homology.write_monomer: len(monomer_id) is not 2!") 
   3.224 -            exit()
   3.225 -        try:
   3.226 -            if column_number:
   3.227 -                file.write("%s\t%s\t%s\t%s\n" % (class_id,monomer_id[0], monomer_id[1], column_number)) 
   3.228 -            else:
   3.229 -                file.write("%s\t%s\t%s\n" % (class_id,monomer_id[0], monomer_id[1]) ) 
   3.230 -
   3.231 -        except:
   3.232 -            raise Exception("Failed to write monomer into file!") 
   3.233 -            exit()
   3.234 -
   3.235 -
   3.236 -#################################################################      
   3.237 -
   3.238 -    def add_block(self,alignment, block):
   3.239 -        """ Add classes of plus-block to Homology
   3.240 -        """
   3.241 -        for column in block.columns:
   3.242 -            if len(column) == 0:
   3.243 -                continue
   3.244 -
   3.245 -            try:
   3.246 -                column_number = alignment.markups['number'][column]
   3.247 -            except:
   3.248 -                raise Exception("Alignment column has no number! Alignment must be marked up by numbers before .add_block")   
   3.249 -                exit()
   3.250 -
   3.251 -            for sequence in block.sequences:
   3.252 -                if sequence in column:
   3.253 -
   3.254 -                    try: 
   3.255 -                        monomer_id = (sequence.name, column[sequence].number) 
   3.256 -                    except:
   3.257 -                        raise Exception("Monomer has no number! Sequences must be marked up by numbers before .writ_block") 
   3.258 -                        exit()
   3.259 -
   3.260 -                    self.add_monomer(monomer_id,self.next_class_id, column_number)
   3.261 -
   3.262 -            self.next_class_id +=1
   3.263 -
   3.264 -
   3.265 -         
   3.266 -
   3.267 -
   3.268 -    def write_block(self,file,alignment, block, markedup = True):    
   3.269 -        """ Writes each block column into as one homology class
   3.270 -        WARRNINGS: 
   3.271 -            (1) method works in object of class MonomerHomology
   3.272 -            (2) all sequences MUST BE MARKED UP with resudue NUMBERS!
   3.273 -            (3) automatic class ids (actually, numbers) are assigned to homology classes
   3.274 -            (4) if markedup, then block MUST be marked up by column numbers 
   3.275 -
   3.276 -        Block may contain "gaps"
   3.277 -        """
   3.278 -        for column in block.columns:
   3.279 -
   3.280 -            if len(column) == 0:
   3.281 -                continue
   3.282 -
   3.283 -            if markedup:
   3.284 -                column_number = alignment.markups['number'][column]
   3.285 -            else:
   3.286 -                column_number = False
   3.287 -
   3.288 -            for sequence in block.sequences:
   3.289 -
   3.290 -                if sequence in column:
   3.291 -
   3.292 -                    try: 
   3.293 -                        monomer_id = (sequence.name, column[sequence].number) 
   3.294 -                    except:
   3.295 -                        raise Exception("Monomer has no number! Sequences must be marked up by numbers before .writ_block") 
   3.296 -                        exit()
   3.297 -                    MonomerHomology.write_monomer(file,monomer_id,self.next_class_id, column_number = column_number)
   3.298 -
   3.299 -            self.next_class_id +=1
   3.300 -
   3.301 -################################################################# 
   3.302 -
   3.303 -    def _sequences_of_class(self,monomer_ids):
   3.304 -        """  RETURN set of sequences from a list of monomer_ids
   3.305 -        """
   3.306 -        set_sequences = set()
   3.307 -        for x in monomer_ids:
   3.308 -            set_sequences.add(x[0])
   3.309 -        return set_sequences
   3.310 -
   3.311 -
   3.312 -    def highest_blocks(self):
   3.313 -        """ Makes blocks of maximal possible heights from monomer homology classes
   3.314 -        block = set of homology classes with the same set of sequences
   3.315 -        block MUST BE marked up by column numbers
   3.316 -
   3.317 -        blocks_data = [block_data, ...]
   3.318 -        block_data = (sequence_names,class_ids)
   3.319 -            sequence_names = set( [sequence_1_name,...] )
   3.320 -            class_ids = = set( [class_1_id, ...] )
   3.321 -
   3.322 -
   3.323 -        RETURN: self.blocks
   3.324 -
   3.325 -        """
   3.326 -        class_ids = list(self.classes)
   3.327 -        class_ids.sort()
   3.328 -        self.blocks_data = []
   3.329 -        block_number = 0
   3.330 -
   3.331 -        for i in range(len(class_ids)):
   3.332 -            class_id_1 = class_ids[i]
   3.333 -
   3.334 -            if type(class_id_1) == type(tuple()):
   3.335 -                continue
   3.336 -
   3.337 -            block_number += 1
   3.338 -            try: 
   3.339 -                column_number = self.columns[class_id_1]
   3.340 -            except:
   3.341 -                raise Exception("Fail to get column_number! Homology classes must be marked to creats highest blocks") 
   3.342 -
   3.343 -            # NEW BLOCK
   3.344 -
   3.345 -            set_sequences_1 = self._sequences_of_class(self.classes[class_id_1])
   3.346 -      
   3.347 -            self.blocks_data.append( (set_sequences_1, set([class_id_1]) ) ) 
   3.348 -            class_ids[i] = (class_id_1,i)
   3.349 -
   3.350 -            # ADD classes to BLOCK
   3.351 -            for j in range(i+1,len(class_ids)):
   3.352 -                class_id_2 = class_ids[j]
   3.353 -
   3.354 -                if type(class_id_2) == type(tuple()):
   3.355 -                    continue
   3.356 -
   3.357 -                set_sequences_2 = self._sequences_of_class(self.classes[class_id_2])
   3.358 -
   3.359 -                if set_sequences_2 == set_sequences_1:
   3.360 -                    try:
   3.361 -                        column_number = self.columns[class_id_2]
   3.362 -                    except:                                                                                                  
   3.363 -                        raise Exception("Fail to get column_number! Homology classes must be marked to creats hiest blocks") 
   3.364 -                    class_ids[j] = (class_id_2, j)
   3.365 -                    self.blocks_data[len(self.blocks_data)-1][1].add( class_id_2)
   3.366 -
   3.367 -        return self.blocks_data 
   3.368 -
   3.369 -################################################################
   3.370 -
   3.371 -    def alignment_blocks(self, alignment):
   3.372 -        """ From homology.blocks creates a list of alignment blocks (accessible for visualization) 
   3.373 -
   3.374 -        blocks_data = [block_data, ...]
   3.375 -        block_data = (sequence_names,class_ids)
   3.376 -            sequence_names = set( [sequence_1_name,...] )
   3.377 -            class_ids = = set( [class_1_id, ...] )
   3.378 -        RETURN blocks, list of blocks in alignment 
   3.379 -
   3.380 -        """
   3.381 -        blocks = []
   3.382 -        dict_sequences = {}
   3.383 -        for sequence in alignment.sequences:
   3.384 -            dict_sequences[sequence.name]=sequence 
   3.385 -
   3.386 -        dict_columns = {}
   3.387 -        for column in alignment.columns:
   3.388 -            try:
   3.389 -                dict_columns[alignment.markups['number'][column]] = column
   3.390 -            except:
   3.391 -                raise Exception("alignment columns are not marked up by numbers! Can't creat block from blocks data")
   3.392 -                exit()
   3.393 -
   3.394 -        for block_data in self.blocks_data:
   3.395 -            set_sequence_names = block_data[0]
   3.396 -            set_class_ids = block_data[1]
   3.397 -
   3.398 -            block_sequences = []
   3.399 -
   3.400 -            for sequence_name in set_sequence_names:
   3.401 -
   3.402 -                try:
   3.403 -                    s = dict_sequences[sequence_name]
   3.404 -                    block_sequences.append(s)
   3.405 -                except:
   3.406 -                    raise Exception("Sequence name %s from block data is not in alignment sequences!" % sequence_name)
   3.407 -                    exit()
   3.408 -
   3.409 -            block_columns = []
   3.410 -            for class_id in set_class_ids:
   3.411 -                column_number = self.columns[class_id]
   3.412 -                try:
   3.413 -                    block_columns.append(dict_columns[column_number])
   3.414 -                except:
   3.415 -                    raise Exception("Column number %s from block data is not in alignment columns numbers!" % column_number)
   3.416 -                    exit()
   3.417 -
   3.418 -            block = protein.Block.from_alignment(alignment, sequences = block_sequences, columns = block_columns)
   3.419 -            blocks.append(block)
   3.420 -        return blocks
   3.421 -
   3.422 -#################################################################
   3.423 -    @staticmethod
   3.424 -    def case_homology(in_file_name,out_file_name, case = False, format = 'fasta'):
   3.425 -        """ Makes homology file from input alignment
   3.426 -        case = True => Upper letters in a column are in one class, each lower letter in separate class
   3.427 -        case = False => all letter in a column are in one class
   3.428 -
   3.429 -        RETURN number of classes
   3.430 -        """
   3.431 -        try: 
   3.432 -            f = open(in_file_name) 
   3.433 -        except:
   3.434 -            raise Exception("Failed to open file %s" % in_file_name)
   3.435 -            exit()
   3.436 -        try:
   3.437 -            print format
   3.438 -            alignment = protein.Alignment().append_file(f, format=format) 
   3.439 -            f.close()
   3.440 -        except:
   3.441 -            raise Exception("Failed to create alignment from file %s, format %s!" % (in_file_name,format) )
   3.442 -            exit()
   3.443 -        try:  
   3.444 -            g = open(out_file_name, 'w')
   3.445 -        except:
   3.446 -            raise Exception("Failed to open output file %s!" % out_file_name)
   3.447 -            exit()
   3.448 -    
   3.449 -    # MARKUPING    
   3.450 -        markups.AlignmentNumberMarkup(alignment)
   3.451 -    
   3.452 -        for sequence in alignment.sequences: 
   3.453 -            markups.SequenceNumberMarkup(sequence)
   3.454 -            if case and format != "markup":
   3.455 -                markups.SequenceCaseMarkup(sequence)
   3.456 -        
   3.457 -    
   3.458 -    #letters = ''.join(v[0] for v in seq.markups['case'].as_list())
   3.459 -    
   3.460 -    # WRITING CLASSES    
   3.461 -        next_class_id = 1
   3.462 -    
   3.463 -        for column in alignment.columns: 
   3.464 -            column_number = alignment.markups['number'][column]
   3.465 -            column_class = []
   3.466 -    
   3.467 -            for sequence in column:
   3.468 -                monomer = column[sequence]
   3.469 -                monomer_id = (sequence.name, monomer.number) 
   3.470 -                if case:
   3.471 -                    if monomer.case == "lower":              
   3.472 -                        MonomerHomology.write_monomer(g,monomer_id,next_class_id,column_number)
   3.473 -                        next_class_id += 1
   3.474 -                        continue
   3.475 -                column_class.append(monomer_id) 
   3.476 -    
   3.477 -            if len(column_class) > 0:
   3.478 -                MonomerHomology.write_class(g,column_class,next_class_id, column_number)
   3.479 -                next_class_id += 1
   3.480 -    
   3.481 -        g.close()    
   3.482 -        return next_class_id - 1
   3.483 -
   3.484 -################################################################
   3.485 -
   3.486 -
   3.487 -
   3.488 -
   3.489 +from allpy import protein
   3.490 +from allpy import markups
   3.491 +
   3.492 +
   3.493 +
   3.494 +
   3.495 +class  MonomerHomology(object):
   3.496 +    """ Essentially, alignment is a set of monomer homology classes.
   3.497 +    Object of type MonomerHomology desribes an alignment  in terms of monomer homology.
   3.498 +    Each monomer of any sequence from an alignment must be contained in a homology class
   3.499 +
   3.500 +    Homology of nonequal monomers of the same sequence is allowed (formally) in attributes,
   3.501 +        but there is no implemented methods to deal with
   3.502 +
   3.503 +    DATA:
   3.504 +        monomer_ids = {monomer_id:class_id}
   3.505 +            monomer_id = (sequence_name, monomer_number)
   3.506 +                monomer_number is a number of the monomer in the sequence
   3.507 +            class_id = string
   3.508 +        classes     = {class_id:[monomer_id1, monomer_id2,...], ...}
   3.509 +        columns = {class_id:column_number}
   3.510 +        blocks_data = [block_data, ...]
   3.511 +        block_data = (sequence_names,class_ids)
   3.512 +            sequence_names = set( [sequence_1_name,...] )
   3.513 +            class_ids = = set( [class_1_id, ...] )
   3.514 +
   3.515 +     block_data contain identifiers of objects only, alignment object is not needed.
   3.516 +     block_data may be converted to bloks of an alignment by appropriate method
   3.517 +
   3.518 +    METHODS:
   3.519 +       + .read(file_name, columns = True)
   3.520 +               Reads file of monomer homology format into MonomerHomology object.
   3.521 +       + .write_monomer(file,monomer_id,monomer_homology_class_id, column_number = column_number)   STATIC
   3.522 +       + .write_class(file,list_of_monomer_ids,monomer_homology_class_id,column_number = column_number)  STATIC
   3.523 +       + .write_block(file, alignment, block)
   3.524 +       + .add_monomer(monomer_id,class_id,column_number)
   3.525 +       + .add_class(monomer_ids,class_id, column_number)
   3.526 +       + .add_block(alignment, block)
   3.527 +       + .compare_with(class)
   3.528 +           + .two_vs_one(classes_one, classes_two)  STATIC
   3.529 +       + .highest_blocks()
   3.530 +       + .alignment_blocks(alignment)
   3.531 +       + .case_homology(in_file_name,out_file_name, case)  STATIC
   3.532 +    """
   3.533 +    def __init__(self, next_class_id = 1):
   3.534 +         self.classes = {}
   3.535 +         self.monomer_ids = {}
   3.536 +         self.columns = {}
   3.537 +         self.blocks_data = []
   3.538 +         self.next_class_id = next_class_id
   3.539 +
   3.540 +################################################################
   3.541 +
   3.542 +    def read(self, file_name, columns = False):
   3.543 +        """
   3.544 +        Monomer_homology file format is as follows
   3.545 +           One line corresponds to one monomer.
   3.546 +               Thus, number of lines with information is equal to the sum of all sequences lengths
   3.547 +           Three obligatory fields are in each line:
   3.548 +               - homology_class_id   (string)  arbitrary
   3.549 +               - sequence_id         (string)  sequence.name is used as sequence id
   3.550 +               - monomer_number      (integer) number in the sequence, 1, 2, ...
   3.551 +           If columns:
   3.552 +               - column_number
   3.553 +        Everything from "#" to the line end is ignored
   3.554 +        Fields are delimited by white spaces
   3.555 +        Empty lines (only white speces in the line) are skipped
   3.556 +
   3.557 +        RETURN total number of monomers
   3.558 +        """
   3.559 +        try:
   3.560 +            f = open(file_name)
   3.561 +        except:
   3.562 +            raise Exception("Failed to open file %s" % file_name)
   3.563 +            exit()
   3.564 +
   3.565 +        monomers_count = 0
   3.566 +
   3.567 +        for line in f:
   3.568 +            line = line.strip()
   3.569 +            if len(line) == 0:
   3.570 +                continue
   3.571 +            line = line.split('#')[0]
   3.572 +            if len(line) == 0:
   3.573 +                continue
   3.574 +            line_split = line.split()
   3.575 +
   3.576 +            try:
   3.577 +                class_id = line_split[0]
   3.578 +                sequence_id = line_split[1]
   3.579 +                monomer_number = int(line_split[2])
   3.580 +                if columns:
   3.581 +                    column_number = int(line_split[3])
   3.582 +            except:
   3.583 +                raise Exception("Wrong format in line %s of file %s! Line skipped" % (line, file_name))
   3.584 +                continue
   3.585 +
   3.586 +            self.monomer_ids[(sequence_id,monomer_number)] = class_id
   3.587 +
   3.588 +            if class_id in self.classes:
   3.589 +                self.classes[class_id].append( (sequence_id,monomer_number) )
   3.590 +            else:
   3.591 +                self.classes[class_id] = [(sequence_id,monomer_number)]
   3.592 +
   3.593 +            if columns:
   3.594 +                if not (class_id in self.columns):
   3.595 +                    self.columns[class_id] = column_number
   3.596 +
   3.597 +            monomers_count += 1
   3.598 +        f.close()
   3.599 +        return monomers_count
   3.600 +
   3.601 +################################################################
   3.602 +
   3.603 +    @staticmethod
   3.604 +    def  two_vs_one(classes_one, classes_two):
   3.605 +        """ Computes weighted average number of mistakes of classes_two with respect to classes_one
   3.606 +        May be used as external function
   3.607 +        See compare_with help for more details
   3.608 +        Actually, sizes of intersections are computed and store in class_one_splits but not used
   3.609 +        """
   3.610 +        classes_one_size = len(classes_one.monomer_ids)
   3.611 +        classes_two_size = len(classes_two.monomer_ids)
   3.612 +
   3.613 +
   3.614 +        if classes_one_size !=  classes_two_size:
   3.615 +            raise Exception("Comparing sets of monomers are not equal! Check input data.")
   3.616 +            exit()
   3.617 +
   3.618 +        weighted_mistakes = 0.0
   3.619 +
   3.620 +
   3.621 +        for class_one in classes_one.classes:
   3.622 +
   3.623 +            class_one_size = len(classes_one.classes[class_one])
   3.624 +            class_one_splits = {}
   3.625 +
   3.626 +            class_one_monomer_ids = classes_one.classes[class_one]
   3.627 +
   3.628 +
   3.629 +            for monomer_id in class_one_monomer_ids:
   3.630 +
   3.631 +
   3.632 +                 try:
   3.633 +                     class_two_id = classes_two.monomer_ids[monomer_id]
   3.634 +                 except:
   3.635 +                     raise Exception("Comparing sets of monomers are not equal!! Check input data.")
   3.636 +                     exit()
   3.637 +
   3.638 +                 if class_two_id in class_one_splits:
   3.639 +                     class_one_splits[class_two_id] += 1
   3.640 +                 else:
   3.641 +                     class_one_splits[class_two_id] = 1
   3.642 +            splitting_number = len(class_one_splits)
   3.643 +            weighted_mistakes += float(splitting_number-1)* float(class_one_size)/float(classes_one_size)
   3.644 +
   3.645 +        return weighted_mistakes
   3.646 +
   3.647 +
   3.648 +    def compare_with(self,other):
   3.649 +        """Compares two monomer homology classes made on the same set of sequences: self and other
   3.650 +        Both sets of classes MUST contain isomorfic sets of monomer_ids
   3.651 +
   3.652 +        RETURN two weighted averege number of mistakes: other vs self and self vs other
   3.653 +            Number of mistakes other vs self in a homology class of self is
   3.654 +                number of classes of other intersecting with the class of self minus one
   3.655 +                In other words, one mistake of other is splitting a class of self
   3.656 +                    (believed to be true monomer homology class) into two classes
   3.657 +           Wieght of a class of self is size of the class divided by total number of monomeres.
   3.658 +
   3.659 +        Different mesures and outputs may be implemented later.
   3.660 +        """
   3.661 +
   3.662 +        mistakes_two_vs_one = MonomerHomology.two_vs_one(self, other) # mistakes are splitting self by intersections with other
   3.663 +        mistakes_one_vs_two = MonomerHomology.two_vs_one(other, self) # mistakes are splitting other by intersections with self
   3.664 +
   3.665 +        return (mistakes_two_vs_one, mistakes_one_vs_two)
   3.666 +
   3.667 +################################################################
   3.668 +
   3.669 +    @staticmethod
   3.670 +    def write_class(file,monomer_ids,class_id, column_number = False):
   3.671 +        """ Writes list of monomer_ids forming one homology_class
   3.672 +        """
   3.673 +        for monomer_id in monomer_ids:
   3.674 +            MonomerHomology.write_monomer(file,monomer_id,class_id, column_number = column_number)
   3.675 +
   3.676 +
   3.677 +    def add_class(self,monomer_ids,class_id, column_number):
   3.678 +        """ Adds list of monomer_ids forming one homology_class
   3.679 +        """
   3.680 +        for monomer_id in monomer_ids:
   3.681 +            self.add_monomer(monomer_id,class_id, column_number)
   3.682 +
   3.683 +
   3.684 +
   3.685 +
   3.686 +#################################################################
   3.687 +
   3.688 +    def add_monomer(self,monomer_id,class_id,column_number):
   3.689 +        """ Add one monomer to Homology
   3.690 +        """
   3.691 +        if len(monomer_id) != 2:
   3.692 +            raise Exception("wrong parameters given for Monomer_homology.write_monomer: len(monomer_id) is not 2!")
   3.693 +            exit()
   3.694 +        self.monomer_ids[monomer_id] = class_id
   3.695 +
   3.696 +        if class_id in self.classes:
   3.697 +             self.classes[class_id].append(monomer_id)
   3.698 +        else:
   3.699 +             self.classes[class_id] = [monomer_id]
   3.700 +
   3.701 +        self.columns[class_id] = column_number
   3.702 +
   3.703 +    @staticmethod
   3.704 +    def write_monomer(file, monomer_id, class_id, column_number = False):
   3.705 +        """ Write a line "class_id sequence_id  monome number \n"  into file
   3.706 +        """
   3.707 +        if len(monomer_id) != 2:
   3.708 +            raise Exception("wrong parameters given for Monomer_homology.write_monomer: len(monomer_id) is not 2!")
   3.709 +            exit()
   3.710 +        try:
   3.711 +            if column_number:
   3.712 +                file.write("%s\t%s\t%s\t%s\n" % (class_id,monomer_id[0], monomer_id[1], column_number))
   3.713 +            else:
   3.714 +                file.write("%s\t%s\t%s\n" % (class_id,monomer_id[0], monomer_id[1]) )
   3.715 +
   3.716 +        except:
   3.717 +            raise Exception("Failed to write monomer into file!")
   3.718 +            exit()
   3.719 +
   3.720 +
   3.721 +#################################################################
   3.722 +
   3.723 +    def add_block(self,alignment, block):
   3.724 +        """ Add classes of plus-block to Homology
   3.725 +        """
   3.726 +        for column in block.columns:
   3.727 +            if len(column) == 0:
   3.728 +                continue
   3.729 +
   3.730 +            try:
   3.731 +                column_number = alignment.markups['number'][column]
   3.732 +            except:
   3.733 +                raise Exception("Alignment column has no number! Alignment must be marked up by numbers before .add_block")
   3.734 +                exit()
   3.735 +
   3.736 +            for sequence in block.sequences:
   3.737 +                if sequence in column:
   3.738 +
   3.739 +                    try:
   3.740 +                        monomer_id = (sequence.name, column[sequence].number)
   3.741 +                    except:
   3.742 +                        raise Exception("Monomer has no number! Sequences must be marked up by numbers before .writ_block")
   3.743 +                        exit()
   3.744 +
   3.745 +                    self.add_monomer(monomer_id,self.next_class_id, column_number)
   3.746 +
   3.747 +            self.next_class_id +=1
   3.748 +
   3.749 +
   3.750 +
   3.751 +
   3.752 +
   3.753 +    def write_block(self,file,alignment, block, markedup = True):
   3.754 +        """ Writes each block column into as one homology class
   3.755 +        WARRNINGS:
   3.756 +            (1) method works in object of class MonomerHomology
   3.757 +            (2) all sequences MUST BE MARKED UP with resudue NUMBERS!
   3.758 +            (3) automatic class ids (actually, numbers) are assigned to homology classes
   3.759 +            (4) if markedup, then block MUST be marked up by column numbers
   3.760 +
   3.761 +        Block may contain "gaps"
   3.762 +        """
   3.763 +        for column in block.columns:
   3.764 +
   3.765 +            if len(column) == 0:
   3.766 +                continue
   3.767 +
   3.768 +            if markedup:
   3.769 +                column_number = alignment.markups['number'][column]
   3.770 +            else:
   3.771 +                column_number = False
   3.772 +
   3.773 +            for sequence in block.sequences:
   3.774 +
   3.775 +                if sequence in column:
   3.776 +
   3.777 +                    try:
   3.778 +                        monomer_id = (sequence.name, column[sequence].number)
   3.779 +                    except:
   3.780 +                        raise Exception("Monomer has no number! Sequences must be marked up by numbers before .writ_block")
   3.781 +                        exit()
   3.782 +                    MonomerHomology.write_monomer(file,monomer_id,self.next_class_id, column_number = column_number)
   3.783 +
   3.784 +            self.next_class_id +=1
   3.785 +
   3.786 +#################################################################
   3.787 +
   3.788 +    def _sequences_of_class(self,monomer_ids):
   3.789 +        """  RETURN set of sequences from a list of monomer_ids
   3.790 +        """
   3.791 +        set_sequences = set()
   3.792 +        for x in monomer_ids:
   3.793 +            set_sequences.add(x[0])
   3.794 +        return set_sequences
   3.795 +
   3.796 +
   3.797 +    def highest_blocks(self):
   3.798 +        """ Makes blocks of maximal possible heights from monomer homology classes
   3.799 +        block = set of homology classes with the same set of sequences
   3.800 +        block MUST BE marked up by column numbers
   3.801 +
   3.802 +        blocks_data = [block_data, ...]
   3.803 +        block_data = (sequence_names,class_ids)
   3.804 +            sequence_names = set( [sequence_1_name,...] )
   3.805 +            class_ids = = set( [class_1_id, ...] )
   3.806 +
   3.807 +
   3.808 +        RETURN: self.blocks
   3.809 +
   3.810 +        """
   3.811 +        class_ids = list(self.classes)
   3.812 +        class_ids.sort()
   3.813 +        self.blocks_data = []
   3.814 +        block_number = 0
   3.815 +
   3.816 +        for i in range(len(class_ids)):
   3.817 +            class_id_1 = class_ids[i]
   3.818 +
   3.819 +            if type(class_id_1) == type(tuple()):
   3.820 +                continue
   3.821 +
   3.822 +            block_number += 1
   3.823 +            try:
   3.824 +                column_number = self.columns[class_id_1]
   3.825 +            except:
   3.826 +                raise Exception("Fail to get column_number! Homology classes must be marked to creats highest blocks")
   3.827 +
   3.828 +            # NEW BLOCK
   3.829 +
   3.830 +            set_sequences_1 = self._sequences_of_class(self.classes[class_id_1])
   3.831 +
   3.832 +            self.blocks_data.append( (set_sequences_1, set([class_id_1]) ) )
   3.833 +            class_ids[i] = (class_id_1,i)
   3.834 +
   3.835 +            # ADD classes to BLOCK
   3.836 +            for j in range(i+1,len(class_ids)):
   3.837 +                class_id_2 = class_ids[j]
   3.838 +
   3.839 +                if type(class_id_2) == type(tuple()):
   3.840 +                    continue
   3.841 +
   3.842 +                set_sequences_2 = self._sequences_of_class(self.classes[class_id_2])
   3.843 +
   3.844 +                if set_sequences_2 == set_sequences_1:
   3.845 +                    try:
   3.846 +                        column_number = self.columns[class_id_2]
   3.847 +                    except:
   3.848 +                        raise Exception("Fail to get column_number! Homology classes must be marked to creats hiest blocks")
   3.849 +                    class_ids[j] = (class_id_2, j)
   3.850 +                    self.blocks_data[len(self.blocks_data)-1][1].add( class_id_2)
   3.851 +
   3.852 +        return self.blocks_data
   3.853 +
   3.854 +################################################################
   3.855 +
   3.856 +    def alignment_blocks(self, alignment):
   3.857 +        """ From homology.blocks creates a list of alignment blocks (accessible for visualization)
   3.858 +
   3.859 +        blocks_data = [block_data, ...]
   3.860 +        block_data = (sequence_names,class_ids)
   3.861 +            sequence_names = set( [sequence_1_name,...] )
   3.862 +            class_ids = = set( [class_1_id, ...] )
   3.863 +        RETURN blocks, list of blocks in alignment
   3.864 +
   3.865 +        """
   3.866 +        blocks = []
   3.867 +        dict_sequences = {}
   3.868 +        for sequence in alignment.sequences:
   3.869 +            dict_sequences[sequence.name]=sequence
   3.870 +
   3.871 +        dict_columns = {}
   3.872 +        for column in alignment.columns:
   3.873 +            try:
   3.874 +                dict_columns[alignment.markups['number'][column]] = column
   3.875 +            except:
   3.876 +                raise Exception("alignment columns are not marked up by numbers! Can't creat block from blocks data")
   3.877 +                exit()
   3.878 +
   3.879 +        for block_data in self.blocks_data:
   3.880 +            set_sequence_names = block_data[0]
   3.881 +            set_class_ids = block_data[1]
   3.882 +
   3.883 +            block_sequences = []
   3.884 +
   3.885 +            for sequence_name in set_sequence_names:
   3.886 +
   3.887 +                try:
   3.888 +                    s = dict_sequences[sequence_name]
   3.889 +                    block_sequences.append(s)
   3.890 +                except:
   3.891 +                    raise Exception("Sequence name %s from block data is not in alignment sequences!" % sequence_name)
   3.892 +                    exit()
   3.893 +
   3.894 +            block_columns = []
   3.895 +            for class_id in set_class_ids:
   3.896 +                column_number = self.columns[class_id]
   3.897 +                try:
   3.898 +                    block_columns.append(dict_columns[column_number])
   3.899 +                except:
   3.900 +                    raise Exception("Column number %s from block data is not in alignment columns numbers!" % column_number)
   3.901 +                    exit()
   3.902 +
   3.903 +            block = protein.Block.from_alignment(alignment, sequences = block_sequences, columns = block_columns)
   3.904 +            blocks.append(block)
   3.905 +        return blocks
   3.906 +
   3.907 +#################################################################
   3.908 +    @staticmethod
   3.909 +    def case_homology(in_file_name,out_file_name, case = False, format = 'fasta'):
   3.910 +        """ Makes homology file from input alignment
   3.911 +        case = True => Upper letters in a column are in one class, each lower letter in separate class
   3.912 +        case = False => all letter in a column are in one class
   3.913 +
   3.914 +        RETURN number of classes
   3.915 +        """
   3.916 +        try:
   3.917 +            f = open(in_file_name)
   3.918 +        except:
   3.919 +            raise Exception("Failed to open file %s" % in_file_name)
   3.920 +            exit()
   3.921 +        try:
   3.922 +            print format
   3.923 +            alignment = protein.Alignment().append_file(f, format=format)
   3.924 +            f.close()
   3.925 +        except:
   3.926 +            raise Exception("Failed to create alignment from file %s, format %s!" % (in_file_name,format) )
   3.927 +            exit()
   3.928 +        try:
   3.929 +            g = open(out_file_name, 'w')
   3.930 +        except:
   3.931 +            raise Exception("Failed to open output file %s!" % out_file_name)
   3.932 +            exit()
   3.933 +
   3.934 +    # MARKUPING
   3.935 +        markups.AlignmentNumberMarkup(alignment)
   3.936 +
   3.937 +        for sequence in alignment.sequences:
   3.938 +            markups.SequenceNumberMarkup(sequence)
   3.939 +            if case and format != "markup":
   3.940 +                markups.SequenceCaseMarkup(sequence)
   3.941 +
   3.942 +
   3.943 +    #letters = ''.join(v[0] for v in seq.markups['case'].as_list())
   3.944 +
   3.945 +    # WRITING CLASSES
   3.946 +        next_class_id = 1
   3.947 +
   3.948 +        for column in alignment.columns:
   3.949 +            column_number = alignment.markups['number'][column]
   3.950 +            column_class = []
   3.951 +
   3.952 +            for sequence in column:
   3.953 +                monomer = column[sequence]
   3.954 +                monomer_id = (sequence.name, monomer.number)
   3.955 +                if case:
   3.956 +                    if monomer.case == "lower":
   3.957 +                        MonomerHomology.write_monomer(g,monomer_id,next_class_id,column_number)
   3.958 +                        next_class_id += 1
   3.959 +                        continue
   3.960 +                column_class.append(monomer_id)
   3.961 +
   3.962 +            if len(column_class) > 0:
   3.963 +                MonomerHomology.write_class(g,column_class,next_class_id, column_number)
   3.964 +                next_class_id += 1
   3.965 +
   3.966 +        g.close()
   3.967 +        return next_class_id - 1
   3.968 +
   3.969 +################################################################
   3.970 +
   3.971 +
   3.972 +
   3.973 +
     4.1 --- a/blocks3d/wt/files/js/jquery.countdown.pack.js	Thu Jul 14 14:05:39 2011 +0400
     4.2 +++ b/blocks3d/wt/files/js/jquery.countdown.pack.js	Thu Jul 14 14:28:32 2011 +0400
     4.3 @@ -1,7 +1,7 @@
     4.4 -/* http://keith-wood.name/countdown.html
     4.5 -   Countdown for jQuery v1.5.8.
     4.6 -   Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
     4.7 -   Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and 
     4.8 -   MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses. 
     4.9 -   Please attribute the author if you use it. */
    4.10 -eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(B($){B 1i(){8.1D=[];8.1D[\'\']={1j:[\'2C\',\'2D\',\'2E\',\'2F\',\'2G\',\'2H\',\'2I\'],2J:[\'2K\',\'2L\',\'2M\',\'2N\',\'2O\',\'2P\',\'2Q\'],1k:[\'y\',\'m\',\'w\',\'d\'],1u:E,1E:\':\',1V:Q};8.1g={1W:E,1X:E,1Y:E,1Z:E,20:\'2R\',1l:\'\',21:Q,1v:0,1F:\'\',22:\'\',23:\'\',25:Q,26:E,27:E,28:1};$.1m(8.1g,8.1D[\'\']);8.1n=[]}x w=\'G\';x Y=0;x O=1;x W=2;x D=3;x H=4;x M=5;x S=6;$.1m(1i.29,{1o:\'2S\',2T:2U(B(){$.G.2a()},2V),19:[],2W:B(a){8.1G(8.1g,a);1H(8.1g,a||{})},1I:B(a,b,c,e,f,g,h,i){A(1p b==\'2X\'&&b.2Y==P){i=b.1J();h=b.1K();g=b.1L();f=b.1M();e=b.T();c=b.17();b=b.18()}x d=K P();d.2Z(b);d.2b(1);d.31(c||0);d.2b(e||1);d.33(f||0);d.34((g||0)-(U.35(a)<30?a*1a:a));d.36(h||0);d.37(i||0);F d},2c:B(a){F a[0]*38+a[1]*39+a[2]*2d+a[3]*2e+a[4]*2f+a[5]*1a+a[6]},3a:B(a,b){A(!b){F $.G.1g}x c=$.X(a,w);F(b==\'3b\'?c.Z:c.Z[b])},2g:B(a,b){x c=$(a);A(c.2h(8.1o)){F}c.3c(8.1o);x d={Z:$.1m({},b),z:[0,0,0,0,0,0,0]};$.X(a,w,d);8.2i(a)},1N:B(a){A(!8.1O(a)){8.19.2j(a)}},1O:B(a){F($.3d(a,8.19)>-1)},1w:B(b){8.19=$.3e(8.19,B(a){F(a==b?E:a)})},2a:B(){V(x i=8.19.1x-1;i>=0;i--){8.1q(8.19[i])}},1q:B(a,b){x c=$(a);b=b||$.X(a,w);A(!b){F}c.3f(8.2k(b));c[(8.C(b,\'1V\')?\'3g\':\'3h\')+\'3i\'](\'3j\');x d=8.C(b,\'27\');A(d){x e=b.R!=\'2l\'?b.z:8.1y(b,b.11,8.C(b,\'1v\'),K P());x f=8.C(b,\'28\');A(f==1||8.2c(e)%f==0){d.1r(a,[e])}}x g=b.R!=\'1s\'&&(b.I?b.1b.L()<b.I.L():b.1b.L()>=b.13.L());A(g&&!b.1P){b.1P=1Q;A(8.1O(a)||8.C(b,\'25\')){8.1w(a);x h=8.C(b,\'26\');A(h){h.1r(a,[])}x i=8.C(b,\'23\');A(i){x j=8.C(b,\'1l\');b.Z.1l=i;8.1q(a,b);b.Z.1l=j}x k=8.C(b,\'22\');A(k){3k.3l=k}}b.1P=Q}1c A(b.R==\'1s\'){8.1w(a)}$.X(a,w,b)},2i:B(a,b,c){b=b||{};A(1p b==\'1R\'){x d=b;b={};b[d]=c}x e=$.X(a,w);A(e){8.1G(e.Z,b);1H(e.Z,b);8.2m(a,e);$.X(a,w,e);x f=K P();A((e.I&&e.I<f)||(e.13&&e.13>f)){8.1N(a)}8.1q(a,e)}},1G:B(a,b){x c=Q;V(x n 1S b){A(n!=\'1u\'&&n.N(/[2n]2o/)){c=1Q;14}}A(c){V(x n 1S a){A(n.N(/[2n]2o[0-9]/)){a[n]=E}}}},2m:B(a,b){x c;x d=8.C(b,\'1Z\');x e=0;x f=E;V(x i=0;i<8.1n.1x;i++){A(8.1n[i][0]==d){f=8.1n[i][1];14}}A(f!=E){e=(d?f:0);c=K P()}1c{x g=(d?d.1r(a,[]):E);c=K P();e=(g?c.L()-g.L():0);8.1n.2j([d,e])}x h=8.C(b,\'1Y\');h=(h==E?-c.3m():h);b.I=8.C(b,\'1X\');A(b.I!=E){b.I=8.1I(h,8.1z(b.I,E));A(b.I&&e){b.I.1A(b.I.1J()+e)}}b.13=8.1I(h,8.1z(8.C(b,\'1W\'),c));A(e){b.13.1A(b.13.1J()+e)}b.11=8.2p(b)},3n:B(a){x b=$(a);A(!b.2h(8.1o)){F}8.1w(a);b.3o(8.1o).3p();$.3q(a,w)},3r:B(a){8.R(a,\'1s\')},3s:B(a){8.R(a,\'2l\')},3t:B(a){8.R(a,E)},R:B(a,b){x c=$.X(a,w);A(c){A(c.R==\'1s\'&&!b){c.z=c.2q;x d=(c.I?\'-\':\'+\');c[c.I?\'I\':\'13\']=8.1z(d+c.z[0]+\'y\'+d+c.z[1]+\'o\'+d+c.z[2]+\'w\'+d+c.z[3]+\'d\'+d+c.z[4]+\'h\'+d+c.z[5]+\'m\'+d+c.z[6]+\'s\');8.1N(a)}c.R=b;c.2q=(b==\'1s\'?c.z:E);$.X(a,w,c);8.1q(a,c)}},3u:B(a){x b=$.X(a,w);F(!b?E:(!b.R?b.z:8.1y(b,b.11,8.C(b,\'1v\'),K P())))},C:B(a,b){F(a.Z[b]!=E?a.Z[b]:$.G.1g[b])},1z:B(k,l){x m=B(a){x b=K P();b.2r(b.L()+a*15);F b};x n=B(a){a=a.3v();x b=K P();x c=b.18();x d=b.17();x e=b.T();x f=b.1M();x g=b.1L();x h=b.1K();x i=/([+-]?[0-9]+)\\s*(s|m|h|d|w|o|y)?/g;x j=i.2s(a);3w(j){3x(j[2]||\'s\'){1d\'s\':h+=1e(j[1],10);14;1d\'m\':g+=1e(j[1],10);14;1d\'h\':f+=1e(j[1],10);14;1d\'d\':e+=1e(j[1],10);14;1d\'w\':e+=1e(j[1],10)*7;14;1d\'o\':d+=1e(j[1],10);e=U.1B(e,$.G.1h(c,d));14;1d\'y\':c+=1e(j[1],10);e=U.1B(e,$.G.1h(c,d));14}j=i.2s(a)}F K P(c,d,e,f,g,h,0)};x o=(k==E?l:(1p k==\'1R\'?n(k):(1p k==\'3y\'?m(k):k)));A(o)o.1A(0);F o},1h:B(a,b){F 32-K P(a,b,32).T()},1T:B(a){F a},2k:B(c){x d=8.C(c,\'1v\');c.z=(c.R?c.z:8.1y(c,c.11,d,K P()));x e=Q;x f=0;x g=d;x h=$.1m({},c.11);V(x i=Y;i<=S;i++){e|=(c.11[i]==\'?\'&&c.z[i]>0);h[i]=(c.11[i]==\'?\'&&!e?E:c.11[i]);f+=(h[i]?1:0);g-=(c.z[i]>0?1:0)}x j=[Q,Q,Q,Q,Q,Q,Q];V(x i=S;i>=Y;i--){A(c.11[i]){A(c.z[i]){j[i]=1Q}1c{j[i]=g>0;g--}}}x k=8.C(c,\'21\');x l=8.C(c,\'1l\');x m=(k?8.C(c,\'1k\'):8.C(c,\'1j\'));x n=8.C(c,\'1u\')||8.1T;x o=8.C(c,\'1E\');x p=8.C(c,\'1F\')||\'\';x q=B(a){x b=$.G.C(c,\'1k\'+n(c.z[a]));F(h[a]?c.z[a]+(b?b[a]:m[a])+\' \':\'\')};x r=B(a){x b=$.G.C(c,\'1j\'+n(c.z[a]));F((!d&&h[a])||(d&&j[a])?\'<16 1t="3z"><16 1t="2t">\'+c.z[a]+\'</16><3A/>\'+(b?b[a]:m[a])+\'</16>\':\'\')};F(l?8.2u(c,h,l,k,d,j):((k?\'<16 1t="1U 2t\'+(c.R?\' 2v\':\'\')+\'">\'+q(Y)+q(O)+q(W)+q(D)+(h[H]?8.J(c.z[H],2):\'\')+(h[M]?(h[H]?o:\'\')+8.J(c.z[M],2):\'\')+(h[S]?(h[H]||h[M]?o:\'\')+8.J(c.z[S],2):\'\'):\'<16 1t="1U 3B\'+(d||f)+(c.R?\' 2v\':\'\')+\'">\'+r(Y)+r(O)+r(W)+r(D)+r(H)+r(M)+r(S))+\'</16>\'+(p?\'<16 1t="1U 3C">\'+p+\'</16>\':\'\')))},2u:B(c,d,e,f,g,h){x j=8.C(c,(f?\'1k\':\'1j\'));x k=8.C(c,\'1u\')||8.1T;x l=B(a){F($.G.C(c,(f?\'1k\':\'1j\')+k(c.z[a]))||j)[a]};x m=B(a,b){F U.1C(a/b)%10};x o={3D:8.C(c,\'1F\'),3E:8.C(c,\'1E\'),3F:l(Y),3G:c.z[Y],3H:8.J(c.z[Y],2),3I:8.J(c.z[Y],3),3J:m(c.z[Y],1),3K:m(c.z[Y],10),3L:m(c.z[Y],1f),3M:m(c.z[Y],15),3N:l(O),3O:c.z[O],3P:8.J(c.z[O],2),3Q:8.J(c.z[O],3),3R:m(c.z[O],1),3S:m(c.z[O],10),3T:m(c.z[O],1f),3U:m(c.z[O],15),3V:l(W),3W:c.z[W],3X:8.J(c.z[W],2),3Y:8.J(c.z[W],3),3Z:m(c.z[W],1),40:m(c.z[W],10),41:m(c.z[W],1f),42:m(c.z[W],15),43:l(D),44:c.z[D],45:8.J(c.z[D],2),46:8.J(c.z[D],3),47:m(c.z[D],1),48:m(c.z[D],10),49:m(c.z[D],1f),4a:m(c.z[D],15),4b:l(H),4c:c.z[H],4d:8.J(c.z[H],2),4e:8.J(c.z[H],3),4f:m(c.z[H],1),4g:m(c.z[H],10),4h:m(c.z[H],1f),4i:m(c.z[H],15),4j:l(M),4k:c.z[M],4l:8.J(c.z[M],2),4m:8.J(c.z[M],3),4n:m(c.z[M],1),4o:m(c.z[M],10),4p:m(c.z[M],1f),4q:m(c.z[M],15),4r:l(S),4s:c.z[S],4t:8.J(c.z[S],2),4u:8.J(c.z[S],3),4v:m(c.z[S],1),4w:m(c.z[S],10),4x:m(c.z[S],1f),4y:m(c.z[S],15)};x p=e;V(x i=Y;i<=S;i++){x q=\'4z\'.4A(i);x r=K 2w(\'\\\\{\'+q+\'<\\\\}(.*)\\\\{\'+q+\'>\\\\}\',\'g\');p=p.2x(r,((!g&&d[i])||(g&&h[i])?\'$1\':\'\'))}$.2y(o,B(n,v){x a=K 2w(\'\\\\{\'+n+\'\\\\}\',\'g\');p=p.2x(a,v)});F p},J:B(a,b){a=\'\'+a;A(a.1x>=b){F a}a=\'4B\'+a;F a.4C(a.1x-b)},2p:B(a){x b=8.C(a,\'20\');x c=[];c[Y]=(b.N(\'y\')?\'?\':(b.N(\'Y\')?\'!\':E));c[O]=(b.N(\'o\')?\'?\':(b.N(\'O\')?\'!\':E));c[W]=(b.N(\'w\')?\'?\':(b.N(\'W\')?\'!\':E));c[D]=(b.N(\'d\')?\'?\':(b.N(\'D\')?\'!\':E));c[H]=(b.N(\'h\')?\'?\':(b.N(\'H\')?\'!\':E));c[M]=(b.N(\'m\')?\'?\':(b.N(\'M\')?\'!\':E));c[S]=(b.N(\'s\')?\'?\':(b.N(\'S\')?\'!\':E));F c},1y:B(c,d,e,f){c.1b=f;c.1b.1A(0);x g=K P(c.1b.L());A(c.I){A(f.L()<c.I.L()){c.1b=f=g}1c{f=c.I}}1c{g.2r(c.13.L());A(f.L()>c.13.L()){c.1b=f=g}}x h=[0,0,0,0,0,0,0];A(d[Y]||d[O]){x i=$.G.1h(f.18(),f.17());x j=$.G.1h(g.18(),g.17());x k=(g.T()==f.T()||(g.T()>=U.1B(i,j)&&f.T()>=U.1B(i,j)));x l=B(a){F(a.1M()*1a+a.1L())*1a+a.1K()};x m=U.4D(0,(g.18()-f.18())*12+g.17()-f.17()+((g.T()<f.T()&&!k)||(k&&l(g)<l(f))?-1:0));h[Y]=(d[Y]?U.1C(m/12):0);h[O]=(d[O]?m-h[Y]*12:0);f=K P(f.L());x n=(f.T()==i);x o=$.G.1h(f.18()+h[Y],f.17()+h[O]);A(f.T()>o){f.2z(o)}f.4E(f.18()+h[Y]);f.4F(f.17()+h[O]);A(n){f.2z(o)}}x p=U.1C((g.L()-f.L())/15);x q=B(a,b){h[a]=(d[a]?U.1C(p/b):0);p-=h[a]*b};q(W,2d);q(D,2e);q(H,2f);q(M,1a);q(S,1);A(p>0&&!c.I){x r=[1,12,4.4G,7,24,1a,1a];x s=S;x t=1;V(x u=S;u>=Y;u--){A(d[u]){A(h[s]>=t){h[s]=0;p=1}A(p>0){h[u]++;p=0;s=u;t=1}}t*=r[u]}}A(e){V(x u=Y;u<=S;u++){A(e&&h[u]){e--}1c A(!e){h[u]=0}}}F h}});B 1H(a,b){$.1m(a,b);V(x c 1S b){A(b[c]==E){a[c]=E}}F a}$.4H.G=B(a){x b=4I.29.4J.4K(4L,1);A(a==\'4M\'||a==\'4N\'){F $.G[\'2A\'+a+\'1i\'].1r($.G,[8[0]].2B(b))}F 8.2y(B(){A(1p a==\'1R\'){$.G[\'2A\'+a+\'1i\'].1r($.G,[8].2B(b))}1c{$.G.2g(8,a)}})};$.G=K 1i()})(4O);',62,299,'||||||||this|||||||||||||||||||||||||var||_periods|if|function|_get||null|return|countdown||_since|_minDigits|new|getTime||match||Date|false|_hold||getDate|Math|for||data||options||_show||_until|break|1000|span|getMonth|getFullYear|_timerTargets|60|_now|else|case|parseInt|100|_defaults|_getDaysInMonth|Countdown|labels|compactLabels|layout|extend|_serverSyncs|markerClassName|typeof|_updateCountdown|apply|pause|class|whichLabels|significant|_removeTarget|length|_calculatePeriods|_determineTime|setMilliseconds|min|floor|regional|timeSeparator|description|_resetExtraLabels|extendRemove|UTCDate|getMilliseconds|getSeconds|getMinutes|getHours|_addTarget|_hasTarget|_expiring|true|string|in|_normalLabels|countdown_row|isRTL|until|since|timezone|serverSync|format|compact|expiryUrl|expiryText||alwaysExpire|onExpiry|onTick|tickInterval|prototype|_updateTargets|setUTCDate|periodsToSeconds|604800|86400|3600|_attachCountdown|hasClass|_changeCountdown|push|_generateHTML|lap|_adjustSettings|Ll|abels|_determineShow|_savePeriods|setTime|exec|countdown_amount|_buildLayout|countdown_holding|RegExp|replace|each|setDate|_|concat|Years|Months|Weeks|Days|Hours|Minutes|Seconds|labels1|Year|Month|Week|Day|Hour|Minute|Second|dHMS|hasCountdown|_timer|setInterval|980|setDefaults|object|constructor|setUTCFullYear||setUTCMonth||setUTCHours|setUTCMinutes|abs|setUTCSeconds|setUTCMilliseconds|31557600|2629800|_settingsCountdown|all|addClass|inArray|map|html|add|remove|Class|countdown_rtl|window|location|getTimezoneOffset|_destroyCountdown|removeClass|empty|removeData|_pauseCountdown|_lapCountdown|_resumeCountdown|_getTimesCountdown|toLowerCase|while|switch|number|countdown_section|br|countdown_show|countdown_descr|desc|sep|yl|yn|ynn|ynnn|y1|y10|y100|y1000|ol|on|onn|onnn|o1|o10|o100|o1000|wl|wn|wnn|wnnn|w1|w10|w100|w1000|dl|dn|dnn|dnnn|d1|d10|d100|d1000|hl|hn|hnn|hnnn|h1|h10|h100|h1000|ml|mn|mnn|mnnn|m1|m10|m100|m1000|sl|sn|snn|snnn|s1|s10|s100|s1000|yowdhms|charAt|0000000000|substr|max|setFullYear|setMonth|3482|fn|Array|slice|call|arguments|getTimes|settings|jQuery'.split('|'),0,{}))
    4.11 \ No newline at end of file
    4.12 +/* http://keith-wood.name/countdown.html
    4.13 +   Countdown for jQuery v1.5.8.
    4.14 +   Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
    4.15 +   Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
    4.16 +   MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
    4.17 +   Please attribute the author if you use it. */
    4.18 +eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(B($){B 1i(){8.1D=[];8.1D[\'\']={1j:[\'2C\',\'2D\',\'2E\',\'2F\',\'2G\',\'2H\',\'2I\'],2J:[\'2K\',\'2L\',\'2M\',\'2N\',\'2O\',\'2P\',\'2Q\'],1k:[\'y\',\'m\',\'w\',\'d\'],1u:E,1E:\':\',1V:Q};8.1g={1W:E,1X:E,1Y:E,1Z:E,20:\'2R\',1l:\'\',21:Q,1v:0,1F:\'\',22:\'\',23:\'\',25:Q,26:E,27:E,28:1};$.1m(8.1g,8.1D[\'\']);8.1n=[]}x w=\'G\';x Y=0;x O=1;x W=2;x D=3;x H=4;x M=5;x S=6;$.1m(1i.29,{1o:\'2S\',2T:2U(B(){$.G.2a()},2V),19:[],2W:B(a){8.1G(8.1g,a);1H(8.1g,a||{})},1I:B(a,b,c,e,f,g,h,i){A(1p b==\'2X\'&&b.2Y==P){i=b.1J();h=b.1K();g=b.1L();f=b.1M();e=b.T();c=b.17();b=b.18()}x d=K P();d.2Z(b);d.2b(1);d.31(c||0);d.2b(e||1);d.33(f||0);d.34((g||0)-(U.35(a)<30?a*1a:a));d.36(h||0);d.37(i||0);F d},2c:B(a){F a[0]*38+a[1]*39+a[2]*2d+a[3]*2e+a[4]*2f+a[5]*1a+a[6]},3a:B(a,b){A(!b){F $.G.1g}x c=$.X(a,w);F(b==\'3b\'?c.Z:c.Z[b])},2g:B(a,b){x c=$(a);A(c.2h(8.1o)){F}c.3c(8.1o);x d={Z:$.1m({},b),z:[0,0,0,0,0,0,0]};$.X(a,w,d);8.2i(a)},1N:B(a){A(!8.1O(a)){8.19.2j(a)}},1O:B(a){F($.3d(a,8.19)>-1)},1w:B(b){8.19=$.3e(8.19,B(a){F(a==b?E:a)})},2a:B(){V(x i=8.19.1x-1;i>=0;i--){8.1q(8.19[i])}},1q:B(a,b){x c=$(a);b=b||$.X(a,w);A(!b){F}c.3f(8.2k(b));c[(8.C(b,\'1V\')?\'3g\':\'3h\')+\'3i\'](\'3j\');x d=8.C(b,\'27\');A(d){x e=b.R!=\'2l\'?b.z:8.1y(b,b.11,8.C(b,\'1v\'),K P());x f=8.C(b,\'28\');A(f==1||8.2c(e)%f==0){d.1r(a,[e])}}x g=b.R!=\'1s\'&&(b.I?b.1b.L()<b.I.L():b.1b.L()>=b.13.L());A(g&&!b.1P){b.1P=1Q;A(8.1O(a)||8.C(b,\'25\')){8.1w(a);x h=8.C(b,\'26\');A(h){h.1r(a,[])}x i=8.C(b,\'23\');A(i){x j=8.C(b,\'1l\');b.Z.1l=i;8.1q(a,b);b.Z.1l=j}x k=8.C(b,\'22\');A(k){3k.3l=k}}b.1P=Q}1c A(b.R==\'1s\'){8.1w(a)}$.X(a,w,b)},2i:B(a,b,c){b=b||{};A(1p b==\'1R\'){x d=b;b={};b[d]=c}x e=$.X(a,w);A(e){8.1G(e.Z,b);1H(e.Z,b);8.2m(a,e);$.X(a,w,e);x f=K P();A((e.I&&e.I<f)||(e.13&&e.13>f)){8.1N(a)}8.1q(a,e)}},1G:B(a,b){x c=Q;V(x n 1S b){A(n!=\'1u\'&&n.N(/[2n]2o/)){c=1Q;14}}A(c){V(x n 1S a){A(n.N(/[2n]2o[0-9]/)){a[n]=E}}}},2m:B(a,b){x c;x d=8.C(b,\'1Z\');x e=0;x f=E;V(x i=0;i<8.1n.1x;i++){A(8.1n[i][0]==d){f=8.1n[i][1];14}}A(f!=E){e=(d?f:0);c=K P()}1c{x g=(d?d.1r(a,[]):E);c=K P();e=(g?c.L()-g.L():0);8.1n.2j([d,e])}x h=8.C(b,\'1Y\');h=(h==E?-c.3m():h);b.I=8.C(b,\'1X\');A(b.I!=E){b.I=8.1I(h,8.1z(b.I,E));A(b.I&&e){b.I.1A(b.I.1J()+e)}}b.13=8.1I(h,8.1z(8.C(b,\'1W\'),c));A(e){b.13.1A(b.13.1J()+e)}b.11=8.2p(b)},3n:B(a){x b=$(a);A(!b.2h(8.1o)){F}8.1w(a);b.3o(8.1o).3p();$.3q(a,w)},3r:B(a){8.R(a,\'1s\')},3s:B(a){8.R(a,\'2l\')},3t:B(a){8.R(a,E)},R:B(a,b){x c=$.X(a,w);A(c){A(c.R==\'1s\'&&!b){c.z=c.2q;x d=(c.I?\'-\':\'+\');c[c.I?\'I\':\'13\']=8.1z(d+c.z[0]+\'y\'+d+c.z[1]+\'o\'+d+c.z[2]+\'w\'+d+c.z[3]+\'d\'+d+c.z[4]+\'h\'+d+c.z[5]+\'m\'+d+c.z[6]+\'s\');8.1N(a)}c.R=b;c.2q=(b==\'1s\'?c.z:E);$.X(a,w,c);8.1q(a,c)}},3u:B(a){x b=$.X(a,w);F(!b?E:(!b.R?b.z:8.1y(b,b.11,8.C(b,\'1v\'),K P())))},C:B(a,b){F(a.Z[b]!=E?a.Z[b]:$.G.1g[b])},1z:B(k,l){x m=B(a){x b=K P();b.2r(b.L()+a*15);F b};x n=B(a){a=a.3v();x b=K P();x c=b.18();x d=b.17();x e=b.T();x f=b.1M();x g=b.1L();x h=b.1K();x i=/([+-]?[0-9]+)\\s*(s|m|h|d|w|o|y)?/g;x j=i.2s(a);3w(j){3x(j[2]||\'s\'){1d\'s\':h+=1e(j[1],10);14;1d\'m\':g+=1e(j[1],10);14;1d\'h\':f+=1e(j[1],10);14;1d\'d\':e+=1e(j[1],10);14;1d\'w\':e+=1e(j[1],10)*7;14;1d\'o\':d+=1e(j[1],10);e=U.1B(e,$.G.1h(c,d));14;1d\'y\':c+=1e(j[1],10);e=U.1B(e,$.G.1h(c,d));14}j=i.2s(a)}F K P(c,d,e,f,g,h,0)};x o=(k==E?l:(1p k==\'1R\'?n(k):(1p k==\'3y\'?m(k):k)));A(o)o.1A(0);F o},1h:B(a,b){F 32-K P(a,b,32).T()},1T:B(a){F a},2k:B(c){x d=8.C(c,\'1v\');c.z=(c.R?c.z:8.1y(c,c.11,d,K P()));x e=Q;x f=0;x g=d;x h=$.1m({},c.11);V(x i=Y;i<=S;i++){e|=(c.11[i]==\'?\'&&c.z[i]>0);h[i]=(c.11[i]==\'?\'&&!e?E:c.11[i]);f+=(h[i]?1:0);g-=(c.z[i]>0?1:0)}x j=[Q,Q,Q,Q,Q,Q,Q];V(x i=S;i>=Y;i--){A(c.11[i]){A(c.z[i]){j[i]=1Q}1c{j[i]=g>0;g--}}}x k=8.C(c,\'21\');x l=8.C(c,\'1l\');x m=(k?8.C(c,\'1k\'):8.C(c,\'1j\'));x n=8.C(c,\'1u\')||8.1T;x o=8.C(c,\'1E\');x p=8.C(c,\'1F\')||\'\';x q=B(a){x b=$.G.C(c,\'1k\'+n(c.z[a]));F(h[a]?c.z[a]+(b?b[a]:m[a])+\' \':\'\')};x r=B(a){x b=$.G.C(c,\'1j\'+n(c.z[a]));F((!d&&h[a])||(d&&j[a])?\'<16 1t="3z"><16 1t="2t">\'+c.z[a]+\'</16><3A/>\'+(b?b[a]:m[a])+\'</16>\':\'\')};F(l?8.2u(c,h,l,k,d,j):((k?\'<16 1t="1U 2t\'+(c.R?\' 2v\':\'\')+\'">\'+q(Y)+q(O)+q(W)+q(D)+(h[H]?8.J(c.z[H],2):\'\')+(h[M]?(h[H]?o:\'\')+8.J(c.z[M],2):\'\')+(h[S]?(h[H]||h[M]?o:\'\')+8.J(c.z[S],2):\'\'):\'<16 1t="1U 3B\'+(d||f)+(c.R?\' 2v\':\'\')+\'">\'+r(Y)+r(O)+r(W)+r(D)+r(H)+r(M)+r(S))+\'</16>\'+(p?\'<16 1t="1U 3C">\'+p+\'</16>\':\'\')))},2u:B(c,d,e,f,g,h){x j=8.C(c,(f?\'1k\':\'1j\'));x k=8.C(c,\'1u\')||8.1T;x l=B(a){F($.G.C(c,(f?\'1k\':\'1j\')+k(c.z[a]))||j)[a]};x m=B(a,b){F U.1C(a/b)%10};x o={3D:8.C(c,\'1F\'),3E:8.C(c,\'1E\'),3F:l(Y),3G:c.z[Y],3H:8.J(c.z[Y],2),3I:8.J(c.z[Y],3),3J:m(c.z[Y],1),3K:m(c.z[Y],10),3L:m(c.z[Y],1f),3M:m(c.z[Y],15),3N:l(O),3O:c.z[O],3P:8.J(c.z[O],2),3Q:8.J(c.z[O],3),3R:m(c.z[O],1),3S:m(c.z[O],10),3T:m(c.z[O],1f),3U:m(c.z[O],15),3V:l(W),3W:c.z[W],3X:8.J(c.z[W],2),3Y:8.J(c.z[W],3),3Z:m(c.z[W],1),40:m(c.z[W],10),41:m(c.z[W],1f),42:m(c.z[W],15),43:l(D),44:c.z[D],45:8.J(c.z[D],2),46:8.J(c.z[D],3),47:m(c.z[D],1),48:m(c.z[D],10),49:m(c.z[D],1f),4a:m(c.z[D],15),4b:l(H),4c:c.z[H],4d:8.J(c.z[H],2),4e:8.J(c.z[H],3),4f:m(c.z[H],1),4g:m(c.z[H],10),4h:m(c.z[H],1f),4i:m(c.z[H],15),4j:l(M),4k:c.z[M],4l:8.J(c.z[M],2),4m:8.J(c.z[M],3),4n:m(c.z[M],1),4o:m(c.z[M],10),4p:m(c.z[M],1f),4q:m(c.z[M],15),4r:l(S),4s:c.z[S],4t:8.J(c.z[S],2),4u:8.J(c.z[S],3),4v:m(c.z[S],1),4w:m(c.z[S],10),4x:m(c.z[S],1f),4y:m(c.z[S],15)};x p=e;V(x i=Y;i<=S;i++){x q=\'4z\'.4A(i);x r=K 2w(\'\\\\{\'+q+\'<\\\\}(.*)\\\\{\'+q+\'>\\\\}\',\'g\');p=p.2x(r,((!g&&d[i])||(g&&h[i])?\'$1\':\'\'))}$.2y(o,B(n,v){x a=K 2w(\'\\\\{\'+n+\'\\\\}\',\'g\');p=p.2x(a,v)});F p},J:B(a,b){a=\'\'+a;A(a.1x>=b){F a}a=\'4B\'+a;F a.4C(a.1x-b)},2p:B(a){x b=8.C(a,\'20\');x c=[];c[Y]=(b.N(\'y\')?\'?\':(b.N(\'Y\')?\'!\':E));c[O]=(b.N(\'o\')?\'?\':(b.N(\'O\')?\'!\':E));c[W]=(b.N(\'w\')?\'?\':(b.N(\'W\')?\'!\':E));c[D]=(b.N(\'d\')?\'?\':(b.N(\'D\')?\'!\':E));c[H]=(b.N(\'h\')?\'?\':(b.N(\'H\')?\'!\':E));c[M]=(b.N(\'m\')?\'?\':(b.N(\'M\')?\'!\':E));c[S]=(b.N(\'s\')?\'?\':(b.N(\'S\')?\'!\':E));F c},1y:B(c,d,e,f){c.1b=f;c.1b.1A(0);x g=K P(c.1b.L());A(c.I){A(f.L()<c.I.L()){c.1b=f=g}1c{f=c.I}}1c{g.2r(c.13.L());A(f.L()>c.13.L()){c.1b=f=g}}x h=[0,0,0,0,0,0,0];A(d[Y]||d[O]){x i=$.G.1h(f.18(),f.17());x j=$.G.1h(g.18(),g.17());x k=(g.T()==f.T()||(g.T()>=U.1B(i,j)&&f.T()>=U.1B(i,j)));x l=B(a){F(a.1M()*1a+a.1L())*1a+a.1K()};x m=U.4D(0,(g.18()-f.18())*12+g.17()-f.17()+((g.T()<f.T()&&!k)||(k&&l(g)<l(f))?-1:0));h[Y]=(d[Y]?U.1C(m/12):0);h[O]=(d[O]?m-h[Y]*12:0);f=K P(f.L());x n=(f.T()==i);x o=$.G.1h(f.18()+h[Y],f.17()+h[O]);A(f.T()>o){f.2z(o)}f.4E(f.18()+h[Y]);f.4F(f.17()+h[O]);A(n){f.2z(o)}}x p=U.1C((g.L()-f.L())/15);x q=B(a,b){h[a]=(d[a]?U.1C(p/b):0);p-=h[a]*b};q(W,2d);q(D,2e);q(H,2f);q(M,1a);q(S,1);A(p>0&&!c.I){x r=[1,12,4.4G,7,24,1a,1a];x s=S;x t=1;V(x u=S;u>=Y;u--){A(d[u]){A(h[s]>=t){h[s]=0;p=1}A(p>0){h[u]++;p=0;s=u;t=1}}t*=r[u]}}A(e){V(x u=Y;u<=S;u++){A(e&&h[u]){e--}1c A(!e){h[u]=0}}}F h}});B 1H(a,b){$.1m(a,b);V(x c 1S b){A(b[c]==E){a[c]=E}}F a}$.4H.G=B(a){x b=4I.29.4J.4K(4L,1);A(a==\'4M\'||a==\'4N\'){F $.G[\'2A\'+a+\'1i\'].1r($.G,[8[0]].2B(b))}F 8.2y(B(){A(1p a==\'1R\'){$.G[\'2A\'+a+\'1i\'].1r($.G,[8].2B(b))}1c{$.G.2g(8,a)}})};$.G=K 1i()})(4O);',62,299,'||||||||this|||||||||||||||||||||||||var||_periods|if|function|_get||null|return|countdown||_since|_minDigits|new|getTime||match||Date|false|_hold||getDate|Math|for||data||options||_show||_until|break|1000|span|getMonth|getFullYear|_timerTargets|60|_now|else|case|parseInt|100|_defaults|_getDaysInMonth|Countdown|labels|compactLabels|layout|extend|_serverSyncs|markerClassName|typeof|_updateCountdown|apply|pause|class|whichLabels|significant|_removeTarget|length|_calculatePeriods|_determineTime|setMilliseconds|min|floor|regional|timeSeparator|description|_resetExtraLabels|extendRemove|UTCDate|getMilliseconds|getSeconds|getMinutes|getHours|_addTarget|_hasTarget|_expiring|true|string|in|_normalLabels|countdown_row|isRTL|until|since|timezone|serverSync|format|compact|expiryUrl|expiryText||alwaysExpire|onExpiry|onTick|tickInterval|prototype|_updateTargets|setUTCDate|periodsToSeconds|604800|86400|3600|_attachCountdown|hasClass|_changeCountdown|push|_generateHTML|lap|_adjustSettings|Ll|abels|_determineShow|_savePeriods|setTime|exec|countdown_amount|_buildLayout|countdown_holding|RegExp|replace|each|setDate|_|concat|Years|Months|Weeks|Days|Hours|Minutes|Seconds|labels1|Year|Month|Week|Day|Hour|Minute|Second|dHMS|hasCountdown|_timer|setInterval|980|setDefaults|object|constructor|setUTCFullYear||setUTCMonth||setUTCHours|setUTCMinutes|abs|setUTCSeconds|setUTCMilliseconds|31557600|2629800|_settingsCountdown|all|addClass|inArray|map|html|add|remove|Class|countdown_rtl|window|location|getTimezoneOffset|_destroyCountdown|removeClass|empty|removeData|_pauseCountdown|_lapCountdown|_resumeCountdown|_getTimesCountdown|toLowerCase|while|switch|number|countdown_section|br|countdown_show|countdown_descr|desc|sep|yl|yn|ynn|ynnn|y1|y10|y100|y1000|ol|on|onn|onnn|o1|o10|o100|o1000|wl|wn|wnn|wnnn|w1|w10|w100|w1000|dl|dn|dnn|dnnn|d1|d10|d100|d1000|hl|hn|hnn|hnnn|h1|h10|h100|h1000|ml|mn|mnn|mnnn|m1|m10|m100|m1000|sl|sn|snn|snnn|s1|s10|s100|s1000|yowdhms|charAt|0000000000|substr|max|setFullYear|setMonth|3482|fn|Array|slice|call|arguments|getTimes|settings|jQuery'.split('|'),0,{}))
     5.1 --- a/blocks3d/www/input/blocks.js	Thu Jul 14 14:05:39 2011 +0400
     5.2 +++ b/blocks3d/www/input/blocks.js	Thu Jul 14 14:28:32 2011 +0400
     5.3 @@ -1,385 +1,385 @@
     5.4 -
     5.5 -/*
     5.6 -list of blocks
     5.7 -block = {
     5.8 -    int start; (inclusive) // do not use with positions
     5.9 -    int end; (inclusive) // do not use with positions
    5.10 -    int[] positions; // do not use with start and end
    5.11 -    IDs: list of IDs
    5.12 -    cores: []
    5.13 -    is_conservative: list, mapping pos to bool
    5.14 -}
    5.15 -*/
    5.16 -
    5.17 -var blocks = {};
    5.18 -
    5.19 -// fasta_dict[ID] = string reprentation of sequence
    5.20 -var fasta_dict = {};
    5.21 -
    5.22 -
    5.23 -// parameters
    5.24 -
    5.25 -var h1_height = 50; // header cell height
    5.26 -var mainpanel_height = 100; // toolbar height
    5.27 -var legend_interval = 10; // interval of position number captions
    5.28 -
    5.29 -var letter_width = 9; // letter width
    5.30 -var letter_height = 17; // letter height
    5.31 -var scroller_height_width = 16; // scrollbar height and width
    5.32 -
    5.33 -var boundary = 70; // margin
    5.34 -
    5.35 -// autogenerated variables
    5.36 -
    5.37 -var selected_block_i; // current block
    5.38 -var ID_order = []; // ID sequence
    5.39 -
    5.40 -var ID_order_now = []; // currently used ID_order
    5.41 -
    5.42 -var max_ID_length; // max name length
    5.43 -var seq_length; // sequence length
    5.44 -var IDs_count; // total number of sequences
    5.45 -
    5.46 -// alignment_strings[ID] = string with sequence for <pre>
    5.47 -var alignment_strings = {};
    5.48 -
    5.49 -var conservative_groups_dict = []; // list of dictsets of uppercased letters
    5.50 -
    5.51 -// useful_positions[ID][position] = block id
    5.52 -// (if this element is a part of at least one block)
    5.53 -var useful_positions = {};
    5.54 -
    5.55 -var blocks_inited = false;
    5.56 -
    5.57 -function is_conservative_column(column, sequences)
    5.58 -{
    5.59 -    var result = false;
    5.60 -    $.each(conservative_groups_dict, function(i, group) {
    5.61 -        var inside_group = true;
    5.62 -        $.each(sequences, function(j, ID) {
    5.63 -            if (!group[fasta_dict[ID].charAt(column).toUpperCase()])
    5.64 -            {
    5.65 -                inside_group = false;
    5.66 -            }
    5.67 -        });
    5.68 -        if (inside_group)
    5.69 -        {
    5.70 -            result = true;
    5.71 -        }
    5.72 -    });
    5.73 -    return result;
    5.74 -}
    5.75 -
    5.76 -// run application
    5.77 -function blocks_init()
    5.78 -{
    5.79 -    if (blocks_inited)
    5.80 -    {
    5.81 -        return;
    5.82 -    }
    5.83 -    blocks_inited = true;
    5.84 -
    5.85 -    var ID, block;
    5.86 -    var i, j, k;
    5.87 -    var t = '';
    5.88 -
    5.89 -    for (i = 0; i < conservative_groups.length; i++)
    5.90 -    {
    5.91 -        var group = conservative_groups[i];
    5.92 -        var d = {};
    5.93 -        for (j = 0; j < group.length; j++)
    5.94 -        {
    5.95 -            var letter = group[j].toUpperCase();
    5.96 -            d[letter] = true;
    5.97 -        }
    5.98 -        conservative_groups_dict.push(d);
    5.99 -    }
   5.100 -
   5.101 -    var seq;
   5.102 -
   5.103 -    // generate positions for deprecated start-end blocks
   5.104 -    for (i = 0; i < blocks.length; i++)
   5.105 -    {
   5.106 -        block = blocks[i];
   5.107 -        if (block.end)
   5.108 -        {
   5.109 -            block.positions = [];
   5.110 -            for (j = block.start; j <= block.end; j++)
   5.111 -            {
   5.112 -                block.positions.push(j);
   5.113 -            }
   5.114 -        }
   5.115 -    }
   5.116 -
   5.117 -    // calculate max_ID_length
   5.118 -    max_ID_length = 0;
   5.119 -    for (ID in fasta_dict)
   5.120 -    {
   5.121 -        max_ID_length = Math.max(max_ID_length, ID.length);
   5.122 -    }
   5.123 -
   5.124 -    // sequence length
   5.125 -    for (ID in fasta_dict)
   5.126 -    {
   5.127 -        seq_length = fasta_dict[ID].length;
   5.128 -        break;
   5.129 -    }
   5.130 -    // number of sequences
   5.131 -    IDs_count = 0;
   5.132 -    $.each(fasta_dict, function(k,v) { IDs_count+=1});
   5.133 -
   5.134 -    // mark colorable positions
   5.135 -    useful_positions = {};
   5.136 -    for (ID in fasta_dict)
   5.137 -    {
   5.138 -        useful_positions[ID] = [];
   5.139 -    }
   5.140 -    for (i = 0; i < blocks.length; i++)
   5.141 -    {
   5.142 -        block = blocks[i];
   5.143 -        for (k = 0; k < block.IDs.length; k++)
   5.144 -        {
   5.145 -            ID = block.IDs[k];
   5.146 -            $.each(block.positions, function(key, pos) {
   5.147 -                useful_positions[ID][pos] = i;
   5.148 -            });
   5.149 -        }
   5.150 -    }
   5.151 -
   5.152 -    var is_conservative = [];
   5.153 -    var all_sequences = [];
   5.154 -    $.each(fasta_dict, function(ID, seq) { all_sequences.push(ID); });
   5.155 -    for (j = 0; j < seq_length; j++)
   5.156 -    {
   5.157 -        is_conservative[j] = is_conservative_column(j, all_sequences);
   5.158 -    }
   5.159 -
   5.160 -    for (i = 0; i < blocks.length; i++)
   5.161 -    {
   5.162 -        block = blocks[i];
   5.163 -        block.is_conservative = [];
   5.164 -        $.each(block.positions, function(key, pos) {
   5.165 -            block.is_conservative[j] = is_conservative_column(pos, block.IDs);
   5.166 -        });
   5.167 -    }
   5.168 -
   5.169 -    // pre-calculate strings for <pre>
   5.170 -    alignment_strings = {};
   5.171 -    var block_i;
   5.172 -    for (ID in fasta_dict)
   5.173 -    {
   5.174 -        t = '';
   5.175 -        seq = fasta_dict[ID];
   5.176 -        for (j = 0; j < seq_length; j++)
   5.177 -        {
   5.178 -            block_i = useful_positions[ID][j];
   5.179 -            block = blocks[block_i];
   5.180 -            if (block_i || block_i === 0)
   5.181 -            {
   5.182 -                // current element is a part of block
   5.183 -                var dark = block.is_conservative[j] && seq.charAt(j) != '-';
   5.184 -                var color = crc32_color(json(block), dark);
   5.185 -                t += '<font ';
   5.186 -                t += ' style="background:' + color + '; cursor:pointer;" ' ;
   5.187 -                t += ' onclick=letter_click("' + ID + '",' + j + ') ' ;
   5.188 -                t += ' class=block' + block_i + ' ';
   5.189 -                t += '>';
   5.190 -            }
   5.191 -            t += seq.charAt(j);
   5.192 -            if (block_i || block_i === 0)
   5.193 -            {
   5.194 -                t += '</font>';
   5.195 -            }
   5.196 -        }
   5.197 -        alignment_strings[ID] = t;
   5.198 -    }
   5.199 -
   5.200 -    // style
   5.201 -    set_table_width_height();
   5.202 -
   5.203 -    // position numbers
   5.204 -    t = '';
   5.205 -    var c = Math.floor(seq_length / legend_interval); // number of captions
   5.206 -    var current_number; // current number
   5.207 -    for (i = 1; i <= c; i++)
   5.208 -    {
   5.209 -        current_number = i * legend_interval;
   5.210 -        current_number = '' + current_number; // convert to string
   5.211 -        for (j = 0; j < legend_interval - current_number.length; j++)
   5.212 -        {
   5.213 -            t += ' ';
   5.214 -        }
   5.215 -        t += current_number;
   5.216 -    }
   5.217 -    var conservative_t = '';
   5.218 -    for (i = 0; i < t.length; i++)
   5.219 -    {
   5.220 -        var dark = is_conservative[i];
   5.221 -        var bgcolor = dark ? 'black' : 'white';
   5.222 -        var fgcolor = dark ? 'white' : 'black';
   5.223 -        var l;
   5.224 -        if (t.charAt(i) == ' ')
   5.225 -        {
   5.226 -            l = '&nbsp;'
   5.227 -        }
   5.228 -        else
   5.229 -        {
   5.230 -            l = t.charAt(i);
   5.231 -        }
   5.232 -        conservative_t += '<font ';
   5.233 -        conservative_t += ' style="background:' + bgcolor + ';color:' + fgcolor + ';" ' ;
   5.234 -        conservative_t += '>' + l + '</font>';
   5.235 -    }
   5.236 -    t = '<pre><nobr>' + conservative_t + '</nobr></pre>';
   5.237 -    $('#legend').html(t);
   5.238 -
   5.239 -    // run
   5.240 -    ID_order = [];
   5.241 -    $.each(fasta_dict, function(k,v) { ID_order.push(k); });
   5.242 -    blocks_show();
   5.243 -}
   5.244 -
   5.245 -function blocks_bind_mouseover()
   5.246 -{
   5.247 -    for (var i = 0; i < blocks.length; i++)
   5.248 -    {
   5.249 -        var s = '.block' + i;
   5.250 -        $(s).bind('mouseover', {s: s}, function(event) {
   5.251 -            $(event.data.s).css('color', 'green');
   5.252 -        });
   5.253 -        $(s).bind('mouseleave', {s: s}, function(event) {
   5.254 -            $(event.data.s).css('color', 'black');
   5.255 -        });
   5.256 -    }
   5.257 -}
   5.258 -// set width and height of main table
   5.259 -function set_table_width_height()
   5.260 -{
   5.261 -    /*
   5.262 -    in-<pre> string should have '\n' at start and at end
   5.263 -    */
   5.264 -    $('#mainpanel').height(mainpanel_height);
   5.265 -    $('#h1_header').height(h1_height);
   5.266 -    $('#legend').height(letter_height * 2);
   5.267 -    var screen_width = $(document).width();
   5.268 -    var screen_height = $(document).height();
   5.269 -    
   5.270 -    // width of panel with names = (width of name + 3 chars (" : ")) * width of char (9)
   5.271 -    var IDs_panel_width = (max_ID_length + 3) * letter_width;
   5.272 -    $('#IDs').width(IDs_panel_width);
   5.273 -
   5.274 -    // keep remaining
   5.275 -    var width_1 = screen_width - IDs_panel_width - boundary;
   5.276 -    // self-width
   5.277 -    var width_2 = letter_width * seq_length;
   5.278 -    var width = Math.min(width_1, width_2);
   5.279 -
   5.280 -    // keep remaining
   5.281 -    var height_1 = screen_height - h1_height - mainpanel_height - letter_height * 2 - boundary;
   5.282 -    // self-height
   5.283 -    var height_2 = letter_height * (IDs_count + 2);
   5.284 -    var height = Math.min(height_1, height_2);
   5.285 -
   5.286 -    $('#legend').width(width);
   5.287 -    if (height != height_2)
   5.288 -    {
   5.289 -        // add scrollbar size
   5.290 -        width += scroller_height_width;
   5.291 -    }
   5.292 -
   5.293 -    $('#alignment').width(width);
   5.294 -    $('#IDs').height(height);
   5.295 -
   5.296 -    if (width != width_2)
   5.297 -    {
   5.298 -        // add scrollbar size
   5.299 -        height += scroller_height_width;
   5.300 -    }
   5.301 -
   5.302 -    $('#alignment').height(height);
   5.303 -}
   5.304 -
   5.305 -// handler of scrolling
   5.306 -function alignment_onscroll()
   5.307 -{
   5.308 -    $('#legend').get(0).scrollLeft = $('#alignment').get(0).scrollLeft;
   5.309 -    $('#IDs').get(0).scrollTop = $('#alignment').get(0).scrollTop;
   5.310 -}
   5.311 -
   5.312 -// renders <pre> with alignment, if needed
   5.313 -function blocks_make_pre()
   5.314 -{
   5.315 -    if (json(ID_order) == json(ID_order_now))
   5.316 -    {
   5.317 -        return; // nothing changed
   5.318 -    }
   5.319 -
   5.320 -    var ID, block;
   5.321 -    var i, j;
   5.322 -    var t = '';
   5.323 -
   5.324 -    // Alignment
   5.325 -    t = '';
   5.326 -    t += "<pre>";
   5.327 -    for (i = 0; i < ID_order.length; i++)
   5.328 -    {
   5.329 -        ID = ID_order[i];
   5.330 -        t += alignment_strings[ID];
   5.331 -        if (i != ID_order.length - 1)
   5.332 -        {
   5.333 -            t += "\n";
   5.334 -        }
   5.335 -    }
   5.336 -    t += "</pre>\n";
   5.337 -    $('#alignment').html(t);
   5.338 -
   5.339 -    // panel with names
   5.340 -    t = '';
   5.341 -    t += "<pre>";
   5.342 -    for (i = 0; i < ID_order.length; i++)
   5.343 -    {
   5.344 -        ID = ID_order[i];
   5.345 -        // add spaces
   5.346 -        for (j = 0; j < max_ID_length - ID.length; j++)
   5.347 -        {
   5.348 -            t += ' ';
   5.349 -        }
   5.350 -        // name
   5.351 -        t += ID + ' : ';
   5.352 -        t += "\n";
   5.353 -    }
   5.354 -    t += "</pre>\n";
   5.355 -    $('#IDs').html(t);
   5.356 -
   5.357 -    ID_order_now = $.extend(true, [], ID_order);
   5.358 -}
   5.359 -
   5.360 -// handler of click event of letter
   5.361 -function letter_click(ID, pos)
   5.362 -{
   5.363 -    selected_block_i = useful_positions[ID][pos];
   5.364 -    // add block sequences
   5.365 -    ID_order = $.extend(true, [], blocks[selected_block_i].IDs);
   5.366 -    // other sequences
   5.367 -    for (ID in fasta_dict)
   5.368 -    {
   5.369 -        if ($.inArray(ID, ID_order) == -1)
   5.370 -        {
   5.371 -            ID_order.push(ID);
   5.372 -        }
   5.373 -    }
   5.374 -    blocks_show();
   5.375 -}
   5.376 -
   5.377 -function blocks_show()
   5.378 -{
   5.379 -    var t = '';
   5.380 -    if (selected_block_i || selected_block_i === 0)
   5.381 -    {
   5.382 -        t += 'Block ' + selected_block_i + '. ';
   5.383 -    }
   5.384 -    $('#mainpanel').html(t);
   5.385 -    blocks_make_pre();
   5.386 -    blocks_bind_mouseover();
   5.387 -}
   5.388 -
   5.389 +
   5.390 +/*
   5.391 +list of blocks
   5.392 +block = {
   5.393 +    int start; (inclusive) // do not use with positions
   5.394 +    int end; (inclusive) // do not use with positions
   5.395 +    int[] positions; // do not use with start and end
   5.396 +    IDs: list of IDs
   5.397 +    cores: []
   5.398 +    is_conservative: list, mapping pos to bool
   5.399 +}
   5.400 +*/
   5.401 +
   5.402 +var blocks = {};
   5.403 +
   5.404 +// fasta_dict[ID] = string reprentation of sequence
   5.405 +var fasta_dict = {};
   5.406 +
   5.407 +
   5.408 +// parameters
   5.409 +
   5.410 +var h1_height = 50; // header cell height
   5.411 +var mainpanel_height = 100; // toolbar height
   5.412 +var legend_interval = 10; // interval of position number captions
   5.413 +
   5.414 +var letter_width = 9; // letter width
   5.415 +var letter_height = 17; // letter height
   5.416 +var scroller_height_width = 16; // scrollbar height and width
   5.417 +
   5.418 +var boundary = 70; // margin
   5.419 +
   5.420 +// autogenerated variables
   5.421 +
   5.422 +var selected_block_i; // current block
   5.423 +var ID_order = []; // ID sequence
   5.424 +
   5.425 +var ID_order_now = []; // currently used ID_order
   5.426 +
   5.427 +var max_ID_length; // max name length
   5.428 +var seq_length; // sequence length
   5.429 +var IDs_count; // total number of sequences
   5.430 +
   5.431 +// alignment_strings[ID] = string with sequence for <pre>
   5.432 +var alignment_strings = {};
   5.433 +
   5.434 +var conservative_groups_dict = []; // list of dictsets of uppercased letters
   5.435 +
   5.436 +// useful_positions[ID][position] = block id
   5.437 +// (if this element is a part of at least one block)
   5.438 +var useful_positions = {};
   5.439 +
   5.440 +var blocks_inited = false;
   5.441 +
   5.442 +function is_conservative_column(column, sequences)
   5.443 +{
   5.444 +    var result = false;
   5.445 +    $.each(conservative_groups_dict, function(i, group) {
   5.446 +        var inside_group = true;
   5.447 +        $.each(sequences, function(j, ID) {
   5.448 +            if (!group[fasta_dict[ID].charAt(column).toUpperCase()])
   5.449 +            {
   5.450 +                inside_group = false;
   5.451 +            }
   5.452 +        });
   5.453 +        if (inside_group)
   5.454 +        {
   5.455 +            result = true;
   5.456 +        }
   5.457 +    });
   5.458 +    return result;
   5.459 +}
   5.460 +
   5.461 +// run application
   5.462 +function blocks_init()
   5.463 +{
   5.464 +    if (blocks_inited)
   5.465 +    {
   5.466 +        return;
   5.467 +    }
   5.468 +    blocks_inited = true;
   5.469 +
   5.470 +    var ID, block;
   5.471 +    var i, j, k;
   5.472 +    var t = '';
   5.473 +
   5.474 +    for (i = 0; i < conservative_groups.length; i++)
   5.475 +    {
   5.476 +        var group = conservative_groups[i];
   5.477 +        var d = {};
   5.478 +        for (j = 0; j < group.length; j++)
   5.479 +        {
   5.480 +            var letter = group[j].toUpperCase();
   5.481 +            d[letter] = true;
   5.482 +        }
   5.483 +        conservative_groups_dict.push(d);
   5.484 +    }
   5.485 +
   5.486 +    var seq;
   5.487 +
   5.488 +    // generate positions for deprecated start-end blocks
   5.489 +    for (i = 0; i < blocks.length; i++)
   5.490 +    {
   5.491 +        block = blocks[i];
   5.492 +        if (block.end)
   5.493 +        {
   5.494 +            block.positions = [];
   5.495 +            for (j = block.start; j <= block.end; j++)
   5.496 +            {
   5.497 +                block.positions.push(j);
   5.498 +            }
   5.499 +        }
   5.500 +    }
   5.501 +
   5.502 +    // calculate max_ID_length
   5.503 +    max_ID_length = 0;
   5.504 +    for (ID in fasta_dict)
   5.505 +    {
   5.506 +        max_ID_length = Math.max(max_ID_length, ID.length);
   5.507 +    }
   5.508 +
   5.509 +    // sequence length
   5.510 +    for (ID in fasta_dict)
   5.511 +    {
   5.512 +        seq_length = fasta_dict[ID].length;
   5.513 +        break;
   5.514 +    }
   5.515 +    // number of sequences
   5.516 +    IDs_count = 0;
   5.517 +    $.each(fasta_dict, function(k,v) { IDs_count+=1});
   5.518 +
   5.519 +    // mark colorable positions
   5.520 +    useful_positions = {};
   5.521 +    for (ID in fasta_dict)
   5.522 +    {
   5.523 +        useful_positions[ID] = [];
   5.524 +    }
   5.525 +    for (i = 0; i < blocks.length; i++)
   5.526 +    {
   5.527 +        block = blocks[i];
   5.528 +        for (k = 0; k < block.IDs.length; k++)
   5.529 +        {
   5.530 +            ID = block.IDs[k];
   5.531 +            $.each(block.positions, function(key, pos) {
   5.532 +                useful_positions[ID][pos] = i;
   5.533 +            });
   5.534 +        }
   5.535 +    }
   5.536 +
   5.537 +    var is_conservative = [];
   5.538 +    var all_sequences = [];
   5.539 +    $.each(fasta_dict, function(ID, seq) { all_sequences.push(ID); });
   5.540 +    for (j = 0; j < seq_length; j++)
   5.541 +    {
   5.542 +        is_conservative[j] = is_conservative_column(j, all_sequences);
   5.543 +    }
   5.544 +
   5.545 +    for (i = 0; i < blocks.length; i++)
   5.546 +    {
   5.547 +        block = blocks[i];
   5.548 +        block.is_conservative = [];
   5.549 +        $.each(block.positions, function(key, pos) {
   5.550 +            block.is_conservative[j] = is_conservative_column(pos, block.IDs);
   5.551 +        });
   5.552 +    }
   5.553 +
   5.554 +    // pre-calculate strings for <pre>
   5.555 +    alignment_strings = {};
   5.556 +    var block_i;
   5.557 +    for (ID in fasta_dict)
   5.558 +    {
   5.559 +        t = '';
   5.560 +        seq = fasta_dict[ID];
   5.561 +        for (j = 0; j < seq_length; j++)
   5.562 +        {
   5.563 +            block_i = useful_positions[ID][j];
   5.564 +            block = blocks[block_i];
   5.565 +            if (block_i || block_i === 0)
   5.566 +            {
   5.567 +                // current element is a part of block
   5.568 +                var dark = block.is_conservative[j] && seq.charAt(j) != '-';
   5.569 +                var color = crc32_color(json(block), dark);
   5.570 +                t += '<font ';
   5.571 +                t += ' style="background:' + color + '; cursor:pointer;" ' ;
   5.572 +                t += ' onclick=letter_click("' + ID + '",' + j + ') ' ;
   5.573 +                t += ' class=block' + block_i + ' ';
   5.574 +                t += '>';
   5.575 +            }
   5.576 +            t += seq.charAt(j);
   5.577 +            if (block_i || block_i === 0)
   5.578 +            {
   5.579 +                t += '</font>';
   5.580 +            }
   5.581 +        }
   5.582 +        alignment_strings[ID] = t;
   5.583 +    }
   5.584 +
   5.585 +    // style
   5.586 +    set_table_width_height();
   5.587 +
   5.588 +    // position numbers
   5.589 +    t = '';
   5.590 +    var c = Math.floor(seq_length / legend_interval); // number of captions
   5.591 +    var current_number; // current number
   5.592 +    for (i = 1; i <= c; i++)
   5.593 +    {
   5.594 +        current_number = i * legend_interval;
   5.595 +        current_number = '' + current_number; // convert to string
   5.596 +        for (j = 0; j < legend_interval - current_number.length; j++)
   5.597 +        {
   5.598 +            t += ' ';
   5.599 +        }
   5.600 +        t += current_number;
   5.601 +    }
   5.602 +    var conservative_t = '';
   5.603 +    for (i = 0; i < t.length; i++)
   5.604 +    {
   5.605 +        var dark = is_conservative[i];
   5.606 +        var bgcolor = dark ? 'black' : 'white';
   5.607 +        var fgcolor = dark ? 'white' : 'black';
   5.608 +        var l;
   5.609 +        if (t.charAt(i) == ' ')
   5.610 +        {
   5.611 +            l = '&nbsp;'
   5.612 +        }
   5.613 +        else
   5.614 +        {
   5.615 +            l = t.charAt(i);
   5.616 +        }
   5.617 +        conservative_t += '<font ';
   5.618 +        conservative_t += ' style="background:' + bgcolor + ';color:' + fgcolor + ';" ' ;
   5.619 +        conservative_t += '>' + l + '</font>';
   5.620 +    }
   5.621 +    t = '<pre><nobr>' + conservative_t + '</nobr></pre>';
   5.622 +    $('#legend').html(t);
   5.623 +
   5.624 +    // run
   5.625 +    ID_order = [];
   5.626 +    $.each(fasta_dict, function(k,v) { ID_order.push(k); });
   5.627 +    blocks_show();
   5.628 +}
   5.629 +
   5.630 +function blocks_bind_mouseover()
   5.631 +{
   5.632 +    for (var i = 0; i < blocks.length; i++)
   5.633 +    {
   5.634 +        var s = '.block' + i;
   5.635 +        $(s).bind('mouseover', {s: s}, function(event) {
   5.636 +            $(event.data.s).css('color', 'green');
   5.637 +        });
   5.638 +        $(s).bind('mouseleave', {s: s}, function(event) {
   5.639 +            $(event.data.s).css('color', 'black');
   5.640 +        });
   5.641 +    }
   5.642 +}
   5.643 +// set width and height of main table
   5.644 +function set_table_width_height()
   5.645 +{
   5.646 +    /*
   5.647 +    in-<pre> string should have '\n' at start and at end
   5.648 +    */
   5.649 +    $('#mainpanel').height(mainpanel_height);
   5.650 +    $('#h1_header').height(h1_height);
   5.651 +    $('#legend').height(letter_height * 2);
   5.652 +    var screen_width = $(document).width();
   5.653 +    var screen_height = $(document).height();
   5.654 +
   5.655 +    // width of panel with names = (width of name + 3 chars (" : ")) * width of char (9)
   5.656 +    var IDs_panel_width = (max_ID_length + 3) * letter_width;
   5.657 +    $('#IDs').width(IDs_panel_width);
   5.658 +
   5.659 +    // keep remaining
   5.660 +    var width_1 = screen_width - IDs_panel_width - boundary;
   5.661 +    // self-width
   5.662 +    var width_2 = letter_width * seq_length;
   5.663 +    var width = Math.min(width_1, width_2);
   5.664 +
   5.665 +    // keep remaining
   5.666 +    var height_1 = screen_height - h1_height - mainpanel_height - letter_height * 2 - boundary;
   5.667 +    // self-height
   5.668 +    var height_2 = letter_height * (IDs_count + 2);
   5.669 +    var height = Math.min(height_1, height_2);
   5.670 +
   5.671 +    $('#legend').width(width);
   5.672 +    if (height != height_2)
   5.673 +    {
   5.674 +        // add scrollbar size
   5.675 +        width += scroller_height_width;
   5.676 +    }
   5.677 +
   5.678 +    $('#alignment').width(width);
   5.679 +    $('#IDs').height(height);
   5.680 +
   5.681 +    if (width != width_2)
   5.682 +    {
   5.683 +        // add scrollbar size
   5.684 +        height += scroller_height_width;
   5.685 +    }
   5.686 +
   5.687 +    $('#alignment').height(height);
   5.688 +}
   5.689 +
   5.690 +// handler of scrolling
   5.691 +function alignment_onscroll()
   5.692 +{
   5.693 +    $('#legend').get(0).scrollLeft = $('#alignment').get(0).scrollLeft;
   5.694 +    $('#IDs').get(0).scrollTop = $('#alignment').get(0).scrollTop;
   5.695 +}
   5.696 +
   5.697 +// renders <pre> with alignment, if needed
   5.698 +function blocks_make_pre()
   5.699 +{
   5.700 +    if (json(ID_order) == json(ID_order_now))
   5.701 +    {
   5.702 +        return; // nothing changed
   5.703 +    }
   5.704 +
   5.705 +    var ID, block;
   5.706 +    var i, j;
   5.707 +    var t = '';
   5.708 +
   5.709 +    // Alignment
   5.710 +    t = '';
   5.711 +    t += "<pre>";
   5.712 +    for (i = 0; i < ID_order.length; i++)
   5.713 +    {
   5.714 +        ID = ID_order[i];
   5.715 +        t += alignment_strings[ID];
   5.716 +        if (i != ID_order.length - 1)
   5.717 +        {
   5.718 +            t += "\n";
   5.719 +        }
   5.720 +    }
   5.721 +    t += "</pre>\n";
   5.722 +    $('#alignment').html(t);
   5.723 +
   5.724 +    // panel with names
   5.725 +    t = '';
   5.726 +    t += "<pre>";
   5.727 +    for (i = 0; i < ID_order.length; i++)
   5.728 +    {
   5.729 +        ID = ID_order[i];
   5.730 +        // add spaces
   5.731 +        for (j = 0; j < max_ID_length - ID.length; j++)
   5.732 +        {
   5.733 +            t += ' ';
   5.734 +        }
   5.735 +        // name
   5.736 +        t += ID + ' : ';
   5.737 +        t += "\n";
   5.738 +    }
   5.739 +    t += "</pre>\n";
   5.740 +    $('#IDs').html(t);
   5.741 +
   5.742 +    ID_order_now = $.extend(true, [], ID_order);
   5.743 +}
   5.744 +
   5.745 +// handler of click event of letter
   5.746 +function letter_click(ID, pos)
   5.747 +{
   5.748 +    selected_block_i = useful_positions[ID][pos];
   5.749 +    // add block sequences
   5.750 +    ID_order = $.extend(true, [], blocks[selected_block_i].IDs);
   5.751 +    // other sequences
   5.752 +    for (ID in fasta_dict)
   5.753 +    {
   5.754 +        if ($.inArray(ID, ID_order) == -1)
   5.755 +        {
   5.756 +            ID_order.push(ID);
   5.757 +        }
   5.758 +    }
   5.759 +    blocks_show();
   5.760 +}
   5.761 +
   5.762 +function blocks_show()
   5.763 +{
   5.764 +    var t = '';
   5.765 +    if (selected_block_i || selected_block_i === 0)
   5.766 +    {
   5.767 +        t += 'Block ' + selected_block_i + '. ';
   5.768 +    }
   5.769 +    $('#mainpanel').html(t);
   5.770 +    blocks_make_pre();
   5.771 +    blocks_bind_mouseover();
   5.772 +}
   5.773 +
     6.1 --- a/blocks3d/www/input/crc32.js	Thu Jul 14 14:05:39 2011 +0400
     6.2 +++ b/blocks3d/www/input/crc32.js	Thu Jul 14 14:28:32 2011 +0400
     6.3 @@ -1,27 +1,27 @@
     6.4 -
     6.5 -function crc32 ( str ) {
     6.6 -    // http://kevin.vanzonneveld.net
     6.7 -    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
     6.8 -    // +   improved by: T0bsn
     6.9 -    // -    depends on: utf8_encode
    6.10 -    // *     example 1: crc32('Kevin van Zonneveld');
    6.11 -    // *     returns 1: 1249991249
    6.12 -
    6.13 -    //str = this.utf8_encode(str); // commented by bnagaev
    6.14 -    
    6.15 -    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";
    6.16 -
    6.17 -    var crc = 0;
    6.18 -    var x = 0;
    6.19 -    var y = 0;
    6.20 -
    6.21 -    crc = crc ^ (-1);
    6.22 -    for (var i = 0, iTop = str.length; i < iTop; i++) {
    6.23 -        y = ( crc ^ str.charCodeAt( i ) ) & 0xFF;
    6.24 -        x = "0x" + table.substr( y * 9, 8 );
    6.25 -        crc = ( crc >>> 8 ) ^ x;
    6.26 -    }
    6.27 -
    6.28 -    return crc ^ (-1);
    6.29 -}
    6.30 -
    6.31 +
    6.32 +function crc32 ( str ) {
    6.33 +    // http://kevin.vanzonneveld.net
    6.34 +    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    6.35 +    // +   improved by: T0bsn
    6.36 +    // -    depends on: utf8_encode
    6.37 +    // *     example 1: crc32('Kevin van Zonneveld');
    6.38 +    // *     returns 1: 1249991249
    6.39 +
    6.40 +    //str = this.utf8_encode(str); // commented by bnagaev
    6.41 +
    6.42 +    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";
    6.43 +
    6.44 +    var crc = 0;
    6.45 +    var x = 0;
    6.46 +    var y = 0;
    6.47 +
    6.48 +    crc = crc ^ (-1);
    6.49 +    for (var i = 0, iTop = str.length; i < iTop; i++) {
    6.50 +        y = ( crc ^ str.charCodeAt( i ) ) & 0xFF;
    6.51 +        x = "0x" + table.substr( y * 9, 8 );
    6.52 +        crc = ( crc >>> 8 ) ^ x;
    6.53 +    }
    6.54 +
    6.55 +    return crc ^ (-1);
    6.56 +}
    6.57 +
     7.1 --- a/blocks3d/www/input/crc32_color.js	Thu Jul 14 14:05:39 2011 +0400
     7.2 +++ b/blocks3d/www/input/crc32_color.js	Thu Jul 14 14:28:32 2011 +0400
     7.3 @@ -1,40 +1,40 @@
     7.4 -
     7.5 -/**
     7.6 - * returns color, corresponding to something (using crc32 value)
     7.7 - *
     7.8 - * @param string something string
     7.9 - * @param bool dark Should color be dark
    7.10 - *      If dark is true, first bit of each byte from color is set to 0,
    7.11 - *      otherwise to 1
    7.12 - */
    7.13 -function crc32_color(something, dark)
    7.14 -{
    7.15 -    var crc = crc32(something);
    7.16 -    var rgb = []; // [r, g, b] (3 last bytes of crc32 are used)
    7.17 -    rgb[0] = crc & 0xFF;
    7.18 -    rgb[1] = (crc >> 8) & 0xFF;
    7.19 -    rgb[2] = (crc >> 16) & 0xFF;
    7.20 -    var j;
    7.21 -    // lighten
    7.22 -    for (j = 0; j < 3; j++)
    7.23 -    {
    7.24 -        rgb[j] |= 0x80;
    7.25 -    }
    7.26 -    for (j = 0; j < 3; j++)
    7.27 -    {
    7.28 -        if (dark)
    7.29 -        {
    7.30 -            rgb[j] *= 0.8;
    7.31 -        }
    7.32 -    }
    7.33 -    for (j = 0; j < 3; j++)
    7.34 -    {
    7.35 -        rgb[j] = dechex(rgb[j]);
    7.36 -        if (rgb[j].length == 1)
    7.37 -        {
    7.38 -            rgb[j] = '0' + rgb[j];
    7.39 -        }
    7.40 -    }
    7.41 -    return '#' + rgb.join('');
    7.42 -}
    7.43 -
    7.44 +
    7.45 +/**
    7.46 + * returns color, corresponding to something (using crc32 value)
    7.47 + *
    7.48 + * @param string something string
    7.49 + * @param bool dark Should color be dark
    7.50 + *      If dark is true, first bit of each byte from color is set to 0,
    7.51 + *      otherwise to 1
    7.52 + */
    7.53 +function crc32_color(something, dark)
    7.54 +{
    7.55 +    var crc = crc32(something);
    7.56 +    var rgb = []; // [r, g, b] (3 last bytes of crc32 are used)
    7.57 +    rgb[0] = crc & 0xFF;
    7.58 +    rgb[1] = (crc >> 8) & 0xFF;
    7.59 +    rgb[2] = (crc >> 16) & 0xFF;
    7.60 +    var j;
    7.61 +    // lighten
    7.62 +    for (j = 0; j < 3; j++)
    7.63 +    {
    7.64 +        rgb[j] |= 0x80;
    7.65 +    }
    7.66 +    for (j = 0; j < 3; j++)
    7.67 +    {
    7.68 +        if (dark)
    7.69 +        {
    7.70 +            rgb[j] *= 0.8;
    7.71 +        }
    7.72 +    }
    7.73 +    for (j = 0; j < 3; j++)
    7.74 +    {
    7.75 +        rgb[j] = dechex(rgb[j]);
    7.76 +        if (rgb[j].length == 1)
    7.77 +        {
    7.78 +            rgb[j] = '0' + rgb[j];
    7.79 +        }
    7.80 +    }
    7.81 +    return '#' + rgb.join('');
    7.82 +}
    7.83 +
     8.1 --- a/blocks3d/www/input/dechex.js	Thu Jul 14 14:05:39 2011 +0400
     8.2 +++ b/blocks3d/www/input/dechex.js	Thu Jul 14 14:28:32 2011 +0400
     8.3 @@ -1,19 +1,19 @@
     8.4 -
     8.5 -function dechex (number) {
     8.6 -    // http://kevin.vanzonneveld.net
     8.7 -    // +   original by: Philippe Baumann
     8.8 -    // +   bugfixed by: Onno Marsman
     8.9 -    // +   improved by: http://stackoverflow.com/questions/57803/how-to-convert-decimal-to-hex-in-javascript
    8.10 -    // +   input by: pilus
    8.11 -    // *     example 1: dechex(10);
    8.12 -    // *     returns 1: 'a'
    8.13 -    // *     example 2: dechex(47);
    8.14 -    // *     returns 2: '2f'
    8.15 -    // *     example 3: dechex(-1415723993);
    8.16 -    // *     returns 3: 'ab9dc427'
    8.17 -    if (number < 0) {
    8.18 -        number = 0xFFFFFFFF + number + 1;
    8.19 -    }
    8.20 -    return parseInt(number, 10).toString(16);
    8.21 -}
    8.22 -
    8.23 +
    8.24 +function dechex (number) {
    8.25 +    // http://kevin.vanzonneveld.net
    8.26 +    // +   original by: Philippe Baumann
    8.27 +    // +   bugfixed by: Onno Marsman
    8.28 +    // +   improved by: http://stackoverflow.com/questions/57803/how-to-convert-decimal-to-hex-in-javascript
    8.29 +    // +   input by: pilus
    8.30 +    // *     example 1: dechex(10);
    8.31 +    // *     returns 1: 'a'
    8.32 +    // *     example 2: dechex(47);
    8.33 +    // *     returns 2: '2f'
    8.34 +    // *     example 3: dechex(-1415723993);
    8.35 +    // *     returns 3: 'ab9dc427'
    8.36 +    if (number < 0) {
    8.37 +        number = 0xFFFFFFFF + number + 1;
    8.38 +    }
    8.39 +    return parseInt(number, 10).toString(16);
    8.40 +}
    8.41 +
     9.1 --- a/blocks3d/www/input/index.txt	Thu Jul 14 14:05:39 2011 +0400
     9.2 +++ b/blocks3d/www/input/index.txt	Thu Jul 14 14:28:32 2011 +0400
     9.3 @@ -1,68 +1,68 @@
     9.4 -restindex
     9.5 -    format: html
     9.6 -    page-title: Blocks3D
     9.7 -    encoding: utf-8
     9.8 -    output-encoding: None
     9.9 -/restindex
    9.10 -
    9.11 -<style type="text/css">
    9.12 -{include_minified;css.css}
    9.13 -</style>
    9.14 -
    9.15 -<table width="100%" cellpadding="0" cellspacing="0">
    9.16 -
    9.17 -    <tr align="left" valign="top">
    9.18 -        <td colspan="2">
    9.19 -            <div id="h1_header"><h1>Reliable blocks finding</h1></div>
    9.20 -        </td>
    9.21 -    </tr>
    9.22 -
    9.23 -    <tr align="left" valign="top">
    9.24 -        <td colspan="2">
    9.25 -            <div id="mainpanel">Enable Javascript!</div>
    9.26 -        </td>
    9.27 -    </tr>
    9.28 -
    9.29 -    <tr align="left" valign="top">
    9.30 -        <td>
    9.31 -        </td>
    9.32 -        <td>
    9.33 -            <div id="legend"></div>
    9.34 -        </td>
    9.35 -    </tr>
    9.36 -
    9.37 -
    9.38 -    <tr align=left valign=top>
    9.39 -        <td>
    9.40 -            <div id="IDs"></div>
    9.41 -        </td>
    9.42 -        <td>
    9.43 -            <div id="alignment" onscroll="alignment_onscroll()"></div>
    9.44 -        </td>
    9.45 -    </tr>
    9.46 -
    9.47 -</table>
    9.48 -
    9.49 -
    9.50 -</table>
    9.51 -
    9.52 -<script type="text/javascript">
    9.53 -//<!--
    9.54 -
    9.55 -{include_minified;/usr/share/javascript/jquery/jquery.min.js}
    9.56 -{include_minified;json2.js}
    9.57 -{include_minified;crc32_color.js}
    9.58 -{include_minified;crc32.js}
    9.59 -{include_minified;dechex.js}
    9.60 -{include_minified;conservative_groups.js}
    9.61 -{include_minified;blocks.js}
    9.62 -
    9.63 -self_js_text
    9.64 -
    9.65 -$(document).ready(function() {
    9.66 -    blocks_init();
    9.67 -    });
    9.68 -
    9.69 -//-->
    9.70 -</script>
    9.71 -
    9.72 +restindex
    9.73 +    format: html
    9.74 +    page-title: Blocks3D
    9.75 +    encoding: utf-8
    9.76 +    output-encoding: None
    9.77 +/restindex
    9.78 +
    9.79 +<style type="text/css">
    9.80 +{include_minified;css.css}
    9.81 +</style>
    9.82 +
    9.83 +<table width="100%" cellpadding="0" cellspacing="0">
    9.84 +
    9.85 +    <tr align="left" valign="top">
    9.86 +        <td colspan="2">
    9.87 +            <div id="h1_header"><h1>Reliable blocks finding</h1></div>
    9.88 +        </td>
    9.89 +    </tr>
    9.90 +
    9.91 +    <tr align="left" valign="top">
    9.92 +        <td colspan="2">
    9.93 +            <div id="mainpanel">Enable Javascript!</div>
    9.94 +        </td>
    9.95 +    </tr>
    9.96 +
    9.97 +    <tr align="left" valign="top">
    9.98 +        <td>
    9.99 +        </td>
   9.100 +        <td>
   9.101 +            <div id="legend"></div>
   9.102 +        </td>
   9.103 +    </tr>
   9.104 +
   9.105 +
   9.106 +    <tr align=left valign=top>
   9.107 +        <td>
   9.108 +            <div id="IDs"></div>
   9.109 +        </td>
   9.110 +        <td>
   9.111 +            <div id="alignment" onscroll="alignment_onscroll()"></div>
   9.112 +        </td>
   9.113 +    </tr>
   9.114 +
   9.115 +</table>
   9.116 +
   9.117 +
   9.118 +</table>
   9.119 +
   9.120 +<script type="text/javascript">
   9.121 +//<!--
   9.122 +
   9.123 +{include_minified;/usr/share/javascript/jquery/jquery.min.js}
   9.124 +{include_minified;json2.js}
   9.125 +{include_minified;crc32_color.js}
   9.126 +{include_minified;crc32.js}
   9.127 +{include_minified;dechex.js}
   9.128 +{include_minified;conservative_groups.js}
   9.129 +{include_minified;blocks.js}
   9.130 +
   9.131 +self_js_text
   9.132 +
   9.133 +$(document).ready(function() {
   9.134 +    blocks_init();
   9.135 +    });
   9.136 +
   9.137 +//-->
   9.138 +</script>
   9.139 +
    10.1 --- a/blocks3d/www/input/json2.js	Thu Jul 14 14:05:39 2011 +0400
    10.2 +++ b/blocks3d/www/input/json2.js	Thu Jul 14 14:28:32 2011 +0400
    10.3 @@ -1,495 +1,495 @@
    10.4 -/*
    10.5 -    http://www.JSON.org/json2.js
    10.6 -    2009-06-29
    10.7 -
    10.8 -    Public Domain.
    10.9 -
   10.10 -    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
   10.11 -
   10.12 -    See http://www.JSON.org/js.html
   10.13 -
   10.14 -    This file creates a global JSON object containing two methods: stringify
   10.15 -    and parse.
   10.16 -
   10.17 -        JSON.stringify(value, replacer, space)
   10.18 -            value       any JavaScript value, usually an object or array.
   10.19 -
   10.20 -            replacer    an optional parameter that determines how object
   10.21 -                        values are stringified for objects. It can be a
   10.22 -                        function or an array of strings.
   10.23 -
   10.24 -            space       an optional parameter that specifies the indentation
   10.25 -                        of nested structures. If it is omitted, the text will
   10.26 -                        be packed without extra whitespace. If it is a number,
   10.27 -                        it will specify the number of spaces to indent at each
   10.28 -                        level. If it is a string (such as '\t' or '&nbsp;'),
   10.29 -                        it contains the characters used to indent at each level.
   10.30 -
   10.31 -            This method produces a JSON text from a JavaScript value.
   10.32 -
   10.33 -            When an object value is found, if the object contains a toJSON
   10.34 -            method, its toJSON method will be called and the result will be
   10.35 -            stringified. A toJSON method does not serialize: it returns the
   10.36 -            value represented by the name/value pair that should be serialized,
   10.37 -            or undefined if nothing should be serialized. The toJSON method
   10.38 -            will be passed the key associated with the value, and this will be
   10.39 -            bound to the object holding the key.
   10.40 -
   10.41 -            For example, this would serialize Dates as ISO strings.
   10.42 -
   10.43 -                Date.prototype.toJSON = function (key) {
   10.44 -                    function f(n) {
   10.45 -                        // Format integers to have at least two digits.
   10.46 -                        return n < 10 ? '0' + n : n;
   10.47 -                    }
   10.48 -
   10.49 -                    return this.getUTCFullYear()   + '-' +
   10.50 -                         f(this.getUTCMonth() + 1) + '-' +
   10.51 -                         f(this.getUTCDate())      + 'T' +
   10.52 -                         f(this.getUTCHours())     + ':' +
   10.53 -                         f(this.getUTCMinutes())   + ':' +
   10.54 -                         f(this.getUTCSeconds())   + 'Z';
   10.55 -                };
   10.56 -
   10.57 -            You can provide an optional replacer method. It will be passed the
   10.58 -            key and value of each member, with this bound to the containing
   10.59 -            object. The value that is returned from your method will be
   10.60 -            serialized. If your method returns undefined, then the member will
   10.61 -            be excluded from the serialization.
   10.62 -
   10.63 -            If the replacer parameter is an array of strings, then it will be
   10.64 -            used to select the members to be serialized. It filters the results
   10.65 -            such that only members with keys listed in the replacer array are
   10.66 -            stringified.
   10.67 -
   10.68 -            Values that do not have JSON representations, such as undefined or
   10.69 -            functions, will not be serialized. Such values in objects will be
   10.70 -            dropped; in arrays they will be replaced with null. You can use
   10.71 -            a replacer function to replace those with JSON values.
   10.72 -            JSON.stringify(undefined) returns undefined.
   10.73 -
   10.74 -            The optional space parameter produces a stringification of the
   10.75 -            value that is filled with line breaks and indentation to make it
   10.76 -            easier to read.
   10.77 -
   10.78 -            If the space parameter is a non-empty string, then that string will
   10.79 -            be used for indentation. If the space parameter is a number, then
   10.80 -            the indentation will be that many spaces.
   10.81 -
   10.82 -            Example:
   10.83 -
   10.84 -            text = JSON.stringify(['e', {pluribus: 'unum'}]);
   10.85 -            // text is '["e",{"pluribus":"unum"}]'
   10.86 -
   10.87 -
   10.88 -            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
   10.89 -            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
   10.90 -
   10.91 -            text = JSON.stringify([new Date()], function (key, value) {
   10.92 -                return this[key] instanceof Date ?
   10.93 -                    'Date(' + this[key] + ')' : value;
   10.94 -            });
   10.95 -            // text is '["Date(---current time---)"]'
   10.96 -
   10.97 -
   10.98 -        JSON.parse(text, reviver)
   10.99 -            This method parses a JSON text to produce an object or array.
  10.100 -            It can throw a SyntaxError exception.
  10.101 -
  10.102 -            The optional reviver parameter is a function that can filter and
  10.103 -            transform the results. It receives each of the keys and values,
  10.104 -            and its return value is used instead of the original value.
  10.105 -            If it returns what it received, then the structure is not modified.
  10.106 -            If it returns undefined then the member is deleted.
  10.107 -
  10.108 -            Example:
  10.109 -
  10.110 -            // Parse the text. Values that look like ISO date strings will
  10.111 -            // be converted to Date objects.
  10.112 -
  10.113 -            myData = JSON.parse(text, function (key, value) {
  10.114 -                var a;
  10.115 -                if (typeof value === 'string') {
  10.116 -                    a =
  10.117 -/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
  10.118 -                    if (a) {
  10.119 -                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
  10.120 -                            +a[5], +a[6]));
  10.121 -                    }
  10.122 -                }
  10.123 -                return value;
  10.124 -            });
  10.125 -
  10.126 -            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
  10.127 -                var d;
  10.128 -                if (typeof value === 'string' &&
  10.129 -                        value.slice(0, 5) === 'Date(' &&
  10.130 -                        value.slice(-1) === ')') {
  10.131 -                    d = new Date(value.slice(5, -1));
  10.132 -                    if (d) {
  10.133 -                        return d;
  10.134 -                    }
  10.135 -                }
  10.136 -                return value;
  10.137 -            });
  10.138 -
  10.139 -
  10.140 -    This is a reference implementation. You are free to copy, modify, or
  10.141 -    redistribute.
  10.142 -
  10.143 -    This code should be minified before deployment.
  10.144 -    See http://javascript.crockford.com/jsmin.html
  10.145 -
  10.146 -    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
  10.147 -    NOT CONTROL.
  10.148 -*/
  10.149 -
  10.150 -/*jslint evil: true */
  10.151 -
  10.152 -/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
  10.153 -    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
  10.154 -    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
  10.155 -    lastIndex, length, parse, prototype, push, replace, slice, stringify,
  10.156 -    test, toJSON, toString, valueOf
  10.157 -*/
  10.158 -
  10.159 -// Create a JSON object only if one does not already exist. We create the
  10.160 -// methods in a closure to avoid creating global variables.
  10.161 -
  10.162 -var JSON = JSON || {};
  10.163 -
  10.164 -(function () {
  10.165 -
  10.166 -    function f(n) {
  10.167 -        // Format integers to have at least two digits.
  10.168 -        return n < 10 ? '0' + n : n;
  10.169 -    }
  10.170 -
  10.171 -    if (typeof Date.prototype.toJSON !== 'function') {
  10.172 -
  10.173 -        Date.prototype.toJSON = function (key) {
  10.174 -
  10.175 -            return isFinite(this.valueOf()) ?
  10.176 -                   this.getUTCFullYear()   + '-' +
  10.177 -                 f(this.getUTCMonth() + 1) + '-' +
  10.178 -                 f(this.getUTCDate())      + 'T' +
  10.179 -                 f(this.getUTCHours())     + ':' +
  10.180 -                 f(this.getUTCMinutes())   + ':' +
  10.181 -                 f(this.getUTCSeconds())   + 'Z' : null;
  10.182 -        };
  10.183 -
  10.184 -        String.prototype.toJSON =
  10.185 -        Number.prototype.toJSON =
  10.186 -        Boolean.prototype.toJSON = function (key) {
  10.187 -            return this.valueOf();
  10.188 -        };
  10.189 -    }
  10.190 -
  10.191 -    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
  10.192 -        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
  10.193 -        gap,
  10.194 -        indent,
  10.195 -        meta = {    // table of character substitutions
  10.196 -            '\b': '\\b',
  10.197 -            '\t': '\\t',
  10.198 -            '\n': '\\n',
  10.199 -            '\f': '\\f',
  10.200 -            '\r': '\\r',
  10.201 -            '"' : '\\"',
  10.202 -            '\\': '\\\\'
  10.203 -        },
  10.204 -        rep;
  10.205 -
  10.206 -
  10.207 -    function quote(string) {
  10.208 -
  10.209 -// If the string contains no control characters, no quote characters, and no
  10.210 -// backslash characters, then we can safely slap some quotes around it.
  10.211 -// Otherwise we must also replace the offending characters with safe escape
  10.212 -// sequences.
  10.213 -
  10.214 -        escapable.lastIndex = 0;
  10.215 -        return escapable.test(string) ?
  10.216 -            '"' + string.replace(escapable, function (a) {
  10.217 -                var c = meta[a];
  10.218 -                return typeof c === 'string' ? c :
  10.219 -                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
  10.220 -            }) + '"' :
  10.221 -            '"' + string + '"';
  10.222 -    }
  10.223 -
  10.224 -
  10.225 -    function str(key, holder) {
  10.226 -
  10.227 -// Produce a string from holder[key].
  10.228 -
  10.229 -        var i,          // The loop counter.
  10.230 -            k,          // The member key.
  10.231 -            v,          // The member value.
  10.232 -            length,
  10.233 -            mind = gap,
  10.234 -            partial,
  10.235 -            value = holder[key];
  10.236 -
  10.237 -// If the value has a toJSON method, call it to obtain a replacement value.
  10.238 -
  10.239 -        if (value && typeof value === 'object' &&
  10.240 -                typeof value.toJSON === 'function') {
  10.241 -            value = value.toJSON(key);
  10.242 -        }
  10.243 -
  10.244 -// If we were called with a replacer function, then call the replacer to
  10.245 -// obtain a replacement value.
  10.246 -
  10.247 -        if (typeof rep === 'function') {
  10.248 -            value = rep.call(holder, key, value);
  10.249 -        }
  10.250 -
  10.251 -// What happens next depends on the value's type.
  10.252 -
  10.253 -        switch (typeof value) {
  10.254 -        case 'string':
  10.255 -            return quote(value);
  10.256 -
  10.257 -        case 'number':
  10.258 -
  10.259 -// JSON numbers must be finite. Encode non-finite numbers as null.
  10.260 -
  10.261 -            return isFinite(value) ? String(value) : 'null';
  10.262 -
  10.263 -        case 'boolean':
  10.264 -        case 'null':
  10.265 -
  10.266 -// If the value is a boolean or null, convert it to a string. Note:
  10.267 -// typeof null does not produce 'null'. The case is included here in
  10.268 -// the remote chance that this gets fixed someday.
  10.269 -
  10.270 -            return String(value);
  10.271 -
  10.272 -// If the type is 'object', we might be dealing with an object or an array or
  10.273 -// null.
  10.274 -
  10.275 -        case 'object':
  10.276 -
  10.277 -// Due to a specification blunder in ECMAScript, typeof null is 'object',
  10.278 -// so watch out for that case.
  10.279 -
  10.280 -            if (!value) {
  10.281 -                return 'null';
  10.282 -            }
  10.283 -
  10.284 -// Make an array to hold the partial results of stringifying this object value.
  10.285 -
  10.286 -            gap += indent;
  10.287 -            partial = [];
  10.288 -
  10.289 -// Is the value an array?
  10.290 -
  10.291 -            if (Object.prototype.toString.apply(value) === '[object Array]') {
  10.292 -
  10.293 -// The value is an array. Stringify every element. Use null as a placeholder
  10.294 -// for non-JSON values.
  10.295 -
  10.296 -                length = value.length;
  10.297 -                for (i = 0; i < length; i += 1) {
  10.298 -                    partial[i] = str(i, value) || 'null';
  10.299 -                }
  10.300 -
  10.301 -// Join all of the elements together, separated with commas, and wrap them in
  10.302 -// brackets.
  10.303 -
  10.304 -                v = partial.length === 0 ? '[]' :
  10.305 -                    gap ? '[\n' + gap +
  10.306 -                            partial.join(',\n' + gap) + '\n' +
  10.307 -                                mind + ']' :
  10.308 -                          '[' + partial.join(',') + ']';
  10.309 -                gap = mind;
  10.310 -                return v;
  10.311 -            }
  10.312 -
  10.313 -// If the replacer is an array, use it to select the members to be stringified.
  10.314 -
  10.315 -            if (rep && typeof rep === 'object') {
  10.316 -                length = rep.length;
  10.317 -                for (i = 0; i < length; i += 1) {
  10.318 -                    k = rep[i];
  10.319 -                    if (typeof k === 'string') {
  10.320 -                        v = str(k, value);
  10.321 -                        if (v) {
  10.322 -                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
  10.323 -                        }
  10.324 -                    }
  10.325 -                }
  10.326 -            } else {
  10.327 -
  10.328 -// Otherwise, iterate through all of the keys in the object.
  10.329 -
  10.330 -                for (k in value) {
  10.331 -                    if (Object.hasOwnProperty.call(value, k)) {
  10.332 -                        v = str(k, value);
  10.333 -                        if (v) {
  10.334 -                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
  10.335 -                        }
  10.336 -                    }
  10.337 -                }
  10.338 -            }
  10.339 -
  10.340 -// Join all of the member texts together, separated with commas,
  10.341 -// and wrap them in braces.
  10.342 -
  10.343 -            v = partial.length === 0 ? '{}' :
  10.344 -                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
  10.345 -                        mind + '}' : '{' + partial.join(',') + '}';
  10.346 -            gap = mind;
  10.347 -            return v;
  10.348 -        }
  10.349 -    }
  10.350 -
  10.351 -// If the JSON object does not yet have a stringify method, give it one.
  10.352 -
  10.353 -    if (typeof JSON.stringify !== 'function') {
  10.354 -        JSON.stringify = function (value, replacer, space) {
  10.355 -
  10.356 -// The stringify method takes a value and an optional replacer, and an optional
  10.357 -// space parameter, and returns a JSON text. The replacer can be a function
  10.358 -// that can replace values, or an array of strings that will select the keys.
  10.359 -// A default replacer method can be provided. Use of the space parameter can
  10.360 -// produce text that is more easily readable.
  10.361 -
  10.362 -            var i;
  10.363 -            gap = '';
  10.364 -            indent = '';
  10.365 -
  10.366 -// If the space parameter is a number, make an indent string containing that
  10.367 -// many spaces.
  10.368 -
  10.369 -            if (typeof space === 'number') {
  10.370 -                for (i = 0; i < space; i += 1) {
  10.371 -                    indent += ' ';
  10.372 -                }
  10.373 -
  10.374 -// If the space parameter is a string, it will be used as the indent string.
  10.375 -
  10.376 -            } else if (typeof space === 'string') {
  10.377 -                indent = space;
  10.378 -            }
  10.379 -
  10.380 -// If there is a replacer, it must be a function or an array.
  10.381 -// Otherwise, throw an error.
  10.382 -
  10.383 -            rep = replacer;
  10.384 -            if (replacer && typeof replacer !== 'function' &&
  10.385 -                    (typeof replacer !== 'object' ||
  10.386 -                     typeof replacer.length !== 'number')) {
  10.387 -                throw new Error('JSON.stringify');
  10.388 -            }
  10.389 -
  10.390 -// Make a fake root object containing our value under the key of ''.
  10.391 -// Return the result of stringifying the value.
  10.392 -
  10.393 -            return str('', {'': value});
  10.394 -        };
  10.395 -    }
  10.396 -
  10.397 -
  10.398 -// If the JSON object does not yet have a parse method, give it one.
  10.399 -
  10.400 -    if (typeof JSON.parse !== 'function') {
  10.401 -        JSON.parse = function (text, reviver) {
  10.402 -
  10.403 -// The parse method takes a text and an optional reviver function, and returns
  10.404 -// a JavaScript value if the text is a valid JSON text.
  10.405 -
  10.406 -            var j;
  10.407 -
  10.408 -            function walk(holder, key) {
  10.409 -
  10.410 -// The walk method is used to recursively walk the resulting structure so
  10.411 -// that modifications can be made.
  10.412 -
  10.413 -                var k, v, value = holder[key];
  10.414 -                if (value && typeof value === 'object') {
  10.415 -                    for (k in value) {
  10.416 -                        if (Object.hasOwnProperty.call(value, k)) {
  10.417 -                            v = walk(value, k);
  10.418 -                            if (v !== undefined) {
  10.419 -                                value[k] = v;
  10.420 -                            } else {
  10.421 -                                delete value[k];
  10.422 -                            }
  10.423 -                        }
  10.424 -                    }
  10.425 -                }
  10.426 -                return reviver.call(holder, key, value);
  10.427 -            }
  10.428 -
  10.429 -
  10.430 -// Parsing happens in four stages. In the first stage, we replace certain
  10.431 -// Unicode characters with escape sequences. JavaScript handles many characters
  10.432 -// incorrectly, either silently deleting them, or treating them as line endings.
  10.433 -
  10.434 -            cx.lastIndex = 0;
  10.435 -            if (cx.test(text)) {
  10.436 -                text = text.replace(cx, function (a) {
  10.437 -                    return '\\u' +
  10.438 -                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
  10.439 -                });
  10.440 -            }
  10.441 -
  10.442 -// In the second stage, we run the text against regular expressions that look
  10.443 -// for non-JSON patterns. We are especially concerned with '()' and 'new'
  10.444 -// because they can cause invocation, and '=' because it can cause mutation.
  10.445 -// But just to be safe, we want to reject all unexpected forms.
  10.446 -
  10.447 -// We split the second stage into 4 regexp operations in order to work around
  10.448 -// crippling inefficiencies in IE's and Safari's regexp engines. First we
  10.449 -// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
  10.450 -// replace all simple value tokens with ']' characters. Third, we delete all
  10.451 -// open brackets that follow a colon or comma or that begin the text. Finally,
  10.452 -// we look to see that the remaining characters are only whitespace or ']' or
  10.453 -// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
  10.454 -
  10.455 -            if (/^[\],:{}\s]*$/.
  10.456 -test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
  10.457 -replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
  10.458 -replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
  10.459 -
  10.460 -// In the third stage we use the eval function to compile the text into a
  10.461 -// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
  10.462 -// in JavaScript: it can begin a block or an object literal. We wrap the text
  10.463 -// in parens to eliminate the ambiguity.
  10.464 -
  10.465 -                j = eval('(' + text + ')');
  10.466 -
  10.467 -// In the optional fourth stage, we recursively walk the new structure, passing
  10.468 -// each name/value pair to a reviver function for possible transformation.
  10.469 -
  10.470 -                return typeof reviver === 'function' ?
  10.471 -                    walk({'': j}, '') : j;
  10.472 -            }
  10.473 -
  10.474 -// If the text is not JSON parseable, then a SyntaxError is thrown.
  10.475 -
  10.476 -            throw new SyntaxError('JSON.parse');
  10.477 -        };
  10.478 -    }
  10.479 -}());
  10.480 -
  10.481 -
  10.482 -
  10.483 -
  10.484 -// JSON
  10.485 -function json(obj7)
  10.486 -{
  10.487 -    if (typeof(obj7) == 'string')
  10.488 -    {
  10.489 -        // decode
  10.490 -        return JSON.parse(obj7);
  10.491 -    }
  10.492 -    else
  10.493 -    {
  10.494 -        // encode
  10.495 -        return JSON.stringify(obj7);
  10.496 -    }
  10.497 -}
  10.498 -
  10.499 +/*
  10.500 +    http://www.JSON.org/json2.js
  10.501 +    2009-06-29
  10.502 +
  10.503 +    Public Domain.
  10.504 +
  10.505 +    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
  10.506 +
  10.507 +    See http://www.JSON.org/js.html
  10.508 +
  10.509 +    This file creates a global JSON object containing two methods: stringify
  10.510 +    and parse.
  10.511 +
  10.512 +        JSON.stringify(value, replacer, space)
  10.513 +            value       any JavaScript value, usually an object or array.
  10.514 +
  10.515 +            replacer    an optional parameter that determines how object
  10.516 +                        values are stringified for objects. It can be a
  10.517 +                        function or an array of strings.
  10.518 +
  10.519 +            space       an optional parameter that specifies the indentation
  10.520 +                        of nested structures. If it is omitted, the text will
  10.521 +                        be packed without extra whitespace. If it is a number,
  10.522 +                        it will specify the number of spaces to indent at each
  10.523 +                        level. If it is a string (such as '\t' or '&nbsp;'),
  10.524 +                        it contains the characters used to indent at each level.
  10.525 +
  10.526 +            This method produces a JSON text from a JavaScript value.
  10.527 +
  10.528 +            When an object value is found, if the object contains a toJSON
  10.529 +            method, its toJSON method will be called and the result will be
  10.530 +            stringified. A toJSON method does not serialize: it returns the
  10.531 +            value represented by the name/value pair that should be serialized,
  10.532 +            or undefined if nothing should be serialized. The toJSON method
  10.533 +            will be passed the key associated with the value, and this will be
  10.534 +            bound to the object holding the key.
  10.535 +
  10.536 +            For example, this would serialize Dates as ISO strings.
  10.537 +
  10.538 +                Date.prototype.toJSON = function (key) {
  10.539 +                    function f(n) {
  10.540 +                        // Format integers to have at least two digits.
  10.541 +                        return n < 10 ? '0' + n : n;
  10.542 +                    }
  10.543 +
  10.544 +                    return this.getUTCFullYear()   + '-' +
  10.545 +                         f(this.getUTCMonth() + 1) + '-' +
  10.546 +                         f(this.getUTCDate())      + 'T' +
  10.547 +                         f(this.getUTCHours())     + ':' +
  10.548 +                         f(this.getUTCMinutes())   + ':' +
  10.549 +                         f(this.getUTCSeconds())   + 'Z';
  10.550 +                };
  10.551 +
  10.552 +            You can provide an optional replacer method. It will be passed the
  10.553 +            key and value of each member, with this bound to the containing
  10.554 +            object. The value that is returned from your method will be
  10.555 +            serialized. If your method returns undefined, then the member will
  10.556 +            be excluded from the serialization.
  10.557 +
  10.558 +            If the replacer parameter is an array of strings, then it will be
  10.559 +            used to select the members to be serialized. It filters the results
  10.560 +            such that only members with keys listed in the replacer array are
  10.561 +            stringified.
  10.562 +
  10.563 +            Values that do not have JSON representations, such as undefined or
  10.564 +            functions, will not be serialized. Such values in objects will be
  10.565 +            dropped; in arrays they will be replaced with null. You can use
  10.566 +            a replacer function to replace those with JSON values.
  10.567 +            JSON.stringify(undefined) returns undefined.
  10.568 +
  10.569 +            The optional space parameter produces a stringification of the
  10.570 +            value that is filled with line breaks and indentation to make it
  10.571 +            easier to read.
  10.572 +
  10.573 +            If the space parameter is a non-empty string, then that string will
  10.574 +            be used for indentation. If the space parameter is a number, then
  10.575 +            the indentation will be that many spaces.
  10.576 +
  10.577 +            Example:
  10.578 +
  10.579 +            text = JSON.stringify(['e', {pluribus: 'unum'}]);
  10.580 +            // text is '["e",{"pluribus":"unum"}]'
  10.581 +
  10.582 +
  10.583 +            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
  10.584 +            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
  10.585 +
  10.586 +            text = JSON.stringify([new Date()], function (key, value) {
  10.587 +                return this[key] instanceof Date ?
  10.588 +                    'Date(' + this[key] + ')' : value;
  10.589 +            });
  10.590 +            // text is '["Date(---current time---)"]'
  10.591 +
  10.592 +
  10.593 +        JSON.parse(text, reviver)
  10.594 +            This method parses a JSON text to produce an object or array.
  10.595 +            It can throw a SyntaxError exception.
  10.596 +
  10.597 +            The optional reviver parameter is a function that can filter and
  10.598 +            transform the results. It receives each of the keys and values,
  10.599 +            and its return value is used instead of the original value.
  10.600 +            If it returns what it received, then the structure is not modified.
  10.601 +            If it returns undefined then the member is deleted.
  10.602 +
  10.603 +            Example:
  10.604 +
  10.605 +            // Parse the text. Values that look like ISO date strings will
  10.606 +            // be converted to Date objects.
  10.607 +
  10.608 +            myData = JSON.parse(text, function (key, value) {
  10.609 +                var a;
  10.610 +                if (typeof value === 'string') {
  10.611 +                    a =
  10.612 +/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
  10.613 +                    if (a) {
  10.614 +                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
  10.615 +                            +a[5], +a[6]));
  10.616 +                    }
  10.617 +                }
  10.618 +                return value;
  10.619 +            });
  10.620 +
  10.621 +            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
  10.622 +                var d;
  10.623 +                if (typeof value === 'string' &&
  10.624 +                        value.slice(0, 5) === 'Date(' &&
  10.625 +                        value.slice(-1) === ')') {
  10.626 +                    d = new Date(value.slice(5, -1));
  10.627 +                    if (d) {
  10.628 +                        return d;
  10.629 +                    }
  10.630 +                }
  10.631 +                return value;
  10.632 +            });
  10.633 +
  10.634 +
  10.635 +    This is a reference implementation. You are free to copy, modify, or
  10.636 +    redistribute.
  10.637 +
  10.638 +    This code should be minified before deployment.
  10.639 +    See http://javascript.crockford.com/jsmin.html
  10.640 +
  10.641 +    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
  10.642 +    NOT CONTROL.
  10.643 +*/
  10.644 +
  10.645 +/*jslint evil: true */
  10.646 +
  10.647 +/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
  10.648 +    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
  10.649 +    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
  10.650 +    lastIndex, length, parse, prototype, push, replace, slice, stringify,
  10.651 +    test, toJSON, toString, valueOf
  10.652 +*/
  10.653 +
  10.654 +// Create a JSON object only if one does not already exist. We create the
  10.655 +// methods in a closure to avoid creating global variables.
  10.656 +
  10.657 +var JSON = JSON || {};
  10.658 +
  10.659 +(function () {
  10.660 +
  10.661 +    function f(n) {
  10.662 +        // Format integers to have at least two digits.
  10.663 +        return n < 10 ? '0' + n : n;
  10.664 +    }
  10.665 +
  10.666 +    if (typeof Date.prototype.toJSON !== 'function') {
  10.667 +
  10.668 +        Date.prototype.toJSON = function (key) {
  10.669 +
  10.670 +            return isFinite(this.valueOf()) ?
  10.671 +                   this.getUTCFullYear()   + '-' +
  10.672 +                 f(this.getUTCMonth() + 1) + '-' +
  10.673 +                 f(this.getUTCDate())      + 'T' +
  10.674 +                 f(this.getUTCHours())     + ':' +
  10.675 +                 f(this.getUTCMinutes())   + ':' +
  10.676 +                 f(this.getUTCSeconds())   + 'Z' : null;
  10.677 +        };
  10.678 +
  10.679 +        String.prototype.toJSON =
  10.680 +        Number.prototype.toJSON =
  10.681 +        Boolean.prototype.toJSON = function (key) {
  10.682 +            return this.valueOf();
  10.683 +        };
  10.684 +    }
  10.685 +
  10.686 +    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
  10.687 +        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
  10.688 +        gap,
  10.689 +        indent,
  10.690 +        meta = {    // table of character substitutions
  10.691 +            '\b': '\\b',
  10.692 +            '\t': '\\t',
  10.693 +            '\n': '\\n',
  10.694 +            '\f': '\\f',
  10.695 +            '\r': '\\r',
  10.696 +            '"' : '\\"',
  10.697 +            '\\': '\\\\'
  10.698 +        },
  10.699 +        rep;
  10.700 +
  10.701 +
  10.702 +    function quote(string) {
  10.703 +
  10.704 +// If the string contains no control characters, no quote characters, and no
  10.705 +// backslash characters, then we can safely slap some quotes around it.
  10.706 +// Otherwise we must also replace the offending characters with safe escape
  10.707 +// sequences.
  10.708 +
  10.709 +        escapable.lastIndex = 0;
  10.710 +        return escapable.test(string) ?
  10.711 +            '"' + string.replace(escapable, function (a) {
  10.712 +                var c = meta[a];
  10.713 +                return typeof c === 'string' ? c :
  10.714 +                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
  10.715 +            }) + '"' :
  10.716 +            '"' + string + '"';
  10.717 +    }
  10.718 +
  10.719 +
  10.720 +    function str(key, holder) {
  10.721 +
  10.722 +// Produce a string from holder[key].
  10.723 +
  10.724 +        var i,          // The loop counter.
  10.725 +            k,          // The member key.
  10.726 +            v,          // The member value.
  10.727 +            length,
  10.728 +            mind = gap,
  10.729 +            partial,
  10.730 +            value = holder[key];
  10.731 +
  10.732 +// If the value has a toJSON method, call it to obtain a replacement value.
  10.733 +
  10.734 +        if (value && typeof value === 'object' &&
  10.735 +                typeof value.toJSON === 'function') {
  10.736 +            value = value.toJSON(key);
  10.737 +        }
  10.738 +
  10.739 +// If we were called with a replacer function, then call the replacer to
  10.740 +// obtain a replacement value.
  10.741 +
  10.742 +        if (typeof rep === 'function') {
  10.743 +            value = rep.call(holder, key, value);
  10.744 +        }
  10.745 +
  10.746 +// What happens next depends on the value's type.
  10.747 +
  10.748 +        switch (typeof value) {
  10.749 +        case 'string':
  10.750 +            return quote(value);
  10.751 +
  10.752 +        case 'number':
  10.753 +
  10.754 +// JSON numbers must be finite. Encode non-finite numbers as null.
  10.755 +
  10.756 +            return isFinite(value) ? String(value) : 'null';
  10.757 +
  10.758 +        case 'boolean':
  10.759 +        case 'null':
  10.760 +
  10.761 +// If the value is a boolean or null, convert it to a string. Note:
  10.762 +// typeof null does not produce 'null'. The case is included here in
  10.763 +// the remote chance that this gets fixed someday.
  10.764 +
  10.765 +            return String(value);
  10.766 +
  10.767 +// If the type is 'object', we might be dealing with an object or an array or
  10.768 +// null.
  10.769 +
  10.770 +        case 'object':
  10.771 +
  10.772 +// Due to a specification blunder in ECMAScript, typeof null is 'object',
  10.773 +// so watch out for that case.
  10.774 +
  10.775 +            if (!value) {
  10.776 +                return 'null';
  10.777 +            }
  10.778 +
  10.779 +// Make an array to hold the partial results of stringifying this object value.
  10.780 +
  10.781 +            gap += indent;
  10.782 +            partial = [];
  10.783 +
  10.784 +// Is the value an array?
  10.785 +
  10.786 +            if (Object.prototype.toString.apply(value) === '[object Array]') {
  10.787 +
  10.788 +// The value is an array. Stringify every element. Use null as a placeholder
  10.789 +// for non-JSON values.
  10.790 +
  10.791 +                length = value.length;
  10.792 +                for (i = 0; i < length; i += 1) {
  10.793 +                    partial[i] = str(i, value) || 'null';
  10.794 +                }
  10.795 +
  10.796 +// Join all of the elements together, separated with commas, and wrap them in
  10.797 +// brackets.
  10.798 +
  10.799 +                v = partial.length === 0 ? '[]' :
  10.800 +                    gap ? '[\n' + gap +
  10.801 +                            partial.join(',\n' + gap) + '\n' +
  10.802 +                                mind + ']' :
  10.803 +                          '[' + partial.join(',') + ']';
  10.804 +                gap = mind;
  10.805 +                return v;
  10.806 +            }
  10.807 +
  10.808 +// If the replacer is an array, use it to select the members to be stringified.
  10.809 +
  10.810 +            if (rep && typeof rep === 'object') {
  10.811 +                length = rep.length;
  10.812 +                for (i = 0; i < length; i += 1) {
  10.813 +                    k = rep[i];
  10.814 +                    if (typeof k === 'string') {
  10.815 +                        v = str(k, value);
  10.816 +                        if (v) {
  10.817 +                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
  10.818 +                        }
  10.819 +                    }
  10.820 +                }
  10.821 +            } else {
  10.822 +
  10.823 +// Otherwise, iterate through all of the keys in the object.
  10.824 +
  10.825 +                for (k in value) {
  10.826 +                    if (Object.hasOwnProperty.call(value, k)) {
  10.827 +                        v = str(k, value);
  10.828 +                        if (v) {
  10.829 +                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
  10.830 +                        }
  10.831 +                    }
  10.832 +                }
  10.833 +            }
  10.834 +
  10.835 +// Join all of the member texts together, separated with commas,
  10.836 +// and wrap them in braces.
  10.837 +
  10.838 +            v = partial.length === 0 ? '{}' :
  10.839 +                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
  10.840 +                        mind + '}' : '{' + partial.join(',') + '}';
  10.841 +            gap = mind;
  10.842 +            return v;
  10.843 +        }
  10.844 +    }
  10.845 +
  10.846 +// If the JSON object does not yet have a stringify method, give it one.
  10.847 +
  10.848 +    if (typeof JSON.stringify !== 'function') {
  10.849 +        JSON.stringify = function (value, replacer, space) {
  10.850 +
  10.851 +// The stringify method takes a value and an optional replacer, and an optional
  10.852 +// space parameter, and returns a JSON text. The replacer can be a function
  10.853 +// that can replace values, or an array of strings that will select the keys.
  10.854 +// A default replacer method can be provided. Use of the space parameter can
  10.855 +// produce text that is more easily readable.
  10.856 +
  10.857 +            var i;
  10.858 +            gap = '';
  10.859 +            indent = '';
  10.860 +
  10.861 +// If the space parameter is a number, make an indent string containing that
  10.862 +// many spaces.
  10.863 +
  10.864 +            if (typeof space === 'number') {
  10.865 +                for (i = 0; i < space; i += 1) {
  10.866 +                    indent += ' ';
  10.867 +                }
  10.868 +
  10.869 +// If the space parameter is a string, it will be used as the indent string.
  10.870 +
  10.871 +            } else if (typeof space === 'string') {
  10.872 +                indent = space;
  10.873 +            }
  10.874 +
  10.875 +// If there is a replacer, it must be a function or an array.
  10.876 +// Otherwise, throw an error.
  10.877 +
  10.878 +            rep = replacer;
  10.879 +            if (replacer && typeof replacer !== 'function' &&
  10.880 +                    (typeof replacer !== 'object' ||
  10.881 +                     typeof replacer.length !== 'number')) {
  10.882 +                throw new Error('JSON.stringify');
  10.883 +            }
  10.884 +
  10.885 +// Make a fake root object containing our value under the key of ''.
  10.886 +// Return the result of stringifying the value.
  10.887 +
  10.888 +            return str('', {'': value});
  10.889 +        };
  10.890 +    }
  10.891 +
  10.892 +
  10.893 +// If the JSON object does not yet have a parse method, give it one.
  10.894 +
  10.895 +    if (typeof JSON.parse !== 'function') {
  10.896 +        JSON.parse = function (text, reviver) {
  10.897 +
  10.898 +// The parse method takes a text and an optional reviver function, and returns
  10.899 +// a JavaScript value if the text is a valid JSON text.
  10.900 +
  10.901 +            var j;
  10.902 +
  10.903 +            function walk(holder, key) {
  10.904 +
  10.905 +// The walk method is used to recursively walk the resulting structure so
  10.906 +// that modifications can be made.
  10.907 +
  10.908 +                var k, v, value = holder[key];
  10.909 +                if (value && typeof value === 'object') {
  10.910 +                    for (k in value) {
  10.911 +                        if (Object.hasOwnProperty.call(value, k)) {
  10.912 +                            v = walk(value, k);
  10.913 +                            if (v !== undefined) {
  10.914 +                                value[k] = v;
  10.915 +                            } else {
  10.916 +                                delete value[k];
  10.917 +                            }
  10.918 +                        }
  10.919 +                    }
  10.920 +                }
  10.921 +                return reviver.call(holder, key, value);
  10.922 +            }
  10.923 +
  10.924 +
  10.925 +// Parsing happens in four stages. In the first stage, we replace certain
  10.926 +// Unicode characters with escape sequences. JavaScript handles many characters
  10.927 +// incorrectly, either silently deleting them, or treating them as line endings.
  10.928 +
  10.929 +            cx.lastIndex = 0;
  10.930 +            if (cx.test(text)) {
  10.931 +                text = text.replace(cx, function (a) {
  10.932 +                    return '\\u' +
  10.933 +                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
  10.934 +                });
  10.935 +            }
  10.936 +
  10.937 +// In the second stage, we run the text against regular expressions that look
  10.938 +// for non-JSON patterns. We are especially concerned with '()' and 'new'
  10.939 +// because they can cause invocation, and '=' because it can cause mutation.
  10.940 +// But just to be safe, we want to reject all unexpected forms.
  10.941 +
  10.942 +// We split the second stage into 4 regexp operations in order to work around
  10.943 +// crippling inefficiencies in IE's and Safari's regexp engines. First we
  10.944 +// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
  10.945 +// replace all simple value tokens with ']' characters. Third, we delete all
  10.946 +// open brackets that follow a colon or comma or that begin the text. Finally,
  10.947 +// we look to see that the remaining characters are only whitespace or ']' or
  10.948 +// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
  10.949 +
  10.950 +            if (/^[\],:{}\s]*$/.
  10.951 +test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
  10.952 +replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
  10.953 +replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
  10.954 +
  10.955 +// In the third stage we use the eval function to compile the text into a
  10.956 +// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
  10.957 +// in JavaScript: it can begin a block or an object literal. We wrap the text
  10.958 +// in parens to eliminate the ambiguity.
  10.959 +
  10.960 +                j = eval('(' + text + ')');
  10.961 +
  10.962 +// In the optional fourth stage, we recursively walk the new structure, passing
  10.963 +// each name/value pair to a reviver function for possible transformation.
  10.964 +
  10.965 +                return typeof reviver === 'function' ?
  10.966 +                    walk({'': j}, '') : j;
  10.967 +            }
  10.968 +
  10.969 +// If the text is not JSON parseable, then a SyntaxError is thrown.
  10.970 +
  10.971 +            throw new SyntaxError('JSON.parse');
  10.972 +        };
  10.973 +    }
  10.974 +}());
  10.975 +
  10.976 +
  10.977 +
  10.978 +
  10.979 +// JSON
  10.980 +function json(obj7)
  10.981 +{
  10.982 +    if (typeof(obj7) == 'string')
  10.983 +    {
  10.984 +        // decode
  10.985 +        return JSON.parse(obj7);
  10.986 +    }
  10.987 +    else
  10.988 +    {
  10.989 +        // encode
  10.990 +        return JSON.stringify(obj7);
  10.991 +    }
  10.992 +}
  10.993 +
    11.1 --- a/sandbox/bufferedcanvas.py	Thu Jul 14 14:05:39 2011 +0400
    11.2 +++ b/sandbox/bufferedcanvas.py	Thu Jul 14 14:28:32 2011 +0400
    11.3 @@ -1,142 +1,142 @@
    11.4 -"""
    11.5 -BufferedCanvas -- Double-buffered, flicker-free canvas widget
    11.6 -Copyright (C) 2005, 2006 Daniel Keep
    11.7 -
    11.8 -To use this widget, just override or replace the draw method.
    11.9 -This will be called whenever the widget size changes, or when
   11.10 -the update method is explicitly called.
   11.11 -
   11.12 -Please submit any improvements/bugfixes/ideas to the following
   11.13 -url:
   11.14 -
   11.15 -  http://wiki.wxpython.org/index.cgi/BufferedCanvas
   11.16 -
   11.17 -2006-04-29: Added bugfix for a crash on Mac provided by Marc Jans.
   11.18 -"""
   11.19 -
   11.20 -# Hint: try removing '.sp4msux0rz'
   11.21 -__author__ = 'Daniel Keep <daniel.keep.sp4msux0rz@gmail.com>'
   11.22 -
   11.23 -__license__ = """
   11.24 -This library is free software; you can redistribute it and/or
   11.25 -modify it under the terms of the GNU Lesser General Public License as
   11.26 -published by the Free Software Foundation; either version 2.1 of the
   11.27 -License, or (at your option) any later version.
   11.28 -
   11.29 -As a special exception, the copyright holders of this library
   11.30 -hereby recind Section 3 of the GNU Lesser General Public License. This
   11.31 -means that you MAY NOT apply the terms of the ordinary GNU General
   11.32 -Public License instead of this License to any given copy of the
   11.33 -Library. This has been done to prevent users of the Library from being
   11.34 -denied access or the ability to use future improvements.
   11.35 -
   11.36 -This library is distributed in the hope that it will be useful, but
   11.37 -WITHOUT ANY WARRANTY; without even the implied warranty of
   11.38 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
   11.39 -General Public License for more details.
   11.40 -
   11.41 -You should have received a copy of the GNU Lesser General Public
   11.42 -License along with this library; if not, write to the Free Software
   11.43 -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   11.44 -"""
   11.45 -
   11.46 -__all__ = ['BufferedCanvas']
   11.47 -
   11.48 -import wx
   11.49 -import wx.lib.scrolledpanel as sp
   11.50 -
   11.51 -class BufferedCanvas(sp.ScrolledPanel):
   11.52 -    """
   11.53 -    Implements a double-buffered, flicker-free canvas widget.
   11.54 -
   11.55 -    Standard usage is to subclass this class, and override the
   11.56 -    draw method.  The draw method is passed a device context, which
   11.57 -    should be used to do your drawing.
   11.58 -
   11.59 -    Also, you should NOT call dc.BeginDrawing() and dc.EndDrawing() --
   11.60 -    these methods are automatically called for you, although you still
   11.61 -    need to manually clear the device context.
   11.62 -
   11.63 -    If you want to force a redraw (for whatever reason), you should
   11.64 -    call the update method.  This is because the draw method is never
   11.65 -    called as a result of an EVT_PAINT event.
   11.66 -    """
   11.67 -
   11.68 -    # These are our two buffers.  Just be aware that when the buffers
   11.69 -    # are flipped, the REFERENCES are swapped.  So I wouldn't want to
   11.70 -    # try holding onto explicit references to one or the other ;)
   11.71 -    buffer = None
   11.72 -    backbuffer = None
   11.73 -
   11.74 -    def __init__(self,
   11.75 -                 parent,
   11.76 -                 ID=-1,
   11.77 -                 pos=wx.DefaultPosition,
   11.78 -                 size=wx.DefaultSize,
   11.79 -                 style=wx.NO_FULL_REPAINT_ON_RESIZE):
   11.80 -        sp.ScrolledPanel.__init__(self,parent,ID,pos,size,style)
   11.81 -
   11.82 -        # Bind events
   11.83 -        self.Bind(wx.EVT_PAINT, self.onPaint)
   11.84 -        self.Bind(wx.EVT_SIZE, self.onSize)
   11.85 -
   11.86 -        # Disable background erasing (flicker-licious)
   11.87 -        def disable_event(*pargs,**kwargs):
   11.88 -            pass # the sauce, please
   11.89 -        self.Bind(wx.EVT_ERASE_BACKGROUND, disable_event)
   11.90 -
   11.91 -        # Ensure that the buffers are setup correctly
   11.92 -        self.onSize(None)
   11.93 -
   11.94 -    ##
   11.95 -    ## General methods
   11.96 -    ##
   11.97 -
   11.98 -    def draw(self,dc):
   11.99 -        """
  11.100 -        Stub: called when the canvas needs to be re-drawn.
  11.101 -        """
  11.102 -        pass
  11.103 -
  11.104 -
  11.105 -    def flip(self):
  11.106 -        """
  11.107 -        Flips the front and back buffers.
  11.108 -        """
  11.109 -        self.buffer,self.backbuffer = self.backbuffer,self.buffer
  11.110 -        self.Refresh()
  11.111 -
  11.112 -
  11.113 -    def update(self):
  11.114 -        """
  11.115 -        Causes the canvas to be updated.
  11.116 -        """
  11.117 -        dc = wx.MemoryDC()
  11.118 -        dc.SelectObject(self.backbuffer)
  11.119 -        dc.BeginDrawing()
  11.120 -        self.draw(dc)
  11.121 -        dc.EndDrawing()
  11.122 -        self.flip()
  11.123 -
  11.124 -    ##
  11.125 -    ## Event handlers
  11.126 -    ##
  11.127 -
  11.128 -    def onPaint(self, event):
  11.129 -        # Blit the front buffer to the screen
  11.130 -        dc = wx.BufferedPaintDC(self, self.buffer)
  11.131 -
  11.132 -
  11.133 -    def onSize(self, event):
  11.134 -        # Here we need to create a new off-screen buffer to hold
  11.135 -        # the in-progress drawings on.
  11.136 -        width,height = self.GetClientSizeTuple()
  11.137 -        if width == 0:
  11.138 -            width = 1
  11.139 -        if height == 0:
  11.140 -            height = 1
  11.141 -        self.buffer = wx.EmptyBitmap(width,height)
  11.142 -        self.backbuffer = wx.EmptyBitmap(width,height)
  11.143 -
  11.144 -        # Now update the screen
  11.145 -        self.update()
  11.146 +"""
  11.147 +BufferedCanvas -- Double-buffered, flicker-free canvas widget
  11.148 +Copyright (C) 2005, 2006 Daniel Keep
  11.149 +
  11.150 +To use this widget, just override or replace the draw method.
  11.151 +This will be called whenever the widget size changes, or when
  11.152 +the update method is explicitly called.
  11.153 +
  11.154 +Please submit any improvements/bugfixes/ideas to the following
  11.155 +url:
  11.156 +
  11.157 +  http://wiki.wxpython.org/index.cgi/BufferedCanvas
  11.158 +
  11.159 +2006-04-29: Added bugfix for a crash on Mac provided by Marc Jans.
  11.160 +"""
  11.161 +
  11.162 +# Hint: try removing '.sp4msux0rz'
  11.163 +__author__ = 'Daniel Keep <daniel.keep.sp4msux0rz@gmail.com>'
  11.164 +
  11.165 +__license__ = """
  11.166 +This library is free software; you can redistribute it and/or
  11.167 +modify it under the terms of the GNU Lesser General Public License as
  11.168 +published by the Free Software Foundation; either version 2.1 of the
  11.169 +License, or (at your option) any later version.
  11.170 +
  11.171 +As a special exception, the copyright holders of this library
  11.172 +hereby recind Section 3 of the GNU Lesser General Public License. This
  11.173 +means that you MAY NOT apply the terms of the ordinary GNU General
  11.174 +Public License instead of this License to any given copy of the
  11.175 +Library. This has been done to prevent users of the Library from being
  11.176 +denied access or the ability to use future improvements.
  11.177 +
  11.178 +This library is distributed in the hope that it will be useful, but
  11.179 +WITHOUT ANY WARRANTY; without even the implied warranty of
  11.180 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
  11.181 +General Public License for more details.
  11.182 +
  11.183 +You should have received a copy of the GNU Lesser General Public
  11.184 +License along with this library; if not, write to the Free Software
  11.185 +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  11.186 +"""
  11.187 +
  11.188 +__all__ = ['BufferedCanvas']
  11.189 +
  11.190 +import wx
  11.191 +import wx.lib.scrolledpanel as sp
  11.192 +
  11.193 +class BufferedCanvas(sp.ScrolledPanel):
  11.194 +    """
  11.195 +    Implements a double-buffered, flicker-free canvas widget.
  11.196 +
  11.197 +    Standard usage is to subclass this class, and override the
  11.198 +    draw method.  The draw method is passed a device context, which
  11.199 +    should be used to do your drawing.
  11.200 +
  11.201 +    Also, you should NOT call dc.BeginDrawing() and dc.EndDrawing() --
  11.202 +    these methods are automatically called for you, although you still
  11.203 +    need to manually clear the device context.
  11.204 +
  11.205 +    If you want to force a redraw (for whatever reason), you should
  11.206 +    call the update method.  This is because the draw method is never
  11.207 +    called as a result of an EVT_PAINT event.
  11.208 +    """
  11.209 +
  11.210 +    # These are our two buffers.  Just be aware that when the buffers
  11.211 +    # are flipped, the REFERENCES are swapped.  So I wouldn't want to
  11.212 +    # try holding onto explicit references to one or the other ;)
  11.213 +    buffer = None
  11.214 +    backbuffer = None
  11.215 +
  11.216 +    def __init__(self,
  11.217 +                 parent,
  11.218 +                 ID=-1,
  11.219 +                 pos=wx.DefaultPosition,
  11.220 +                 size=wx.DefaultSize,
  11.221 +                 style=wx.NO_FULL_REPAINT_ON_RESIZE):
  11.222 +        sp.ScrolledPanel.__init__(self,parent,ID,pos,size,style)
  11.223 +
  11.224 +        # Bind events
  11.225 +        self.Bind(wx.EVT_PAINT, self.onPaint)
  11.226 +        self.Bind(wx.EVT_SIZE, self.onSize)
  11.227 +
  11.228 +        # Disable background erasing (flicker-licious)
  11.229 +        def disable_event(*pargs,**kwargs):
  11.230 +            pass # the sauce, please
  11.231 +        self.Bind(wx.EVT_ERASE_BACKGROUND, disable_event)
  11.232 +
  11.233 +        # Ensure that the buffers are setup correctly
  11.234 +        self.onSize(None)
  11.235 +
  11.236 +    ##
  11.237 +    ## General methods
  11.238 +    ##
  11.239 +
  11.240 +    def draw(self,dc):
  11.241 +        """
  11.242 +        Stub: called when the canvas needs to be re-drawn.
  11.243 +        """
  11.244 +        pass
  11.245 +
  11.246 +
  11.247 +    def flip(self):
  11.248 +        """
  11.249 +        Flips the front and back buffers.
  11.250 +        """
  11.251 +        self.buffer,self.backbuffer = self.backbuffer,self.buffer
  11.252 +        self.Refresh()
  11.253 +
  11.254 +
  11.255 +    def update(self):
  11.256 +        """
  11.257 +        Causes the canvas to be updated.
  11.258 +        """
  11.259 +        dc = wx.MemoryDC()
  11.260 +        dc.SelectObject(self.backbuffer)
  11.261 +        dc.BeginDrawing()
  11.262 +        self.draw(dc)
  11.263 +        dc.EndDrawing()
  11.264 +        self.flip()
  11.265 +
  11.266 +    ##
  11.267 +    ## Event handlers
  11.268 +    ##
  11.269 +
  11.270 +    def onPaint(self, event):
  11.271 +        # Blit the front buffer to the screen
  11.272 +        dc = wx.BufferedPaintDC(self, self.buffer)
  11.273 +
  11.274 +
  11.275 +    def onSize(self, event):
  11.276 +        # Here we need to create a new off-screen buffer to hold
  11.277 +        # the in-progress drawings on.
  11.278 +        width,height = self.GetClientSizeTuple()
  11.279 +        if width == 0:
  11.280 +            width = 1
  11.281 +        if height == 0:
  11.282 +            height = 1
  11.283 +        self.buffer = wx.EmptyBitmap(width,height)
  11.284 +        self.backbuffer = wx.EmptyBitmap(width,height)
  11.285 +
  11.286 +        # Now update the screen
  11.287 +        self.update()
    12.1 --- a/sandbox/gl.py	Thu Jul 14 14:05:39 2011 +0400
    12.2 +++ b/sandbox/gl.py	Thu Jul 14 14:28:32 2011 +0400
    12.3 @@ -1,46 +1,46 @@
    12.4 -#!/usr/bin/python
    12.5 -# http://disruption.ca/gutil/example3/example3a.html
    12.6 -# vim: set noet:
    12.7 -
    12.8 -import gutil
    12.9 -import pygame
   12.10 -from pygame.locals import *
   12.11 -from OpenGL.GL import *
   12.12 -
   12.13 -from Image import Image
   12.14 -
   12.15 -
   12.16 -def main():
   12.17 -	pygame.init()
   12.18 -	gutil.initializeDisplay(800, 600)
   12.19 -
   12.20 -	done = False
   12.21 -
   12.22 -	cow = Image('cow')
   12.23 -	alien = Image('alien')
   12.24 -
   12.25 -	white = (255,255,255,255)
   12.26 -	stringTex, w, h, tw, th = gutil.loadText("Cow!", color=white)
   12.27 -	stringDL = gutil.createTexDL(stringTex, tw, th)
   12.28 -
   12.29 -	while not done:
   12.30 -		glClear(GL_COLOR_BUFFER_BIT)
   12.31 -		glLoadIdentity()
   12.32 -		glColor4f(1.0,1.0,1.0,1.0)
   12.33 -		glTranslatef(100, 400, 0)
   12.34 -		glCallList(stringDL)
   12.35 -
   12.36 -		cow.draw(pos=(100,100),width=128,height=128)
   12.37 -		alien.draw(pos=(400, 400),rotation=-15,color=(.9,.3,.2,1))
   12.38 -
   12.39 -
   12.40 -		pygame.display.flip()
   12.41 -
   12.42 -		eventlist = pygame.event.get()
   12.43 -		for event in eventlist:
   12.44 -			if event.type == QUIT \
   12.45 -			   or event.type == KEYDOWN and event.key == K_ESCAPE:
   12.46 -				done = True
   12.47 -
   12.48 -if __name__ == '__main__':
   12.49 -	main()
   12.50 +#!/usr/bin/python
   12.51 +# http://disruption.ca/gutil/example3/example3a.html
   12.52 +# vim: set noet:
   12.53 +
   12.54 +import gutil
   12.55 +import pygame
   12.56 +from pygame.locals import *
   12.57 +from OpenGL.GL import *
   12.58 +
   12.59 +from Image import Image
   12.60 +
   12.61 +
   12.62 +def main():
   12.63 +	pygame.init()
   12.64 +	gutil.initializeDisplay(800, 600)
   12.65 +
   12.66 +	done = False
   12.67 +
   12.68 +	cow = Image('cow')
   12.69 +	alien = Image('alien')
   12.70 +
   12.71 +	white = (255,255,255,255)
   12.72 +	stringTex, w, h, tw, th = gutil.loadText("Cow!", color=white)
   12.73 +	stringDL = gutil.createTexDL(stringTex, tw, th)
   12.74 +
   12.75 +	while not done:
   12.76 +		glClear(GL_COLOR_BUFFER_BIT)
   12.77 +		glLoadIdentity()
   12.78 +		glColor4f(1.0,1.0,1.0,1.0)
   12.79 +		glTranslatef(100, 400, 0)
   12.80 +		glCallList(stringDL)
   12.81 +
   12.82 +		cow.draw(pos=(100,100),width=128,height=128)
   12.83 +		alien.draw(pos=(400, 400),rotation=-15,color=(.9,.3,.2,1))
   12.84 +
   12.85 +
   12.86 +		pygame.display.flip()
   12.87 +
   12.88 +		eventlist = pygame.event.get()
   12.89 +		for event in eventlist:
   12.90 +			if event.type == QUIT \
   12.91 +			   or event.type == KEYDOWN and event.key == K_ESCAPE:
   12.92 +				done = True
   12.93 +
   12.94 +if __name__ == '__main__':
   12.95 +	main()
    13.1 --- a/sandbox/ttk.py	Thu Jul 14 14:05:39 2011 +0400
    13.2 +++ b/sandbox/ttk.py	Thu Jul 14 14:28:32 2011 +0400
    13.3 @@ -1,159 +1,159 @@
    13.4 -from tkinter import ttk, filedialog
    13.5 -import tkinter
    13.6 -
    13.7 -class Scrollbar(tkinter.Scrollbar):
    13.8 -
    13.9 -    def __init__(self, *args, **kw):
   13.10 -        tkinter.Scrollbar.__init__(self, *args, **kw)
   13.11 -        self['command'] = self._command
   13.12 -        self._attached_widgets = set()
   13.13 -        self._orient = {'horizontal': 'x', 'vertical': 'y'}[self['orient']]
   13.14 -
   13.15 -    def attach(self, widget):
   13.16 -        self._attached_widgets.add(widget)
   13.17 -        command = self._orient + 'scrollcommand'
   13.18 -        widget[command] = lambda *args, **kw: self._set(widget, *args, **kw)
   13.19 -
   13.20 -    def _command(self, *args, **kw):
   13.21 -        command = self._orient + 'view'
   13.22 -        result = None
   13.23 -        for widget in self._attached_widgets:
   13.24 -            result = getattr(widget, command)(*args, **kw)
   13.25 -        return result
   13.26 -
   13.27 -    def _set(self, sender, *args, **kw):
   13.28 -        command = self._orient + 'view'
   13.29 -        self.set(*args, **kw)
   13.30 -        for widget in self._attached_widgets:
   13.31 -            if widget is sender:
   13.32 -                continue
   13.33 -            getattr(widget, command)('moveto', args[0])
   13.34 -
   13.35 -class MegaText(tkinter.Text):
   13.36 -
   13.37 -    def __init__(self, *args, **kw):
   13.38 -        tkinter.Text.__init__(self, *args, **kw)
   13.39 -
   13.40 -        self.bind("<B1-Motion>", self._select)
   13.41 -        self.bind("<B1-ButtonRelease>", self._select_end)
   13.42 -        self.tag_configure('vselection', borderwidth=1, relief="solid", background='#ffbbbb')
   13.43 -
   13.44 -    def tag_clear(self, tag):
   13.45 -        """Remove the tag from anywhere in the text."""
   13.46 -        ranges = self.tag_ranges(tag)
   13.47 -        for begin, end in zip(ranges[::2], ranges[1::2]):
   13.48 -            self.tag_remove(tag, begin, end)
   13.49 -
   13.50 -    def insert(self, *args, **kw):
   13.51 -        self['state'] = 'normal'
   13.52 -        result = tkinter.Text.insert(self, *args, **kw)
   13.53 -        self['state'] = 'disabled'
   13.54 -        return result
   13.55 -
   13.56 -    def _select (self, ev):
   13.57 -        index = self.index("@%s,%s" % (ev.x, ev.y))
   13.58 -        line, pos = map(int, index.split('.'))
   13.59 -        if not hasattr(self, '_selection'):
   13.60 -            self._selection = [line, line, pos, pos]
   13.61 -        self._selection[1] = line
   13.62 -        self._selection[3] = pos
   13.63 -
   13.64 -        self.tag_clear('vselection')
   13.65 -        line0, line1 = sorted(self._selection[0:2])
   13.66 -        pos0, pos1 = sorted(self._selection[2:4])
   13.67 -        for line in range(line0, line1 + 1):
   13.68 -            self.tag_add(
   13.69 -                'vselection',
   13.70 -                '%s.%s' % (line, pos0),
   13.71 -                '%s.%s' % (line, pos1)
   13.72 -            )
   13.73 -        return "break"
   13.74 -
   13.75 -    def _select_end(self, ev):
   13.76 -        self._select(ev)
   13.77 -        del self._selection
   13.78 -        return "break"
   13.79 -
   13.80 -def open_file():
   13.81 -    global seqs
   13.82 -    names.delete(0, 'end')
   13.83 -    sequences.delete('1.0', 'end')
   13.84 -
   13.85 -    filename = filedialog.askopenfilename()
   13.86 -    seqs = set()
   13.87 -    for item in open(filename).read().split('\n>'):
   13.88 -        lines = item.split('\n')
   13.89 -        name = lines[0].lstrip('>').strip()
   13.90 -        body = "".join(map(str.strip, lines[1:]))
   13.91 -
   13.92 -        names.insert('end', name)
   13.93 -        sequences.insert('end', body+'\n')
   13.94 -        line = int(sequences.index('end - 1 line').split('.')[0])
   13.95 -        seqs.add((name, body, line))
   13.96 -
   13.97 -def colorize():
   13.98 -    length = len(list(seqs)[0][1])
   13.99 -    num_seqs = len(seqs)
  13.100 -    seq_weights = []
  13.101 -    for pos in range(length):
  13.102 -        weights = {}
  13.103 -        for name, seq, _ in seqs:
  13.104 -            char = seq[pos]
  13.105 -            weights[char] = weights.get(char, 0) + 1
  13.106 -        for char in weights:
  13.107 -            weights[char] = weights[char] * 10 // num_seqs
  13.108 -        seq_weights.append(weights)
  13.109 -
  13.110 -    for name, seq, line in seqs:
  13.111 -        for pos in range(len(seq)):
  13.112 -            char = seq[pos]
  13.113 -            tag = 'id%d0' % seq_weights[pos].get(char, 0)
  13.114 -            sequences.tag_add(tag, '%d.%d' % (line, pos))
  13.115 -
  13.116 -    for id in range(10+1):
  13.117 -        w = (10 - id) * 256 / 10
  13.118 -        color = '#%02x%02x%02x' % (w, w, w)
  13.119 -        sequences.tag_configure('id%d0' % id, background=color)
  13.120 -
  13.121 -root = tkinter.Tk()
  13.122 -
  13.123 -root.option_add('*tearOff', False)
  13.124 -menu = tkinter.Menu(root)
  13.125 -menu_file = tkinter.Menu(menu)
  13.126 -menu_file.add_command(label='Open', command=open_file)
  13.127 -menu.add_cascade(menu=menu_file, label='File')
  13.128 -menu.add_command(label='Colorize', command=colorize)
  13.129 -root['menu'] = menu
  13.130 -
  13.131 -main = ttk.PanedWindow(root, orient="horizontal")
  13.132 -names = tkinter.Listbox(main)
  13.133 -sequences = MegaText(main)
  13.134 -
  13.135 -sequences['font'] = names['font'] = "Courier 10"
  13.136 -
  13.137 -def _select(*args):
  13.138 -    sequences.tag_clear('sel')
  13.139 -    for line in names.curselection():
  13.140 -        line = int(line) + 1
  13.141 -        sequences.tag_add('sel', "%s.0" % line, "%s.end" % line)
  13.142 -sequences['inactiveselectbackground'] = 'blue'
  13.143 -names.bind('<<ListboxSelect>>', _select)
  13.144 -
  13.145 -#sequences['spacing3'] = 1
  13.146 -sequences['exportselection'] = False
  13.147 -sequences['wrap'] = 'none'
  13.148 -#names['selectborderwidth'] = -1
  13.149 -names['highlightthickness'] = 0
  13.150 -names['activestyle'] = 'none'
  13.151 -names['exportselection'] = False
  13.152 -
  13.153 -main.add(names)
  13.154 -main.add(sequences)
  13.155 -main.pack(side='right', fill='both', expand=True)
  13.156 -
  13.157 -vscroll = Scrollbar(root, orient='vertical')
  13.158 -vscroll.attach(names)
  13.159 -vscroll.attach(sequences)
  13.160 -vscroll.pack(side='right', fill='y')
  13.161 -
  13.162 -root.mainloop()
  13.163 +from tkinter import ttk, filedialog
  13.164 +import tkinter
  13.165 +
  13.166 +class Scrollbar(tkinter.Scrollbar):
  13.167 +
  13.168 +    def __init__(self, *args, **kw):
  13.169 +        tkinter.Scrollbar.__init__(self, *args, **kw)
  13.170 +        self['command'] = self._command
  13.171 +        self._attached_widgets = set()
  13.172 +        self._orient = {'horizontal': 'x', 'vertical': 'y'}[self['orient']]
  13.173 +
  13.174 +    def attach(self, widget):
  13.175 +        self._attached_widgets.add(widget)
  13.176 +        command = self._orient + 'scrollcommand'
  13.177 +        widget[command] = lambda *args, **kw: self._set(widget, *args, **kw)
  13.178 +
  13.179 +    def _command(self, *args, **kw):
  13.180 +        command = self._orient + 'view'
  13.181 +        result = None
  13.182 +        for widget in self._attached_widgets:
  13.183 +            result = getattr(widget, command)(*args, **kw)
  13.184 +        return result
  13.185 +
  13.186 +    def _set(self, sender, *args, **kw):
  13.187 +        command = self._orient + 'view'
  13.188 +        self.set(*args, **kw)
  13.189 +        for widget in self._attached_widgets:
  13.190 +            if widget is sender:
  13.191 +                continue
  13.192 +            getattr(widget, command)('moveto', args[0])
  13.193 +
  13.194 +class MegaText(tkinter.Text):
  13.195 +
  13.196 +    def __init__(self, *args, **kw):
  13.197 +        tkinter.Text.__init__(self, *args, **kw)
  13.198 +
  13.199 +        self.bind("<B1-Motion>", self._select)
  13.200 +        self.bind("<B1-ButtonRelease>", self._select_end)
  13.201 +        self.tag_configure('vselection', borderwidth=1, relief="solid", background='#ffbbbb')
  13.202 +
  13.203 +    def tag_clear(self, tag):
  13.204 +        """Remove the tag from anywhere in the text."""
  13.205 +        ranges = self.tag_ranges(tag)
  13.206 +        for begin, end in zip(ranges[::2], ranges[1::2]):
  13.207 +            self.tag_remove(tag, begin, end)
  13.208 +
  13.209 +    def insert(self, *args, **kw):
  13.210 +        self['state'] = 'normal'
  13.211 +        result = tkinter.Text.insert(self, *args, **kw)
  13.212 +        self['state'] = 'disabled'
  13.213 +        return result
  13.214 +
  13.215 +    def _select (self, ev):
  13.216 +        index = self.index("@%s,%s" % (ev.x, ev.y))
  13.217 +        line, pos = map(int, index.split('.'))
  13.218 +        if not hasattr(self, '_selection'):
  13.219 +            self._selection = [line, line, pos, pos]
  13.220 +        self._selection[1] = line
  13.221 +        self._selection[3] = pos
  13.222 +
  13.223 +        self.tag_clear('vselection')
  13.224 +        line0, line1 = sorted(self._selection[0:2])
  13.225 +        pos0, pos1 = sorted(self._selection[2:4])
  13.226 +        for line in range(line0, line1 + 1):
  13.227 +            self.tag_add(
  13.228 +                'vselection',
  13.229 +                '%s.%s' % (line, pos0),
  13.230 +                '%s.%s' % (line, pos1)
  13.231 +            )
  13.232 +        return "break"
  13.233 +
  13.234 +    def _select_end(self, ev):
  13.235 +        self._select(ev)
  13.236 +        del self._selection
  13.237 +        return "break"
  13.238 +
  13.239 +def open_file():
  13.240 +    global seqs
  13.241 +    names.delete(0, 'end')
  13.242 +    sequences.delete('1.0', 'end')
  13.243 +
  13.244 +    filename = filedialog.askopenfilename()
  13.245 +    seqs = set()
  13.246 +    for item in open(filename).read().split('\n>'):
  13.247 +        lines = item.split('\n')
  13.248 +        name = lines[0].lstrip('>').strip()
  13.249 +        body = "".join(map(str.strip, lines[1:]))
  13.250 +
  13.251 +        names.insert('end', name)
  13.252 +        sequences.insert('end', body+'\n')
  13.253 +        line = int(sequences.index('end - 1 line').split('.')[0])
  13.254 +        seqs.add((name, body, line))
  13.255 +
  13.256 +def colorize():
  13.257 +    length = len(list(seqs)[0][1])
  13.258 +    num_seqs = len(seqs)
  13.259 +    seq_weights = []
  13.260 +    for pos in range(length):
  13.261 +        weights = {}
  13.262 +        for name, seq, _ in seqs:
  13.263 +            char = seq[pos]
  13.264 +            weights[char] = weights.get(char, 0) + 1
  13.265 +        for char in weights:
  13.266 +            weights[char] = weights[char] * 10 // num_seqs
  13.267 +        seq_weights.append(weights)
  13.268 +
  13.269 +    for name, seq, line in seqs:
  13.270 +        for pos in range(len(seq)):
  13.271 +            char = seq[pos]
  13.272 +            tag = 'id%d0' % seq_weights[pos].get(char, 0)
  13.273 +            sequences.tag_add(tag, '%d.%d' % (line, pos))
  13.274 +
  13.275 +    for id in range(10+1):
  13.276 +        w = (10 - id) * 256 / 10
  13.277 +        color = '#%02x%02x%02x' % (w, w, w)
  13.278 +        sequences.tag_configure('id%d0' % id, background=color)
  13.279 +
  13.280 +root = tkinter.Tk()
  13.281 +
  13.282 +root.option_add('*tearOff', False)
  13.283 +menu = tkinter.Menu(root)
  13.284 +menu_file = tkinter.Menu(menu)
  13.285 +menu_file.add_command(label='Open', command=open_file)
  13.286 +menu.add_cascade(menu=menu_file, label='File')
  13.287 +menu.add_command(label='Colorize', command=colorize)
  13.288 +root['menu'] = menu
  13.289 +
  13.290 +main = ttk.PanedWindow(root, orient="horizontal")
  13.291 +names = tkinter.Listbox(main)
  13.292 +sequences = MegaText(main)
  13.293 +
  13.294 +sequences['font'] = names['font'] = "Courier 10"
  13.295 +
  13.296 +def _select(*args):
  13.297 +    sequences.tag_clear('sel')
  13.298 +    for line in names.curselection():
  13.299 +        line = int(line) + 1
  13.300 +        sequences.tag_add('sel', "%s.0" % line, "%s.end" % line)
  13.301 +sequences['inactiveselectbackground'] = 'blue'
  13.302 +names.bind('<<ListboxSelect>>', _select)
  13.303 +
  13.304 +#sequences['spacing3'] = 1
  13.305 +sequences['exportselection'] = False
  13.306 +sequences['wrap'] = 'none'
  13.307 +#names['selectborderwidth'] = -1
  13.308 +names['highlightthickness'] = 0
  13.309 +names['activestyle'] = 'none'
  13.310 +names['exportselection'] = False
  13.311 +
  13.312 +main.add(names)
  13.313 +main.add(sequences)
  13.314 +main.pack(side='right', fill='both', expand=True)
  13.315 +
  13.316 +vscroll = Scrollbar(root, orient='vertical')
  13.317 +vscroll.attach(names)
  13.318 +vscroll.attach(sequences)
  13.319 +vscroll.pack(side='right', fill='y')
  13.320 +
  13.321 +root.mainloop()
    14.1 --- a/sandbox/wx-dc.py	Thu Jul 14 14:05:39 2011 +0400
    14.2 +++ b/sandbox/wx-dc.py	Thu Jul 14 14:28:32 2011 +0400
    14.3 @@ -1,52 +1,52 @@
    14.4 -#!/usr/bin/python
    14.5 -
    14.6 -import wx
    14.7 -import bufferedcanvas
    14.8 -import common
    14.9 -
   14.10 -class Text(bufferedcanvas.BufferedCanvas):
   14.11 -
   14.12 -	def __init__(self, seqs, *args, **kw):
   14.13 -		self.seqs = seqs
   14.14 -		self.font = wx.FFont(12, wx.FONTFAMILY_MODERN)
   14.15 -		bufferedcanvas.BufferedCanvas.__init__(self, *args, **kw)
   14.16 -
   14.17 -		dc = wx.ClientDC(self)
   14.18 -		dc.SetFont(self.font)
   14.19 -		w = (len(seqs[0][1])+1) * dc.GetCharWidth()
   14.20 -		h = (len(seqs)+1) * (dc.GetCharHeight() + 1)
   14.21 -		self.size = w, h
   14.22 -		self.SetVirtualSize(self.size)
   14.23 -
   14.24 -		self.Bind(wx.EVT_SCROLL, self.onPaint)
   14.25 -
   14.26 -		self.SetupScrolling()
   14.27 -
   14.28 -	def draw(self, dc):
   14.29 -		dc.SetBackground(wx.Brush("White"))
   14.30 -		dc.Clear()
   14.31 -		dc.SetFont(self.font)
   14.32 -
   14.33 -		w = dc.GetCharWidth()
   14.34 -		h = dc.GetCharHeight()
   14.35 -		for i, (name, body, ids, colors) in enumerate(self.seqs):
   14.36 -			for j in xrange(len(body)):
   14.37 -				x = j * w
   14.38 -				y = i * (h + 1)
   14.39 -				dc.SetBrush(wx.Brush(colors[j]))
   14.40 -				dc.SetPen(wx.Pen(colors[j]))
   14.41 -				dc.DrawRectangle(x, y, x + w, y + h)
   14.42 -				dc.SetPen(wx.Pen("Black"))
   14.43 -				dc.DrawText(body[j], x, y)
   14.44 -
   14.45 -		if hasattr(self, 'size'):
   14.46 -			self.SetVirtualSize(self.size)
   14.47 -
   14.48 -seqs = common.autoload('data/small.fasta')
   14.49 -
   14.50 -app = wx.App(False)
   14.51 -top = wx.Frame(None, title='Example', size=(500, 500))
   14.52 -text = Text(seqs, top)
   14.53 -top.Show(True)
   14.54 -
   14.55 -app.MainLoop()
   14.56 +#!/usr/bin/python
   14.57 +
   14.58 +import wx
   14.59 +import bufferedcanvas
   14.60 +import common
   14.61 +
   14.62 +class Text(bufferedcanvas.BufferedCanvas):
   14.63 +
   14.64 +	def __init__(self, seqs, *args, **kw):
   14.65 +		self.seqs = seqs
   14.66 +		self.font = wx.FFont(12, wx.FONTFAMILY_MODERN)
   14.67 +		bufferedcanvas.BufferedCanvas.__init__(self, *args, **kw)
   14.68 +
   14.69 +		dc = wx.ClientDC(self)
   14.70 +		dc.SetFont(self.font)
   14.71 +		w = (len(seqs[0][1])+1) * dc.GetCharWidth()
   14.72 +		h = (len(seqs)+1) * (dc.GetCharHeight() + 1)
   14.73 +		self.size = w, h
   14.74 +		self.SetVirtualSize(self.size)
   14.75 +
   14.76 +		self.Bind(wx.EVT_SCROLL, self.onPaint)
   14.77 +
   14.78 +		self.SetupScrolling()
   14.79 +
   14.80 +	def draw(self, dc):
   14.81 +		dc.SetBackground(wx.Brush("White"))
   14.82 +		dc.Clear()
   14.83 +		dc.SetFont(self.font)
   14.84 +
   14.85 +		w = dc.GetCharWidth()
   14.86 +		h = dc.GetCharHeight()
   14.87 +		for i, (name, body, ids, colors) in enumerate(self.seqs):
   14.88 +			for j in xrange(len(body)):
   14.89 +				x = j * w
   14.90 +				y = i * (h + 1)
   14.91 +				dc.SetBrush(wx.Brush(colors[j]))
   14.92 +				dc.SetPen(wx.Pen(colors[j]))
   14.93 +				dc.DrawRectangle(x, y, x + w, y + h)
   14.94 +				dc.SetPen(wx.Pen("Black"))
   14.95 +				dc.DrawText(body[j], x, y)
   14.96 +
   14.97 +		if hasattr(self, 'size'):
   14.98 +			self.SetVirtualSize(self.size)
   14.99 +
  14.100 +seqs = common.autoload('data/small.fasta')
  14.101 +
  14.102 +app = wx.App(False)
  14.103 +top = wx.Frame(None, title='Example', size=(500, 500))
  14.104 +text = Text(seqs, top)
  14.105 +top.Show(True)
  14.106 +
  14.107 +app.MainLoop()
    15.1 --- a/sandbox/wx-textctrl.py	Thu Jul 14 14:05:39 2011 +0400
    15.2 +++ b/sandbox/wx-textctrl.py	Thu Jul 14 14:28:32 2011 +0400
    15.3 @@ -1,54 +1,54 @@
    15.4 -#!/usr/bin/python
    15.5 -
    15.6 -import wx
    15.7 -import common
    15.8 -
    15.9 -app = wx.App(False)
   15.10 -font = wx.FFont(12, wx.FONTFAMILY_MODERN)
   15.11 -top = wx.Frame(None, title='Example', size=(1000, 600))
   15.12 -text = wx.TextCtrl(top, style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP|wx.TE_RICH2)
   15.13 -text.SetFont(font)
   15.14 -top.Show(True)
   15.15 -
   15.16 -seqs = common.autoload('data/large.fasta')
   15.17 -
   15.18 -# ## v1: bw
   15.19 -# text.AppendText("\n".join(body for name, body, ids, colors in seqs))
   15.20 -
   15.21 -# ## v1.1: bw
   15.22 -# for name, body, ids, colors in seqs:
   15.23 -# 	text.WriteText(body + "\n")
   15.24 -
   15.25 -# ## v2: naive color
   15.26 -# for name, body, ids, colors in seqs:
   15.27 -# 	for x in xrange(len(body)):
   15.28 -# 		text.SetDefaultStyle(wx.TextAttr('black', colors[x]))
   15.29 -# 		text.AppendText(body[x])
   15.30 -# 	text.AppendText(body + "\n")
   15.31 -
   15.32 -# ## v3: preconfigured color
   15.33 -# attrs = []
   15.34 -# for i in xrange(11):
   15.35 -# 	c = i * 255 // 10
   15.36 -# 	attrs.append(wx.TextAttr('black', '#%02x%02x%02x' % (c,c,c)))
   15.37 -#
   15.38 -# for name, body, ids, colors in seqs:
   15.39 -# 	for x in xrange(len(body)):
   15.40 -# 		text.SetDefaultStyle(attrs[ids[x]])
   15.41 -# 		text.AppendText(body[x])
   15.42 -# 	text.AppendText(body + "\n")
   15.43 -
   15.44 -# ## v4: output text, then colorize
   15.45 -# text.WriteText("\n".join(body for name, body, ids, colors in seqs))
   15.46 -#
   15.47 -# i = 0
   15.48 -# text.Freeze()
   15.49 -# for name, body, ids, colors in seqs:
   15.50 -# 	print name
   15.51 -# 	for x in xrange(len(body)):
   15.52 -# 		text.SetStyle(i, i+1, wx.TextAttr('black', colors[x]))
   15.53 -# 		i += 1
   15.54 -# 	i += 1
   15.55 -# text.Thaw()
   15.56 -
   15.57 -app.MainLoop()
   15.58 +#!/usr/bin/python
   15.59 +
   15.60 +import wx
   15.61 +import common
   15.62 +
   15.63 +app = wx.App(False)
   15.64 +font = wx.FFont(12, wx.FONTFAMILY_MODERN)
   15.65 +top = wx.Frame(None, title='Example', size=(1000, 600))
   15.66 +text = wx.TextCtrl(top, style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP|wx.TE_RICH2)
   15.67 +text.SetFont(font)
   15.68 +top.Show(True)
   15.69 +
   15.70 +seqs = common.autoload('data/large.fasta')
   15.71 +
   15.72 +# ## v1: bw
   15.73 +# text.AppendText("\n".join(body for name, body, ids, colors in seqs))
   15.74 +
   15.75 +# ## v1.1: bw
   15.76 +# for name, body, ids, colors in seqs:
   15.77 +# 	text.WriteText(body + "\n")
   15.78 +
   15.79 +# ## v2: naive color
   15.80 +# for name, body, ids, colors in seqs:
   15.81 +# 	for x in xrange(len(body)):
   15.82 +# 		text.SetDefaultStyle(wx.TextAttr('black', colors[x]))
   15.83 +# 		text.AppendText(body[x])
   15.84 +# 	text.AppendText(body + "\n")
   15.85 +
   15.86 +# ## v3: preconfigured color
   15.87 +# attrs = []
   15.88 +# for i in xrange(11):
   15.89 +# 	c = i * 255 // 10
   15.90 +# 	attrs.append(wx.TextAttr('black', '#%02x%02x%02x' % (c,c,c)))
   15.91 +#
   15.92 +# for name, body, ids, colors in seqs:
   15.93 +# 	for x in xrange(len(body)):
   15.94 +# 		text.SetDefaultStyle(attrs[ids[x]])
   15.95 +# 		text.AppendText(body[x])
   15.96 +# 	text.AppendText(body + "\n")
   15.97 +
   15.98 +# ## v4: output text, then colorize
   15.99 +# text.WriteText("\n".join(body for name, body, ids, colors in seqs))
  15.100 +#
  15.101 +# i = 0
  15.102 +# text.Freeze()
  15.103 +# for name, body, ids, colors in seqs:
  15.104 +# 	print name
  15.105 +# 	for x in xrange(len(body)):
  15.106 +# 		text.SetStyle(i, i+1, wx.TextAttr('black', colors[x]))
  15.107 +# 		i += 1
  15.108 +# 	i += 1
  15.109 +# text.Thaw()
  15.110 +
  15.111 +app.MainLoop()
    16.1 --- a/test/1jcc_in.fasta	Thu Jul 14 14:05:39 2011 +0400
    16.2 +++ b/test/1jcc_in.fasta	Thu Jul 14 14:28:32 2011 +0400
    16.3 @@ -1,5 +1,5 @@
    16.4 ->1jcc_B
    16.5 -SNAKIDQLSSDAQTANAKADQASNDANAARSDAQAAKDDAARANQRLDNM
    16.6 -
    16.7 ->1KFM_A
    16.8 -SNAKIDQLSSDVQTLNAKVDQLSNDVNAARSDAQAAKDDAARANQRLDNM
    16.9 +>1jcc_B
   16.10 +SNAKIDQLSSDAQTANAKADQASNDANAARSDAQAAKDDAARANQRLDNM
   16.11 +
   16.12 +>1KFM_A
   16.13 +SNAKIDQLSSDVQTLNAKVDQLSNDVNAARSDAQAAKDDAARANQRLDNM
    17.1 --- a/utils/make_homologies.py	Thu Jul 14 14:05:39 2011 +0400
    17.2 +++ b/utils/make_homologies.py	Thu Jul 14 14:28:32 2011 +0400
    17.3 @@ -1,79 +1,79 @@
    17.4 -#!/usr/bin/python
    17.5 -import sys
    17.6 -sys.path.append("/home/preps/aba/Python/allpy/utils")
    17.7 -
    17.8 -from allpy import protein
    17.9 -from allpy.homology import MonomerHomology
   17.10 -from allpy import markups
   17.11 -#import allpy.utils.extract_pfam
   17.12 -import extract_pfam 
   17.13 -markups.SequencePdbResiMarkup = extract_pfam.SequencePdbResiMarkup 
   17.14 -
   17.15 -import optparse
   17.16 -
   17.17 -
   17.18 -
   17.19 -if len(sys.argv) == 1:                                                     
   17.20 -    print("Makes homology files from (case sensitive by request) input alignments")
   17.21 -    print("Type 'python make_homologies.py -h' for parameters")                                                                                                       
   17.22 -    exit()                                                                                                                                             
   17.23 -                                                                                                                                                       
   17.24 -parser = optparse.OptionParser()                                                                                                                       
   17.25 -
   17.26 -parser.add_option("-c", "--case", action="store_true", help="Case sensitive interpretation of input alignment (False if -c missed)", dest="case")
   17.27 -parser.add_option("-n", "--file_names", help="File with alignment fasta files names", dest="file_names")
   17.28 -
   17.29 -parser.add_option("-d", "--base_in", help="Name of directory with alignment files (default=\"\")", dest="base_in", default="")
   17.30 -parser.add_option("-s", "--suffix", help="Suffix for out files", dest="suffix", default = "hom")                                                           
   17.31 -parser.add_option("-o", "--base_out", help="Name of directory for outfiles (default=\"\")", dest="base_out", default="")
   17.32 -parser.add_option("-f", "--format", help="Format of input file: 'markup' or 'fasta' (default)", dest="format", default = "fasta")
   17.33 -
   17.34 -
   17.35 -# FOR ONE INPUT ALIGNMENT
   17.36 -#parser.add_option("-i", "--in_file", help="File with an alignment in fasta", dest="in_file")                                                           
   17.37 -#parser.add_option("-o", "--result", help="Output file with monomer homology classes (default: result.xls)", dest="out_file", default = "result.xls")
   17.38 -
   17.39 -options, args = parser.parse_args()                                                                                                                    
   17.40 -vars().update(vars(options))                              
   17.41 -                                                                                        
   17.42 -
   17.43 -try: 
   17.44 -    f = open(file_names)
   17.45 -except:
   17.46 -    raise Exception("File %s does not exists! Use python make_homologies.py -h for parameters" % file_names)
   17.47 -
   17.48 -
   17.49 -
   17.50 -alignment_names = []
   17.51 -for line in f:
   17.52 -    line = line.strip()
   17.53 -    if len(line) == 0:
   17.54 -        continue
   17.55 -    line = line.strip().split("#")[0]
   17.56 -    if len(line) == 0:
   17.57 -        continue
   17.58 -    alignment_names.append(line.split()[0])
   17.59 -
   17.60 -
   17.61 -if len(base_in) > 0:
   17.62 -    if base_in[-1]!= "/":
   17.63 -        base_in = base_in + "/"
   17.64 -
   17.65 -if len(base_out) > 0:
   17.66 -    if base_out[-1]!= "/":
   17.67 -        base_out = base_out + "/"
   17.68 -
   17.69 -
   17.70 -print("Wait...")
   17.71 -
   17.72 -for alignment_name in alignment_names:
   17.73 -    in_file_name = base_in + alignment_name
   17.74 -    out_file_name = base_out + alignment_name.partition(".fasta")[0] + ".xls"
   17.75 -
   17.76 -    classes_number = MonomerHomology.case_homology(in_file_name,out_file_name, case, format)
   17.77 -    print ("File %s: %s monomer homology classes stored" % (out_file_name,classes_number))
   17.78 -
   17.79 -print("...Done")
   17.80 -
   17.81 -
   17.82 -
   17.83 +#!/usr/bin/python
   17.84 +import sys
   17.85 +sys.path.append("/home/preps/aba/Python/allpy/utils")
   17.86 +
   17.87 +from allpy import protein
   17.88 +from allpy.homology import MonomerHomology
   17.89 +from allpy import markups
   17.90 +#import allpy.utils.extract_pfam
   17.91 +import extract_pfam
   17.92 +markups.SequencePdbResiMarkup = extract_pfam.SequencePdbResiMarkup
   17.93 +
   17.94 +import optparse
   17.95 +
   17.96 +
   17.97 +
   17.98 +if len(sys.argv) == 1:
   17.99 +    print("Makes homology files from (case sensitive by request) input alignments")
  17.100 +    print("Type 'python make_homologies.py -h' for parameters")
  17.101 +    exit()
  17.102 +
  17.103 +parser = optparse.OptionParser()
  17.104 +
  17.105 +parser.add_option("-c", "--case", action="store_true", help="Case sensitive interpretation of input alignment (False if -c missed)", dest="case")
  17.106 +parser.add_option("-n", "--file_names", help="File with alignment fasta files names", dest="file_names")
  17.107 +
  17.108 +parser.add_option("-d", "--base_in", help="Name of directory with alignment files (default=\"\")", dest="base_in", default="")
  17.109 +parser.add_option("-s", "--suffix", help="Suffix for out files", dest="suffix", default = "hom")
  17.110 +parser.add_option("-o", "--base_out", help="Name of directory for outfiles (default=\"\")", dest="base_out", default="")
  17.111 +parser.add_option("-f", "--format", help="Format of input file: 'markup' or 'fasta' (default)", dest="format", default = "fasta")
  17.112 +
  17.113 +
  17.114 +# FOR ONE INPUT ALIGNMENT
  17.115 +#parser.add_option("-i", "--in_file", help="File with an alignment in fasta", dest="in_file")
  17.116 +#parser.add_option("-o", "--result", help="Output file with monomer homology classes (default: result.xls)", dest="out_file", default = "result.xls")
  17.117 +
  17.118 +options, args = parser.parse_args()
  17.119 +vars().update(vars(options))
  17.120 +
  17.121 +
  17.122 +try:
  17.123 +    f = open(file_names)
  17.124 +except:
  17.125 +    raise Exception("File %s does not exists! Use python make_homologies.py -h for parameters" % file_names)
  17.126 +
  17.127 +
  17.128 +
  17.129 +alignment_names = []
  17.130 +for line in f:
  17.131 +    line = line.strip()
  17.132 +    if len(line) == 0:
  17.133 +        continue
  17.134 +    line = line.strip().split("#")[0]
  17.135 +    if len(line) == 0:
  17.136 +        continue
  17.137 +    alignment_names.append(line.split()[0])
  17.138 +
  17.139 +
  17.140 +if len(base_in) > 0:
  17.141 +    if base_in[-1]!= "/":
  17.142 +        base_in = base_in + "/"
  17.143 +
  17.144 +if len(base_out) > 0:
  17.145 +    if base_out[-1]!= "/":
  17.146 +        base_out = base_out + "/"
  17.147 +
  17.148 +
  17.149 +print("Wait...")
  17.150 +
  17.151 +for alignment_name in alignment_names:
  17.152 +    in_file_name = base_in + alignment_name
  17.153 +    out_file_name = base_out + alignment_name.partition(".fasta")[0] + ".xls"
  17.154 +
  17.155 +    classes_number = MonomerHomology.case_homology(in_file_name,out_file_name, case, format)
  17.156 +    print ("File %s: %s monomer homology classes stored" % (out_file_name,classes_number))
  17.157 +
  17.158 +print("...Done")
  17.159 +
  17.160 +
  17.161 +
    18.1 --- a/utils/make_homology.py	Thu Jul 14 14:05:39 2011 +0400
    18.2 +++ b/utils/make_homology.py	Thu Jul 14 14:28:32 2011 +0400
    18.3 @@ -1,37 +1,37 @@
    18.4 -#!/usr/bin/python
    18.5 -import sys
    18.6 -sys.path.append("/home/preps/aba/Python/allpy/utils")
    18.7 -
    18.8 -from allpy import protein
    18.9 -from allpy.homology import MonomerHomology
   18.10 -from allpy import markups
   18.11 -#import allpy.utils.extract_pfam
   18.12 -import extract_pfam 
   18.13 -markups.SequencePdbResiMarkup = extract_pfam.SequencePdbResiMarkup 
   18.14 -
   18.15 -
   18.16 -import optparse
   18.17 -
   18.18 -
   18.19 -if len(sys.argv) == 1:                                                     
   18.20 -    print("Makes homology file from  case sensitive input alignment")
   18.21 -    print("Type 'python test_homology.py -h' for parameters")                                                                                                       
   18.22 -    exit()                                                                                                                                             
   18.23 -                                                                                                                                                       
   18.24 -parser = optparse.OptionParser()                                                                                                                       
   18.25 -parser.add_option("-i", "--in_file", help="File with alignment in fasta", dest="in_file")                                                           
   18.26 -parser.add_option("-o", "--result", help="Output file with monomer homology classes (default: result.xls)", dest="out_file", default = "result.xls")
   18.27 -parser.add_option("-c", "--case", action="store_true", help="Case sensitive interpretation of input alignment (False if -c missed)", dest="case")
   18.28 -parser.add_option("-f", "--format", help="Format of input file: 'markup' or 'fasta' (default)", dest="format", default = "fasta")
   18.29 -
   18.30 -options, args = parser.parse_args()                                                                                                                    
   18.31 -vars().update(vars(options))                              
   18.32 -                                                                                        
   18.33 -                                                                                                                                                       
   18.34 -print("Wait...")                                                                                                                                       
   18.35 -
   18.36 -classes_number = MonomerHomology.case_homology(in_file,out_file, case, format)
   18.37 -
   18.38 -print ("%s monomer homology classes stored" % classes_number)
   18.39 -print("...Done")
   18.40 -
   18.41 +#!/usr/bin/python
   18.42 +import sys
   18.43 +sys.path.append("/home/preps/aba/Python/allpy/utils")
   18.44 +
   18.45 +from allpy import protein
   18.46 +from allpy.homology import MonomerHomology
   18.47 +from allpy import markups
   18.48 +#import allpy.utils.extract_pfam
   18.49 +import extract_pfam
   18.50 +markups.SequencePdbResiMarkup = extract_pfam.SequencePdbResiMarkup
   18.51 +
   18.52 +
   18.53 +import optparse
   18.54 +
   18.55 +
   18.56 +if len(sys.argv) == 1:
   18.57 +    print("Makes homology file from  case sensitive input alignment")
   18.58 +    print("Type 'python test_homology.py -h' for parameters")
   18.59 +    exit()
   18.60 +
   18.61 +parser = optparse.OptionParser()
   18.62 +parser.add_option("-i", "--in_file", help="File with alignment in fasta", dest="in_file")
   18.63 +parser.add_option("-o", "--result", help="Output file with monomer homology classes (default: result.xls)", dest="out_file", default = "result.xls")
   18.64 +parser.add_option("-c", "--case", action="store_true", help="Case sensitive interpretation of input alignment (False if -c missed)", dest="case")
   18.65 +parser.add_option("-f", "--format", help="Format of input file: 'markup' or 'fasta' (default)", dest="format", default = "fasta")
   18.66 +
   18.67 +options, args = parser.parse_args()
   18.68 +vars().update(vars(options))
   18.69 +
   18.70 +
   18.71 +print("Wait...")
   18.72 +
   18.73 +classes_number = MonomerHomology.case_homology(in_file,out_file, case, format)
   18.74 +
   18.75 +print ("%s monomer homology classes stored" % classes_number)
   18.76 +print("...Done")
   18.77 +