OUTPUT BUFFER:
#!/usr/local/bin/wish set Ltags "I white magenta L white magenta M white magenta V white magenta R white blue K white blue F white red Y white red W white red D white forestgreen E white forestgreen Q white green P white black G black orange H black cyan N black cyan S white darkviolet T white darkviolet A white darkviolet C white darkviolet ILMV white magenta RK white blue FYW white red DE white forestgreen HN white cyan STAC white darkviolet Q white green P white black G black orange" # Cinfigure tags for 20 amino acids proc ConfTag {} { global wt global Ltags foreach {n f b} $Ltags { $wt tag configure "Tag$n" -foreground $f -background $b } } proc JunkData {} { global data set l ".ACDEF..GHI..KLMNP....QRS.....TVWY..AFGE" set dt "[string repeat $l 30]\n" set data "[string repeat $dt 300]" } proc InitWindow2 {} { global data global wt wx wy set WdHt 50 set WdWd 120 set wt .f3.t set wx .f3.sx set wy .f3.sy frame .f3 text .f3.t -font "Courier 10 bold" -wrap none -yscrollcommand [list $wy set] -xscrollcommand [list $wx set] -height $WdHt -width $WdWd scrollbar .f3.sy -command "$wt yview" scrollbar .f3.sx -command "$wt xview" -orient horizontal pack .f3.sy -side right -fill y -expand 1 pack .f3.sx -side bottom -fill x pack .f3.t -expand 1 -fill both pack .f3 -side top $wt insert end $data $wt configure -foreground white -background "#303030303030" update return } proc TagTout2 {w t} { set Ltxt [split $t "\n"] set Lgaa [list "STAC" "DE" "ILMV" "FYW" "P" "RK" "Q" "G" "HN"] set i 0 foreach s $Ltxt { incr i set ls [split $s ""] foreach g $Lgaa { set freg "[join [split $g ""] "|"]" set lv [lsearch -all -regexp $ls $freg] if {$lv == {} } {continue} foreach e $lv { lappend lt($g) $i.$e $i.[expr {$e+1}] } } } foreach g $Lgaa { eval $w tag add Tag$g [set lt($g)] } update idletasks } proc TagTout3 {w t} { set Ltxt [split $t "\n"] set Lgaa [list "STAC" "DE" "ILMV" "FYW" "P" "RK" "Q" "G" "HN"] set i 0 foreach s $Ltxt { incr i foreach g $Lgaa { set freg "[join [split $g ""] "|"]" set lv [regexp -all -inline -indices -- $freg $s] if {$lv == {} } {continue} foreach e $lv { foreach {d f} $e {} incr f lappend lt($g) $i.$d $i.$f } } } foreach g $Lgaa { eval $w tag add Tag$g [set lt($g)] } update idletasks } proc TagTout4 {w t} { set Ltxt [split $t "\n"] set Lgaa [split "STACDEILMVFYWPRKQGHN" ""] set i 0 foreach s $Ltxt { incr i foreach g $Lgaa { set lv [regexp -all -inline -indices -- $g $s] if {$lv == {} } {continue} foreach e $lv { foreach {d f} $e {} incr f lappend lt($g) $i.$d $i.$f } } } foreach g $Lgaa { eval $w tag add Tag$g [set lt($g)] } update idletasks } JunkData InitWindow2 ConfTag global wt set t [$wt get 1.0 end] puts "[time {TagTout4 $wt $t} 1]"