2 # Copyright (C) 2005-2009, Parrot Foundation.
4 # Reads from stdin a file in the format made by fasta.pir
6 # N = 2500000 for fasta
8 # 2.2 s on AMD@2000/512K cache
10 # Original by Joshua Isom, heavily hacked by Leopold Toetsch
12 # create tr table at compile-time
13 # tr{wsatugcyrkmbdhvnATUGCYRKMBDHVN}
14 # {WSTAACGRYMKVHDBNTAACGRYMKVHDBN};
16 .sub tr_00_init :immediate
18 tr_array = new 'FixedIntegerArray' # Todo char array
19 tr_array = 256 # Python compat ;)
20 .local string from, to
21 from = 'wsatugcyrkmbdhvnATUGCYRKMBDHVN'
22 to = 'WSTAACGRYMKVHDBNTAACGRYMKVHDBN'
23 .local int i, ch, r, len
36 .local pmc stdin, stdout
37 .local string line, seq
40 # stdout is linebuffered per default - make it block buffered
41 stdout.'buffer_size'(8192)
47 unless line goto endwhile
49 unless $I0 == 62 goto else # '>'
50 if seq == '' goto no_rev
62 if seq == '' goto done
69 .local int i, linelen, ch
75 .const 'Sub' tr_00 = 'tr_00_init'
76 $P0.'trans'(line, tr_00)
81 $S0 = substr line, i, 60
85 if i >= linelen goto done
96 # vim: expandtab shiftwidth=4 ft=pir: