]> git.donarmstrong.com Git - bin.git/blob - seq_to_grep
remove convert_to_xls and .sa_bin
[bin.git] / seq_to_grep
1 #!/usr/bin/perl
2
3 # code  description
4 # A     Adenine
5 # C     Cytosine
6 # G     Guanine
7 # T     Thymine
8 # U     Uracil
9 # R     Purine (A or G)
10 # Y     Pyrimidine (C, T, or U)
11 # M     C or A
12 # K     T, U, or G
13 # W     T, U, or A
14 # S     C or G
15 # B     C, T, U, or G (not A)
16 # D     A, T, U, or G (not C)
17 # H     A, T, U, or C (not G)
18 # V     A, C, or G (not T, not U)
19 # N     Any base (A, C, G, T, or U)
20
21 my %code_table =
22     (A => 'A',
23      C => 'C',
24      G => 'G',
25      T => 'TU',
26      U => 'TU',
27      R => 'AGR',
28      Y => 'CTUY',
29      M => 'CAM',
30      K => 'TUGK',
31      W => 'TUAW',
32      S => 'CGS',
33      B => 'CTUGBYWK',
34      D => 'ATUGDRWK',
35      H => 'ATUCHYWM',
36      V => 'ACGVRMS',
37      N => 'ACGTUYMKWSBDHVN',
38     );
39 for my $code (keys %code_table) {
40     $code_table{$code} =
41         '['.$code_table{$code} . lc($code_table{$code}) .']';
42 }
43
44 for my $sequence (@ARGV) {
45     print map {exists $code_table{$_}?$code_table{$_}:$_} split //,$sequence;
46     print "\n";
47 }