1 /* Jalview - a java multiple alignment editor
\r
2 * Copyright (C) 1998 Michele Clamp
\r
4 * This program is free software; you can redistribute it and/or
\r
5 * modify it under the terms of the GNU General Public License
\r
6 * as published by the Free Software Foundation; either version 2
\r
7 * of the License, or (at your option) any later version.
\r
9 * This program is distributed in the hope that it will be useful,
\r
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 * GNU General Public License for more details.
\r
14 * You should have received a copy of the GNU General Public License
\r
15 * along with this program; if not, write to the Free Software
\r
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
\r
18 package jalview.datamodel;
\r
20 import jalview.io.*;
\r
21 import jalview.analysis.PCA;
\r
22 import jalview.jbgui.*;
\r
23 import jalview.schemes.*;
\r
27 public class BinarySequence extends Sequence {
\r
31 public BinarySequence(SequenceI s) {
\r
32 super(s.getName(),s.getSequence(),s.getStart(),s.getEnd());
\r
35 public BinarySequence(String name, String sequence, int start, int end) {
\r
36 super(name,sequence,start,end);
\r
39 public void encode() {
\r
40 // Set all matrix to 0
\r
41 dbinary = new double[getSequence().length() * 21];
\r
43 for (int i = 0; i < dbinary.length; i++) {
\r
47 for (int i=0; i < getSequence().length(); i++ ) {
\r
50 aanum = ((Integer)ResidueProperties.getAAHash().get(getSequence().substring(i,i+1))).intValue();
\r
51 } catch (NullPointerException e) {
\r
58 dbinary[i* nores + aanum] = 1.0;
\r
63 public void blosumEncode() {
\r
65 // Set all matrix to 0
\r
66 dbinary = new double[getSequence().length() * 21];
\r
68 //for (int i = 0; i < dbinary.length; i++) {
\r
69 // dbinary[i] = 0.0;
\r
72 for (int i=0; i < getSequence().length(); i++ ) {
\r
75 aanum = ((Integer)ResidueProperties.getAAHash().get(getSequence().substring(i,i+1))).intValue();
\r
76 } catch (NullPointerException e) {
\r
83 // Do the blosum thing
\r
84 for (int j = 0;j < 20;j++) {
\r
85 dbinary[i * nores + j] = ResidueProperties.getBLOSUM62()[aanum][j];
\r
91 public String toBinaryString() {
\r
93 for (int i=0; i < binary.length;i++) {
\r
94 out += (new Integer(binary[i])).toString();
\r
95 if (i < binary.length-1) {
\r
102 public double[] getDBinary() {
\r
106 public static void printMemory(Runtime rt) {
\r
107 System.out.println("Free memory = " + rt.freeMemory());
\r