From 9360a7970c15aacc7e53eb3bdd2732d2c7bef9c8 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 15 Dec 2004 17:28:07 +0000 Subject: [PATCH] Added for the moment, only used by ClustalxColourScheme --- src/jalview/schemes/Consensus.java | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 src/jalview/schemes/Consensus.java diff --git a/src/jalview/schemes/Consensus.java b/src/jalview/schemes/Consensus.java new file mode 100755 index 0000000..7b0dbbb --- /dev/null +++ b/src/jalview/schemes/Consensus.java @@ -0,0 +1,72 @@ +/* Jalview - a java multiple alignment editor + * Copyright (C) 1998 Michele Clamp + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package jalview.schemes; + +import jalview.datamodel.*; +import java.util.*; +//////////////////////////////////////////// +// This does nothing at all at the moment!!!!!!!!!! +// AW 15th Dec 2004 +///////////////////////////////////////// +public class Consensus { + + int[] mask; + double threshold; + + public Consensus(String m, double threshold) + { + mask = setNums(m); + this.threshold = threshold; + } + + + public boolean isConserved(int[][] cons2,int col, int res,int size) + { + int tot = 0; + +try{ + for (int i=0; i < mask.length; i++) + tot += cons2[col][mask[i]]; +}catch(Exception ex) +{ return true; } + + if ((double)tot > threshold*size/100) + return true; + + return false; + } + + int[] setNums(String s) + { + int [] out = new int[s.length()]; + int i = 0; + while (i < s.length()) + { + out[i] = ( (Integer) ResidueProperties.aaHash.get(s.substring(i, i + 1))).intValue(); + i++; + } + return out; + } + + +} + + + + -- 1.7.10.2