From b78fb1a396fb5bcc5f6b428e6514061328464cde Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Mon, 30 Oct 2017 15:33:41 +0000 Subject: [PATCH] JAL-2795 implemented getting/setting identifiers --- src/jalview/ext/forester/ForesterMatrix.java | 27 +++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/jalview/ext/forester/ForesterMatrix.java b/src/jalview/ext/forester/ForesterMatrix.java index daeec3b..cac1993 100644 --- a/src/jalview/ext/forester/ForesterMatrix.java +++ b/src/jalview/ext/forester/ForesterMatrix.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.io.Writer; import java.text.DecimalFormat; import java.text.NumberFormat; +import java.util.Arrays; import org.forester.evoinference.matrix.distance.DistanceMatrix; import org.forester.util.ForesterUtil; @@ -29,11 +30,17 @@ public class ForesterMatrix implements DistanceMatrix this.jalviewMatrix = jalviewInputMatrix; this.sequences = matrixSequences; - if (jalviewMatrix.width() != jalviewMatrix.height()) { // some kind of warning? } + int i = 0; + + for (Sequence sequence : sequences) + { + identifiers[i] = sequence.getName(); + i++; + } } @@ -48,6 +55,13 @@ public class ForesterMatrix implements DistanceMatrix { // some kind of warning? } + int i = 0; + + for (String identifier : matrixIdentifiers) + { + identifiers[i] = identifier; + i++; + } } @@ -55,14 +69,13 @@ public class ForesterMatrix implements DistanceMatrix @Override public String getIdentifier(int i) { - // TODO Auto-generated method stub - return null; + return identifiers[i]; } @Override public int getIndex(String identifier) { - return 0; + return Arrays.asList(identifiers).indexOf(identifier); } /** @@ -76,7 +89,7 @@ public class ForesterMatrix implements DistanceMatrix /** * See {@link MatrixI#getValue(int,int)} except that the order of column, row - * in the parameters is inverted here + * in the parameters is inverted here (as that is how forester demands it) */ @Override public double getValue(int col, int row) @@ -87,13 +100,13 @@ public class ForesterMatrix implements DistanceMatrix @Override public void setIdentifier(int i, String identifier) { - // TODO Auto-generated method stub + identifiers[i] = identifier; } /** * See {@link MatrixI#setValue()} except that the order of column, row in the - * parameters is inverted here + * parameters is inverted here (as that is how forester demands it) */ @Override public void setValue(int col, int row, double distance) -- 1.7.10.2