From 5235e3d065984303def2aeb8cc662223fb2f9c5a Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Mon, 30 Oct 2017 16:29:31 +0000 Subject: [PATCH] JAL-2795 rebuilt MatrixConverter to be purely static --- src/jalview/ext/archaeopteryx/MatrixConverter.java | 58 +++++++++++--------- src/jalview/ext/forester/ForesterMatrix.java | 14 +---- 2 files changed, 32 insertions(+), 40 deletions(-) diff --git a/src/jalview/ext/archaeopteryx/MatrixConverter.java b/src/jalview/ext/archaeopteryx/MatrixConverter.java index 779d7a3..9eaece8 100644 --- a/src/jalview/ext/archaeopteryx/MatrixConverter.java +++ b/src/jalview/ext/archaeopteryx/MatrixConverter.java @@ -1,50 +1,54 @@ package jalview.ext.archaeopteryx; +import jalview.datamodel.Sequence; +import jalview.ext.forester.ForesterMatrix; import jalview.math.MatrixI; import org.forester.evoinference.matrix.distance.DistanceMatrix; -public class MatrixConverter +public final class MatrixConverter { - DistanceMatrix foresterMatrix; - - MatrixI jalviewMatrix; - - public static MatrixConverter createConverter( - DistanceMatrix foresterInputMatrix) + /** + * Shouldn't get instantiated + */ + private MatrixConverter() { - MatrixConverter converter = new MatrixConverter(); - converter.setForesterMatrix(foresterInputMatrix); - return converter; } - public static MatrixConverter createConverter(MatrixI jalviewInputMatrix) + + public static DistanceMatrix convertJalviewToForester( + final MatrixI jalviewInputMatrix, + final Sequence[] matrixSequences) { - MatrixConverter converter = new MatrixConverter(); - converter.setJalviewMatrix(jalviewInputMatrix); - return converter; + if (jalviewInputMatrix.width() != jalviewInputMatrix.height()) + { + // some kind of warning? + } + DistanceMatrix foresterMatrix = new ForesterMatrix(jalviewInputMatrix, + matrixSequences); + return foresterMatrix; + } - protected DistanceMatrix getForesterMatrix() + public static DistanceMatrix convertJalviewToForester( + final MatrixI jalviewInputMatrix, + final String[] matrixIdentifiers) { + if (jalviewInputMatrix.width() != jalviewInputMatrix.height()) + { + // some kind of warning? + } + + DistanceMatrix foresterMatrix = new ForesterMatrix(jalviewInputMatrix, + matrixIdentifiers); return foresterMatrix; - } - protected void setForesterMatrix(DistanceMatrix foresterMatrix) - { - this.foresterMatrix = foresterMatrix; - } - protected MatrixI getJalviewMatrix() - { - return jalviewMatrix; } - protected void setJalviewMatrix(MatrixI jalviewMatrix) - { - this.jalviewMatrix = jalviewMatrix; - } + + } diff --git a/src/jalview/ext/forester/ForesterMatrix.java b/src/jalview/ext/forester/ForesterMatrix.java index c58b2a9..4ce3d12 100644 --- a/src/jalview/ext/forester/ForesterMatrix.java +++ b/src/jalview/ext/forester/ForesterMatrix.java @@ -22,7 +22,7 @@ public class ForesterMatrix implements DistanceMatrix private Sequence[] sequences; - private String[] identifiers; + private final String[] identifiers; public ForesterMatrix(final MatrixI jalviewInputMatrix, final Sequence[] matrixSequences) @@ -31,10 +31,6 @@ public class ForesterMatrix implements DistanceMatrix this.sequences = matrixSequences; this.identifiers = new String[sequences.length]; - if (jalviewMatrix.width() != jalviewMatrix.height()) - { - // some kind of warning? - } int i = 0; for (Sequence sequence : sequences) @@ -51,14 +47,6 @@ public class ForesterMatrix implements DistanceMatrix this.jalviewMatrix = jalviewInputMatrix; this.identifiers = matrixIdentifiers; - - if (jalviewMatrix.width() != jalviewMatrix.height()) - { - // some kind of warning? - } - - - } @Override -- 1.7.10.2