in reply to Keep getting "use of unitialized value" error in a weird place
Hi listendohg and welcome to Perlmonks.
Your approach is more of a C programming style which can be made to work but isn't much fun. Try the Perl way and you'll start to see why many of us enjoy Perl so much. It makes easy things easy and hard things possible.
Disclaimer: I'm not an expert in biology so the following is just an example and probably isn't correct as far as the dna and codons are concerned. I found the information included from
#!/usr/bin/perl use strict; use warnings; ### random 30 character dna sequence from ### http://www.bioinformatics.org/sms2/random_dna.html my $dohg2 = 'ttcgtgaggcaggctgtcaattagagtcgt'; my @sub8 = ( $dohg2 =~ m/.../g ); print "@sub8\n"; # Codon : a sequence of three nucleotides that together form a unit of + # genetic code in a DNA or RNA molecule. #https://en.wikipedia.org/wiki/DNA_codon_table # From the following site I copied this hash definition: #http://web.cs.iastate.edu/~cs596/notes/perl_hashes.html my %DNA_code = ( 'GCT' => 'A', 'GCC' => 'A', 'GCA' => 'A', 'GCG' => 'A', 'TTA' => 'L', 'TTG' => 'L', 'CTT' => 'L', 'CTC' => 'L', 'CTA' => 'L', 'CTG' => 'L', 'CGT' => 'R', 'CGC' => 'R', 'CGA' => 'R', 'CGG' => 'R', 'AGA' => 'R', 'AGG' => 'R', 'AAA' => 'K', 'AAG' => 'K', 'AAT' => 'N', 'AAC' => 'N', 'ATG' => 'M', 'GAT' => 'D', 'GAC' => 'D', 'TTT' => 'F', 'TTC' => 'F', 'TGT' => 'C', 'TGC' => 'C', 'CCT' => 'P', 'CCC' => 'P', 'CCA' => 'P', 'CCG' => 'P', 'CAA' => 'Q', 'CAG' => 'Q', 'TCT' => 'S', 'TCC' => 'S', 'TCA' => 'S', 'TCG' => 'S', 'AGT' => 'S', 'AGC' => 'S', 'GAA' => 'E', 'GAG' => 'E', 'ACT' => 'T', 'ACC' => 'T', 'ACA' => 'T', 'ACG' => 'T', 'GGT' => 'G', 'GGC' => 'G', 'GGA' => 'G', 'GGG' => 'G', 'TGG' => 'W', 'CAT' => 'H', 'CAC' => 'H', 'TAT' => 'Y', 'TAC' => 'Y', 'ATT' => 'I', 'ATC' => 'I', 'ATA' => 'I', 'GTT' => 'V', 'GTC' => 'V', 'GTA' => 'V', 'GTG' => 'V',); foreach ( @sub8 ) { if( defined $DNA_code{uc $_} ) { print "$_ => $DNA_code{uc $_}\n"; } else { print "$_ => ???\n"; } }
The result is below:
ttc gtg agg cag gct gtc aat tag agt cgt ttc => F gtg => V agg => R cag => Q gct => A gtc => V aat => N tag => ??? agt => S cgt => R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Keep getting "use of unitialized value" error in a weird place
by Anonymous Monk on Apr 09, 2016 at 22:33 UTC |