-public class Comparison {\r
-\r
- public static float compare(SequenceI ii, SequenceI jj)\r
- {\r
- return Comparison.compare(ii,jj,0,ii.getLength()-1);\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
-\r
- int ilen = end-start;\r
- int jlen = end-start;\r
-\r
- if ( jalview.util.Comparison.isGap( si.charAt(start+ilen)) )\r
- {\r
- ilen--;\r
-\r
- while (jalview.util.Comparison.isGap( si.charAt(start+ilen)))\r
- {\r
- ilen--;\r
- }\r
- }\r
-\r
- if ( jalview.util.Comparison.isGap( sj.charAt(start+jlen)) )\r
- {\r
- jlen--;\r
-\r
- while (jalview.util.Comparison.isGap( sj.charAt(start+jlen)))\r
- {\r
- jlen--;\r
- }\r
- }\r
-\r
- int count = 0;\r
- int match = 0;\r
- float pid = -1;\r
-\r
- if (ilen > jlen) {\r
-\r
- for (int j = 0; j < jlen; j++) {\r
- if (si.substring(start + j,start + j+1).equals(sj.substring(start + j,start + j+1))) {\r
- match++;\r
- }\r
- count++;\r
- }\r
- pid = (float)match/(float)ilen * 100;\r
- } else {\r
- for (int j = 0; j < jlen; j++) {\r
- if (si.substring(start + j,start + j+1).equals(sj.substring(start + j,start + j+1))) {\r
- match++;\r
- }\r
- count++;\r
- }\r
- pid = (float)match/(float)jlen * 100;\r
- }\r
-\r
- return pid;\r
- }\r
-\r
- /** */\r
- public static float PID(Sequence s1 , Sequence s2)\r
- {\r
- int len;\r
-\r
- if (s1.getSequence().length() > s2.getSequence().length())\r
- len = s1.getSequence().length();\r
- else\r
- len = s2.getSequence().length();\r
-\r
-\r
- int bad = 0;\r
-\r
- for (int i = 0; i < len; i++)\r
- {\r
- char chr1;\r
- char chr2;\r
-\r
- if (i < s1.getSequence().length())\r
- chr1 = s1.getSequence().charAt(i);\r
- else\r
- chr1 = '.';\r
-\r