X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fdatamodel%2FAlignmentAnnotationTests.java;h=e47e9d6804292f240d1986a8242ee4a20b6647cd;hb=0125cee3edfa0ba5584631bae3ad9c808ec0b30d;hp=6d639d0b2a8214236bb80cb6014185a9ada0fcd6;hpb=db93a1adcbe0a4eaaf06e0a70ade0d6c5c1961c3;p=jalview.git diff --git a/test/jalview/datamodel/AlignmentAnnotationTests.java b/test/jalview/datamodel/AlignmentAnnotationTests.java index 6d639d0..e47e9d6 100644 --- a/test/jalview/datamodel/AlignmentAnnotationTests.java +++ b/test/jalview/datamodel/AlignmentAnnotationTests.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2) - * Copyright (C) 2015 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -24,12 +24,24 @@ import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertNull; import jalview.analysis.AlignSeq; +import jalview.gui.JvOptionPane; import jalview.io.AppletFormatAdapter; +import jalview.io.FileFormat; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class AlignmentAnnotationTests { + + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + @Test(groups = { "Functional" }) public void testCopyConstructor() { @@ -119,7 +131,8 @@ public class AlignmentAnnotationTests alSeq2.setEnd(sqTo.getStart() + align.getSeq2End() - 1); alSeq2.setDatasetSequence(sqTo); System.out.println(new AppletFormatAdapter() - .formatSequences("STH", new Alignment(new SequenceI[] { sqFrom, +.formatSequences( + FileFormat.Stockholm, new Alignment(new SequenceI[] { sqFrom, alSeq1, sqTo, alSeq2 }), true)); Mapping mp = align.getMappingFromS1(false); @@ -143,7 +156,8 @@ public class AlignmentAnnotationTests AlignmentI all = new Alignment(new SequenceI[] { alSeq1, alSeq2 }); all.addAnnotation(almap1); all.addAnnotation(almap2); - System.out.println(new AppletFormatAdapter().formatSequences("STH", + System.out.println(new AppletFormatAdapter().formatSequences( + FileFormat.Stockholm, all, true)); for (int p = 0; p < alSeq1.getLength(); p++) @@ -280,4 +294,45 @@ public class AlignmentAnnotationTests ann.getDefaultRnaHelixSymbol(i)); } } -} \ No newline at end of file + + public static Annotation newAnnotation(String ann) + { + float val = 0f; + try + { + val = Float.parseFloat(ann); + } catch (NumberFormatException q) + { + } + ; + return new Annotation(ann, ann, '\0', val); + } + + @Test(groups = { "Functional" }) + public void testIsQuantitative() + { + AlignmentAnnotation ann = null; + + ann = new AlignmentAnnotation("an", "some an", null); + Assert.assertFalse(ann.isQuantitative(), + "Empty annotation set should not be quantitative."); + + ann = new AlignmentAnnotation("an", "some an", new Annotation[] { + newAnnotation("4"), newAnnotation("1"), newAnnotation("1"), + newAnnotation("0.1"), newAnnotation("0.3") }); + Assert.assertTrue(ann.isQuantitative(), + "All numbers annotation set should be quantitative."); + + ann = new AlignmentAnnotation("an", "some an", new Annotation[] { + newAnnotation("E"), newAnnotation("E"), newAnnotation("E"), + newAnnotation("E"), newAnnotation("E") }); + Assert.assertFalse(ann.isQuantitative(), + "All 'E' annotation set should not be quantitative."); + + ann = new AlignmentAnnotation("an", "some an", new Annotation[] { + newAnnotation("E"), newAnnotation("1"), newAnnotation("2"), + newAnnotation("3"), newAnnotation("E") }); + Assert.assertTrue(ann.isQuantitative(), + "Mixed 'E' annotation set should be quantitative."); + } +}