One more (I promise, I’ll stop hogging the fourm) mail to script conversion, 
this time from Ric’s contribution. (This is all great stuff, thank you guys 
very much!!)

   NB. Rick2, without Key
NB.If you want compare the summaries without the original text strings, then
NB.perhaps Key is not the best approach.
NB.This should work:
getTrigrams=: 3 ,\ ]
countTrigrams=: (~. ; #/.~)@getTrigrams
compareTrigrams=: dyad define

alltrig=. x ~.@;@,&({.) y

cnttrigs=. ((alltrig i.~ [) { 0 ,~ ])&>/&> x;<y

alltrig ; |: cnttrigs

)
]'X Y'=: 27 ({. ; }.) 'actg' {~ 60 ?@$ 4
+---------------------------+---------------------------------+
|gttgtcactgaacgaaatcgagaacca|agaatatgcgctaggccctgcttatagtctcct|
+---------------------------+---------------------------------+
]Xsumry=: countTrigrams X
+---+-----------------------------------------+
|gtt|1 1 1 1 1 1 1 1 1 3 2 1 2 1 1 1 1 1 1 1 1|
|ttg| |
|tgt| |
|gtc| |
|tca| |
|cac| |
|act| |
|ctg| |
|tga| |
|gaa| |
|aac| |
|acg| |
|cga| |
|aaa| |
|aat| |
|atc| |
|tcg| |
|gag| |
|aga| |
|acc| |
|cca| |
+---+-----------------------------------------+
]Ysumry=: countTrigrams Y
+---+-------------------------------------------------+
|aga|1 1 1 2 2 1 2 1 1 2 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1|
|gaa| |
|aat| |
|ata| |
|tat| |
|atg| |
|tgc| |
|gcg| |
|cgc| |
|gct| |
|cta| |
|tag| |
|agg| |
|ggc| |
|gcc| |
|ccc| |
|cct| |
|ctg| |
|ctt| |
|tta| |
|agt| |
|gtc| |
|tct| |
|ctc| |
|tcc| |
+---+-------------------------------------------------+
Xsumry compareTrigrams Ysumry
+---+---+
|gtt|1 0|
|ttg|1 0|
|tgt|1 0|
|gtc|1 1|
|tca|1 0|
|cac|1 0|
|act|1 0|
|ctg|1 1|
|tga|1 0|
|gaa|3 1|
|aac|2 0|
|acg|1 0|
|cga|2 0|
|aaa|1 0|
|aat|1 1|
|atc|1 0|
|tcg|1 0|
|gag|1 0|
|aga|1 1|
|acc|1 0|
|cca|1 0|
|ata|0 2|
|tat|0 2|
|atg|0 1|
|tgc|0 2|
|gcg|0 1|
|cgc|0 1|
|gct|0 2|
|cta|0 1|
|tag|0 2|
|agg|0 1|
|ggc|0 1|
|gcc|0 1|
|ccc|0 1|
|cct|0 2|
|ctt|0 1|
|tta|0 1|
|agt|0 1|
|tct|0 1|
|ctc|0 1|
|tcc|0 1|
+---+---+
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to