Page 1 of 1

whooploafSoftware and s/w Development

Dec 13, 2013 (3 years and 4 months ago)

280 views







  
     
          
     


  

      
 
       
      
!"#$
 
%
&  
%
' 
%
(
%
((
%
)



 
#
*




 


 

 











 





%2'=A=3&&%0>2 0


%2'=-=2


%2'=<(=2


 &)=";2
+
"00


%2)=<=5 ";2
+
"00?


%2)='=80  B5 50 C


%2)=)=";2D> D 


%2)=@=3*B
+
EC


%2)=,=F<!3&   


%2)=.=$  F< 


%2)=/=F'=&!3%2&   


%2)=A=F)=&!3 &   


%2)=-=G38""3$54


%2)=<(= 08&8";2 $%"6


%2)=<<=F=&!31 &   


%2)=<'=G$2   "$


%2)=<)=3 &2


%2)=<@=2


%2)=<,=2


 &@=%H21 2


%2@=<= 2


%2@='=1 "=&!3 51 


%2@=)=%H1 "=&!%H21 1


%2@=@=2


%2@=,=2


 &,=3 29


%2,=<=0";2


%2,='==&!3 > 


%2,=)=2=&!1020%


%2,=@=$02>&


%2,=,=2


%2,=.=2

!  2


 &.=   $


%2.=<=" D>$


%2.='=&   $


%2.=)=  $$


%2.=@=%2:00


%2.=,=306$


%2.=.=  
$$0


%2.=/= $ $ $2> 


%2.=A=3$& 


%2.=-=3 &2


%2.=<(=2


%2.=<<=2


 &/=  5


%2/=<=G 554


%2/='=5% 


%2/=)= F2


%2/=@=!  0$250


%2/=,=2


 &A= F& 2


%2A=<=&F& 2


%2A='=F$


%2A=)=30F$F& 22&=&


%2A=@=>40F& 
Page
2
of
3
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh4A55.htm


%2A=,=2


%2A=.=2


 &-=2 &


%2-=<= F  &


%2-='= 0 &


%2-=)=0 &


%2-=@= &  


%2-=,="";2


%2-=.=& =&


%2-=/=& =& !H2I& $


%2-=A=80 & > 

!3&&


3&&3= %


%23=<=&


%23='=


%23=)=%2 J %2 J 


%23=@=30


%23=,=% 24


%23=.=3


%23=/=G 


%23=A=& $%2


%23=-="&


%23=<(="&22


%23=<<= 2"&


%23=<'= 02 "&


%23=<)= 0"&


%23=<@=&


%23=<,=&K"&


%23=<.=0 &


%23=</=%2 


%23=<A=%


%23=<-=> 240


%23='(=";2
+
"00


%23='<=  
+
12


3&& = 0


%2 =<= 0 6&


%2 ='=J


%2 =)=322


%2 =@=$ 0


%2 =,=G 0


%2 =.=10G &

 & 


 


Page
3
of
3
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh4A55.htm



 


Preface
      
          
   
       
!  "#   
   
$    
 $     
    
!     %&  
  '   
    
  
( 
(  
  )  "
       
      
*   "     
     
   +   

 


 


About This Book
       
,-"./
$ 0$      
 
+ ( (    
1 #   
      +   
    
(    
 !        
    2   
       
   

3    $  
           4 +
    #  
. +  56$   
 
      
2   
        
  
$  
 7888 8
  
 
 


 


Page
1
of
5
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh9B80.htm

What You Need to Know to Use This Book
    +   
9+ 9      9
        9   
  9 9   9
  (  
+    :   + 5   
  
( + 

$$
     ++
#;)!-..$6,
09      
   9  "          
  # 
         56$
   39  56$  +9 
 9     :  +5 .  
        
 
      
   :  ,: 5   0  
    +5 ,+ 5   0*  
.,.  435 0$  1  
      +    
   
 


 


Organization of This Book
2"    ("   +  
    ( 
   +  
+ (

; <

*  += =   
 ' ;:(   
     +$
     5 (
   *      +
  "    +(  (
   

; >

;       ++ 
   , 0+
2   
    +    
+     "   
Page
2
of
5
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh9B80.htm
'        
9    
   '  
  $'(   
           
   +
; ?

-1 #   (
       
,!;!-..$6 9;@@)1 # 9+
 0( "   +   1 # 
! 1 # 
       1 # +
        
; A

(  1 #     
       ,!$'$:;: 0 
   
; %

  1 #    
.  3        
  
+ ((

; B

.     3 
       'C
   (    
     *'C +
; D

E+"  (  (     
  E+ ;:( 
    E
; F

G        
 (      
     E+:5
   
; H

 +    ( 
 "    1  ,
   0  
3 (    
 (+ 
       
Page
3
of
5
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh9B80.htm


+ (((

$$

3  +"
$

   +

 


 


Conventions Used in This Book
   7
Constant

width

G1  
       
 

G G. 
 
        

  J

!   .;  -".6   
-".  7
 788

 


 


Acknowledgments
* )        
-".2 (  -". 
       (    
 7): )) $* 'C(  5*
; 
; ?
(      
      (
             
 9     (  4:
)+     $(  #
.4)  

 


Page
5
of
5
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh9B80.htm




 


Part I: Object-Oriented Programming in Perl
 


 


Chapter 1. Modular Programming with Perl
      
    
 
  ! 
 " # $%$
#&'   #
GeneticCode.pm
( 
  #&' (  
&'  # # % )
*+, 
+ *+, %  -  
 %.*+,# ( 
) / #
' ##
 


 


1.1 What Is a Module?
+ 
  %   
(   
my

use

strict

 0) 

 


 


1.2 Why Perl Modules?
 ) ) 1%  #
 #+ $$ 
 #0   + 
 #1
# ## 0
# 
1.2.1 Subroutines and Software Engineering
 
  0 !
 #  ##
 
+ #
 2,+1  1 
/%#
%   %
  #%+ 
Page
1
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
 # + 
# % 
 % 

&'0   
  1  1% 
 3  0)

+  

#  
'2,+
&+++++2,+#
#'
2,+/ 
#'  %
4(  %2,+
"
sub DNAappend {
my ($dna, $tail) = @_;

return($dna . $tail);
}
 "
my $dna = 'ACCGGAGTTGACTCTCCGAATA';
my $polyT = 'TTTTTTTT';

print DNAappend($dna, $polyT);
&# 
polyT

polyA
 %"
sub polyT {
my ($dna) = @_;

return DNAappend($dna, 'TTTTTTTT');
}
sub polyA {
my ($dna) = @_;

return DNAappend($dna, 'AAAAAAAA');
}
+# % -# 
     
1.2.2 Modules and Libraries
&0#&     

 #
 #
  
  #&0  # 
    ( 

5

      # -   
      
  # 
Page
2
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm


%6#%    % 
 ((

 


 


1.3 Namespaces
+    
    
%%
   +  
 +(# 
  
   
   
#))   3
 

package
 (
&  '
 ) 

1.3.1 Namespaces Compared with Scoping: my and use strict
    
7   
my

   % 89  

use

strict
1
my
  
use strict

my
  !%

my
%
use

strict

 


 


1.4 Packages
%'  & #
 # 
   
%+) 
package
 4'
 ( "
$dna = 'AAAAAAAAAA';
package Mouse;
$dna = 'CCCCCCCCCC';
package Celegans;
$dna = 'GGGGGGGGGG';
&# ##
$dna
4#
%#   
 
  )+2,+ 
$dna
 
%(  #
$dna
  
main

Page
3
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
  
 
package Mouse;
+#
main
 #
Mouse

 , -' )
      
 
main

,
Mouse
# #  #
$dna
#
    & )*2,+
6 #   % 
Celegans
 # 
 
$dna
# ):2,+

$dna
 #(  % 
# "
print "The DNA from the main package:\n\n";
print $main::dna, "\n\n";

print "The DNA from the Mouse package:\n\n";
print $Mouse::dna, "\n\n";

print "The DNA from the Celegans package:\n\n";
print $Celegans::dna, "\n\n";
 "
The DNA from the main package:

AAAAAAAAAA

The DNA from the Mouse package:

CCCCCCCCCC

The DNA from the Celegans package:

GGGGGGGGGG
+#  %%
  
$
#
@
#
%

  &'%# %#
 
main
%# ( "
#
# Define the variables in the packages
#

$dna = 'AAAAAAAAAA';

package Mouse;

$dna = 'CCCCCCCCCC';

#
# Print the values of the variables
#

print "The DNA from the current package:\n\n";
print $dna, "\n\n";

print "The DNA from the Mouse package:\n\n";
print $Mouse::dna, "\n\n";
Page
4
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm


 "
The DNA from the current package:
CCCCCCCCCC

The DNA from the Mouse package:
CCCCCCCCCC

print $dna

print $Mouse::dna
  
package
 
package

Mouse;
#
print

$dna
  
$dna
%#
Mouse

 #% #% (%
   7  % %# #
#%  %# #
 

package
  
   #(

 


 


1.5 Defining Modules
#%   %
Newmodule.pm
,# 
 "
package Newmodule;
  
1;
7'  
%
Celegans
 #   
Celegans.pm
# "
package Celegans;
+  
1;
#'
Celegans
   0 
 '&'#
 


 


1.6 Storing Modules
.
.pm
   # '%
6  # 
perlmod

perlmodlib
 
";; 
7 
perldoc

perlmod

perldoc

perlmodlib
 
<   #'
 #   -
   #  #
4'  
Celegans.pm
 
"
use Celegans;
Page
5
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
4#'   ( - ) 
 #  *+,#'  3 1 #
 -   #   
  #  
  %
  ## 
 # 
.  #  
=  #  %
#  ( )
@INC
# %"
print join("\n", @INC), "\n";
<(#& "
/usr/local/lib/perl5/5.8.0/i686-linux
/usr/local/lib/perl5/5.8.0
/usr/local/lib/perl5/site_perl/5.8.0/i686-linux
/usr/local/lib/perl5/site_perl/5.8.0
/usr/local/lib/perl5/site_perl/5.6.1
/usr/local/lib/perl5/site_perl/5.6.0
/usr/local/lib/perl5/site_perl
.
     (
@INC
 
 %
#/( 
 . 
,    $
#$# &
 # #  
.pm
 

.   #   
& #  # 

use MODULE
#    
 16#& &' 
 
Celegans.pm
#
Celegans.pm
 (

 
  
#&
use lib

# %"
use lib "/home/tisdall/MasteringPerlBio/development/lib";

use Celegans;
   
@INC

Celegans.pm
   "
use lib "/home/tisdall/MasteringPerlBio/development/lib";

print join("\n", @INC), "\n";
"
/home/tisdall/MasteringPerlBio/development/lib
/usr/local/lib/perl5/5.8.0/i686-linux
/usr/local/lib/perl5/5.8.0
/usr/local/lib/perl5/site_perl/5.8.0/i686-linux
/usr/local/lib/perl5/site_perl/5.8.0
Page
6
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm

/usr/local/lib/perl5/site_perl/5.6.1
/usr/local/lib/perl5/site_perl/5.6.0
/usr/local/lib/perl5/site_perl
.
%
use lib
# 
Celegans.pm
 
@INC
 
+  
&  
#
  
&##  %'#'
#
=>?&   # 
  (  ,=>?&  "
PERL5LIB=$PERL5LIB:/my/perl/modules
7 "
setenv PERL5LIB /my/perl/modules
&$$%  # 
## 
7   "
perl -I/my/perl/modules myprogram.pl
'  '7'   

Genomes::Modelorganisms::Celegans
#
   %

@INC
 )&( #  %
Genomes

@INC

-
Modelorganisms

Genomes
- #
 
Celegans.pm

Modelorganisms
#  "
/home/tisdall/MasteringPerlBio/development/lib/Genomes/Modelorganisms/Celegans.pm
'   %"
use lib "/home/tisdall/MasteringPerlBio/development/lib";

use Genomes::Modelorganisms::Celegans;
   #
 3
perlmod
#
perlrun
#
perlmodlib
  
 

 


 


1.7 Writing Your First Perl Module
,' #' (%
(  
&#'   
Geneticcode.pm
# 
2,+ 2,+1
Page
7
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm

1.7.1 An Example: Geneticcode.pm
'  
Geneticcode.pm

  
%genetic_code
.'   
codon2aa

  
4  
Geneticcode.pm
"
package Geneticcode;

use strict;
use warnings;

my(%genetic_code) = (

'TCA' => 'S', # Serine
'TCC' => 'S', # Serine
'TCG' => 'S', # Serine
'TCT' => 'S', # Serine
'TTC' => 'F', # Phenylalanine
'TTT' => 'F', # Phenylalanine
'TTA' => 'L', # Leucine
'TTG' => 'L', # Leucine
'TAC' => 'Y', # Tyrosine
'TAT' => 'Y', # Tyrosine
'TAA' => '_', # Stop
'TAG' => '_', # Stop
'TGC' => 'C', # Cysteine
'TGT' => 'C', # Cysteine
'TGA' => '_', # Stop
'TGG' => 'W', # Tryptophan
'CTA' => 'L', # Leucine
'CTC' => 'L', # Leucine
'CTG' => 'L', # Leucine
'CTT' => 'L', # Leucine
'CCA' => 'P', # Proline
'CCC' => 'P', # Proline
'CCG' => 'P', # Proline
'CCT' => 'P', # Proline
'CAC' => 'H', # Histidine
'CAT' => 'H', # Histidine
'CAA' => 'Q', # Glutamine
'CAG' => 'Q', # Glutamine
'CGA' => 'R', # Arginine
'CGC' => 'R', # Arginine
'CGG' => 'R', # Arginine
'CGT' => 'R', # Arginine
'ATA' => 'I', # Isoleucine
'ATC' => 'I', # Isoleucine
'ATT' => 'I', # Isoleucine
'ATG' => 'M', # Methionine
'ACA' => 'T', # Threonine
'ACC' => 'T', # Threonine
'ACG' => 'T', # Threonine
'ACT' => 'T', # Threonine
'AAC' => 'N', # Asparagine
'AAT' => 'N', # Asparagine
'AAA' => 'K', # Lysine
'AAG' => 'K', # Lysine
'AGC' => 'S', # Serine
'AGT' => 'S', # Serine
'AGA' => 'R', # Arginine
'AGG' => 'R', # Arginine
Page
8
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
'GTA' => 'V', # Valine
'GTC' => 'V', # Valine
'GTG' => 'V', # Valine
'GTT' => 'V', # Valine
'GCA' => 'A', # Alanine
'GCC' => 'A', # Alanine
'GCG' => 'A', # Alanine
'GCT' => 'A', # Alanine
'GAC' => 'D', # Aspartic Acid
'GAT' => 'D', # Aspartic Acid
'GAA' => 'E', # Glutamic Acid
'GAG' => 'E', # Glutamic Acid
'GGA' => 'G', # Glycine
'GGC' => 'G', # Glycine
'GGG' => 'G', # Glycine
'GGT' => 'G', # Glycine
);


#
# codon2aa
#
# A subroutine to translate a DNA 3-character codon to an amino acid
# Version 3, using hash lookup

sub codon2aa {
my($codon) = @_;

$codon = uc $codon;

if(exists $genetic_code{$codon}) {
return $genetic_code{$codon};
}else{
die "Bad codon '$codon'!!\n";
}
}

1;
,# '(6#  %
Geneticcode

 
Geneticcode.pm
# (
.pm

"
use strict;
use warnings;
  
use strict

my
 
 
use warnings
   
& 1@
#3
perldiag
#
perllexwarn
#
perlmodlib
 
  
6 #
codon2aa
+#%
2,+
&   %
%genetic_code
 

return
 )

codon2aa
 
die
(3
(
& %#&
%genetic_code

codon2aa

 #  #%&
Page
9
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
#  # # 
#

Geneticcode
% 
Geneticcode.pm
 
"
use Geneticcode;
=1 
codon2aa
  

4'( 
Geneticcode
 #  
testGeneticcode

perl testGeneticcode
"
use strict;
use warnings;

use lib "/home/tisdall/MasteringPerlBio/development/lib";

use Geneticcode;

my $dna = 'AACCTTCCTTCCGGAAGAGAG';

# Initialize variables
my $protein = '';

# Translate each three-base codon to an amino acid, and append to a protein
for(my $i=0; $i < (length($dna) - 2) ; $i += 3) {
$protein .= Geneticcode::codon2aa( substr($dna,$i,3) );
}

print $protein, "\n";
>   )
substr
(&#
substr

(
$dna
 
$i
-
)
codon2aa

"
NLPSGRE
1.7.2 Expanding Geneticcode.pm
,# '(
Geneticcode
 (   
  
 '#  
 
!    .
 #  
4# -1
   # '
 .' (
Geneticcode
 - ' 
SequenceIO
 
<#    
SequenceIO.pm
#   
 @#' 
Geneticcode

 
4'
Geneticcode.pm
"
package Geneticcode;

use strict;
use warnings;
Page
10
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm

my(%genetic_code) = (

'TCA' => 'S', # Serine
'TCC' => 'S', # Serine
'TCG' => 'S', # Serine
'TCT' => 'S', # Serine
'TTC' => 'F', # Phenylalanine

... as before ...

'GAG' => 'E', # Glutamic Acid
'GGA' => 'G', # Glycine
'GGC' => 'G', # Glycine
'GGG' => 'G', # Glycine
'GGT' => 'G', # Glycine
);


#
# codon2aa
#
# A subroutine to translate a DNA 3-character codon to an amino acid
# Version 3, using hash lookup

sub codon2aa {
my($codon) = @_;

$codon = uc $codon;

if(exists $genetic_code{$codon}) {
return $genetic_code{$codon};
}else{

die "Bad codon '$codon'!!\n";
}
}

#
# dna2peptide
#
# A subroutine to translate DNA sequence into a peptide

sub dna2peptide {

my($dna) = @_;

# Initialize variables
my $protein = '';

# Translate each three-base codon to an amino acid, and append to a protein
for(my $i=0; $i < (length($dna) - 2) ; $i += 3) {
$protein .= codon2aa( substr($dna,$i,3) );
}

return $protein;
}

# translate_frame
#
# A subroutine to translate a frame of DNA

sub translate_frame {

my($seq, $start, $end) = @_;
my $protein;

Page
11
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
# To make the subroutine easier to use, you won't need to specify
# the end point-it will just go to the end of the sequence
# by default.
unless($end) {
$end = length($seq);
}

# Finally, calculate and return the translation
return dna2peptide ( substr ( $seq, $start - 1, $end -$start + 1) );
}

1;
,#   4#
 16+3+1 #1 
   % #%
% 0 #1(#1
 -  
A3( 
4' 
SequenceIO.pm
#  #(
6+3+1#1"
package SequenceIO;

use strict;
use warnings;

# get_file_data
#
# A subroutine to get data from a file given its filename

sub get_file_data {

my($filename) = @_;

# Initialize variables
my @filedata = ( );

open(GET_FILE_DATA, $filename) or die "Cannot open file '$filename':$!\n\n";

@filedata = <GET_FILE_DATA>;

close GET_FILE_DATA;

return @filedata;
}

# extract_sequence_from_fasta_data
#
# A subroutine to extract FASTA sequence data from an array

sub extract_sequence_from_fasta_data {

my(@fasta_file_data) = @_;

# Declare and initialize variables
my $sequence = '';

foreach my $line (@fasta_file_data) {

# discard blank line
if ($line =~ /^\s*$/) {
next;

# discard comment line
Page
12
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
} elsif($line =~ /^\s*#/) {
next;

# discard fasta header line
} elsif($line =~ /^>/) {
next;

# keep line, add to sequence string
} else {
$sequence .= $line;
}
}

# remove non-sequence data (in this case, whitespace) from $sequence string
$sequence =~ s/\s//g;

return $sequence;
}

# print_sequence
#
# A subroutine to format and print sequence data

sub print_sequence {

my($sequence, $length) = @_;

# Print sequence in lines of $length
for ( my $pos = 0 ; $pos < length($sequence) ; $pos += $length ) {
print substr($sequence, $pos, $length), "\n";
}
}

1;
# ' "
# Translate a DNA sequence into one of the six reading frames

use strict;
use warnings;

use lib "/home/tisdall/MasteringPerlBio/development/lib";
use Geneticcode;
use SequenceIO;

# Initialize variables
my @file_data = ( );
my $dna = '';
my $revcom = '';
my $protein = '';

# Read in the contents of the file "sample.dna"
@file_data = SequenceIO::get_file_data("sample.dna");

# Extract the sequence data from the contents of the file "sample.dna"
$dna = SequenceIO::extract_sequence_from_fasta_data(@file_data);

# Translate the DNA to protein in one of the six reading frames
# and print the protein in lines 70 characters long

print "\n -------Reading Frame 1--------\n\n";

$protein = Geneticcode::translate_frame($dna, 1);

SequenceIO::print_sequence($protein, 70);
Page
13
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm


exit;
4' "
> sample dna (This is a typical fasta header.)
agatggcggcgctgaggggtcttgggggctctaggccggccacctactgg
tttgcagcggagacgacgcatggggcctgcgcaataggagtacgctgcct
gggaggcgtgactagaagcggaagtagttgtgggcgcctttgcaaccgcc
tgggacgccgccgagtggtctgtgcaggttcgcgggtcgctggcgggggt
cgtgagggagtgcgccgggagcggagatatggagggagatggttcagacc
cagagcctccagatgccggggaggacagcaagtccgagaatggggagaat
gcgcccatctactgcatctgccgcaaaccggacatcaactgcttcatgat
cgggtgtgacaactgcaatgagtggttccatggggactgcatccggatca
ctgagaagatggccaaggccatccgggagtggtactgtcgggagtgcaga
gagaaagaccccaagctagagattcgctatcggcacaagaagtcacggga
gcgggatggcaatgagcgggacagcagtgagccccgggatgagggtggag
ggcgcaagaggcctgtccctgatccagacctgcagcgccgggcagggtca
gggacaggggttggggccatgcttgctcggggctctgcttcgccccacaa
atcctctccgcagcccttggtggccacacccagccagcatcaccagcagc
agcagcagcagatcaaacggtcagcccgcatgtgtggtgagtgtgaggca
tgtcggcgcactgaggactgtggtcactgtgatttctgtcgggacatgaa
gaagttcgggggccccaacaagatccggcagaagtgccggctgcgccagt
gccagctgcgggcccgggaatcgtacaagtacttcccttcctcgctctca
ccagtgacgccctcagagtccctgccaaggccccgccggccactgcccac
ccaacagcagccacagccatcacagaagttagggcgcatccgtgaagatg
agggggcagtggcgtcatcaacagtcaaggagcctcctgaggctacagcc
acacctgagccactctcagatgaggaccta
4'"
-------Reading Frame 1--------

RWRR_GVLGALGRPPTGLQRRRRMGPAQ_EYAAWEA_LEAEVVVGAFATAWDAAEWSVQVRGSLAGVVRE
CAGSGDMEGDGSDPEPPDAGEDSKSENGENAPIYCICRKPDINCFMIGCDNCNEWFHGDCIRITEKMAKA
IREWYCRECREKDPKLEIRYRHKKSRERDGNERDSSEPRDEGGGRKRPVPDPDLQRRAGSGTGVGAMLAR
GSASPHKSSPQPLVATPSQHHQQQQQQIKRSARMCGECEACRRTEDCGHCDFCRDMKKFGGPNKIRQKCR
LRQCQLRARESYKYFPSSLSPVTPSESLPRPRRPLPTQQQPQPSQKLGRIREDEGAVASSTVKEPPEATA
TPEPLSDEDL
+6# 
Geneticcode

  
%genetic_code

codon2aa
#
dna2peptide
#
translate_frame
#  2,+
1 ##
SequenceIO
 
get_file_data
#
extract_sequence_from_fasta_data
#

print_sequence

,# (- ' %
 
 


 


1.8 Using Modules
3# 1 7
  
package
  # 
  B
1.8.1 Exporting Names
'     
 
Exporter
  
use MODULE
  
Page
14
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm


:%( 
Geneticcode.pm
 #  "
package Geneticcode;
 
genetic_code

codon2aa

&  #(  
  7
#
codon2aa

Geneticcode::codon2aa
4'( 
%
perldoc Exporter
  "
package Geneticcode;

require Exporter;
@ISA = qw(Exporter);

@EXPORT_OK = qw(...); # symbols to export on request
4'(
codon2aa
  (  1"
@EXPORT_OK = qw(codon2aa); # symbols to export on request
 (  1
codon2aa
  %"
use Geneticcode qw(codon2aa);
&# 0"
codon2aa($codon);
"
Geneticcode::codon2aa($codon);

Exporter
 '    
#0 +' #0)
  '
Export
 # 
%6(( %
$ $ # 
Exporter
 
perldoc
Exporter
 
";; 
 
 


 


1.9 CPAN Modules
* +,%*+,#
";;
  
      *+,   .#
 %
  # '%
( *+,  
*+,6# 
     7
0*+,# # 
.' % %( ( 
Page
15
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
3# *+,  
 3AC
*+,   #'
CPAN.pm
  )
 %   1% #
  &'
CPAN.pm
# 
7  "
perldoc CPAN
7 %61 +%D6+D   *+,
1.9.1 What's Available at CPAN?
*+, $$*+,    
 ## ( # 4
)    "
Development Support
Operating System Interfaces
Networking Devices IPC
Data Type Utilities
Database Interfaces
User Interfaces
Language Interfaces
File Names Systems Locking
String Lang Text Proc
Opt Arg Param Proc
Internationalization Locale
Security and Encryption
World Wide Web HTML HTTP CGI
Server and Daemon Utilities
Archiving and Compression
Images Pixmaps Bitmaps
Mail and Usenet News
Control Flow Utilities
File Handle Input Output
Microsoft Windows Modules
Miscellaneous Modules
Commercial Software Interfaces
Not In Modulelist
1.9.2 Searching CPAN
*+,''
 %'   .' 
#  # 
+*+,# %$$ %   &$$
  #' EFF#   )
7' G? -'' "
1. Statistics::Candidates
Statistics-MaxEntropy-0.9 - 26 Nov 1998 - Hugo WL ter Doest

2. Statistics::ChiSquare
How random is your data?
Statistics-ChiSquare-0.3 - 23 Nov 2001 - Jon Orwant

3. Statistics::Contingency
Calculate precision, recall, F1, accuracy, etc.
Page
16
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
Statistics-Contingency-0.03 - 09 Aug 2002 - Ken Williams

4. Statistics::DEA
Discontiguous Exponential Averaging
Statistics-DEA-0.04 - 17 Aug 2002 - Jarkko Hietaniemi

5. Statistics::Descriptive
Module of basic descriptive statistical functions.
Statistics-Descriptive-2.4 - 26 Apr 1999 - Colin Kuskie

6. Statistics::Distributions
Perl module for calculating critical values of common statistical distributions
Statistics-Distributions-0.07 - 22 Jun 2001 - Michael Kospach

7. Statistics::Frequency
simple counting of elements
Statistics-Frequency-0.02 - 24 Apr 2002 - Jarkko Hietaniemi

8. Statistics::GaussHelmert
General weighted least squares estimation
Statistics-GaussHelmert-0.05 - 18 Apr 2002 - Stephan Heuel

9. Statistics::LTU
An implementation of Linear Threshold Units
Statistics-LTU-2.8 - 27 Feb 1997 - Tom Fawcett

10. Statistics::Lite
Small stats stuff.
Statistics-Lite-1.02 - 15 Apr 2002 - Brian Lalonde

11. Statistics::MaxEntropy
Statistics-MaxEntropy-0.9 - 26 Nov 1998 - Hugo WL ter Doest

12. Statistics::OLS
perform ordinary least squares and associated statistics, v 0.07.
Statistics-OLS-0.07 - 13 Oct 2000 - Sanford Morton

13. Statistics::ROC
receiver-operator-characteristic (ROC) curves with nonparametric confidence bounds
Statistics-ROC-0.01 - 22 Jul 1998 - Hans A. Kestler

14. Statistics::Regression
weighted linear regression package (line+plane fitting)
StatisticsRegression - 26 May 2001 - ivo welch

15. Statistics::SparseVector
Perl5 extension for manipulating sparse bitvectors
Statistics-MaxEntropy-0.9 - 26 Nov 1998 - Hugo WL ter Doest

16. Statistics::Descriptive::Discrete
Compute descriptive statistics for discrete data sets.
Statistics-Descriptive-Discrete-0.07 - 13 Jun 2002 - Rhet Turnbull

17. Bio::Tree::Statistics
Calculate certain statistics for a Tree
bioperl-1.0.2 - 16 Jul 2002 - Ewan Birney

18. Device::ISDN::OCLM::Statistics
OCLM statistics superclass
Device-ISDN-OCLM-0.40 - 02 Jan 2000 - Merlin Hughes

19. Device::ISDN::OCLM::CurrentStatistics
OCLM current call statistics
Device-ISDN-OCLM-0.40 - 02 Jan 2000 - Merlin Hughes

20. Device::ISDN::OCLM::ISDNStatistics
OCLM ISDN statistics
Page
17
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
Device-ISDN-OCLM-0.40 - 02 Jan 2000 - Merlin Hughes

21. Device::ISDN::OCLM::Last10Statistics
OCLM Last10 call statistics
Device-ISDN-OCLM-0.40 - 02 Jan 2000 - Merlin Hughes

22. Device::ISDN::OCLM::LastStatistics
OCLM last call statistics
Device-ISDN-OCLM-0.40 - 02 Jan 2000 - Merlin Hughes

23. Device::ISDN::OCLM::ManualStatistics
OCLM manual call statistics
Device-ISDN-OCLM-0.40 - 02 Jan 2000 - Merlin Hughes

24. Device::ISDN::OCLM::SPStatistics
OCLM service provider statistics
Device-ISDN-OCLM-0.40 - 02 Jan 2000 - Merlin Hughes

25. Device::ISDN::OCLM::SystemStatistics
OCLM system statistics
Device-ISDN-OCLM-0.40 - 02 Jan 2000 - Merlin Hughes
'%
Statistics::ChiSquare
 
6# % %
Statistics::ChiSquare
-'  # 
###( #
<  %- '  4A&
 %
source
 %#'   0
 4' "
package Statistics::ChiSquare;

# ChiSquare.pm
#
# Jon Orwant, orwant@media.mit.edu
#
# 31 Oct 95, revised Mon Oct 18 12:16:47 1999, and again November 2001
# to fix an off-by-one error
#
# Copyright 1995, 1999, 2001 Jon Orwant. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
# Version 0.3. Module list status is "Rdpf"

use strict;
use vars qw($VERSION @ISA @EXPORT);

require Exporter;
require AutoLoader;

@ISA = qw(Exporter AutoLoader);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
@EXPORT = qw(chisquare);

$VERSION = '0.3';

my @chilevels = (100, 99, 95, 90, 70, 50, 30, 10, 5, 1);
my %chitable = ( );

# assume the expected probability distribution is uniform
sub chisquare {
Page
18
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
my @data = @_;
@data = @{$data[0]} if @data = = 1 and ref($data[0]);
my $degrees_of_freedom = scalar(@data) - 1;
my ($chisquare, $num_samples, $expected, $i) = (0, 0, 0, 0);
if (! exists($chitable{$degrees_of_freedom})) {
return "I can't handle ", scalar(@data),
" choices without a better table.";
}
foreach (@data) { $num_samples += $_ }
$expected = $num_samples / scalar(@data);
return "There's no data!" unless $expected;
foreach (@data) {
$chisquare += (($_ - $expected) ** 2) / $expected;
}
foreach (@{$chitable{$degrees_of_freedom}}) {
if ($chisquare < $_) {
return
"There's a <$chilevels[$i+1]% and <$chilevels[$i]% chance that this data
is random.";
}
$i++;
}
return "There's a <$chilevels[$#chilevels]% chance that this data is random.";
}
$chitable{1} = [0.00016, 0.0039, 0.016, 0.15, 0.46, 1.07, 2.71, 3.84, 6.64];
$chitable{2} = [0.020, 0.10, 0.21, 0.71, 1.39, 2.41, 4.60, 5.99, 9.21];
$chitable{3} = [0.12, 0.35, 0.58, 1.42, 2.37, 3.67, 6.25, 7.82, 11.34];
$chitable{4} = [0.30, 0.71, 1.06, 2.20, 3.36, 4.88, 7.78, 9.49, 13.28];
$chitable{5} = [0.55, 1.14, 1.61, 3.00, 4.35, 6.06, 9.24, 11.07, 15.09];
$chitable{6} = [0.87, 1.64, 2.20, 3.83, 5.35, 7.23, 10.65, 12.59, 16.81];
$chitable{7} = [1.24, 2.17, 2.83, 4.67, 6.35, 8.38, 12.02, 14.07, 18.48];
$chitable{8} = [1.65, 2.73, 3.49, 5.53, 7.34, 9.52, 13.36, 15.51, 20.09];
$chitable{9} = [2.09, 3.33, 4.17, 6.39, 8.34, 10.66, 14.68, 16.92, 21.67];
$chitable{10} = [2.56, 3.94, 4.86, 7.27, 9.34, 11.78, 15.99, 18.31, 23.21];
$chitable{11} = [3.05, 4.58, 5.58, 8.15, 10.34, 12.90, 17.28, 19.68, 24.73];
$chitable{12} = [3.57, 5.23, 6.30, 9.03, 11.34, 14.01, 18.55, 21.03, 26.22];
$chitable{13} = [4.11, 5.89, 7.04, 9.93, 12.34, 15.12, 19.81, 22.36, 27.69];
$chitable{14} = [4.66, 6.57, 7.79, 10.82, 13.34, 16.22, 21.06, 23.69, 29.14];
$chitable{15} = [5.23, 7.26, 8.55, 11.72, 14.34, 17.32, 22.31, 25.00, 30.58];
$chitable{16} = [5.81, 7.96, 9.31, 12.62, 15.34, 18.42, 23.54, 26.30, 32.00];
$chitable{17} = [6.41, 8.67, 10.09, 13.53, 16.34, 19.51, 24.77, 27.59, 33.41];
$chitable{18} = [7.00, 9.39, 10.87, 14.44, 17.34, 20.60, 25.99, 28.87, 34.81];
$chitable{19} = [7.63, 10.12, 11.65, 15.35, 18.34, 21.69, 27.20, 30.14, 36.19];
$chitable{20} = [8.26, 10.85, 12.44, 16.27, 19.34, 22.78, 28.41, 31.41, 37.57];

1;
3  % -*%
package
#
use

strict
#
require

Exporter
-' '0
7'  
version
#
Autoloader
#
use

vars
#   

chitable
#  6#%1%)
 %
&#  ' 
/ 0  #
 #''%
1.9.3 Installing Modules Using CPAN.pm
<(%  
CPAN.pm
 & 
Statistics::ChiSquare
(
CPAN.pm

&#%#'*+,6+D  "
Page
19
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
How do I install Perl modules?

Installing a new module can be as simple as typing

perl -MCPAN -e 'install Chocolate::Belgian'.

The CPAN.pm documentation has more complete instructions on how to use
this convenient tool. If you are uncomfortable with having something
take that much control over your software installation, or it otherwise
doesn't work for you, the perlmodinstall documentation covers
module installation for UNIX, Windows and Macintosh in more familiar terms.

Finally, if you're using ActivePerl on Windows, the PPM (Perl Package Manager)
has much of the same functionality as CPAN.pm.
   , &  # 
 B
[tisdall@coltrane tisdall]$ perl -MCPAN -e 'install Statistics::ChiSquare'
CPAN: Storable loaded ok
mkdir /root/.cpan: Permission denied at /usr/local/lib/perl5/5.6.1/CPAN.pm line 2218
[tisdall@coltrane tisdall]$ su
Password:
[root@coltrane tisdall]# perl -MCPAN -e 'install Statistics::ChiSquare'
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
Database was generated on Wed, 20 Mar 2002 00:39:29 GMT
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
ftp://cpan.cse.msu.edu/authors/01mailrc.txt.gz
Going to read /root/.cpan/sources/authors/01mailrc.txt.gz
CPAN: Compress::Zlib loaded ok
Fetching with LWP:
ftp://cpan.cse.msu.edu/modules/02packages.details.txt.gz
Going to read /root/.cpan/sources/modules/02packages.details.txt.gz
Database was generated on Mon, 26 Aug 2002 00:22:07 GMT

There's a new CPAN.pm version (v1.62) available!
[Current version is v1.59_54]
You might want to try
install Bundle::CPAN
reload cpan
without quitting the current session. It should be a seamless upgrade
while we are running...

Fetching with LWP:
ftp://cpan.cse.msu.edu/modules/03modlist.data.gz
Going to read /root/.cpan/sources/modules/03modlist.data.gz
Going to write /root/.cpan/Metadata
Running install for module Statistics::ChiSquare
Running make for J/JO/JONO/Statistics-ChiSquare-0.3.tar.gz
Fetching with LWP:
ftp://cpan.cse.msu.edu/authors/id/J/JO/JONO/Statistics-ChiSquare-0.3.tar.gz
CPAN: MD5 loaded ok
Fetching with LWP:
ftp://cpan.cse.msu.edu/authors/id/J/JO/JONO/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/J/JO/JONO/Statistics-ChiSquare-0.3.
tar.gz ok
Scanning cache /root/.cpan/build for sizes
Deleting from cache: /root/.cpan/build/IO-stringy-2.108 (21.4>20.0 MB)
Deleting from cache: /root/.cpan/build/XML-Node-0.11 (20.8>20.0 MB)
Deleting from cache: /root/.cpan/build/bioperl-0.7.2 (20.7>20.0 MB)
Statistics/ChiSquare-0.3/
Statistics/ChiSquare-0.3/ChiSquare.pm
Statistics/ChiSquare-0.3/Makefile.PL
Statistics/ChiSquare-0.3/test.pl
Page
20
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
Statistics/ChiSquare-0.3/Changes
Statistics/ChiSquare-0.3/MANIFEST
Package seems to come without Makefile.PL.
(The test -f "/root/.cpan/build/Statistics/Makefile.PL" returned false.)
Writing one on our own (setting NAME to StatisticsChiSquare)

CPAN.pm: Going to build J/JO/JONO/Statistics-ChiSquare-0.3.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Statistics::ChiSquare
Writing Makefile for StatisticsChiSquare
make[1]: Entering directory `/root/.cpan/build/Statistics/ChiSquare-0.3'
cp ChiSquare.pm ../blib/lib/Statistics/ChiSquare.pm
AutoSplitting ../blib/lib/Statistics/ChiSquare.pm (../blib/lib/auto/
Statistics/ChiSquare)
Manifying ../blib/man3/Statistics::ChiSquare.3
make[1]: Leaving directory `/root/.cpan/build/Statistics/ChiSquare-0.3'
/usr/bin/make -- OK
Running make test
make[1]: Entering directory `/root/.cpan/build/Statistics/ChiSquare-0.3'
make[1]: Leaving directory `/root/.cpan/build/Statistics/ChiSquare-0.3'
make[1]: Entering directory `/root/.cpan/build/Statistics/ChiSquare-0.3'
PERL_DL_NONLAZY=1 /usr/bin/perl -I../blib/arch -I../blib/lib -I/usr/local/lib/
perl5/5.6.1/i686-linux -I/usr/local/lib/perl5/5.6.1 test.pl
1..2
ok 1
ok 2
make[1]: Leaving directory `/root/.cpan/build/Statistics/ChiSquare-0.3'
/usr/bin/make test -- OK
Running make install
make[1]: Entering directory `/root/.cpan/build/Statistics/ChiSquare-0.3'
make[1]: Leaving directory `/root/.cpan/build/Statistics/ChiSquare-0.3'
Installing /usr/local/lib/perl5/site_perl/5.6.1/Statistics/ChiSquare.pm
Installing /usr/local/lib/perl5/site_perl/5.6.1/auto/Statistics/ChiSquare/
autosplit.ix
Installing /usr/local/man/man3/Statistics::ChiSquare.3
Writing /usr/local/lib/perl5/site_perl/5.6.1/i686-linux/auto/
StatisticsChiSquare/.packlist
Appending installation info to /usr/local/lib/perl5/5.6.1/i686-linux/perllocal.pod
/usr/bin/make install UNINST=1 -- OK
[root@coltrane tisdall]#
 %###  
#   
7 %  *+, "
[tisdall@coltrane tisdall]$ perl -MCPAN -e 'install Statistics::ChiSquare'
CPAN: Storable loaded ok
mkdir /root/.cpan: Permission denied at /usr/local/lib/perl5/5.6.1/CPAN.pm line 2218
+#'%#</(#'
 
G

&#/(
su
*+,
"
G

7*+,
) &'/((+3' .
## 
[tisdall@coltrane tisdall]$ su
Password:
[root@coltrane tisdall]# perl -MCPAN -e 'install Statistics::ChiSquare'
:#%& %#'  # 
Page
21
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm
##  
#A
&' # < # #  
&#(  -# 
  +  '
#%# - .)
 (# %  &(#  
' 
1.9.4 Using the Newly Installed CPAN Module
,' % 
 
,  #"
perldoc Statistics::ChiSquare
7  %
";;
=#
'  ( *31 "
NAME
"Statistics::ChiSquare" - How random is your data?

SYNOPSIS
use Statistics::Chisquare;
print chisquare(@array_of_numbers);
Statistics::ChiSquare is available at a CPAN site near
you.

DESCRIPTION
Suppose you flip a coin 100 times, and it turns up heads
70 times. Is the coin fair?
Suppose you roll a die 100 times, and it shows 30 sixes.
Is the die loaded?
In statistics, the chi-square test calculates "how random"
a series of numbers is. But it doesn't simply say "yes"
or "no". Instead, it gives you a confidence interval,
which sets upper and lower bounds on the likelihood that
the variation in your data is due to chance. See the
examples below.
...
(  
 
H#
SYNOPSIS
  %&
(   &#'  #
0+(#0

chisquare
 
'.' % )
I+  !#5J35EI3
4 .' '+ '
 "
use strict;
use warnings;

use Statistics::ChiSquare;

Page
22
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm

my(@subwaystops) = (14, 18, 23, 28, 34, 42, 50, 59, 66, 72, 79, 86, 96, 103, 110,
116, 125, 137);

print chisquare(@subwaystops);
"
There's a <1% chance that this data is random.
C  ),7%*3#& 
%, #% 
1.9.5 Problems with CPAN Modules
+ #) & 

SYNOPSIS
#' "
use Statistics::Chisquare;
  *1#  
  *31 3& # # #
# %  % &
use
Statistics::Chisquare
#'  '#
use
Statistics::ChiSquare
# # 
#) # 
 # %
+#&'   ##
 &# 1 &' 
*+,   1 1 #
*+,# &' 
 #
# 1  
3 #' *+,
 #  ) )  #
( 3#'0*+,
 -    
*+,6+D(  
*+,
 


 


1.10 Exercises
   
.   A
   !
. # #%#A
   "
.  
   #
Page
23
of
161
20/09/2004
file://C:\Documents%20and%20Settings\vivo\Local%20Settings\Temp\~hh7C2B.htm

.   A
   $
> 
   %
.( A. A.
A.A
   &

testGeneticcode
  "
# Translate each three-base codon to an amino acid, and append to a protein
for(my $i=0; $i < (length($dna) - 2) ; $i += 3) {
$protein .= Geneticcode::codon2aa( substr($dna,$i,3) );
}
4'  "