TkLife is a simple drawing tool. Also, TkLife is a generator of complex patterns
simulating birth, life and death of cells. Finally, TkLife can be used to
visualize any kind of numerical data generating so called heat plots. As well as
it can be used for bioinformatics purpose to visualize multiple DNA sequence
alignments.
TkLife manipulates by 64 different colors on interactive canvas. TkLife canvas
is represented by a grid. Each cell of this grid can be painted to a different
color.
Originally, each cell on canvas has so called "empty" state and colored into
black with white outline. If cell is painted, or activated, then outline has
the same color scheme as cell's fill color. There are three modes to operate the
program: drawing mode, "TkLife mode", and "BioMode". Drawing mode is a simple
drawing tool. By mouse click user can paint cells on canvas into 64 different
colors. Results of painting can be saved as a text file. Tklife mode simulates
birth, growth and death of cells by rules defined in the source code of the
program. These rules are described in the paragraph "TkLife Rules" of this
document. TkLife mode is a kind of entertainment. Generated patterns are never
the same. To activate TkLife mode click on "New" and then "Start" buttons.
Do not click on "Start" button if you just busy with manual painting.
Immediately results of your painting will be automatically "mutated" by
unpredictable way. However, if you do it with purpose you may get some fun.
If you run TkLife in "BioMode", it is possible to analyze and visualize DNA
sequences corresponding to ORFs (Open Reading Frames). 64 different colors can
represent 64 different triplets. Each color corresponds to a particular genetic
codon or amino acid. There are 64 different triplets formed by combination of
four nucleotides A, G, C and T. Total number of amino acids corresponding to
codons is 20 because genetic code is redundant. Each codon is distinguishable
by a color specific to this codon.
TkLife can generate heat plots using numerical data from tab-delimited text
files. Files with extension *.tklife are considered as a native TkLife format.
Files with extension *.num_tab are treated as a numerical data. Different
dialogs and data processing will take place depending of a particular file
extension.
DRAWING MODE
To run TkLife in drawing mode start the program and then click on "New"
button. New blank canvas should appear. User can change size of canvas as
well as size of cells from main control panel prior clicking on "New"
button. It is possible to select 64 different colors from main program
window and paint by left mouse click cells on canvas. To restore cell color
to original "empty" state hold SHIFT key and click on left mouse button.
Right mouse click will show color info about painted cell. Using middle mouse
button you can drag (move) cells on canvas. It is possible to save results
of painting in file with extension *.tklife as well as load saved results
of previous work.
NETWORKING DRAWING MODE
Two TkLife programs running on two different computers can interact one with
each other via network sockets. To activate networking mode you need to start
SERVERS on both TkLife programs as well as connections via CLIENTS.
Mouse click events (painting) will be synchronized on both canvases.
DECOMPOSING OF IMAGES
Accompanying Python script Image2TkLife_003.py
converts JPEG images into TkLife file format. User can specify JPEG input file, TkLife
output file and the number of pixels (or cells) on TkLife canvas. Output is readable by
TkLife program. Read more about Image2TkLife_003.py usage and example
outputs on the Decomposed_Art.html web page.
POINCARE RECURRENCE
It is possible to visualize Poincare transformation/recurrence on TkLife canvas.
To run one round of Poincare iteration click on the left mouse button holding Shift
key (or activate Poincare iteration using the Right mouse button). Mouse pointer must
be over the "" control area during activation.
The algorithm of transformation is described at:
http://www.sciencenews.org/
in the article "Scrambled Grids" by Ivars Peterson.
TkLife control panel to activate Poincare iteration is displayed below:
Example input files in TkLife format to visualize Poincare transformation/recurrence:
tk_poincare_matrix.tklife
tk_poincare_rainbow.tklife
Example output:
Poincare transformation/recurrence works slow if the number of nodes is greater than 1000 (for example,
if you are using a grid 30 x 35 or greater). It was designed for visualization purpose. "Save as file"
function does not save a current iteration, it saves the original state. It is possible to save each
iteration in temporary file, default name of temporary file is "temp_pc_iteration_#.tklife" where "#"
is a number of iteration.
some exercises with prime numbers and Poincare transformation - 64 x 48 grid
and 64 x 96 grid
GENERATION OF REPETITIVE PATTERNS
Open new blank canvas by click on "New" button. Point mouse over the color
selection box (upper left). By "Shift + Right Mouse Click" repetitive
patterns will be generated. Currently 16 different rules (patterns) are
available via color select boxes:
0_0_0 0_0_5 0_0_a 0_0_f
0_5_0 0_5_5 0_5_a 0_5_f
0_a_0 0_a_5 0_a_a 0_a_f
0_f_0 0_f_5 0_f_a 0_f_f
Those patterns may be useful for further Poincare transformations.
COLOR SCHEME
64 different colors are formed by combination of "0", "5", "a" and "f"
hexadecimal values. For example:
"#00f" is blue
"#0f0" is green
"#f00" is red
"#f0f" is purple
"#ff0" is yellow
"#0ff" is cyan
"#fff" is white
"#555" is gray
Total number of all possible combinations for four different values is 64.
Values "0", "5", "a" and "f" reflect different level of saturation of
particular color components (red, green or blue).
TKLIFE RULES
By clicking on "New" and then on "Start" buttons TkLife mode will be
activated. During each iteration randomly chosen cell on canvas will be
selected and processed according to following rules:
If it is a time for "Mutation" then randomly chosen color will be assigned
for that cell. That cell will became painted or activated. Time for mutation
is determined by "Mutation Value" (15 by default). It means mutation takes
place one time per 15 iterations. Try to change mutation value from 1 to 100,
for example, to check how it affects patterns formation. If there is no time
for mutation then cell (if it is already painted) will be processed by another
algorithm:
If four cells: above, below, on the left and on the right are already painted
then their color will be changed to color of the middle cell (so called
CROSS TRANSITION):
###################### # # # A X # # DXB -> XXX # # C X # # # # CROSS TRANSITION # ######################
If selected cell is a center of small square (3 x 3) and four corner cells of the square are activated then they painted into color of selected cell. Cells above, below, on the left and on the right have to be painted as selected cell for this condition (so called SQUARE TRANSITION):
###################### # # # AXB XXX # # XXX -> XXX # # DXC XXX # # # # SQUARE TRANSITION # ######################
If selected cell is a center of a large square (5 x 5) and the square has uniform color then death of inner cells may happen if the DEATH status chosen as true. If DEATH status is false then nothing should happen. Green DEATH box corresponds to FALSE state (default), RED to TRUE DEATH state. To change the state click on DEATH box. Upon death inner cells became inactivated (black color with white outline).
###################### # # # XXXXX XXXXX # # XXXXX X---X # # XXXXX -> X---X # # XXXXX X---X # # XXXXX XXXXX # # # # DEATH TRANSITION # ######################
It is possible to stop (pause) animation and save current pattern in file with extension *.tklife. Also, it is possible to restore previously saved pattern from file in TkLife format and continue animation.
TKLIFE BIOMODE
If you run TkLife in "BioMode" color values are associated with DNA nucleotides.
At the same time values "0", "5", "a" and "f" correspond to nucleotides
"A", "G", "C" and "T" respectively. For example:
"#00f" is "AAT" - blue
"#00a" is "AAC"
"#005" is "AAG" - dark blue
"#000" is "AAA" - black
"#ff0" is "TTA" - yellow
"#fa5" is "TCG"
"#f50" is "TGA"
"#fff" is "TTT" - white
Check Amino Acids and Codon Usage
web page to see color scheme for all 64 triplets.
"Empty" state or so called "gap" in a sequence alignment coded as "---".
User can to run the script "DNA_to_TkLife_03.tcl" to transform DNA alignment
into TkLife style input file.
User needs to run custom scripts (or scripts provided with TkLife) to transform
DNA sequences into color coding tab-delimited file. Current version of TkLife
provides the script to transform sequence alignment at DNA level into TkLife
"color" input file. Sequence alignment should be in FASTA format. See the provided
example for a subset of Elongation factor sequences. To run TkLife in BioMode you
need to start the program in command line with argument "BIO". Or uncomment
#set biomode "TRUE" on the end of source code.
Download example files to run TkLife in BioMode:
x-ef2-NCBI.fasta eleven Elongation Factor 2 DNA sequences downloaded from NCBI
x-ef2-dna-one-line.fasta the same sequences with modified header
x-ef2-prot.fasta Translated into protein sequences (first frame)
x-ef2-prot.pir.fasta Protein alignment in FASTA format (by ClustalW)
x-ef2-dna.fasta.alignment DNA alignment derived from protein alignment
x-ef2-dna-one-line.fasta.alignment Modified (one line per sequence)
version of the x-ef2-dna.fasta.alignment file
x-ef2-dna.tklife TkLife file format corresponding to x-ef2-dna.fasta.alignment file
DNA_to_TkLife_05.tcl Tcl/Tk script to transform DNA alignment into TkLife file format
DNA_to_TkLife_07.tcl Tcl/Tk script to transform DNA alignment into TkLife file format
(this version will generate "*.tab_data" file format)
Note: You need to download only x-ef2-dna.tklife file to view it with TkLife program. Other files are here to show
how it was derived. Custom scripts to process DNA data by similar way are available upon request.
TKLIFE DATA MODE
Example of usage in the DATA MODE. File with climate data (average month temperature)
from http://www.worldclimate.com for 10 cities
temperature_wc.sorted was converted into "TkLife"
format using tcl script Data_to_TkLife_03.tcl.
temperature_wc.tab_data was used as input for
TkLife (file extension *.tab_data is critical). The graphical output is here:
INPUT AND OUTPUT FILES
Program is very flexible to user's input. Imagination is a limitation what user
can display using TkLife. It is possible to display simple drawing or visualize
any kind of numeric data. TkLife input file is a tab delimited file with color
values for each cell of the grid. So, user's data should be transformed into
*.tklife format to be digested by this program. Files with extension *.num_tab
are treated as a numerical data and conversion into native TkLife format is not
required.
Output files can be in five different formats. Each file format user can specify
by file extension. For example, file extension *.tklife will generate "TkLife"
tab delimited file with "RGB" values for each cell. File extension *.xpm will
produce XPM file which can be re-opened by drawing program (GIMP, for example).
File extension *.ps will generate file in PostScript format.
File extension *.html will generate web page with the table which looks like an
image. However it is not a real image, it is an html table where each cell
represented as a tile. Combination of these tiles creates illusion of real image.
You can check examples of HTML tables generated by TkLife
here (will be opened in a new window).
File extension *.fasta will generate file which looks like FASTA file with DNA
sequences. However, only *.tklife file format (and *.tab_data or *.num_tab in the DATA mode)
can be used as input files.
DOWNLOAD TKLIFE
TkLife is written in Tcl/Tk. In order to run it you need to install Tcl/Tk interpreter.
Tcl/Tk toolkit is freely available at
tcl.activestate.com
TkLife_012_V248Final.tcl TkLife current version 248 (source code)
TkLife_012_V248Final.exe Windows users can download executables.
In this case you do not need to install Tcl/Tk interpreter.
tk_life_color_matrix.tklife Example input file generated by "TkLife" mode
tk_life_paint_matrix.tklife Example input file generated by "Paint" mode
palette.tar.gz Set of 64 tiles - regular PNG images (you need it if you save TkLife images as HTML table)
palette_magic.tar.gz Set of 64 tiles - animated GIF images (you need it if you save TkLife images as HTML table)
amino_acids.tar.gz In order to run TkLife in "BioMode" you need to download amino
acids images and place them into directory where you run TkLife program
Previous version:
TkLife_012_V246Final.tcl
TkLife_012_V246Final.exe
TkLife_012_V112.tcl
TkLife_012_V112.exe
email to: akozik@atgc.org Alexander Kozik
last modified January 24 2006