From be473361cd547ebfef8066b47c2fd0b2ff57b581 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Sat, 28 Dec 2013 13:22:35 -0800 Subject: [PATCH] add seq_to_grep --- seq_to_grep | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 seq_to_grep diff --git a/seq_to_grep b/seq_to_grep new file mode 100755 index 0000000..b88fdec --- /dev/null +++ b/seq_to_grep @@ -0,0 +1,47 @@ +#!/usr/bin/perl + +# code description +# A Adenine +# C Cytosine +# G Guanine +# T Thymine +# U Uracil +# R Purine (A or G) +# Y Pyrimidine (C, T, or U) +# M C or A +# K T, U, or G +# W T, U, or A +# S C or G +# B C, T, U, or G (not A) +# D A, T, U, or G (not C) +# H A, T, U, or C (not G) +# V A, C, or G (not T, not U) +# N Any base (A, C, G, T, or U) + +my %code_table = + (A => 'A', + C => 'C', + G => 'G', + T => 'TU', + U => 'TU', + R => 'AGR', + Y => 'CTUY', + M => 'CAM', + K => 'TUGK', + W => 'TUAW', + S => 'CGS', + B => 'CTUGBYWK', + D => 'ATUGDRWK', + H => 'ATUCHYWM', + V => 'ACGVRMS', + N => 'ACGTUYMKWSBDHVN', + ); +for my $code (keys %code_table) { + $code_table{$code} = + '['.$code_table{$code} . lc($code_table{$code}) .']'; +} + +for my $sequence (@ARGV) { + print map {exists $code_table{$_}?$code_table{$_}:$_} split //,$sequence; + print "\n"; +} -- 2.39.2