X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FComparison.java;h=67a668a9c66b29d3e4ca6d36a530b8d4900fd901;hb=77e9dc41516acc93470931bcc5f344c67e819e70;hp=6c7197ad1ed3717ca0acf0940a707c2421ed8b6f;hpb=21c9c09f36bd0e6dc64628464a2661c6de57d0ce;p=jalview.git diff --git a/src/jalview/util/Comparison.java b/src/jalview/util/Comparison.java index 6c7197a..67a668a 100755 --- a/src/jalview/util/Comparison.java +++ b/src/jalview/util/Comparison.java @@ -1,26 +1,25 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 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 -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 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.util; import jalview.datamodel.*; - /** * DOCUMENT ME! * @@ -55,8 +54,8 @@ public class Comparison */ public static float compare(SequenceI ii, SequenceI jj, int start, int end) { - String si = ii.getSequence(); - String sj = jj.getSequence(); + String si = ii.getSequenceAsString(); + String sj = jj.getSequenceAsString(); int ilen = si.length() - 1; int jlen = sj.length() - 1; @@ -124,7 +123,7 @@ public class Comparison static final int caseShift = 'a' - 'A'; // Another pid with region specification - public final static float PID(String seq1, String seq2, int start, int end) + public final static float PID(String seq1, String seq2, int start, int end) { int s1len = seq1.length(); @@ -142,17 +141,15 @@ public class Comparison start = len - 1; // we just use a single residue for the difference } - int bad = 0; char chr1; char chr2; - for (int i = start; i < len; i++) { - chr1 = seq1.charAt(i) ; + chr1 = seq1.charAt(i); - chr2 = seq2.charAt(i) ; + chr2 = seq2.charAt(i); if ('a' <= chr1 && chr1 <= 'z') { @@ -167,10 +164,9 @@ public class Comparison chr2 -= caseShift; } - - if (chr1!=chr2 && !isGap(chr1) && !isGap(chr2) ) + if (chr1 != chr2 && !isGap(chr1) && !isGap(chr2)) { - bad++; + bad++; } } @@ -189,7 +185,7 @@ public class Comparison return (c == '-' || c == '.' || c == ' ') ? true : false; } - public static final boolean isNucleotide(SequenceI [] seqs) + public static final boolean isNucleotide(SequenceI[] seqs) { int i = 0, iSize = seqs.length, j, jSize; float nt = 0, aa = 0; @@ -201,11 +197,15 @@ public class Comparison { c = seqs[i].getCharAt(j); if ('a' <= c && c <= 'z') + { c -= ('a' - 'A'); + } if (c == 'A' || c == 'G' || c == 'C' || c == 'T' || c == 'U') + { nt++; - else if (!jalview.util.Comparison.isGap( seqs[i].getCharAt(j))) + } + else if (!jalview.util.Comparison.isGap(seqs[i].getCharAt(j))) { aa++; } @@ -214,9 +214,13 @@ public class Comparison } if ( (nt / (nt + aa)) > 0.85f) + { return true; + } else + { return false; + } } }