From: Sasha Sherstnev Date: Thu, 8 Aug 2013 12:15:19 +0000 (+0100) Subject: Add test of parser of Jpred output X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=737da3b130623e4f8a6d0feec16fb0f120a3f05a;p=jabaws.git Add test of parser of Jpred output --- diff --git a/testsrc/compbio/data/sequence/SequenceUtilTester.java b/testsrc/compbio/data/sequence/SequenceUtilTester.java index e646c1e..e9acca7 100644 --- a/testsrc/compbio/data/sequence/SequenceUtilTester.java +++ b/testsrc/compbio/data/sequence/SequenceUtilTester.java @@ -40,7 +40,7 @@ import compbio.runner.disorder.Disembl; public class SequenceUtilTester { @Test() - public void testisNonAmbNucleotideSequence() { + public void isNonAmbNucleotideSequence() { String dnaseq = "atgatTGACGCTGCTGatgtcgtgagtgga"; assertTrue(SequenceUtil.isNonAmbNucleotideSequence(dnaseq)); String dirtyDnaseq = "atgAGTggt\taGGTgc\ncgcACTgc gACtcgcGAt cgA "; @@ -55,25 +55,22 @@ public class SequenceUtilTester { assertFalse(SequenceUtil.isNonAmbNucleotideSequence(nonDna)); // String ambDna = "AGTCRYMKSWHBVDN"; // see IUPAC Nucleotide Code assertFalse(SequenceUtil.isNonAmbNucleotideSequence(nonDna)); - } @Test() - public void testCleanSequence() { + public void CleanSequence() { String dirtySeq = "atgAGTggt\taGGTgc\ncgcAC\rTgc gACtcgcGAt cgA "; - assertEquals("atgAGTggtaGGTgccgcACTgcgACtcgcGAtcgA".toUpperCase(), - SequenceUtil.cleanSequence(dirtySeq)); + assertEquals("atgAGTggtaGGTgccgcACTgcgACtcgcGAtcgA".toUpperCase(),SequenceUtil.cleanSequence(dirtySeq)); } @Test() - public void testDeepCleanSequence() { + public void DeepCleanSequence() { String dirtySeq = "a!t?g.A;GTggt\ta12GGTgc\ncgc23AC\rTgc gAC<>.,?!|\\|/t@cg-c¬GA=_+(0){]}[:£$&^*\"t cgA "; - assertEquals("atgAGTggtaGGTgccgcACTgcgACtcgcGAtcgA".toUpperCase(), - SequenceUtil.deepCleanSequence(dirtySeq)); + assertEquals("atgAGTggtaGGTgccgcACTgcgACtcgcGAtcgA".toUpperCase(),SequenceUtil.deepCleanSequence(dirtySeq)); } @Test() - public void testisProteinSequence() { + public void isProteinSequence() { String dirtySeq = "atgAGTggt\taGGTgc\ncgcAC\rTgc gACtcgcGAt cgA "; assertFalse(SequenceUtil.isProteinSequence(dirtySeq)); String notaSeq = "atgc1tgatgcatgcatgatgctga"; @@ -86,51 +83,42 @@ public class SequenceUtilTester { } @Test() - public void testCleanProteinSequence() { + public void CleanProteinSequence() { String dirtySeq = "atgAGTggt\taGGTgc\ncgcAC\rTgc gACtcgcGAt cgA "; assertFalse(SequenceUtil.isProteinSequence(dirtySeq)); // This will still be NON protein sequence despite having only correct // letters because the letters match perfectly the nucleotide sequence! - assertFalse(SequenceUtil.isProteinSequence(SequenceUtil - .cleanProteinSequence(dirtySeq))); + assertFalse(SequenceUtil.isProteinSequence(SequenceUtil.cleanProteinSequence(dirtySeq))); String notaSeq = "atgc1tgatgcatgcatgatgmctga"; assertFalse(SequenceUtil.isProteinSequence(notaSeq)); - assertTrue(SequenceUtil.isProteinSequence(SequenceUtil - .cleanProteinSequence(notaSeq))); + assertTrue(SequenceUtil.isProteinSequence(SequenceUtil.cleanProteinSequence(notaSeq))); String AAseq = "ARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDAGQAEAAAAAYTRAHQL"; assertTrue(SequenceUtil.isProteinSequence(AAseq)); - assertTrue(SequenceUtil.isProteinSequence(SequenceUtil - .cleanProteinSequence(AAseq))); + assertTrue(SequenceUtil.isProteinSequence(SequenceUtil.cleanProteinSequence(AAseq))); AAseq += "XU"; assertFalse(SequenceUtil.isProteinSequence(AAseq)); - assertTrue(SequenceUtil.isProteinSequence(SequenceUtil - .cleanProteinSequence(AAseq))); + assertTrue(SequenceUtil.isProteinSequence(SequenceUtil.cleanProteinSequence(AAseq))); } @Test() - public void testReadWriteFasta() { - + public void ReadWriteFasta() { try { - FileInputStream fio = new FileInputStream( - AllTestSuit.TEST_DATA_PATH + "TO1381.fasta"); + FileInputStream fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "TO1381.fasta"); assertNotNull(fio); List fseqs = SequenceUtil.readFasta(fio); assertNotNull(fseqs); assertEquals(3, fseqs.size()); assertEquals(3, fseqs.size()); fio.close(); - FileOutputStream fou = new FileOutputStream( - AllTestSuit.TEST_DATA_PATH + "TO1381.fasta.written"); + FileOutputStream fou = new FileOutputStream(AllTestSuit.TEST_DATA_PATH + "TO1381.fasta.written"); SequenceUtil.writeFasta(fou, fseqs); fou.close(); - FileOutputStream fou20 = new FileOutputStream( - AllTestSuit.TEST_DATA_PATH + "TO1381.fasta20.written"); + FileOutputStream fou20 = new FileOutputStream(AllTestSuit.TEST_DATA_PATH + "TO1381.fasta20.written"); SequenceUtil.writeFasta(fou20, fseqs, 21); fou20.close(); - } catch (FileNotFoundException e) { e.printStackTrace(); fail(e.getLocalizedMessage()); @@ -140,11 +128,9 @@ public class SequenceUtilTester { } } - /** - * This test tests the loading of horizontally formatted Jronn output file - */ + // This method tests the loading of horizontally formatted Jronn output file @Test - public void loadJronnFile() { + public void LoadJronnFile() { FileInputStream fio; try { @@ -155,7 +141,6 @@ public class SequenceUtilTester { Score aseq = aseqs.get("Foobar"); assertNotNull(aseq); assertNotNull(aseq.getScores()); - // System.out.println(aseq); assertEquals(aseq.getScores().size(), aseq.getScores().size()); fio.close(); } catch (FileNotFoundException e) { @@ -168,7 +153,6 @@ public class SequenceUtilTester { e.printStackTrace(); fail(e.getLocalizedMessage()); } - } enum Trial { @@ -187,31 +171,26 @@ public class SequenceUtilTester { */ @SuppressWarnings("unchecked") @Test - public void testReadDisemblResults() { - - + public void ReadDisemblResults() { Map>> _ranges=new HashMap>>(); Map> ranges=new HashMap>(); Map> _values=new HashMap>(); Map values = new HashMap(); Set rset; rset = new HashSet(); - for (String[] se:new String[][] { { "34","41"},{"50","58"},{"83","91"},{"118","127"},{" 160","169"},{" 191","220"},{" 243","252"},{" 287","343"},{" 350","391"},{" 429","485"},{" 497","506"},{"539","547"}}) - { + for (String[] se:new String[][] { { "34","41"},{"50","58"},{"83","91"},{"118","127"},{" 160","169"},{" 191","220"},{" 243","252"},{" 287","343"},{" 350","391"},{" 429","485"},{" 497","506"},{"539","547"}}) { rset.add(new Range(se)); } ranges.put(DisemblResult.COILS.toString(), rset); values.put(DisemblResult.COILS.toString(), Float.valueOf(0.86010f)); rset = new HashSet(); - for (String[] se:new String[][] { { "355","368"}}) - { + for (String[] se:new String[][] { { "355","368"}}) { rset.add(new Range(se)); } ranges.put(DisemblResult.REM465.toString(), rset); values.put(DisemblResult.REM465.toString(), Float.valueOf(0.88512f)); rset = new HashSet(); - for (String[] se:new String[][] { { "190","204"}}) - { + for (String[] se:new String[][] { { "190","204"}}) { rset.add(new Range(se)); } ranges.put(DisemblResult.HOTLOOPS.toString(), rset); @@ -220,23 +199,20 @@ public class SequenceUtilTester { _values.put("Foobar_dundeefriends", values); FileInputStream fio; try { - fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH - + "disembl.out"); + fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "disembl.out"); Map> aseqs = SequenceUtil.readDisembl(fio); assertNotNull(aseqs); assertEquals(aseqs.size(), 3); ScoreManager sman = ScoreManager.newInstance(aseqs); for (String fs : aseqs.keySet()) { - assertTrue(" Foobar_dundeefriends Foobar dundeefriends " - .contains(fs)); + assertTrue(" Foobar_dundeefriends Foobar dundeefriends ".contains(fs)); Set scores = aseqs.get(fs); assertEquals(scores.size(), 3); for (Score sc:scores) { - if (_ranges.containsKey(fs)) - { - assertEquals("Checking range for Method "+sc.getMethod(),_ranges.get(fs).get(sc.getMethod()), sc.getRanges()); - assertEquals("Checking first value for Method "+sc.getMethod(), _values.get(fs).get(sc.getMethod()), sc.getScores().get(0)); + if (_ranges.containsKey(fs)) { + assertEquals("Checking range for Method "+sc.getMethod(),_ranges.get(fs).get(sc.getMethod()), sc.getRanges()); + assertEquals("Checking first value for Method "+sc.getMethod(), _values.get(fs).get(sc.getMethod()), sc.getScores().get(0)); } } } @@ -252,8 +228,9 @@ public class SequenceUtilTester { fail(e.getLocalizedMessage()); } } + /** - * This test tests the loading of horizontally formatted Jronn output file + * This method tests the loading of horizontally formatted Jronn output file * * First sequence: * @@ -275,12 +252,11 @@ public class SequenceUtilTester { */ @SuppressWarnings("unchecked") @Test - public void testReadGlobPlotResults() { + public void ReadGlobPlotResults() { FileInputStream fio; try { - fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH - + "globplot.out"); + fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "globplot.out"); HashMap> aseqs = SequenceUtil.readGlobPlot(fio); assertNotNull(aseqs); assertEquals(aseqs.size(), 3); @@ -299,9 +275,7 @@ public class SequenceUtilTester { sm.writeOut(new PrintWriter(System.out, true)); for (Score score : scores) { - - if (score.getMethod() - .equals(GlobProtResult.Disorder.toString())) { + if (score.getMethod().equals(GlobProtResult.Disorder.toString())) { assertEquals(score.getRanges().size(), 7); assertTrue(score.getScores().isEmpty()); } @@ -324,12 +298,10 @@ public class SequenceUtilTester { } @Test - public void testReadIUPredForShortAndLongDisorder() { + public void ReadIUPredForShortAndLongDisorder() { try { - Map scores = SequenceUtil.readIUPred(new File( - AllTestSuit.TEST_DATA_PATH, "out.long")); + Map scores = SequenceUtil.readIUPred(new File(AllTestSuit.TEST_DATA_PATH, "out.long")); ScoreManager man = ScoreManager.newInstanceSingleScore(scores); - // man.writeOut(new PrintWriter(System.out, true)); assertNotNull(scores); assertEquals(3, scores.size()); @@ -350,7 +322,6 @@ public class SequenceUtilTester { assertEquals(0, score.getRanges().size()); assertEquals(513, score.getScores().size()); assertEquals("Long", score.getMethod()); - } catch (IOException e) { e.printStackTrace(); fail(e.getLocalizedMessage()); @@ -361,21 +332,18 @@ public class SequenceUtilTester { } @Test - public void testReadIUPredForGlobDomain() { + public void ReadIUPredForGlobDomain() { try { - Map scores = SequenceUtil.readIUPred(new File( - AllTestSuit.TEST_DATA_PATH, "output.glob")); + Map scores = SequenceUtil.readIUPred(new File(AllTestSuit.TEST_DATA_PATH, "output.glob")); assertNotNull(scores); assertEquals(2, scores.size()); ScoreManager man = ScoreManager.newInstanceSingleScore(scores); - // man.writeOut(new PrintWriter(System.out, true)); assertEquals(2, man.getNumberOfSeq()); Score score = scores.get("P53_HUMA"); assertNotNull(score); assertEquals(2, score.getRanges().size()); assertEquals(0, score.getScores().size()); assertEquals("Glob", score.getMethod()); - score = scores.get("Foobar_dundeefriends"); assertEquals(0, score.getRanges().size()); } catch (IOException e) { @@ -386,18 +354,17 @@ public class SequenceUtilTester { fail(e.getLocalizedMessage()); } } + @Test - public void testReadAAConResults() { + public void ReadAAConResults() { try { - InputStream inStream = new FileInputStream( - AllTestSuit.TEST_DATA_PATH + "aacon_results.txt"); + InputStream inStream = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "aacon_results.txt"); HashSet result = SequenceUtil.readAAConResults(inStream); inStream.close(); assertNotNull(result); assertEquals(result.size(), 18); - inStream = new FileInputStream(AllTestSuit.TEST_DATA_PATH - + "aacon_result_single.out"); + inStream = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "aacon_result_single.out"); result = SequenceUtil.readAAConResults(inStream); inStream.close(); assertNotNull(result); @@ -408,4 +375,17 @@ public class SequenceUtilTester { fail(e.getMessage()); } } + @Test + public void ReadJpredResults() { + try { + InputStream inStream = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "Jpred.test1.out"); + List result = SequenceUtil.readJpredFile(inStream); + inStream.close(); + assertNotNull(result); + assertEquals(result.size(), 19); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } }