Скачать презентацию Perl IV Part V Hashing Out the Genetic Скачать презентацию Perl IV Part V Hashing Out the Genetic

04e23edcaa60729eaac856ff7a27e40f.ppt

  • Количество слайдов: 16

Perl IV Part V: Hashing Out the Genetic Code, Bioperl Perl IV Part V: Hashing Out the Genetic Code, Bioperl

Hashes l l l There are three main data types in Perl – scalar Hashes l l l There are three main data types in Perl – scalar variables, arrays, and hashes. Hashes provide VERY fast nested-array look-up Format is similar to that of array: • %hash = (‘key’ => ‘value’); • $value = $hash{‘key’};

Hashes %array = ( ‘key 1’, ‘value 1’, ‘key 2’, ‘value 2’, ‘key 3’, Hashes %array = ( ‘key 1’, ‘value 1’, ‘key 2’, ‘value 2’, ‘key 3’, ‘value 3’, ); %array = ( ‘key 1’=> ‘key 2’=> ‘value 2’, ‘key 3’=> ); ‘value 1’, ‘value 3’,

Hashes l l @keys = keys %hash @values = values %hash Hashes l l @keys = keys %hash @values = values %hash

The Binary Search of Arrays l l The ‘halving’ method is considerably faster then The Binary Search of Arrays l l The ‘halving’ method is considerably faster then doing a comparison. e. g. finding a match in a 30000 set array takes 15 times through a loop max. Good method for one sort and multiple comparisons

Comparing Strings l l To compare 2 strings alphabetically in Perl, you use the Comparing Strings l l To compare 2 strings alphabetically in Perl, you use the cmp operator, which returns 0 if the two strings are the same, -1 if they are in alphabetical order, and 1 if they are in reverse order. ‘zzz’ cmp ‘zzz’ returns 0 ‘AAA’ cmp ‘ZZZ’ returns -1 ‘ZZZ’ cmp ‘AAA’ returns 1

Sorting Arrays l Sorting an array of strings alphabetically l Sorting an array of Sorting Arrays l Sorting an array of strings alphabetically l Sorting an array of numbers in ascending order • @array = sort @array; • if given numbers this will sort them lexically • @array = sort { $a <=> $b } @array; • the values $a and $b must be used

Sorting Hashes l Sorting keys and values l Sorting keys in ascending order • Sorting Hashes l Sorting keys and values l Sorting keys in ascending order • foreach ( sort keys (%hash)) { • print “$_t”, “*” x $hash{$_}, ”n”; } • foreach (sort {$hash{$b}<=>$hash{$_}} keys (%hash)) { …… }

print Nested Arrays $array will give ARRAY(0 x 85 d 3 ad 0) but print Nested Arrays $array will give ARRAY(0 x 85 d 3 ad 0) but print $array[$i] gives array of $j l l l $array[$i] -> [$j]; produces $array[$i][$j] Or use hashes: • %hash = (duck => [‘Huey’, ’Louie’, ’Dewey’], horse => [‘Mr. Ed’], dog => [‘Benji’, ‘Lassie’] ); $value = $hash{$key}[$i]

The Genetic Code is Redundant Second Position U UUU U UUC UUA UUG C The Genetic Code is Redundant Second Position U UUU U UUC UUA UUG C Phe First Posit ion CUC CUA Leu UCA UAU Ser UAC UCG UAG Stop UGG Trp G CAU CCC CCA Pro CAC CAA AAU Ile AUA GUG ACC ACA Met s Thr AAC AAA Val ACG AAG GCU GUA C A ACU GUC U Stop AUU G UGC Cys UGA CAG AUG UGU Stop CCG AUC Tyr UAA CUG A G CCU Leu CUU C A UCU UCC GAU GCC GCA GCG Ala GAC GAA GAG His Gln Asn Lys Asp Glu CGU CGC CGA U Arg CGG AGU AGC AGA AGG GGA GGG A G Ser Arg GGU GGC C U C A G U Gly C A G Thi rd Pos itio n

Searching for codons DIFFICULT: my($codon) = @_; return s if ($codon =~ /TCA/i ); Searching for codons DIFFICULT: my($codon) = @_; return s if ($codon =~ /TCA/i ); return s elseif ($codon =~ /TCC/i); return s elseif ($codon =~ /TCG/i); blah

Searching for codons BETTER: my($codon) = @_; return A if ($codon =~ /GC. /i Searching for codons BETTER: my($codon) = @_; return A if ($codon =~ /GC. /i ); return C elseif ($codon =~ /TG[TC]/i); return D elseif ($codon =~ /GA[TC]/i); blah

Searching for codons BEST: my($codon) = @_; $codon uc $codon; my(%genetic_code) = ( ‘TCA’ Searching for codons BEST: my($codon) = @_; $codon uc $codon; my(%genetic_code) = ( ‘TCA’ => ‘S’, ‘TCC’ => ‘S’, ‘TCG’ => ‘S’ …. yadda ); return $genetic_code{$codon} if (exists $genetic_code{$codon})

Modules l l Perl contains the ability to deal with methods in an object-orientated Modules l l Perl contains the ability to deal with methods in an object-orientated manner classes are contained in packages These are often referred to as modules OO structure is: • object. Name ->method(arguments) Note to Self --- how many objects? . .

Bio. Perl (www. bioperl. org) l l The main focus of Bioperl modules is Bio. Perl (www. bioperl. org) l l The main focus of Bioperl modules is to perform sequence manipulation, provide access to various biology databases (both local and web-based), and parse the output of various programs. Its modules rely heavily on additional Perl modules available from CPAN (www. cpan. org)

How to go about comparing an unknown sequence. . . $in = Bio: : How to go about comparing an unknown sequence. . . $in = Bio: : Seq. IO->new(‘file’=>$infile, ‘-format’=>’genbank’); $seqobj = $in->next_seq(); @allfeatures = $seqobj->all_Seq. Features(); $feat = $allfeatures[0]; $feature_start = $feat->start; $feature_strand = $feat->strand; If ($seqobj->species->{common_name} =~ {elegans}) { $seq = $seqobj->primary_seq->{seq} $id = $seqobj->id; }