Question
Need some assistance coding this Fragment file. I have included the test file for the code. Thank you very much. package sequencer; public class Fragment
Need some assistance coding this Fragment file. I have included the test file for the code. Thank you very much.
package sequencer;
public class Fragment {
/**
* Creates a new Fragment based upon a String representing a sequence of nucleotides,
* containing only the uppercase characters G, C, A and T.
* @param nucleotides
* @throws IllegalArgumentException if invalid characters are in the sequence of nucleotides
*/
public Fragment(String nucleotides) throws IllegalArgumentException {
}
/**
* Returns the length of this fragment.
*
* @return the length of this fragment
*/
public int length() {
return 0;
}
/**
* Returns a String representation of this fragment, exactly as was passed to the constructor.
*
* @return a String representation of this fragment
*/
@Override
public String toString() {
return null;
}
/**
* Return true if and only if this fragment contains the same sequence of nucleotides
* as another sequence.
*/
@Override
public boolean equals(Object o) {
return false;
}
/**
* Returns the number of nucleotides of overlap between the end of this fragment and
* the start of another fragment, f.
*
* The largest overlap is found, for example, CAA and AAG have an overlap of 2, not 1.
*
* @param f the other fragment
* @return the number of nucleotides of overlap
*/
public int calculateOverlap(Fragment f) {
return 0;
}
/**
* Returns a new fragment based upon merging this fragment with another fragment f.
*
* This fragment will be on the left, the other fragment will be on the right; the
* fragments will be overlapped as much as possible during the merge.
*
* @param f the other fragment
* @return a new fragment based upon merging this fragment with another fragment
*/
public Fragment mergedWith(Fragment f) {
return null;
}
}
FragmentTest.java
package sequencer;
import static org.junit.Assert.*;
import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout;
public class FragmentTest {
// @Rule // public Timeout globalTimeout = Timeout.seconds(10); // 10 seconds
@Test public void testValidConstructor() { Fragment f = new Fragment("GCAT"); } @Test(expected = IllegalArgumentException.class) public void testInvalidConstructor1() { Fragment f = new Fragment("MARC"); } @Test(expected = IllegalArgumentException.class) public void testInvalidConstructor2() { Fragment f = new Fragment("G C A T"); } @Test public void testLength1() { Fragment f = new Fragment("G"); assertEquals(1, f.length()); } @Test public void testLength5() { Fragment f = new Fragment("GGCAT"); assertEquals(5, f.length()); }
@Test public void testToString() { Fragment f = new Fragment("GCAT"); assertEquals("GCAT", f.toString()); } @Test public void testEqualsTrue1() { Fragment f = new Fragment("GCAT"); assertTrue(f.equals(f)); } @Test public void testEqualsTrue2() { Fragment f = new Fragment(new String("GCAT")); Fragment g = new Fragment(new String("GCAT")); assertTrue(f.equals(g)); assertTrue(g.equals(f)); }
@Test public void testNotEqualsNull() { Fragment f = new Fragment("GCAT"); assertFalse(f.equals(null)); }
@Test public void testNotEqualsObject() { Fragment f = new Fragment("GCAT"); assertFalse(f.equals(new Object())); }
@Test public void testNotEqual() { Fragment f = new Fragment("GCAT"); Fragment g = new Fragment("TACG"); assertFalse(f.equals(g)); }
@Test public void testNoOverlap() { Fragment f = new Fragment("GCAT"); Fragment g = new Fragment("CGTA"); assertEquals(0, f.calculateOverlap(g)); }
@Test public void testOneOverlap() { Fragment f = new Fragment("GGGA"); Fragment g = new Fragment("AGGG"); assertEquals(1, f.calculateOverlap(g)); }
@Test public void testTwoOverlap() { Fragment f = new Fragment("GGAC"); Fragment g = new Fragment("ACGG"); assertEquals(2, f.calculateOverlap(g)); }
@Test public void testTwoOverlapBounds() { Fragment f = new Fragment("TAC"); Fragment g = new Fragment("ACAGAT"); assertEquals(2, f.calculateOverlap(g)); }
@Test public void testThreeOverlap() { Fragment f = new Fragment("GGAAC"); Fragment g = new Fragment("AACGG"); assertEquals(3, f.calculateOverlap(g)); }
@Test public void testOverlapPastBounds() { Fragment f = new Fragment("GGAA"); Fragment g = new Fragment("AAGGAA"); assertEquals(2, f.calculateOverlap(g)); } @Test public void testMultipleOverlap() { Fragment f = new Fragment("GGAACA"); Fragment g = new Fragment("AACAGG"); assertEquals(4, f.calculateOverlap(g)); }
@Test public void testNoMerge() { Fragment f = new Fragment("GCAT"); Fragment g = new Fragment("CGTA"); assertEquals(new Fragment("GCATCGTA"), f.mergedWith(g)); }
@Test public void testOneMerge() { Fragment f = new Fragment("GGGA"); Fragment g = new Fragment("AGGG"); assertEquals(new Fragment("GGGAGGG"), f.mergedWith(g)); }
@Test public void testTwoMerge() { Fragment f = new Fragment("GGAC"); Fragment g = new Fragment("ACGG"); assertEquals(new Fragment("GGACGG"), f.mergedWith(g)); }
@Test public void testSameMergeLength() { Fragment f = new Fragment("GCAT"); Fragment g = new Fragment("GCAT"); assertEquals(4, f.calculateOverlap(g)); }
@Test public void testSameMerge() { Fragment f = new Fragment("GCAT"); Fragment g = new Fragment("GCAT"); assertEquals(new Fragment("GCAT"), f.mergedWith(g)); }
@Test public void testThreeMerge() { Fragment f = new Fragment("GGAAC"); Fragment g = new Fragment("AACGG"); assertEquals(new Fragment("GGAACGG"), f.mergedWith(g)); }
@Test public void testMultipleMerge() { Fragment f = new Fragment("GGAACA"); Fragment g = new Fragment("AACAGG"); assertEquals(new Fragment("GGAACAGG"), f.mergedWith(g)); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started