Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

peptide_mRNA.text ACAAGATGCCATTGTCCCCCGGCCTCCTGCTGCTGCTGCTCTCCGGGGCCACGGCCACCGCTGCCCTGCC CCTGGAGGGTGGCCCCACCGGCCGAGACAGCGAGCATATGCAGGAAGCGGCAGGAATAAGGAAAAGCAGC CTCCTGACTTTCCTCGCTTGGTGGTTTGAGTGGACCTCCCAGGCCAGTGCCGGGCCCCTCATAGGAGAGG AAGCTCGGGAGGTGGCCAGGCGGCAGGAAGGCGCACCCCCCCAGCAATCCGCGCGCCGGGACAGAATGCC CTGCAGGAACTTCTTCTGGAAGACCTTCTCCTCCTGCAAATAAAACCTCACCCATGAATGCTCACGCAAG TTTAATTACAGACCTGAA plainExampleSmall.text GGCAGA PlainSequcenceTest.java import static org.junit.Assert.assertEquals; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.io.FileNotFoundException; import java.util.Map; import java.util.HashMap;

image text in transcribed

peptide_mRNA.text

ACAAGATGCCATTGTCCCCCGGCCTCCTGCTGCTGCTGCTCTCCGGGGCCACGGCCACCGCTGCCCTGCC CCTGGAGGGTGGCCCCACCGGCCGAGACAGCGAGCATATGCAGGAAGCGGCAGGAATAAGGAAAAGCAGC CTCCTGACTTTCCTCGCTTGGTGGTTTGAGTGGACCTCCCAGGCCAGTGCCGGGCCCCTCATAGGAGAGG AAGCTCGGGAGGTGGCCAGGCGGCAGGAAGGCGCACCCCCCCAGCAATCCGCGCGCCGGGACAGAATGCC CTGCAGGAACTTCTTCTGGAAGACCTTCTCCTCCTGCAAATAAAACCTCACCCATGAATGCTCACGCAAG TTTAATTACAGACCTGAA

plainExampleSmall.text

GGCAGA

PlainSequcenceTest.java

import static org.junit.Assert.assertEquals; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.io.FileNotFoundException; import java.util.Map; import java.util.HashMap;

public class PlainSequencesTest {

@Test public void testReadSequences() { Sequences tester = new PlainSequences(); String fileName = "peptide_mRNA.text"; try { tester.readSequences(fileName); } catch (FileNotFoundException e) { } assertEquals("after reading file the number of sequences should be 1", 1, tester.getSequences().size()); assertEquals("after reading file the description of sequences at index 0 should be peptide_mRNA.text", "peptide_mRNA.text", tester.getDescriptions().get(0)); } @Test(expected = FileNotFoundException.class) public void testFileNotFoundExceptionIsThrown() throws FileNotFoundException { Sequences tester = new PlainSequences(); String fileName = "noFileHere.txt"; tester.readSequences(fileName); } @Test public void testIsValidSequences() { Sequences tester = new PlainSequences(); String fileName = "peptide_mRNA.text"; try { tester.readSequences(fileName); } catch (FileNotFoundException e) { } assertEquals("the first sequence read should be valid", true, tester.isValidSequence(0)); }

@Test public void formatInGroups() { Sequences tester = new PlainSequences(); String fileName = "peptide_mRNA.text"; String expected = "ACAAGATGCC ATTGTCCCCC GGCCTCCTGC TGCTGCTGCT CTCCGGGGCC ACGGCCACCG " + "CTGCCCTGCC CCTGGAGGGT GGCCCCACCG GCCGAGACAG CGAGCATATG CAGGAAGCGG " + "CAGGAATAAG GAAAAGCAGC CTCCTGACTT TCCTCGCTTG GTGGTTTGAG TGGACCTCCC " + "AGGCCAGTGC CGGGCCCCTC ATAGGAGAGG AAGCTCGGGA GGTGGCCAGG CGGCAGGAAG " + "GCGCACCCCC CCAGCAATCC GCGCGCCGGG ACAGAATGCC CTGCAGGAAC TTCTTCTGGA " + "AGACCTTCTC CTCCTGCAAA TAAAACCTCA CCCATGAATG CTCACGCAAG TTTAATTACA " + "GACCTGAA"; try { tester.readSequences(fileName); } catch (FileNotFoundException e) { } String actual = tester.formatInGroups(0, 10, 6); assertEquals("the string for sequence 0 in goups of 10 bases with 6 groups per line", expected, actual); } @Test public void generateFrequencies() { Sequences tester = new PlainSequences(); String fileNameLarge = "peptide_mRNA.text"; String fileNameSmall = "plainExampleSmall.text"; Map answersMap = new HashMap(); answersMap.put("GG",1); answersMap.put("GGCAG",1); answersMap.put("A",2); answersMap.put("GGC",1); answersMap.put("GCAG",1); answersMap.put("C",1); answersMap.put("GCA",1); answersMap.put("AG",1); answersMap.put("G",3); answersMap.put("CAGA",1); answersMap.put("GGCAGA",1); answersMap.put("GA",1); answersMap.put("AGA",1); answersMap.put("GC",1); answersMap.put("CA",1); answersMap.put("GGCA",1); answersMap.put("CAG",1); answersMap.put("GCAGA",1); try { tester.readSequences(fileNameSmall); } catch (FileNotFoundException e) { } Map frequencies = tester.generateFrequencies(0); assertEquals("the number of distinct substrings in sequence 0 was not correct.", 18, frequencies.size()); // this original test was not written correctly because it used the map's toString output but the ordering of the entries in a map is not guaranteed so the toString might show different orderings // assertEquals("the frequencies were not as expected.", "{GG=1, GGCAG=1, A=2, GGC=1, GCAG=1, C=1, GCA=1, AG=1, G=3, CAGA=1, GGCAGA=1, CAG=1, GCAGA=1, GA=1, AGA=1, GC=1, CA=1, GGCA=1}", frequencies.toString()); // this test is better in that it compares the two maps using the Map equals method which does the expected thing of making sure all the keys and all the values are the same for both maps assertEquals("the frequencies were not as expected.", answersMap, frequencies); tester = new PlainSequences(); try { tester.readSequences(fileNameLarge); } catch (FileNotFoundException e) { } frequencies = tester.generateFrequencies(0); assertEquals("the number of distinct substrings in sequence 0 was not correct.", 66491, frequencies.size()); }

}

Sequences.java

import java.util.List; import java.util.Map; import java.io.FileNotFoundException;

interface Sequences { public List getDescriptions(); public List getSequences(); public void readSequences(String fileName) throws FileNotFoundException; public boolean isValidSequence(int index); public String formatInGroups(int index, int basesPerGroup, int groupsPerLine); public Map generateFrequencies(int index); }

This week for our Learning Reflections assignment we will use the Map data structure in a new method within our PlainSequences class from last week. This new method will find all substrings of the original sequence string and determine how many times each substring appears in the original sequence string . We will again use Test Driven Development. The revised Sequences.java interface file has a new method called generateFrequencies that you will implement so that all junit tests will pass in the revised PlainSequencesTest.java junit test file. 1. Download the new versions of these four files and either add them to last week's project or create a new directory and add them to that and create for them a project in JGrasp so that the junit tests are enabled. The two text files are needed for the unit tests and should be placed in the same directory as your java files. PlainSequencesTest.java Sequences.java peptide mRNA.text plainExamplesmall.text 2. Revise your PlainSequences.java class so that it implements the generateFrequencies method described in the revised Sequences.java interface. 3. Within your JGrasp project run the tests in the revised PlainSequencesTest.java 4. Repeat step 2 an 3 above until all tests pass. 5. Submit you revised PlainSequnces.java file and a screen shot showing your Junit has run and passed all 5 unit tests. if you are having problems with your implementation of the PlainSequences.java class from last week you may use this implementation of PlainSequences.java to start your work for this week. If your code worked last week, then please please just add to your code from last week

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_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Name and describe Diana Baumrinds three parenting styles.

Answered: 1 week ago