You are on page 1of 2

CSIS 9 Final Project - DNA Matcher

A codon is a sequence of three nucleotides that creates an amino acid. You will use a sample
list of 3 codons ('GTA','GGG','CAC').

Create a module file called DNAmatcher.py that holds the DNAmatcher class.

● This class takes in a list of samples of DNA codons. Don’t forget the create the
__int__ and __repr__ methods.

○ In the __repr__ method, turn the list of sample codons into a string using join,
Below is what his code looks like where self.samples is the list of codons:

○ Return "DNA to match: " + sample_string in the __repr__ method.

● The first method in this class is called read_dna and has one parameter for the input
file. It opens the file and reads each line in a loop and puts them into a string. Return
the string.

● The second method, called dna_codons, takes in the DNA string as a parameter. This
method turns the DNA string into a list of codons. Loop through the string using
range(start, end, increment). In the loop you must check that there are
enough letters left in the string before you create the next codon. Return the list.

● The third method is called match_dna, and it takes in the codon list as a parameter.
You will need to loop through the codon list to see if any of these codons match one of
the codons in the sample list above. Count the number of matches and return this
number.

● The last method is called is_match and it has one parameter for the input file. This
method calls read_dna with the input file. It then calls dna_codons and then
match_dna, using the returns from the previous method calls as arguments for the next
method. If the number of matches returned from match_dna is greater than 3, then you
should return a string that looks like this: “Number of matches: 6 DNA profile
is a match”. Otherwise, you should return “Not a match”

In main.py

● Import DNAmatcher
● Create the sample list of 3 codons from above.

● Instantiate DNAmatcher with the sample list.

● Check which one of the 3 subject files of DNA can be considered a match by calling
is_match and printing an output that looks like this: “Subject 1: Not a match”

Grading Rubric

4 3 2 1 0

Coding Style Your code is Your code is Your code is Your code is No evidence of
organized and mostly not well not well organization or
uses organized but organized but organized and ease of
indentations there are some you are using your use of readability.
and spaces to lines of code indenatations spaces and
make it more that are not and spaces to indentations is
readable grouped well. make it inconsistent.
You are using readable.
indentations
and spaces to
make it
readable.

Documentation Your code is Your code is Your code is Your code has No evidence of
well mostly documents but very little documentation.
documented documented is missing documentation.
with comments but is missing detail.
that are some
English information or
versions of has some
your code. cursory
documentation.

Code Function Your code Your code Your code Your code No instructions
completely mostly follows mostly follows follows a were followed
follows the the instructions the instructions couple of the and output is
instructions on on the and may have instructions missing.
the assignment assignment an error in the and does not
and outputs the and outputs the output. output the
correct results. correct results. correct result.

You might also like