Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 fragments) {

}

/**

* Returns the current list of fragments this assembler contains.

*

* @return the current list of fragments

*/

public List getFragments() {

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 one; private List two; private List three; private List dupFullOverlap;

// This method is run before each test, performing initialization // on and of objects for the test. @Before public void setup() { one = new ArrayList(); one.add(new Fragment("GCAT"));

two = new ArrayList(); two.add(new Fragment("CATG")); two.add(new Fragment("GCAT"));

three = new ArrayList(); three.add(new Fragment("ACTGTG")); three.add(new Fragment("ACACAC")); three.add(new Fragment("TGTGGG"));

dupFullOverlap = new ArrayList(); dupFullOverlap.add(new Fragment("AAGAA")); dupFullOverlap.add(new Fragment("AAGAA")); } @Test public void testValidConstructor() { Assembler a = new Assembler(one); } @Test public void testSimpleAssemble() { Assembler a = new Assembler(two); assertTrue(a.assembleOnce()); } @Test public void testSimpleAssembleStop() { Assembler a = new Assembler(two); assertTrue(a.assembleOnce()); assertFalse(a.assembleOnce()); }

@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 copy = new ArrayList(three); Assembler a = new Assembler(three); a.assembleOnce(); assertEquals(copy, three); } @Test public void testTiebreaker() { List l = new ArrayList(Arrays.asList( new Fragment("GGGAAAC"), new Fragment("AAACGGG"), new Fragment("CCCGTTTA"), new Fragment("TTTAGCCC"))); Assembler a = new Assembler(l); a.assembleOnce(); assertTrue(a.getFragments().contains(new Fragment("GGGAAACGGG"))); } @Test public void testSequenceHaemoglobinSubunitBeta() { Assembler a = new Assembler(Arrays.asList( new Fragment( "CAAGGTGAACGTGGATGAAGTTGGTGGTGAGGCCCTGGGCAGGCTGCTGGTGGTCTACCCTTGGACCCAGAGGTTCTTTGAGTCCTTTGGGGATCTGTCCACTCCTGATGCTGTTATGGGCAACCCTAAGGTGAAGGCTCA"), new Fragment( "TCACTTTGGCAAAGAATTCACCCCACCAGTGCAGGCTGCCTATCAGAAAGTGGTGGCTGGTGTGGCTAATGCCCTGGCCCACAAGTATCACTAAGCTCGCTTTCTTGCTGTCCAATTTCTATTAAAGGTTCCTT"), new Fragment( "TTTCTTGCTGTCCAATTTCTATTAAAGGTTCCTTTGTTCCCTAAGTCCAACTACTAAACTGGGGGATATTATGAAGGGCCTTGAGCATCTGGATTCTGCCTAATAAAAAACATTTATTTTCATTGC"), new Fragment( "ACTCCTGATGCTGTTATGGGCAACCCTAAGGTGAAGGCTCATGGCAAGAAAGTGCTCGGTGCCTTTAGTGATGGCCTGGCTCACCTGGACAACCTCAAGGGCACCTTTGCCACACTGAGTGAGCTGCACTGTGACAAGCTGCACGTGGATCCTGAGA"), new Fragment( "GCACCTTTGCCACACTGAGTGAGCTGCACTGTGACAAGCTGCACGTGGATCCTGAGAACTTCAGGCTCCTGGGCAACGTGCTGGTCTGTGTGCTGGCCCATCACTTTGGCAAAGAATTCACCCCACCAGTGCAGGCTGCCTATCA"), new Fragment( "ACATTTGCTTCTGACACAACTGTGTTCACTAGCAACCTCAAACAGACACCATGGTGCATCTGACTCCTGAGGAGAAGTCTGCCGTTACTGCCCTGTGGGGCAAGGTGAACGTGGATGAAGTTGGTGGTGAGGCCCTGGGCAGGCTGCT"))); a.assembleAll(); assertEquals(1, a.getFragments().size()); assertEquals(new Fragment("ACATTTGCTTCTGACACAACTGTGTTCACTAGCAACCTCAAACAGACACCATGGTGCATCTGACTCCTGAGGAGAAGTCTGCCGTTACTGCCCTGTGGGGCAAGGTGAACGTGGATGAAGTTGGTGGTGAGGCCCTGGGCAGGCTGCTGGTGGTCTACCCTTGGACCCAGAGGTTCTTTGAGTCCTTTGGGGATCTGTCCACTCCTGATGCTGTTATGGGCAACCCTAAGGTGAAGGCTCATGGCAAGAAAGTGCTCGGTGCCTTTAGTGATGGCCTGGCTCACCTGGACAACCTCAAGGGCACCTTTGCCACACTGAGTGAGCTGCACTGTGACAAGCTGCACGTGGATCCTGAGAACTTCAGGCTCCTGGGCAACGTGCTGGTCTGTGTGCTGGCCCATCACTTTGGCAAAGAATTCACCCCACCAGTGCAGGCTGCCTATCAGAAAGTGGTGGCTGGTGTGGCTAATGCCCTGGCCCACAAGTATCACTAAGCTCGCTTTCTTGCTGTCCAATTTCTATTAAAGGTTCCTTTGTTCCCTAAGTCCAACTACTAAACTGGGGGATATTATGAAGGGCCTTGAGCATCTGGATTCTGCCTAATAAAAAACATTTATTTTCATTGC"), a.getFragments().get(0)); }

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

10-2 List four alternate terms for contribution margin.

Answered: 1 week ago

Question

Summarize various training methods.

Answered: 1 week ago

Question

Explain the metrics for evaluating training and development.

Answered: 1 week ago

Question

Identify career planning approaches.

Answered: 1 week ago