
Problem Set (Pattern Matching and Probability) - 1
Problem Set โ Pattern Matching and Probability
Pattern Matching
1. Write something that will look through a string and grab anything that looks like a social
security number (including hyphens).
2. One of the most common uses of pattern matching is to extract what you want from a lot of
extraneous information. For example, GenBank provides more than you probably want to
know about each gene in its data base. Suppose you just want the nucleotide sequence of a
gene and the number of nucleotides GenBank thinks is in the sequence. The latter can be
used as a check to make sure you extracted the entire sequence correctly. First let's get that
number of nucleotides.
a. Go to GenBank and find the file for glnA from Nostoc PCC 6803. Download it as a
text file and upload the file into your file space of BioLingua.
b. Read in the file as a list of lines:
(DEFINE name-of-list AS (FILE-TO-STRING-LIST file-name))
c. Take a look at the first line of the list. Assign that first line to a variable.
d. Write a statement that will extract from the first line the number of nucleotides (bp) in
the file.
e. While we're in the area, write a statement that will extract the date of submission of
the sequence.
3. Sometimes genes come with annotations about the location of one or more promoter
elements that precede them. Let's get that information from the GenBank file of glnA you
uploaded in the previous problem.
a. Get the 19th line of from the file (you can use GET-ELEMENT) and assign it to a
variable
b. Write a statement that will extract the coordinates of the given promoter.
c. Write a loop that will extract and save in a list the coordinates of all promoters
identified in the documentation
d. Write a loop that will extract and save in a list the sequences of all promoters
identified in the documentation.
4. Now to get the sequence of the glnA gene.
a. Get the 61st line from the file and assign it to a variable.
b. Write a statement that will extract the sequence parts of the line and only those parts
(no numbers or blanks) and save them as a list.
c. Write a statement that will take that list and JOIN them into a single sequence.
d. Write a statement that will convert the joined sequence to upper case (use STRING-
UPCASE).
e. Find a way to consider the lines from 61 to the end and extract the sequence from it,
yielding, in the end, a single upper-case sequence with no numbers or blanks.
f. Improve on the above code, by having it find the beginning of the sequence itself.