/*\r
-* Jalview - A Sequence Alignment Editor and Viewer\r
-* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
-*\r
-* This program is free software; you can redistribute it and/or\r
-* modify it under the terms of the GNU General Public License\r
-* as published by the Free Software Foundation; either version 2\r
-* of the License, or (at your option) any later version.\r
-*\r
-* This program is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with this program; if not, write to the Free Software\r
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
-*/\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
package jalview.util;\r
\r
import jalview.datamodel.*;\r
\r
-\r
/**\r
* DOCUMENT ME!\r
*\r
public class Comparison\r
{\r
/** DOCUMENT ME!! */\r
- public static String GapChars = " .-";\r
+ public static final String GapChars = " .-";\r
\r
/**\r
* DOCUMENT ME!\r
*\r
* @return DOCUMENT ME!\r
*/\r
- public static float compare(SequenceI ii, SequenceI jj)\r
+ public static final float compare(SequenceI ii, SequenceI jj)\r
{\r
return Comparison.compare(ii, jj, 0, ii.getLength() - 1);\r
}\r
*/\r
public static float compare(SequenceI ii, SequenceI jj, int start, int end)\r
{\r
- String si = ii.getSequence();\r
- String sj = jj.getSequence();\r
+ String si = ii.getSequenceAsString();\r
+ String sj = jj.getSequenceAsString();\r
\r
int ilen = si.length() - 1;\r
int jlen = sj.length() - 1;\r
static final int caseShift = 'a' - 'A';\r
\r
// Another pid with region specification\r
- public final static float PID(String seq1, String seq2, int start, int end)\r
+ public final static float PID(String seq1, String seq2, int start, int end)\r
{\r
\r
int s1len = seq1.length();\r
start = len - 1; // we just use a single residue for the difference\r
}\r
\r
-\r
int bad = 0;\r
char chr1;\r
char chr2;\r
\r
-\r
for (int i = start; i < len; i++)\r
{\r
- chr1 = seq1.charAt(i) ;\r
+ chr1 = seq1.charAt(i);\r
\r
- chr2 = seq2.charAt(i) ;\r
+ chr2 = seq2.charAt(i);\r
\r
if ('a' <= chr1 && chr1 <= 'z')\r
{\r
chr2 -= caseShift;\r
}\r
\r
-\r
- if (chr1!=chr2 && !isGap(chr1) && !isGap(chr2) )\r
+ if (chr1 != chr2 && !isGap(chr1) && !isGap(chr2))\r
{\r
- bad++;\r
+ bad++;\r
}\r
}\r
\r
*\r
* @return DOCUMENT ME!\r
*/\r
- public static boolean isGap(char c)\r
+ public static final boolean isGap(char c)\r
{\r
return (c == '-' || c == '.' || c == ' ') ? true : false;\r
}\r
\r
- public static boolean isNucleotide(SequenceI [] seqs)\r
+ public static final boolean isNucleotide(SequenceI[] seqs)\r
{\r
int i = 0, iSize = seqs.length, j, jSize;\r
float nt = 0, aa = 0;\r
{\r
c = seqs[i].getCharAt(j);\r
if ('a' <= c && c <= 'z')\r
+ {\r
c -= ('a' - 'A');\r
+ }\r
\r
if (c == 'A' || c == 'G' || c == 'C' || c == 'T' || c == 'U')\r
+ {\r
nt++;\r
- else if (!jalview.util.Comparison.isGap( seqs[i].getCharAt(j)))\r
+ }\r
+ else if (!jalview.util.Comparison.isGap(seqs[i].getCharAt(j)))\r
{\r
aa++;\r
}\r
}\r
\r
if ( (nt / (nt + aa)) > 0.85f)\r
+ {\r
return true;\r
+ }\r
else\r
+ {\r
return false;\r
+ }\r
\r
}\r
}\r