By James Tisdall
Book Price: $39.95 USD
£28.50 GBP
PDF Price: $27.99
Cover | Table of Contents | Colophon
We'll look at the PDB in Chapter 10, but you may want to get a headstart by
visiting the PDB
web site
(print 'ACCTGGTAACCCGGAGATTCCAGCT';
$ perl -v
This is perl, v5.6.1 built for i686-linux Copyright 1987-2001, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using 'man perl' or 'perldoc perl'. If you have access to the Internet, point your browser at http://www.perl.com/, the Perl Home Page.
perl: command not found
perl. You can also try typing
perl
-v, at an MS-DOS command
window or at a shell window on the MacOS X. (Note that the MacOS X is a
Unix system!)
perl
this_program. If you're not in the same
directory, you may have to give the
pathname of the program, for
example:
perl /usr/local/bin/this_program
#!/usr/bin/perl
which
perl to find
the pathname where Perl is installed on your system.
chmod 755 this_program
./this_program. If the
program is in a directory that's included in your
$PATH or
$path variable, you can type
this_program.
bash: ./my_program: No such file or directory
.
http://www.CPAN.org. Try
exploring: you'll find it's organized by topic, so
it's possible to quickly find, for example, web, statistics, or
graphics programs. In our case, you will find the Bioperl module,
which includes several useful bioinformatics functions. A
module is a collection of Perl code that can
be easily loaded and used by your Perl programs.
|
Code
|
Nucleic Acid(s)
|
|---|
$DNA. In
other words, $DNA is the name of the DNA sequence
data used in the program. Note that in Perl, a variable is really the
name for some data you wish to use. The name gives you full access to
the data. Example 4-1 shows the entire program.
#!/usr/bin/perl -w # Storing DNA in a variable, and printing it out # First we store the DNA in a variable called $DNA $DNA = 'ACGGGAGGACGGGAAAATTACTACGGCATTAGC'; # Next, we print the DNA onto the screen print $DNA; # Finally, we'll specifically tell the program to exit. exit;
perl example4-1
perl example4 -1
#!/usr/bin/perl -w # Concatenating DNA # Store two DNA fragments into two variables called $DNA1 and $DNA2 $DNA1 = 'ACGGGAGGACGGGAAAATTACTACGGCATTAGC'; $DNA2 = 'ATAGTGCCGTGAGAGTGATGTAGTA'; # Print the DNA onto the screen print "Here are the original two DNA fragments:\n\n"; print $DNA1, "\n"; print $DNA2, "\n\n"; # Concatenate the DNA fragments into a third variable and print them # Using "string interpolation" $DNA3 = "$DNA1$DNA2"; print "Here is the concatenation of the first two fragments (version 1):\n\n"; print "$DNA3\n\n"; # An alternative way using the "dot operator": # Concatenate the DNA fragments into a third variable and print them $DNA3 = $DNA1 . $DNA2; print "Here is the concatenation of the first two fragments (version 2):\n\n"; print "$DNA3\n\n"; # Print the same thing without using the variable $DNA3 print "Here is the concatenation of the first two fragments (version 3):\n\n"; print $DNA1, $DNA2, "\n"; exit;
$DNA1, $DNA2, and
$DNA3. I've added print
statements for a running commentary, so that the output of the
program that appears on the computer screen makes more sense and
isn't simply some DNA fragments one after the other.
Here are the original two DNA fragments: ACGGGAGGACGGGAAAATTACTACGGCATTAGC ATAGTGCCGTGAGAGTGATGTAGTA Here is the concatenation of the first two fragments (version 1): ACGGGAGGACGGGAAAATTACTACGGCATTAGCATAGTGCCGTGAGAGTGATGTAGTA Here is the concatenation of the first two fragments (version 2): ACGGGAGGACGGGAAAATTACTACGGCATTAGCATAGTGCCGTGAGAGTGATGTAGTA Here is the concatenation of the first two fragments (version 3): ACGGGAGGACGGGAAAATTACTACGGCATTAGCATAGTGCCGTGAGAGTGATGTAGTA
T's are changed to
U's, and that's all that our program
needs to know.
#!/usr/bin/perl -w # Transcribing DNA into RNA # The DNA $DNA = 'ACGGGAGGACGGGAAAATTACTACGGCATTAGC'; # Print the DNA onto the screen print "Here is the starting DNA:\n\n"; print "$DNA\n\n"; # Transcribe the DNA to RNA by substituting all T's with U's. $RNA = $DNA; $RNA =~ s/T/U/g; # Print the RNA onto the screen print "Here is the result of transcribing the DNA to RNA:\n\n"; print "$RNA\n"; # Exit the program. exit;
Here is the starting DNA: ACGGGAGGACGGGAAAATTACTACGGCATTAGC Here is the result of transcribing the DNA to RNA: ACGGGAGGACGGGAAAAUUACUACGGCAUUAGC
$RNA:
$RNA = $DNA;
$RNA that actually contains DNA. Remember this is perfectly
legal—you can call variables anything you like—but it is
potentially confusing to have inaccurate variable names. Now in this
case, the copy is preceded with informative comments and followed
immediately with a statement that indeed causes the variable
http://www.perl.com.
Then click on the Documentation link. Select "Perl's
Builtin Functions" and then "Alphabetical Listing of
Perl's Functions". You'll see a rather lengthy
alphabetical listing of Perl's functions. Once you've
found this page, you may want to bookmark it in your browser, as you
may find yourself turning to it frequently. Now click on Print to
view the print operator.
#!/usr/bin/perl -w # Calculating the reverse complement of a strand of D