X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FBinarySequence.java;h=456b8b05c8f0e39ff2a05d93a9ee3f22cf706fe2;hb=dfa04e77181fccfa6229ffef1591fc9c622d9b39;hp=062f6bab49f33ac6635aba28d6a03dcb4f205048;hpb=9793a4e49836be392513c2a51e9fc71a0b0eb417;p=jalview.git
diff --git a/src/jalview/datamodel/BinarySequence.java b/src/jalview/datamodel/BinarySequence.java
index 062f6ba..456b8b0 100755
--- a/src/jalview/datamodel/BinarySequence.java
+++ b/src/jalview/datamodel/BinarySequence.java
@@ -1,19 +1,20 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
- * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Copyright (C) 2014 The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- *
+ *
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.datamodel;
@@ -42,7 +43,8 @@ public class BinarySequence extends Sequence
double[] dbinary;
- boolean isNa=false;
+ boolean isNa = false;
+
/**
* Creates a new BinarySequence object.
*
@@ -52,16 +54,18 @@ public class BinarySequence extends Sequence
public BinarySequence(String s, boolean isNa)
{
super("", s, 0, s.length());
- this.isNa=isNa;
+ this.isNa = isNa;
}
/**
- * clear the dbinary matrix
+ * clear the dbinary matrix
+ *
* @return nores - dimension of sequence symbol encoding for this sequence
*/
private int initMatrixGetNoRes()
{
- int nores=(isNa) ? ResidueProperties.maxNucleotideIndex : ResidueProperties.maxProteinIndex;
+ int nores = (isNa) ? ResidueProperties.maxNucleotideIndex
+ : ResidueProperties.maxProteinIndex;
// Set all matrix to 0
dbinary = new double[getSequence().length * nores];
@@ -71,32 +75,35 @@ public class BinarySequence extends Sequence
}
return nores;
}
+
private int[] getSymbolmatrix()
{
- return (isNa) ? ResidueProperties.nucleotideIndex : ResidueProperties.aaIndex;
+ return (isNa) ? ResidueProperties.nucleotideIndex
+ : ResidueProperties.aaIndex;
}
+
/**
* DOCUMENT ME!
*/
public void encode()
{
- int nores=initMatrixGetNoRes();
- final int[] sindex=getSymbolmatrix();
+ int nores = initMatrixGetNoRes();
+ final int[] sindex = getSymbolmatrix();
for (int i = 0; i < getSequence().length; i++)
{
- int aanum = nores-1;
+ int aanum = nores - 1;
try
{
aanum = sindex[getCharAt(i)];
} catch (NullPointerException e)
{
- aanum = nores-1;
+ aanum = nores - 1;
}
if (aanum >= nores)
{
- aanum = nores-1;
+ aanum = nores - 1;
}
dbinary[(i * nores) + aanum] = 1.0;
@@ -108,9 +115,10 @@ public class BinarySequence extends Sequence
*
* @param matrix
*/
- public void matrixEncode(final ScoreMatrix matrix) throws InvalidSequenceTypeException
+ public void matrixEncode(final ScoreMatrix matrix)
+ throws InvalidSequenceTypeException
{
- if (isNa!=matrix.isDNA())
+ if (isNa != matrix.isDNA())
{
throw new InvalidSequenceTypeException("matrix "
+ matrix.getClass().getCanonicalName()
@@ -131,21 +139,21 @@ public class BinarySequence extends Sequence
// for (int i = 0; i < dbinary.length; i++) {
// dbinary[i] = 0.0;
// }
- for (int i = 0,iSize=getSequence().length; i=nores)
+ if (aanum >= nores)
{
- aanum = nores-1;
+ aanum = nores - 1;
}
// Do the blosum^H^H^H^H^H score matrix summation thing