Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Perl and Regular Expressions Lab Notes for BIF 101 Fall 2008, Lab Reports of Bioinformatics

These lab notes provide instructions and exercises for using perl and regular expressions as part of the bif 101 fall 2008 course. Details on creating a perl program called 'greet.pl', listing the contents of provided text files, and working through various regex exercises from the textbook. For each exercise, the document asks students to paste the results into their word file and describe what the pattern matched.

Typology: Lab Reports

Pre 2010

Uploaded on 08/19/2009

koofers-user-bdi-2
koofers-user-bdi-2 🇺🇸

9 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
BIF 101 Fall 2008 – Perl and Regular Expressions
Note – make sure to refer to the table of regular expressions in Chapter 4 of your book!!
Turn in: for lab this week you will create a Word file with your answers to the questions.
When you’re done with the lab, email me this file as an attachment. Call the file
BIF101lab4.doc
1. Create a program called greet.pl by typing in the following. Make sure to update the
comment with my initials and date and put in your name and the date. Run the program and
note the results. Run it a couple more times providing different input.
#!/usr/bin/perl
# program that creates a generic greeting, asks a use to type his or her name,
# and inserts that name into the greeting
# DTB 9/24/08
use strict;
use warnings;
# generic greeting
my $greeting = "Hi there person. Guess what? person has just won a contest!";
# variable to hold user's name
my $name;
# issue a prompt to the user
print "type your name: ";
# get the input
$name = <>;
chomp($name); # remove the end of line character
print "original greeting is:\n$greeting\n";
# substitute the name that was typed for person in the greeting
$greeting =~ s/person/$name/g;
print "new greeting is:\n$greeting\n";
Copy/paste your program into your Word file. Copy/paste output from two different runs of the
program into your Word file. Write about this program – describe what it does and for EACH
line that is not a comment, say what that line does. Copy/paste the line then provide an
explanation. For example:
use strict;
This line tells Perl to make sure variables are declared before they are used
For the rest of the lab you will be working through exercises in the book related to the
program regex.pl – first you need to download and unzip the regexPlay.zip folder as
described on p. 53
pf2

Partial preview of the text

Download Perl and Regular Expressions Lab Notes for BIF 101 Fall 2008 and more Lab Reports Bioinformatics in PDF only on Docsity!

BIF 101 Fall 2008 – Perl and Regular Expressions

Note – make sure to refer to the table of regular expressions in Chapter 4 of your book!!

Turn in: for lab this week you will create a Word file with your answers to the questions.

When you’re done with the lab, email me this file as an attachment. Call the file

BIF101lab4.doc

1. Create a program called greet.pl by typing in the following. Make sure to update the

comment with my initials and date and put in your name and the date. Run the program and

note the results. Run it a couple more times providing different input.

#!/usr/bin/perl

program that creates a generic greeting, asks a use to type his or her name,

and inserts that name into the greeting

DTB 9/24/

use strict; use warnings;

generic greeting

my $greeting = "Hi there person. Guess what? person has just won a contest!";

variable to hold user's name

my $name;

issue a prompt to the user

print "type your name: ";

get the input

$name = <>; chomp($name); # remove the end of line character

print "original greeting is:\n$greeting\n";

substitute the name that was typed for person in the greeting

$greeting =~ s/person/$name/g;

print "new greeting is:\n$greeting\n";

Copy/paste your program into your Word file. Copy/paste output from two different runs of the

program into your Word file. Write about this program – describe what it does and for EACH

line that is not a comment, say what that line does. Copy/paste the line then provide an

explanation. For example:

use strict;

This line tells Perl to make sure variables are declared before they are used

For the rest of the lab you will be working through exercises in the book related to the

program regex.pl – first you need to download and unzip the regexPlay.zip folder as

described on p. 53

  1. Look at the text files provided in this folder. List their names and say what is in the files (description).

Read the text in ch 4 very carefully. We will get started as a group so that you understand how to proceed. You should have two windows open, one should have the regex.pl program in it – this is where you will edit the program and save changes. The other window should be a command prompt where you will run the program. This lab involves making changes to the program and running it, then analyzing the output.

Label your answers with page numbers!!

P 58:

Copy/paste the results of the q[^u] pattern into your Word file. Describe what the pattern matched.

Going Back for More section: a-d, for each of these paste in your regex pattern and say how many results you got back, for part d explain what you decided to look for AND paste in your regex pattern and number of results.

P 59: How many results do you get from the G[^T] pattern? Describe what this pattern matched.

Going Back for More: a-c, for each of these paste in your regex pattern and say how many results you got back, for part c explain what you decided to look for AND paste in your regex pattern and number of results.

P 62: how many results do you get for the question at the top of the page? Paste three of the words returned by this pattern.

Going Back for More – say how many results for part a, create your own pattern for part b, describe it and paste it into your Word file, then say how many results it yields.

P 63: How many results do you get fo rhte question at the top of the page? Paste three of these into your World file.

Going Back for More – say how many results for part a, create, show, and describe a pattern for part b and say how many results it returned, paste in one of the results (if any)

P 66: how many results do you get for the question at the top of the page? Paste three of the words returned by this pattern.

Going Back for More – say how many results for parts a-c, for each also paste in a few of the words returned and paste in your regex patterns.

P 67: How many results do you get fo rhte question at the top of the page? Paste three of these into your World file.

Going Back for More – say how many results for parts a-c, for each also paste in a few of the words returned and paste in your regex patterns.