From: amwaterhouse Date: Thu, 30 Jun 2005 14:44:15 +0000 (+0000) Subject: Not used in Jalview X-Git-Tag: Release_2_01~27 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9257b8510c7354cbd7e43a3fc2817978cc8e4ae9;p=jalview.git Not used in Jalview --- diff --git a/src/jalview/analysis/AlignmentUtil.java b/src/jalview/analysis/AlignmentUtil.java deleted file mode 100755 index a2e1c71..0000000 --- a/src/jalview/analysis/AlignmentUtil.java +++ /dev/null @@ -1,205 +0,0 @@ -/* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program 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 2 -* of the License, or (at your option) any later version. -* -* This program 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 this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ -package jalview.analysis; - -import jalview.datamodel.*; - -import jalview.util.*; - -import java.util.*; - - -public class AlignmentUtil { - private AlignmentUtil() { - } - - public static int[][] percentIdentity2(AlignmentI align) { - return percentIdentity2(align, 0, align.getWidth() - 1); - } - - public static int[][] percentIdentity2(AlignmentI align, int start, int end) { - int[][] cons2 = new int[align.getWidth()][24]; - - // Initialize the array - for (int j = 0; j < 24; j++) { - for (int i = 0; i < align.getWidth(); i++) { - cons2[i][j] = 0; - } - } - - return cons2; - } - - public static int getPixelHeight(int i, int j, int charHeight) { - int h = 0; - - while (i < j) { - h += charHeight; - i++; - } - - return h; - } - - public static Vector substitution_rates(AlignmentI align, int start, int end) { - Vector rates = new Vector(); - - int len = (end - start + 1); - - // Turn seqs into char arrays - int[][] seqint = new int[align.getHeight()][len]; - - for (int j = 0; j < align.getHeight(); j++) { - SequenceI seq = align.getSequenceAt(j); - - for (int i = 0; i < len; i++) { - char c = seq.getCharAt((start + i) - 1); - - if (c == 'A') { - seqint[j][i] = 0; - } else if (c == 'C') { - seqint[j][i] = 1; - } else if (c == 'T') { - seqint[j][i] = 2; - } else if (c == 'G') { - seqint[j][i] = 3; - } else { - seqint[j][i] = -1; - } - } - } - - // print_matrix(seqint,2,len); for (int j = 0; j < align.getHeight(); j++) { - for (int j = 0; j < align.getHeight(); j++) { - for (int k = 0; k < align.getHeight(); k++) { - int[][] counts = new int[4][4]; - int tot = 0; - int[] tots = new int[4]; - int fulltot = 0; - int[] fulltots = new int[4]; - - for (int i = 0; i < len; i++) { - if (k != j) { - // System.out.println("Seq " + j + " " + k + " " + i + " " + seqint[j][i] + " " + seqint[k][i]); - if ((seqint[j][i] >= 0) && (seqint[k][i] >= 0)) { - counts[seqint[k][i]][seqint[j][i]]++; - - // print_matrix(counts,4,4); - tots[seqint[j][i]]++; - tot++; - } - - if (seqint[j][i] != -1) { - fulltots[seqint[j][i]]++; - fulltot++; - } - } - } - - if (k != j) { - System.out.println(); - - System.out.println("Sequence " + - align.getSequenceAt(j).getName() + " " + - align.getSequenceAt(k).getName()); - - System.out.println(); - print_matrix(counts, 4, 4); - System.out.println(); - - double[][] out = new double[4][4]; // = constant_multiply_matrix(counts,1.0/tot,4,4); - - for (int i = 0; i < 4; i++) { - for (int jj = 0; jj < 4; jj++) { - out[i][jj] = (double) counts[i][jj] / tots[jj]; - } - } - - print_matrix(out, 4, 4); - System.out.println(); - - System.out.print("RATES\t"); - System.out.print(align.getSequenceAt(j).getName() + "\t" + - align.getSequenceAt(k).getName() + "\t"); - - for (int i = 0; i < 4; i++) { - for (int jj = 0; jj < 4; jj++) { - Format.print(System.out, "%4.3f\t", out[i][jj]); - } - } - - System.out.println(); - - for (int i = 0; i < 4; i++) { - Format.print(System.out, "%4.3f\t", - ((double) fulltots[i] * 1.0) / fulltot); - } - - System.out.println(); - System.out.print("\nGC "); - - Format.print(System.out, "%4.3f\t", - (double) ((100 * fulltots[1]) + fulltots[3]) / fulltot); - - System.out.print((fulltots[1] + fulltots[3]) + "\t" + - fulltot); - - System.out.println(); - - rates.addElement(out); - } - } - } - - return rates; - } - - public static double[][] constant_multiply_matrix(int[][] matrix, double c, - int n, int m) { - double[][] out = new double[n][m]; - - for (int i = 0; i < n; i++) { - for (int j = 0; j < m; j++) { - out[i][j] = matrix[i][j] * c; - } - } - - return out; - } - - public static void print_matrix(int[][] matrix, int n, int m) { - for (int i = 0; i < n; i++) { - for (int j = 0; j < m; j++) { - System.out.print(matrix[i][j] + "\t"); - } - - System.out.println(); - } - } - - public static void print_matrix(double[][] matrix, int n, int m) { - for (int i = 0; i < n; i++) { - for (int j = 0; j < m; j++) { - Format.print(System.out, "%4.3f\t", matrix[i][j]); - } - - System.out.println(); - } - } -} diff --git a/src/jalview/analysis/CompareAlignments.java b/src/jalview/analysis/CompareAlignments.java deleted file mode 100755 index 2752e6f..0000000 --- a/src/jalview/analysis/CompareAlignments.java +++ /dev/null @@ -1,176 +0,0 @@ -/* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle -* -* This program 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 2 -* of the License, or (at your option) any later version. -* -* This program 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 this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ -package jalview.analysis; - -import jalview.datamodel.*; - -import jalview.io.*; - -import java.util.*; - - -public class CompareAlignments { - Vector align; - String refId; - Vector ids; - - public CompareAlignments(Vector align) { - this.align = align; - - ids = new Vector(); - - Alignment al0 = (Alignment) align.elementAt(0); - - for (int i = 0; i < al0.getHeight(); i++) { - SequenceI seq = al0.getSequenceAt(i); - - ids.addElement(seq.getName()); - - if (i == 0) { - setReferenceId(seq.getName()); - } - } - } - - public void compare() { - Hashtable positions = new Hashtable(); - - for (int k = 0; k < ids.size(); k++) { - String id = (String) ids.elementAt(k); - - System.out.println("Ids " + id + " " + refId); - - if (!id.equals(refId)) { - Hashtable fullhash = new Hashtable(); - - for (int i = 0; i < align.size(); i++) { - System.out.println("Alignment " + i); - - Alignment al = (Alignment) align.elementAt(i); - - SequenceI refseq = null; - - for (int j = 0; j < al.getHeight(); j++) { - if (((SequenceI) al.getSequenceAt(j)).getName().equals(refId)) { - refseq = (SequenceI) al.getSequenceAt(j); - } - } - - if (refseq != null) { - System.out.println("Refseq " + refseq.getName()); - - for (int jj = 0; jj < al.getHeight(); jj++) { - SequenceI seq = (SequenceI) al.getSequenceAt(jj); - - if (seq.getName().equals(id)) { - Hashtable hash = getAlignPositions(seq, refseq); - - Enumeration keys = hash.keys(); - - while (keys.hasMoreElements()) { - Integer key = (Integer) keys.nextElement(); - - // System.out.println(key + " " + hash.get(key)); - if (fullhash.get(key) == null) { - fullhash.put(key, new Vector()); - } - - Vector tmp = (Vector) fullhash.get(key); - - tmp.addElement(hash.get(key)); - } - } - } - } - } - - System.out.println("\nId " + id); - - Enumeration keys = fullhash.keys(); - - int totdiff = 0; - - while (keys.hasMoreElements()) { - Integer key = (Integer) keys.nextElement(); - - Vector tmp = (Vector) fullhash.get(key); - - int diff0 = ((Integer) tmp.elementAt(0)).intValue(); - ; - - int diff = 0; - - for (int l = 1; l < tmp.size(); l++) { - diff += Math.abs(diff0 - - ((Integer) tmp.elementAt(l)).intValue()); - } - - if (diff > 0) { - totdiff++; - System.out.print(id + " Ref pos " + key + " : " + - diff0 + " " + diff + " : "); - - for (int l = 1; l < tmp.size(); l++) { - System.out.print(diff0 - - ((Integer) tmp.elementAt(l)).intValue() + " "); - } - - System.out.println(); - } - } - - System.out.println("Total " + id + " " + totdiff); - } - } - } - - public void setReferenceId(String id) { - this.refId = id; - } - - public Hashtable getAlignPositions(SequenceI seq1, SequenceI seq2) { - Hashtable hash = new Hashtable(); - - int i = 0; - - int pos1 = 0; - int pos2 = 0; - - while (i < seq1.getLength()) { - char c1 = seq1.getCharAt(i); - char c2 = seq2.getCharAt(i); - - if (c1 != '-') { - pos1++; - } - - if (c2 != '-') { - pos2++; - } - - if (c1 != '-') { - hash.put(new Integer(pos1), new Integer(pos2)); - } - - i++; - } - - return hash; - } -}