/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4.0.b2)
+ * Copyright (C) 2009 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
// inefficient implementation
int fromStart[] = shiftTo(start);
int fromEnd[] = shiftTo(end); // needs to be inclusive of end of symbol
- // position
+ // position
if (fromStart == null || fromEnd == null)
return null;
int iv[] = getIntervals(fromShifts, fromStart, fromEnd, fromRatio);
startpos = fromStart[0]; // first position in fromStart
endpos = fromEnd[0]; // last position in fromEnd
int endindx = (fromRatio2 - 1); // additional positions to get to last
- // position from endpos
+ // position from endpos
int intv = 0, intvSize = fromShifts2.size();
int iv[], i = 0, fs = -1, fe_s = -1, fe = -1; // containing intervals
// search intervals to locate ones containing startpos and count endindx
// positions on from endpos
- while (intv < intvSize && ( fs == -1 || fe == -1))
+ while (intv < intvSize && (fs == -1 || fe == -1))
{
iv = (int[]) fromShifts2.elementAt(intv++);
- if (fe_s>-1)
+ if (fe_s > -1)
{
endpos = iv[0]; // start counting from beginning of interval
endindx--; // inclusive of endpos
if (endpos + endindx <= iv[1])
{
fe = i;
- endpos = endpos + endindx; // end of end token is within this interval
+ endpos = endpos + endindx; // end of end token is within this
+ // interval
}
else
{
- endindx -= iv[1] - endpos; // skip all this interval too
+ endindx -= iv[1] - endpos; // skip all this interval too
}
}
}
if (endpos - endindx >= iv[1])
{
fe = i;
- endpos = endpos - endindx; // end of end token is within this interval
+ endpos = endpos - endindx; // end of end token is within this
+ // interval
}
else
{
- endindx -= endpos-iv[1]; // skip all this interval too
+ endindx -= endpos - iv[1]; // skip all this interval too
}
}
}
// test internal consistency
int to[] = new int[51];
MapList.testMap(ml, 1, 60);
- MapList mldna = new MapList(new int[] { 2,2,6,8,12,16}, new int[] { 1,3},3,1);
- int[] frm = mldna.locateInFrom(1,1);
- testLocateFrom(mldna, 1,1,new int[] { 2,2,6,7});
- MapList.testMap(mldna, 1,3);
+ MapList mldna = new MapList(new int[]
+ { 2, 2, 6, 8, 12, 16 }, new int[]
+ { 1, 3 }, 3, 1);
+ int[] frm = mldna.locateInFrom(1, 1);
+ testLocateFrom(mldna, 1, 1, new int[]
+ { 2, 2, 6, 7 });
+ MapList.testMap(mldna, 1, 3);
/*
* for (int from=1; from<=51; from++) { int[] too=ml.shiftTo(from); int[]
* toofrom=ml.shiftFrom(too[0]);
* "+too[1]+"\t+-+\tShiftTo("+too[0]+")=="+toofrom[0]+" % "+toofrom[1]); }
*/
System.out.print("Success?\n"); // if we get here - something must be
- // working!
+ // working!
}
private static void testLocateFrom(MapList mldna, int i, int j, int[] ks)
{
int[] frm = mldna.locateInFrom(i, j);
- if (frm==ks || java.util.Arrays.equals(frm,ks))
+ if (frm == ks || java.util.Arrays.equals(frm, ks))
{
- System.out.println("Success test locate from "+i+" to "+j);
- } else {
- System.err.println("Failed test locate from "+i+" to "+j);
+ System.out.println("Success test locate from " + i + " to " + j);
+ }
+ else
+ {
+ System.err.println("Failed test locate from " + i + " to " + j);
for (int c = 0; c < frm.length; c++)
{
System.err.print(frm[c] + ((c % 2 == 0) ? "," : ";"));