In this assignment you will be developing code to investigat
In this assignment, you will be developing code to investigate two important topics in genetics - restriction enzymes and DNA splicing. The Khan Academy has a straight-forward introduction to restriction enzymes and how they can be used to get E Coli bacteria to create insulin. The Howard Hughes Medical Institute also has an excellent animation of the process of splicing via restriction enzymes.
You will be developing a single Java class (LinkedDnaStrand) that uses a linked list of nodes to represent a strand of DNA that supports splicing. Each node in the list will contain a string of one or more nucleotides (A, C, G, or T). The class will be responsible for operations such as append() and cutSplice(), which model real-world restriction enzyme processing. To make the problem tractable, we will be making a number of assumptions that will simplify your work a lot - things like replacing rather than splitting the restriction enzyme. We are also going to be representing only one side of the DNA double-helix.
An illustration of the cut and splice operation on a linked list is shown below. In the diagram, a LinkedDnaStrand\'s linked list is shown just after it\'s constructor has been executed. The list is shown again after a call to cutSplice(). Note that each box in the diagram is an instance of DnaSequenceNode.
Getting Started
Naming is critical in the tasks and requirements described below. If the names don\'t match those described below exactly, your project will not compile and can\'t be graded.
Create a copy of the Java SE Project Template. The project name must follow this pattern: {FLname}_DnaSplicing_{TERM}, where {FLname} is replaced by the first letter of your first name plus your last name, and {TERM} is the semester and year. E.g. if your name is Maria Marciano and it\'s Fall of 2025, your project name must be MMarciano_DnaSplicing_F25.
Create a new package in the src folder called dnasplicing.
DnaSequenceNode
The LinkedDnaStrand class that you will be writing (see below) must use a DnaSequenceNode to hold each item in the linked list.
Save DnaSequenceNode.java (right-click | Save Link As...) into your dnasplicing package folder.
Refresh your project.
You do not modify DnaSequenceNode.java.
DnaStrand
The LinkedDnaStrand class that you will be writing (see below) must implement the DnaStrand interface.
Save DnaStrand.java (right-click | Save Link As...) into your dnasplicing package folder.
Refresh your project.
You will need to read the comments above each method declaration in DnaStrand.java to see what each method is supposed to do.
You do not modify DnaStrand.java. You will be adding your code to LinkedDnaStrand.java (see below).
LinkedDnaStrand
This is the class that you must write.
In the Package Explorer, select the dnasplicing package | New | Class.
In the wizard, set the name to LinkedDnaStrand. Then click the Add (interface) button, and search for DnaStrand. Check the \"Inherited abstract methods\" box. Click Finish. Eclipse will create the class and automatically add method stubs that meet the DnaStrand interface.
SimpleDnaStrand
SimpleDnaStrand is an array-based, inefficient implementation of DnaStrand. It is used by the grading script, LinkedDnaStrandTester, to verify that your code is giving correct output.
Save SimpleDnaStrand.java (right-click | Save Link As...) into your dnasplicing package folder.
Refresh your project.
The grading tester SimpleDnaStrand class that you will be writing (see below) must implement the DnaStrand interface.
You will need to read the comments above each method declaration in DnaStrand.java to see what each method is supposed to do.
You do not modify SimpleDnaStrand.java.
LinkedDnaStrandTester.
This is the grading script. It verifies that LinkedDnaStrand performs its operations correctly and efficiently.
Create a new package in the src folder called sbccunittest. To be clear: sbccunittest should be a child of the src folder, not of the dnasplicing package.
Save LinkedDnaStrandTester.java (right-click Save Link As...) to the sbccunittest package.
You do not modify LinkedDnaStrandTester.java. And be sure that you don\'t accidentally allow Eclipse to modify it for you by accepting any Eclipse Quick Fixes that that it may offer that would change LinkedDnaStrandTester.
NOTE: LinkedDnaStrandTester should have compilation errors at this point. Not to worry - you\'ll be sorting those out below.
cutSplice() will only be called when the linked list has just one node, and it will only be called once for a DnaStrand. This means that you do not need to worry about searching for enzyme matches across node boundaries.
Feel free to add any additional methods, including constructors, that you need to implement the program.
Be sure to read the comments for each method in DnaStrand - they describe what your methods are supposed to do.
Also read the comments for the various tests in LinkedDnaStrandTester. They will help you understand what the test is trying to verify. It can also be very useful to read or step through the test code itself, as this will give the deepest insight into how your code is being graded.
StringUtils has a reverse() method that returns the reverse of a String.
The createReversedDnaStrand() method creates a new DnaStrand whose DNA sequence is a reverse of the original. So if a DnaStrand contains \"CGAT\", then createReversedDnaStrand() would return a DnaStrand that contains \"TAGC\". You will receive extra credit if the returned LinkDnaStrand contains a reversed version of both the DNA sequence and the nodes. E.g. if a LinkedDnaStrandcontained this linked list:
first -> \"TT\" -> \"TTAAGG\" -> \"CC\" -> null
then its reverese would be a new LinkedDnaStrand containing the following linked list:
first -> \"CC\" -> \"GGAATT\" -> \"TT\" -> null
Here are folders: https://drive.google.com/open?id=0B2gb5h869g2aM1lfSzlMTDBqYm8
SPLSolution
LinkedDnaStrand.java
package dnasplicing;
import static java.lang.Math.*;
import static java.lang.System.*;
import static org.apache.commons.lang3.StringUtils.*;
import static org.junit.Assert.*;
import sbccunittest.*;
public class LinkedDnaStrand implements DnaStrand {
private DnaSequenceNode start;
private DnaSequenceNode end;
private int appendCount;
private int nodeCount;
public LinkedDnaStrand(String dna) {
start = new DnaSequenceNode(dna);
end = start;
appendCount = 0;
nodeCount = 1;
}
@Override
public long getNucleotideCount() {
long count = 0;
DnaSequenceNode current = start;
while (current != null) {
count += current.dnaSequence.length();
current = current.next;
}
return count;
}
@Override
public void append(String dnaSequence) {
DnaSequenceNode next = new DnaSequenceNode(dnaSequence);
end.next = next;
next.previous = end;
end = next;
appendCount++;
nodeCount++;
}
@Override
public DnaStrand cutSplice(String enzyme, String splicee) {
if (nodeCount != 1)
throw new IllegalArgumentException(\"This dna strand has \" + this.nodeCount + \" nodes. Must have only one\");
LinkedDnaStrand splicedStrand = null;
String[] split = start.dnaSequence.split(enzyme);
int i;
if (start.dnaSequence.startsWith(enzyme)) {
splicedStrand = new LinkedDnaStrand(splicee);
splicedStrand.append(split[1]);
i = 2;
} else {
splicedStrand = new LinkedDnaStrand(split[0]);
i = 1;
}
for (; i < split.length; i++) {
// splicedStrand.print(\"i = \" + i);
splicedStrand.append(splicee);
splicedStrand.append(split[i]);
}
if (start.dnaSequence.endsWith(enzyme)) {
splicedStrand.append(splicee);
}
// splicedStrand.print(\"Result\");
return splicedStrand;
}
private void print(String tag) {
out.print(tag + \": \");
for (DnaSequenceNode cur = start; cur != null; cur = cur.next) {
out.print(cur.dnaSequence);
if (cur.next != null)
out.print(\"-\");
}
out.printf(\"(%d node(s))\ \", nodeCount);
}
@Override
public DnaStrand createReversedDnaStrand() {
this.print(\"Original\");
LinkedDnaStrand reversed = null;
for (DnaSequenceNode cur = end; cur != null; cur = cur.previous) {
String reverse = reverse(cur.dnaSequence);
if (reversed == null)
reversed = new LinkedDnaStrand(reverse);
else
reversed.append(reverse);
}
reversed.print(\"Reversed\");
return reversed;
}
@Override
public int getAppendCount() {
return appendCount;
}
@Override
public DnaSequenceNode getFirstNode() {
return start;
}
@Override
public int getNodeCount() {
return nodeCount;
}
@Override
public String toString() {
StringBuilder s = new StringBuilder();
DnaSequenceNode current = start;
while (current != null) {
s.append(current.dnaSequence);
current = current.next;
}
out.println(s.length());
out.println(this.nodeCount);
return s.toString();
}
public static void main(String... args) {
{
String dnaSequence = LinkedDnaStrandTester.createRandomDnaSequence(50, 100);
String dnaToAppend = LinkedDnaStrandTester.createRandomDnaSequence(5, 10);
int numTimesToAppend = (int) (random() * 10);
LinkedDnaStrand linkedStrand = new LinkedDnaStrand(dnaSequence);
SimpleDnaStrand simpleStrand = new SimpleDnaStrand(dnaSequence);
for (int ndx = 0; ndx < numTimesToAppend; ndx++) {
linkedStrand.append(dnaToAppend);
simpleStrand.append(dnaToAppend);
}
assertEquals(simpleStrand.toString(), linkedStrand.toString());
assertEquals(numTimesToAppend + 1, linkedStrand.getNodeCount());
LinkedDnaStrand rl = (LinkedDnaStrand) linkedStrand.createReversedDnaStrand();
// Verify that the original linked strand wasn\'t changed
DnaSequenceNode node = linkedStrand.getFirstNode();
int nodeNdx = 0;
while (node != null) {
assertEquals(\"Sequences don\'t match at node index \" + nodeNdx, nodeNdx == 0 ? dnaSequence : dnaToAppend,
node.dnaSequence);
node = node.next;
nodeNdx++;
}
// Verify that the new strand string is reversed
assertEquals(simpleStrand.createReversedDnaStrand().toString(), rl.toString());
int numNodes = linkedStrand.getNodeCount();
if (numNodes == rl.getNodeCount()) {
node = linkedStrand.getFirstNode();
String[] reversedDnaSequences = new String[linkedStrand.getNodeCount()];
nodeNdx = numNodes - 1;
while (node != null) {
reversedDnaSequences[nodeNdx] = reverse(node.dnaSequence);
node = node.next;
nodeNdx--;
}
// Verify that the reversed list\'s nodes contain the same data as in the array
node = rl.getFirstNode();
nodeNdx = 0;
while (node != null) {
if (!node.dnaSequence.equals(reversedDnaSequences[nodeNdx]))
break;
node = node.next;
nodeNdx++;
}
if (nodeNdx == linkedStrand.getNodeCount()) {
}
// extraCredit += 5;
}
}
}
}
DnaStrand.java
package dnasplicing;
public interface DnaStrand {
public String toString();
public long getNucleotideCount();
public void append(String dnaSequence);
public DnaStrand cutSplice(String enzyme, String splicee);
public DnaStrand createReversedDnaStrand();
public int getAppendCount();
public DnaSequenceNode getFirstNode();
public int getNodeCount();
}
DnaSequenceNode.java
package dnasplicing;
public class DnaSequenceNode {
public String dnaSequence;
public DnaSequenceNode previous;
public DnaSequenceNode next;
public DnaSequenceNode(String initialDnaSequence) {
dnaSequence = initialDnaSequence;
}
}
noe: due to limited data i cant able to post this file LinkedDnaStrandTester.java





