Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/raw-rev/1c2f88eedb18
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 08:09:13 2012
Кодировка:

# HG changeset patch
# User boris
# Date 1309167762 -14400
# Node ID 1c2f88eedb18785484a4a7c36ff548a21090488d
# Parent d32ebf19e75a216d98873c411d25fbfeea706baa
Improve javascript blocks viewer

* mark conservative columns darker
* create script to generate javascript config file with conservative groups
from python config file (from project sequence_based_blocks_search)
* add Makefile
* index.txt: remove unwanted spaces

diff -r d32ebf19e75a -r 1c2f88eedb18 .hgignore
--- a/.hgignore Sat Jun 25 00:46:13 2011 +0400
+++ b/.hgignore Mon Jun 27 13:42:42 2011 +0400
@@ -19,6 +19,7 @@

# Temporary files from building
allpy/data/components.cif
+blocks3d/www/input/conservative_groups.js

# Temporary files from sphinx
docs/build
diff -r d32ebf19e75a -r 1c2f88eedb18 NEWS
--- a/NEWS Sat Jun 25 00:46:13 2011 +0400
+++ b/NEWS Mon Jun 27 13:42:42 2011 +0400
@@ -5,6 +5,7 @@
* new: method allpy.base.Alignment.row_as_list(sequence)
* new: method allpy.base.Alignment.row_as_string(sequence)
* new: columns_as_lists() returns list of lists, each has 'column' attribute
+ * new: javascript viewer marks conservative columns darker

1.3.0 (2011-04-15)

diff -r d32ebf19e75a -r 1c2f88eedb18 blocks3d/www/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/www/Makefile Mon Jun 27 13:42:42 2011 +0400
@@ -0,0 +1,5 @@
+
+build:
+ python ../../sequence_based_blocks_search/functional_groups_to_javascript.py > input/conservative_groups.js
+ r2w
+
diff -r d32ebf19e75a -r 1c2f88eedb18 blocks3d/www/input/blocks.js
--- a/blocks3d/www/input/blocks.js Sat Jun 25 00:46:13 2011 +0400
+++ b/blocks3d/www/input/blocks.js Mon Jun 27 13:42:42 2011 +0400
@@ -41,12 +41,12 @@
// alignment_strings[ID] = string with sequence for

var alignment_strings = {};

+var conservative_groups_dict = []; // list of dictsets of uppercased letters

// useful_positions[ID][position] = block id
// (if this element is a part of at least one block)
var useful_positions = {};

-
var blocks_inited = false;

// run application
@@ -62,6 +62,18 @@
var i, j, k;
var t = '';

+ for (i = 0; i < conservative_groups.length; i++)
+ {
+ var group = conservative_groups[i];
+ var d = {};
+ for (j = 0; j < group.length; j++)
+ {
+ var letter = group[j].toUpperCase();
+ d[letter] = true;
+ }
+ conservative_groups_dict.push(d);
+ }
+
var seq;

// calculate max_ID_length
@@ -81,12 +93,6 @@
IDs_count = 0;
$.each(fasta_dict, function(k,v) { IDs_count+=1});

- // calculate a color for each block
- for (i = 0; i < blocks.length; i++)
- {
- blocks[i].color = crc32_color(json(blocks[i]));
- }
-
// mark colorable positions
useful_positions = {};
for (ID in fasta_dict)
@@ -106,6 +112,29 @@
}
}

+ var is_conservative = [];
+ for (j = 0; j < seq_length; j++)
+ {
+ for (i = 0; i < conservative_groups_dict.length; i++)
+ {
+ var inside_group = true;
+ var group = conservative_groups_dict[i];
+ for (ID in fasta_dict)
+ {
+ if (!group[fasta_dict[ID].charAt(j).toUpperCase()])
+ {
+ inside_group = false;
+ break;
+ }
+ }
+ if (inside_group)
+ {
+ is_conservative[j] = true;
+ break;
+ }
+ }
+ }
+
// pre-calculate strings for

alignment_strings = {};
var block_i;
@@ -119,8 +148,10 @@
if (block_i || block_i === 0)
{
// current element is a part of block
+ var dark = is_conservative[j] && seq.charAt(j) != '-';
+ var color = crc32_color(json(blocks[block_i]), dark);
t += ' - t += ' style="background:' + blocks[block_i].color + '; cursor:pointer;" ' ;
+ t += ' style="background:' + color + '; cursor:pointer;" ' ;
t += ' onclick=letter_click("' + ID + '",' + j + ') ' ;
t += '>';
}
@@ -146,11 +177,30 @@
current_number = '' + current_number; // convert to string
for (j = 0; j < legend_interval - current_number.length; j++)
{
- t += ' ';
+ t += ' ';
}
t += current_number;
}
- t = '
' + t + '
';
+ var conservative_t = '';
+ for (i = 0; i < t.length; i++)
+ {
+ var dark = is_conservative[i];
+ var bgcolor = dark ? 'black' : 'white';
+ var fgcolor = dark ? 'white' : 'black';
+ var l;
+ if (t.charAt(i) == ' ')
+ {
+ l = ' '
+ }
+ else
+ {
+ l = t.charAt(i);
+ }
+ conservative_t += ' + conservative_t += ' style="background:' + bgcolor + ';color:' + fgcolor + ';" ' ;
+ conservative_t += '>' + l + '
';
+ }
+ t = '
' + conservative_t + '
';
$('#legend').html(t);

// run
diff -r d32ebf19e75a -r 1c2f88eedb18 blocks3d/www/input/crc32_color.js
--- a/blocks3d/www/input/crc32_color.js Sat Jun 25 00:46:13 2011 +0400
+++ b/blocks3d/www/input/crc32_color.js Mon Jun 27 13:42:42 2011 +0400
@@ -2,9 +2,12 @@
/**
* returns color, corresponding to something (using crc32 value)
*
- * something -- string
+ * @param string something string
+ * @param bool dark Should color be dark
+ * If dark is true, first bit of each byte from color is set to 0,
+ * otherwise to 1
*/
-function crc32_color(something)
+function crc32_color(something, dark)
{
var crc = crc32(something);
var rgb = []; // [r, g, b] (3 last bytes of crc32 are used)
@@ -15,7 +18,14 @@
// lighten
for (j = 0; j < 3; j++)
{
- rgb[j] |= 128;
+ if (dark)
+ {
+ rgb[j] &= 0x7F;
+ }
+ else
+ {
+ rgb[j] |= 0x80;
+ }
}
for (j = 0; j < 3; j++)
{
diff -r d32ebf19e75a -r 1c2f88eedb18 blocks3d/www/input/index.txt
--- a/blocks3d/www/input/index.txt Sat Jun 25 00:46:13 2011 +0400
+++ b/blocks3d/www/input/index.txt Mon Jun 27 13:42:42 2011 +0400
@@ -16,7 +16,7 @@

Reliable blocks finding




-
+


Enable Javascript!

@@ -54,6 +54,7 @@
{include_minified;crc32_color.js}
{include_minified;crc32.js}
{include_minified;dechex.js}
+{include_minified;conservative_groups.js}
{include_minified;blocks.js}

self_js_text
diff -r d32ebf19e75a -r 1c2f88eedb18 sequence_based_blocks_search/functional_groups_to_javascript.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sequence_based_blocks_search/functional_groups_to_javascript.py Mon Jun 27 13:42:42 2011 +0400
@@ -0,0 +1,7 @@
+import pprint
+
+from functional_groups import aminoacids2functional_groups
+
+print 'conservative_groups ='
+pprint.pprint(list(aminoacids2functional_groups.values()))
+