2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.datamodel;
\r
21 import jalview.schemes.*;
\r
29 * @version $Revision$
\r
31 public class BinarySequence extends Sequence
\r
37 * Creates a new BinarySequence object.
\r
39 * @param s DOCUMENT ME!
\r
41 public BinarySequence(SequenceI s)
\r
43 super(s.getName(), s.getSequence(), s.getStart(), s.getEnd());
\r
47 * Creates a new BinarySequence object.
\r
49 * @param name DOCUMENT ME!
\r
50 * @param sequence DOCUMENT ME!
\r
51 * @param start DOCUMENT ME!
\r
52 * @param end DOCUMENT ME!
\r
54 public BinarySequence(String name, String sequence, int start, int end)
\r
56 super(name, sequence, start, end);
\r
62 public void encode()
\r
64 // Set all matrix to 0
\r
65 dbinary = new double[getSequence().length() * 21];
\r
69 for (int i = 0; i < dbinary.length; i++)
\r
74 for (int i = 0; i < getSequence().length(); i++)
\r
80 aanum = ((Integer) ResidueProperties.getAAHash().get(getSequence()
\r
82 i + 1))).intValue();
\r
84 catch (NullPointerException e)
\r
94 dbinary[(i * nores) + aanum] = 1.0;
\r
101 public void blosumEncode()
\r
103 // Set all matrix to 0
\r
104 dbinary = new double[getSequence().length() * 21];
\r
108 //for (int i = 0; i < dbinary.length; i++) {
\r
109 // dbinary[i] = 0.0;
\r
111 for (int i = 0; i < getSequence().length(); i++)
\r
117 aanum = ((Integer) ResidueProperties.getAAHash().get(getSequence()
\r
119 i + 1))).intValue();
\r
121 catch (NullPointerException e)
\r
131 // Do the blosum thing
\r
132 for (int j = 0; j < 20; j++)
\r
134 dbinary[(i * nores) + j] = ResidueProperties.getBLOSUM62()[aanum][j];
\r
142 * @return DOCUMENT ME!
\r
144 public String toBinaryString()
\r
148 for (int i = 0; i < binary.length; i++)
\r
150 out += (new Integer(binary[i])).toString();
\r
152 if (i < (binary.length - 1))
\r
164 * @return DOCUMENT ME!
\r
166 public double[] getDBinary()
\r
174 * @param rt DOCUMENT ME!
\r
176 public static void printMemory(Runtime rt)
\r
178 System.out.println("DEBUG: Free memory = " + rt.freeMemory()); // log.
\r