;;;;;;;;;;;;;;;;;;;;;;;
;; @name haplotype matrix creator
;; @author Kostia Kildor Romanov <kostia<@>ngs.ru>
;; @version 3
;; @url http://kildor.miranda.im/far/haplotype.html
;; @date 02.11.2010
;;;;;;;;;;;;;;;;;;;;;;;
;;$MMode 1
Clip(5)
mmode(1,1)
editor.undo(0);
;; config
;; max number of lines.
%maxNum = 100;
;; max lenght of sequence
%maxLenght = 1000;
;; start script
;; Is current position variable?
%isVariable = 0;
;; current char of upper sequence
%c = substr(Editor.Value,Editor.RealPos-1,1);
;; current char of current sequence
%cS = "";
;; current position
%j=0;
;; \tab-separated string of variabled positions in sequence
%positionsNumber = "";
;; number of variabled positions
%variabled=0;
;; number of identical positions
%ident=0;
;; speed of redraw screen (Each N step)
%redrawStep = 25;
;; !!! Start script execution
BM.Clear();
BM.Add();
$while (%c!= "" && Editor.RealPos<=len(Editor.Value))
$if (mod(%j,%redrawStep)==0)
mmode(1,0);
mmode(1,1);
$end
%cS="!";
%isVariable = 0;
%c = substr(Editor.Value,Editor.RealPos-1,1);
Rctrl9
$if (%c!=" " )
;; && %c!="-")
%i=1;
Down
$while ( asc(%cS)!=0 && !EOF)
%cS = substr(Editor.Value,Editor.RealPos-1,1);
$if (%cS!=%c && %cS!="." && %cS!="?" && %cS!="*" && %cS!="")
%isVariable=1;
$end
Down
%i=%i+1;
$if (%i>%maxNum)
msgbox("Finish", "MaxNum executed", 1)
editor.undo(1);
$exit
$end
$end
$if (%isVariable==0)
%ident=%ident+1;
$rep(%i)
AltUp
$end
AltRight
CtrlD
$else
%variabled=%variabled+1;
%positionsNumber = %positionsNumber+(%j+1)+"\t";
Right
$rep(%i+1)
Tab Left Up
$end
Ctrl9
Right Right
$end
$else
Right
%i=1;
$end
%j=%j+1;
$if (%j>%maxLenght)
msgbox("Finish", "%j>"+%maxLenght, "1")
editor.undo(1);
$exit
$end
$end
BM.Prev();
$if (Editor.CurLine==1)
Home Enter
BM.Prev();
$end
BM.Clear();
Up
print(trim(%positionsNumber));
Ctrl9
Up
editor.undo(1);
msgbox("Script finished", "Result:\n Total positions: "+%j+"\n Variabled: "+%variabled+"\n Identical: "+%ident, 0x0010);