From 917622345899487d12d4e12bc1e0272d6ca86a87 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 9 May 2017 09:59:13 +0100 Subject: [PATCH] JAL-2403 use preferred factory method to create score model --- .../scoremodels/FeatureDistanceModelTest.java | 45 +++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/test/jalview/analysis/scoremodels/FeatureDistanceModelTest.java b/test/jalview/analysis/scoremodels/FeatureDistanceModelTest.java index 0577fae..4bcf5ab 100644 --- a/test/jalview/analysis/scoremodels/FeatureDistanceModelTest.java +++ b/test/jalview/analysis/scoremodels/FeatureDistanceModelTest.java @@ -23,6 +23,7 @@ package jalview.analysis.scoremodels; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; +import jalview.api.analysis.ScoreModelI; import jalview.api.analysis.SimilarityParamsI; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; @@ -113,12 +114,12 @@ public class FeatureDistanceModelTest public void testFeatureScoreModel() throws Exception { AlignFrame alf = getTestAlignmentFrame(); - FeatureDistanceModel fsm = new FeatureDistanceModel(); - assertTrue(fsm.configureFromAlignmentView(alf.getCurrentView() - .getAlignPanel())); + ScoreModelI sm = new FeatureDistanceModel(); + sm = ScoreModels.getInstance().getScoreModel(sm.getName(), + alf.getCurrentView().getAlignPanel()); alf.selectAllSequenceMenuItem_actionPerformed(null); - MatrixI dm = fsm.findDistances( + MatrixI dm = sm.findDistances( alf.getViewport().getAlignmentView(true), SimilarityParams.Jalview); assertEquals(dm.getValue(0, 2), 0d, @@ -133,11 +134,11 @@ public class FeatureDistanceModelTest AlignFrame alf = getTestAlignmentFrame(); // hiding first two columns shouldn't affect the tree alf.getViewport().hideColumns(0, 1); - FeatureDistanceModel fsm = new FeatureDistanceModel(); - assertTrue(fsm.configureFromAlignmentView(alf.getCurrentView() - .getAlignPanel())); + ScoreModelI sm = new FeatureDistanceModel(); + sm = ScoreModels.getInstance().getScoreModel(sm.getName(), + alf.getCurrentView().getAlignPanel()); alf.selectAllSequenceMenuItem_actionPerformed(null); - MatrixI dm = fsm.findDistances( + MatrixI dm = sm.findDistances( alf.getViewport().getAlignmentView(true), SimilarityParams.Jalview); assertEquals(dm.getValue(0, 2), 0d, @@ -153,11 +154,12 @@ public class FeatureDistanceModelTest // hide columns and check tree changes alf.getViewport().hideColumns(3, 4); alf.getViewport().hideColumns(0, 1); - FeatureDistanceModel fsm = new FeatureDistanceModel(); - assertTrue(fsm.configureFromAlignmentView(alf.getCurrentView() - .getAlignPanel())); + // getName() can become static in Java 8 + ScoreModelI sm = new FeatureDistanceModel(); + sm = ScoreModels.getInstance().getScoreModel(sm.getName(), + alf.getCurrentView().getAlignPanel()); alf.selectAllSequenceMenuItem_actionPerformed(null); - MatrixI dm = fsm.findDistances( + MatrixI dm = sm.findDistances( alf.getViewport().getAlignmentView(true), SimilarityParams.Jalview); assertEquals( @@ -252,13 +254,15 @@ public class FeatureDistanceModelTest alf.setShowSeqFeatures(true); alf.getFeatureRenderer().findAllFeatures(true); - FeatureDistanceModel fsm = new FeatureDistanceModel(); - assertTrue(fsm.configureFromAlignmentView(alf.getCurrentView() - .getAlignPanel())); + ScoreModelI sm = new FeatureDistanceModel(); + sm = ScoreModels.getInstance().getScoreModel(sm.getName(), + alf.getCurrentView().getAlignPanel()); alf.selectAllSequenceMenuItem_actionPerformed(null); - MatrixI distances = fsm.findDistances(alf.getViewport() - .getAlignmentView(true), SimilarityParams.Jalview); + AlignmentView alignmentView = alf.getViewport() + .getAlignmentView(true); + MatrixI distances = sm.findDistances(alignmentView, + SimilarityParams.Jalview); assertEquals(distances.width(), 2); assertEquals(distances.height(), 2); assertEquals(distances.getValue(0, 0), 0d); @@ -279,9 +283,10 @@ public class FeatureDistanceModelTest AlignViewport viewport = af.getViewport(); AlignmentView view = viewport.getAlignmentView(false); - FeatureDistanceModel sm = new FeatureDistanceModel(); - sm.configureFromAlignmentView(af.alignPanel); - + ScoreModelI sm = new FeatureDistanceModel(); + sm = ScoreModels.getInstance().getScoreModel(sm.getName(), + af.alignPanel); + /* * feature distance model always normalises by region width * gap-gap is always included (but scores zero) -- 1.7.10.2