The program user will enter a DNA character sequence as the

The program user will enter a DNA character sequence as the master sequence to be compared. They will then enter any number of additional candidate DNA sequences. For each of these candidate sequences entered it will check if its longest common substring with the master sequence is longer than any seen previously. If so, the master sequence will be updated with the value of its best match and the common substring. Once all candidates have been entered the program will report its findings.

UML for InvalidDNAStrandException

InvalidDNAStrandException extends RuntimeException

<<constructor>> InvalidDNAStrandException( )

<<constructor>> InvalidDNAStrandException(molecule : char)

There will be two reasons that cause a DNA strand to be invalid. If the strand is longer than 15 characters (this is due to size limitation of an int) and if there are characters in the strand other than ‘A’, ‘C’, ‘G’, or ‘T’. There are two constructors, one for each problem, giving a different String message for the Exception to reflect the problem.

Methods:

InvalidDNAStrandException( ) – Class constructor. Calls upon super class constructor with the String “Strand too long”

InvalidDNAStrandException(molecule : char) – Class constructor. Calls upon super class constructor with the String, “Invalid molecule: “, followed by the character that is passed.

UML for DNA

DNA

- strandString : String

- bestMatch : DNA

- substringMatch : String

<<constructor>> DNA(strand : String)

+ getStrand( ) : String

+ setStrand(strand : String)

+ toString( ) : String

+ checkMatch(matchCandidate : DNA)

- RabinKarp(find : String) : int

- stringHash(s : String) : int

- charNumericValue(c : char) : int

- RabinKarpHashes(hashes : int[], pos : int, length : int) : int

- linearSearchRecursive(data : int[], key : int, pos : int) : int

An instance of DNA will primarily store the String sequence of that DNA strand. It also has the ability to store a reference to another instance of DNA as well as its longest common substring with that DNA. Methods are also included to update this information given a new DNA candidate.

Data Members:

strandString – String representation of the DNA strand

bestMatch – Reference to another instance of DNA that is the best match found

substringMatch – The longest common substring between this strand and the DNA referenced by bestMatch

Methods:

DNA(strand : String) – Class constructor. Sets the passes String to strandString by calling upon setStrand. Sets bestMatch to null and substringMatch to the empty String, “”.

getStrand( ) : String – returns strandString

setStrand(strand : String) – Attempts to set strandString data member to the String passed. If the passed String is invalid due to it being more than 15 characters or there are invalid characters in the String it will create and throw an InvalidDNAStrandException, calling upon the appropriate constructor.

toString( ) : String – If there is a valid match, will return a String of the following form:

DNA Strand: GATCG

Best Match Strand: AATCT

Matching Substring: ATC

If there is no valid match it will output the strand and the message, “No match found”, as show below:

DNA Strand: GATCG

No match found

checkMatch(matchCandidate : DNA) – Checks if the passed DNA candidate has a longer substring than is currently stored. Uses the Rabin-Karp algorithm for substring matching. In order to do this, you will need to break the candidate strand into all possible substrings and send them to the RabinKarp method. This is a bit, “Brute Force” (there are more efficient but complex ways of doing this), however we can mitigate the work by eliminating a lot of possible substrings. A substring from the candidate that is longer than strandString can be skipped. All substrings whose length is shorter than the current substringMatch can also be skipped. Additionally, if we process the longest substrings first, we can stop once a match is found and not bother with the shorter substrings.

RabinKarp(find : String) : int - Does the preprocessing of finding the hash for the substring find using the stringHash method and the hashes of substrings in the search string using RabinKarpHashes method. Calls upon linearSearchRecursive to determine if the substring hash is in the collection of hashes and returns the result.

stringHash(s : String) : int - Given a string, return the hash value of the entire String. Use a base 4 number system to create the hash as described in class. This will be needed only to find the hash of the substring that is being searched for and the base case for finding all substring hashes in the search string.

charNumericValue(char c) : int - Given a character, returns the numeric value of the character in our base 4 number system. Assign the possible characters, ‘A’, ‘C’, ‘G’, and ‘T’ values 0 – 3.

RabinKarpHashes(hashes : int[], pos : int, length : int) - Finds the hash values of all substrings of size length in the strandString String, starting at index pos and working down. These values are stored in the hashes array that is passed. This method must be recursive, using the technique as described in the Rabin-Karp lecture.

linearSearchRecursive(data : int[], key : int, pos : int) : int - This is a recursive linear search. Return the position of key in the data array, or -1 if it is not present. This method must be recursive.

Note: These last five methods are declared private, as they are only for internal use within the DNA class.

InvalidDNAStrandException extends RuntimeException

<<constructor>> InvalidDNAStrandException( )

<<constructor>> InvalidDNAStrandException(molecule : char)

Solution

String translation(String temp)
temporary worker.toCharArray();
while(i&lt;k-3)
  
if(storefinal.matches(\"AUU\")||storefinal.matches(\"AUC\")||storefinal.matches(\"AUA\"))

if(storefinal.matches(\"AUG\"))

if(storefinal.matches(\"GUU\")||storefinal.matches(\"GUC\")||storefinal.matches(\"GUA\")||storefinal.matches(\"GUG\"))

if(storefinal.matches(\"UCU\")||storefinal.matches(\"UCC\")||storefinal.matches(\"UCA\")||storefinal.matches(\"UCG\"))

if(storefinal.matches(\"AGA\")||storefinal.matches(\"AGG\"))

if(storefinal.matches(\"AGU\")||storefinal.matches(\"AGC\"))

if(storefinal.matches(\"UGG\"))

if(storefinal.matches(\"UGU\")||storefinal.matches(\"UGC\"))

if(storefinal.matches(\"GAA\")||storefinal.matches(\"GAG\"))

if(storefinal.matches(\"GAU\")||storefinal.matches(\"GAC\"))

if(storefinal.matches(\"AAA\")||storefinal.matches(\"AAG\"))

if(storefinal.matches(\"AAU\")||storefinal.matches(\"AAC\"))

if(storefinal.matches(\"CAA\")||storefinal.matches(\"CAG\"))

if(storefinal.matches(\"CAU\")||storefinal.matches(\"CAC\"))

if(storefinal.matches(\"UAU\")||storefinal.matches(\"UAC\"))

if(storefinal.matches(\"CCG\")||storefinal.matches(\"CCA\")||storefinal.matches(\"CCC\")||storefinal.matches(\"CCU\"))

if(storefinal.matches(\"ACG\")||storefinal.matches(\"ACA\")||storefinal.matches(\"ACC\")||storefinal.matches(\"ACU\"))

if(storefinal.matches(\"GCG\")||storefinal.matches(\"GCA\")||storefinal.matches(\"GCC\")||storefinal.matches(\"GCU\"))

if(storefinal.matches(\"CGG\")||storefinal.matches(\"CGA\")||storefinal.matches(\"CGC\")||storefinal.matches(\"CGU\"))

if(storefinal.matches(\"GGG\")||storefinal.matches(\"GGA\")||storefinal.matches(\"GGC\")||storefinal.matches(\"GGU\"))

if(storefinal.matches(\"UAG\")||storefinal.matches(\"UAA\")||storefinal.matches(\"UGA\"))

i++;
}
String finalreturn = new String(pro);
come finalreturn;
}

The program user will enter a DNA character sequence as the master sequence to be compared. They will then enter any number of additional candidate DNA sequence
The program user will enter a DNA character sequence as the master sequence to be compared. They will then enter any number of additional candidate DNA sequence
The program user will enter a DNA character sequence as the master sequence to be compared. They will then enter any number of additional candidate DNA sequence

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site