Docsity

CS174 Problem Set 3: Sequence Alignment in Bioinformatics, Assignments of Environmental Science

Toggle sidebar
bg1
Problem Set 3
ā€œOf Mice and Men – and dogsā€
CS 174 Bioinformatics, Spring 2009
Due May 28th before class
This problem set is about sequence alignment, as discussed in class. Your task is to
implement a dynamic programming procedure to find the optimal global alignment be-
tween two nucleotide sequences. You will use your code to compare a gene from the
human genome to the same gene from the mouse and dog genome and see which is
more ā€œsimilarā€.
Assignment
1. Create a file ps3.py which will contain your code for this assignment. Add some
comment lines at the beginning of the file, indicating ā€œCS174 Problem Set 3ā€ and
your name.
2. Write a function alignSequences that takes as input two nucleotide sequences
(as strings) and computes an optimal global alignment. Employ the scoring func-
tion used in class, which assigns +2 for matching letters and āˆ’1for mismatched
letters (or spaces).
Your implementation should follow the simple dynamic programming algorithm
(i.e., not Hirschberg’s algorithm) and have time and space complexity O(mĀ·n),
where the length of the two input sequences is mand n, respectively.
The function should output the optimal alignment score as well as the alignment
itself. If there are several different alignments giving the same, optimal score, it is
sufficient to output just one of them.
For instance, for the two sequences CTGAT and GTCGA the output should be similar
to the following:
Optimal alignment score: 3
CT-GAT
GTCGA-
(It is probably a good idea to make up a handful of simple examples, solve them
on paper, and compare to your code’s output.)
1
pf2

Partial preview of the text

Download CS174 Problem Set 3: Sequence Alignment in Bioinformatics and more Assignments Environmental Science in PDF only on Docsity!

Problem Set 3

ā€œOf Mice and Men – and dogsā€

CS 174 Bioinformatics, Spring 2009

Due May 28th before class

This problem set is about sequence alignment, as discussed in class. Your task is to implement a dynamic programming procedure to find the optimal global alignment be- tween two nucleotide sequences. You will use your code to compare a gene from the human genome to the same gene from the mouse and dog genome and see which is more ā€œsimilarā€.

Assignment

  1. Create a file ps3.py which will contain your code for this assignment. Add some comment lines at the beginning of the file, indicating ā€œCS174 Problem Set 3ā€ and your name.
  2. Write a function alignSequences that takes as input two nucleotide sequences (as strings) and computes an optimal global alignment. Employ the scoring func- tion used in class, which assigns +2 for matching letters and āˆ’ 1 for mismatched letters (or spaces). Your implementation should follow the simple dynamic programming algorithm (i.e., not Hirschberg’s algorithm) and have time and space complexity O(m Ā· n), where the length of the two input sequences is m and n, respectively. The function should output the optimal alignment score as well as the alignment itself. If there are several different alignments giving the same, optimal score, it is sufficient to output just one of them. For instance, for the two sequences CTGAT and GTCGA the output should be similar to the following:

Optimal alignment score: 3 CT-GAT GTCGA-

(It is probably a good idea to make up a handful of simple examples, solve them on paper, and compare to your code’s output.)

  1. Write a main function that reads n sequences from a FASTA file and performs n āˆ’ 1 pairwise alignments of the first sequence with all other ones. Namely, it first aligns sequence 1 with sequence 2, then sequence 1 with sequence 3, etc. – up to aligning sequence 1 with sequence n. Also extend your script such that it can be run as ps3.py filename.fa from the command line, with the path to the input FASTA file as argument.
  2. Extend alignSequences such that it does the following after finding an optimal alignment:

(a) Determine the length of the alignment, 6 in the example above (not necessar- ily length of the input strings). (b) Count the number of nucleotide matches in the alignment (3 in the above example). (c) Compute and output a similarity measure defined as the ratio of these two numbers. In the example, this would be 3 /6 = 0. 5.

  1. Download the following file:
    • http://www.ics.uci.edu/∼xhx/courses/CS174/ assignments/PS3/genes.fa

This files contains three versions of the same gene, the first from the human, the second from the mouse, and the third from the dog genome. Run your script on this file and record the output into a text file ps3.txt. Is the human gene more similar to the mouse or the dog?

  1. Upload the two files ps3.py and ps3.txt to the assignment submission folder in the EEE dropbox ā€œCS174 Problem Set 3ā€.

General remarks

  • Please keep your code legible so we can read and grade it, if neccessary. For in- stance, variables should have meaningful names. Use comments to explain prin- ciples and ideas, but don’t comment on every single statement.
  • Have complexity in mind when writing your code.
  • We use Python 2.x for this class. Version 2.6.1 is the latest release, you can down- load it for free from http://www.python.org/download/. Version 3.0 has been released, but it is backwards incompatible, and 2.x it is still in wide practical use.