Question
Need some assistance coding this assembler exercise. I have included the test file. Thank you very much. package sequencer; import java.util.List; public class Assembler {
Need some assistance coding this assembler exercise. I have included the test file. Thank you very much.
package sequencer;
import java.util.List;
public class Assembler {
/**
* Creates a new Assembler containing a list of fragments.
*
* The list is copied into this assembler so that the original list will not
* be modified by the actions of this assembler.
*
* @param fragments
*/
public Assembler(List
}
/**
* Returns the current list of fragments this assembler contains.
*
* @return the current list of fragments
*/
public List
return null;
}
/**
* Attempts to perform a single assembly, returning true iff an assembly was
* performed.
*
* This method chooses the best assembly possible, that is, it merges the
* two fragments with the largest overlap, breaking ties between merged
* fragments by choosing the shorter merged fragment.
*
* Merges must have an overlap of at least 1.
*
* After merging two fragments into a new fragment, the new fragment is
* inserted into the list of fragments in this assembler, and the two
* original fragments are removed from the list.
*
* @return true iff an assembly was performed
*/
public boolean assembleOnce() {
return false;
}
/**
* Repeatedly assembles fragments until no more assembly can occur.
*/
public void assembleAll() {
}
}
AssemblerTest.java
package sequencer;
import static org.junit.Assert.*;
import java.util.ArrayList; import java.util.Arrays; import java.util.List;
import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout;
public class AssemblerTest { // @Rule // public Timeout globalTimeout = Timeout.seconds(10); // 10 seconds private List
// This method is run before each test, performing initialization // on and of objects for the test. @Before public void setup() { one = new ArrayList
two = new ArrayList
three = new ArrayList
dupFullOverlap = new ArrayList
@Test public void testCorrectSimpleAssemble() { Assembler a = new Assembler(two); assertTrue(a.assembleOnce()); assertFalse(a.assembleOnce()); assertEquals(Arrays.asList(new Fragment("GCATG")), a.getFragments()); } @Test public void testNoAssemble() { one.add(new Fragment("CAGT")); Assembler a = new Assembler(one); assertFalse(a.assembleOnce()); assertEquals(2, a.getFragments().size()); } @Test public void testDuplicateFullOverlapAssemble() { Assembler a = new Assembler(dupFullOverlap); assertTrue(a.assembleOnce()); assertFalse(a.assembleOnce()); assertEquals(Arrays.asList(new Fragment("AAGAA")), a.getFragments()); } @Test public void testCorrectThreeAssembleStepwise() { Assembler a = new Assembler(three); assertEquals(3, a.getFragments().size()); assertTrue(a.assembleOnce()); assertEquals(2, a.getFragments().size()); assertTrue(a.assembleOnce()); assertEquals(1, a.getFragments().size()); assertFalse(a.assembleOnce()); assertEquals(1, a.getFragments().size()); assertEquals(Arrays.asList(new Fragment("ACACACTGTGGG")), a.getFragments()); }
@Test public void testCorrectThreeAssembleAll() { Assembler a = new Assembler(three); a.assembleAll(); assertEquals(Arrays.asList(new Fragment("ACACACTGTGGG")), a.getFragments()); }
@Test public void testConstructorArgumentUnharmed() { List
}
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