#!/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"; }