git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TreePanel takes viewport
[jalview.git]
/
src
/
jalview
/
util
/
Comparison.java
diff --git
a/src/jalview/util/Comparison.java
b/src/jalview/util/Comparison.java
index
8041d80
..
9a86696
100755
(executable)
--- a/
src/jalview/util/Comparison.java
+++ b/
src/jalview/util/Comparison.java
@@
-21,10
+21,27
@@
package jalview.util;
import jalview.datamodel.*;
\r
\r
\r
import jalview.datamodel.*;
\r
\r
\r
-public class Comparison {
\r
+/**
\r
+ * DOCUMENT ME!
\r
+ *
\r
+ * @author $author$
\r
+ * @version $Revision$
\r
+ */
\r
+public class Comparison
\r
+{
\r
+ /** DOCUMENT ME!! */
\r
public static String GapChars = " .-";
\r
\r
public static String GapChars = " .-";
\r
\r
- public static float compare(SequenceI ii, SequenceI jj) {
\r
+ /**
\r
+ * DOCUMENT ME!
\r
+ *
\r
+ * @param ii DOCUMENT ME!
\r
+ * @param jj DOCUMENT ME!
\r
+ *
\r
+ * @return DOCUMENT ME!
\r
+ */
\r
+ public static float compare(SequenceI ii, SequenceI jj)
\r
+ {
\r
return Comparison.compare(ii, jj, 0, ii.getLength() - 1);
\r
}
\r
\r
return Comparison.compare(ii, jj, 0, ii.getLength() - 1);
\r
}
\r
\r
@@
-36,18
+53,21
@@
public class Comparison {
* @param end int
\r
* @return float
\r
*/
\r
* @param end int
\r
* @return float
\r
*/
\r
- public static float compare(SequenceI ii, SequenceI jj, int start, int end) {
\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
\r
int ilen = si.length() - 1;
\r
int jlen = sj.length() - 1;
\r
\r
String si = ii.getSequence();
\r
String sj = jj.getSequence();
\r
\r
int ilen = si.length() - 1;
\r
int jlen = sj.length() - 1;
\r
\r
- while (jalview.util.Comparison.isGap(si.charAt(start + ilen))) {
\r
+ while (jalview.util.Comparison.isGap(si.charAt(start + ilen)))
\r
+ {
\r
ilen--;
\r
}
\r
\r
ilen--;
\r
}
\r
\r
- while (jalview.util.Comparison.isGap(sj.charAt(start + jlen))) {
\r
+ while (jalview.util.Comparison.isGap(sj.charAt(start + jlen)))
\r
+ {
\r
jlen--;
\r
}
\r
\r
jlen--;
\r
}
\r
\r
@@
-55,10
+75,13
@@
public class Comparison {
int match = 0;
\r
float pid = -1;
\r
\r
int match = 0;
\r
float pid = -1;
\r
\r
- if (ilen > jlen) {
\r
- for (int j = 0; j < jlen; j++) {
\r
+ if (ilen > jlen)
\r
+ {
\r
+ for (int j = 0; j < jlen; j++)
\r
+ {
\r
if (si.substring(start + j, start + j + 1).equals(sj.substring(start +
\r
if (si.substring(start + j, start + j + 1).equals(sj.substring(start +
\r
- j, start + j + 1))) {
\r
+ j, start + j + 1)))
\r
+ {
\r
match++;
\r
}
\r
\r
match++;
\r
}
\r
\r
@@
-66,10
+89,14
@@
public class Comparison {
}
\r
\r
pid = (float) match / (float) ilen * 100;
\r
}
\r
\r
pid = (float) match / (float) ilen * 100;
\r
- } else {
\r
- for (int j = 0; j < jlen; j++) {
\r
+ }
\r
+ else
\r
+ {
\r
+ for (int j = 0; j < jlen; j++)
\r
+ {
\r
if (si.substring(start + j, start + j + 1).equals(sj.substring(start +
\r
if (si.substring(start + j, start + j + 1).equals(sj.substring(start +
\r
- j, start + j + 1))) {
\r
+ j, start + j + 1)))
\r
+ {
\r
match++;
\r
}
\r
\r
match++;
\r
}
\r
\r
@@
-89,36
+116,49
@@
public class Comparison {
* @param s2 SequenceI
\r
* @return float
\r
*/
\r
* @param s2 SequenceI
\r
* @return float
\r
*/
\r
- public static float PID(SequenceI s1, SequenceI s2) {
\r
+ public static float PID(SequenceI s1, SequenceI s2)
\r
+ {
\r
int len;
\r
\r
int len;
\r
\r
- if (s1.getSequence().length() > s2.getSequence().length()) {
\r
+ if (s1.getSequence().length() > s2.getSequence().length())
\r
+ {
\r
len = s1.getSequence().length();
\r
len = s1.getSequence().length();
\r
- } else {
\r
+ }
\r
+ else
\r
+ {
\r
len = s2.getSequence().length();
\r
}
\r
\r
int bad = 0;
\r
\r
len = s2.getSequence().length();
\r
}
\r
\r
int bad = 0;
\r
\r
- for (int i = 0; i < len; i++) {
\r
+ for (int i = 0; i < len; i++)
\r
+ {
\r
char chr1;
\r
char chr2;
\r
\r
char chr1;
\r
char chr2;
\r
\r
- if (i < s1.getSequence().length()) {
\r
- chr1 = s1.getSequence().charAt(i);
\r
- } else {
\r
+ if (i < s1.getSequence().length())
\r
+ {
\r
+ chr1 = Character.toUpperCase(s1.getSequence().charAt(i));
\r
+ }
\r
+ else
\r
+ {
\r
chr1 = '.';
\r
}
\r
\r
chr1 = '.';
\r
}
\r
\r
- if (i < s2.getSequence().length()) {
\r
- chr2 = s2.getSequence().charAt(i);
\r
- } else {
\r
+ if (i < s2.getSequence().length())
\r
+ {
\r
+ chr2 = Character.toUpperCase(s2.getSequence().charAt(i));
\r
+ }
\r
+ else
\r
+ {
\r
chr2 = '.';
\r
}
\r
\r
if (!(jalview.util.Comparison.isGap(chr1)) &&
\r
chr2 = '.';
\r
}
\r
\r
if (!(jalview.util.Comparison.isGap(chr1)) &&
\r
- !(jalview.util.Comparison.isGap(chr2))) {
\r
- if (chr1 != chr2) {
\r
+ !(jalview.util.Comparison.isGap(chr2)))
\r
+ {
\r
+ if (chr1 != chr2)
\r
+ {
\r
bad++;
\r
}
\r
}
\r
bad++;
\r
}
\r
}
\r
@@
-128,44
+168,59
@@
public class Comparison {
}
\r
\r
// Another pid with region specification
\r
}
\r
\r
// Another pid with region specification
\r
- public static float PID(SequenceI s1, SequenceI s2, int start, int end) {
\r
+ public static float PID(SequenceI s1, SequenceI s2, int start, int end)
\r
+ {
\r
int len;
\r
\r
int len;
\r
\r
- if (s1.getSequence().length() > s2.getSequence().length()) {
\r
+ if (s1.getSequence().length() > s2.getSequence().length())
\r
+ {
\r
len = s1.getSequence().length();
\r
len = s1.getSequence().length();
\r
- } else {
\r
+ }
\r
+ else
\r
+ {
\r
len = s2.getSequence().length();
\r
}
\r
\r
len = s2.getSequence().length();
\r
}
\r
\r
- if (end < len) {
\r
+ if (end < len)
\r
+ {
\r
len = end;
\r
}
\r
\r
len = end;
\r
}
\r
\r
- if (len < start) {
\r
+ if (len < start)
\r
+ {
\r
start = len - 1; // we just use a single residue for the difference
\r
}
\r
\r
int bad = 0;
\r
\r
start = len - 1; // we just use a single residue for the difference
\r
}
\r
\r
int bad = 0;
\r
\r
- for (int i = start; i < len; i++) {
\r
+ for (int i = start; i < len; i++)
\r
+ {
\r
char chr1;
\r
char chr2;
\r
\r
char chr1;
\r
char chr2;
\r
\r
- if (i < s1.getSequence().length()) {
\r
- chr1 = s1.getSequence().charAt(i);
\r
- } else {
\r
+ if (i < s1.getSequence().length())
\r
+ {
\r
+ chr1 = Character.toUpperCase(s1.getSequence().charAt(i));
\r
+ }
\r
+ else
\r
+ {
\r
chr1 = '.';
\r
}
\r
\r
chr1 = '.';
\r
}
\r
\r
- if (i < s2.getSequence().length()) {
\r
- chr2 = s2.getSequence().charAt(i);
\r
- } else {
\r
+ if (i < s2.getSequence().length())
\r
+ {
\r
+ chr2 = Character.toUpperCase(s2.getSequence().charAt(i));
\r
+ }
\r
+ else
\r
+ {
\r
chr2 = '.';
\r
}
\r
\r
if (!(jalview.util.Comparison.isGap(chr1)) &&
\r
chr2 = '.';
\r
}
\r
\r
if (!(jalview.util.Comparison.isGap(chr1)) &&
\r
- !(jalview.util.Comparison.isGap(chr2))) {
\r
- if (chr1 != chr2) {
\r
+ !(jalview.util.Comparison.isGap(chr2)))
\r
+ {
\r
+ if (chr1 != chr2)
\r
+ {
\r
bad++;
\r
}
\r
}
\r
bad++;
\r
}
\r
}
\r
@@
-174,7
+229,15
@@
public class Comparison {
return ((float) 100 * (len - bad)) / len;
\r
}
\r
\r
return ((float) 100 * (len - bad)) / len;
\r
}
\r
\r
- public static boolean isGap(char c) {
\r
- return ((c != '.') && (c != '-') && (c != ' ')) ? false : true;
\r
+ /**
\r
+ * DOCUMENT ME!
\r
+ *
\r
+ * @param c DOCUMENT ME!
\r
+ *
\r
+ * @return DOCUMENT ME!
\r
+ */
\r
+ public static boolean isGap(char c)
\r
+ {
\r
+ return ( c=='-' || c=='.' || c==' ' ) ? true : false;
\r
}
\r
}
\r
}
\r
}
\r