Assignment 10
Object oriented programming
In this assignment you will convert code you wrote in earlier assignments into object oriented programs.
DNA sequence class
Write a class called dna_sequence that represents the data and operations that can be applied to a DNA sequence.
Here is the interface that your class should support:
- The constructor should receive a string as its parameter and interpret it as a DNA sequence. It should check that the string represents a valid DNA sequence, and raise a ValueError exception if it doesn't. For our purposes let's assume a DNA sequence can have one of the five letters A,C,G,T,N.
__len__()this method should return the length of the sequence. This allows thelenfunction to be called on an instance of adna_sequence.__repr__()this method should provide useful information about the sequence (e.g. its length).gc_content()this method should return the fraction of nucleotides that are either G or C.nucleotide_composition()this method should return a list with four elements that represent the fraction of A,C,G, and T nucleotides in the sequence (N's should be ignored as we did before).reverse_complement()this method should return an instance of the classdna_sequencewhose sequence is the reverse-complement.
Put the class in a file called dna_sequence.py.
Protein interaction database
Convert the code you submitted into a class called PPI_database. This class should support the following methods:
- The constructor should take as its parameter a file name and construct an interaction dataset out of the interactions in the file. It should work as
load_interactionsin assignment 9. interact,get_interactions, andaverage_interactionsshould work as in assignment 9.__repr__should provide useful information about the dataset: the file from which it was read and how many interactions are in the dataset.__len__returns the number of interactions in the dataset.
Put the class in a file called ppi_database.py
