private final AlignmentI dataset;
+ private ShiftList vismapping;
+
+ private int[] startcontigs;
+
/*
* Working variables for the translation.
*
this.annotations = viewport.getAlignment().getAlignmentAnnotation();
this.dnaWidth = viewport.getAlignment().getWidth();
this.dataset = viewport.getAlignment().getDataset();
+ initContigs();
+ }
+
+ /**
+ * Initialise contigs used as starting point for translateCodingRegion
+ */
+ private void initContigs()
+ {
+ vismapping = new ShiftList(); // map from viscontigs to seqstring
+ // intervals
+
+ int npos = 0;
+ int[] lastregion = null;
+ ArrayList<Integer> tempcontigs = new ArrayList<>();
+ while (contigs.hasNext())
+ {
+ int[] region = contigs.next();
+ if (lastregion == null)
+ {
+ vismapping.addShift(npos, region[0]);
+ }
+ else
+ {
+ // hidden region
+ vismapping.addShift(npos, region[0] - lastregion[1] + 1);
+ }
+ lastregion = region;
+ tempcontigs.add(region[0]);
+ tempcontigs.add(region[1]);
+ }
+
+ startcontigs = new int[tempcontigs.size()];
+ int i = 0;
+ for (Integer val : tempcontigs)
+ {
+ startcontigs[i] = val;
+ i++;
+ }
+ tempcontigs = null;
}
/**
List<SequenceI> proteinSeqs)
{
List<int[]> skip = new ArrayList<>();
- int skipint[] = null;
- ShiftList vismapping = new ShiftList(); // map from viscontigs to seqstring
- // intervals
- int vc = 0;
-
+ int[] skipint = null;
int npos = 0;
- int[] lastregion = null;
- while (contigs.hasNext())
- {
- int[] region = contigs.next();
- if (lastregion == null)
- {
- vismapping.addShift(npos, region[0]);
- }
- else
- {
- // hidden region
- vismapping.addShift(npos, region[0] - lastregion[1] + 1);
- }
- lastregion = region;
- vc++;
- }
+ int vc = 0;
- int[] scontigs = new int[vc];
- vc = 0;
- while (contigs.hasNext())
- {
- int[] region = contigs.next();
- scontigs[vc] = region[0];
- scontigs[vc + 1] = region[1];
- vc++;
- }
+ int[] scontigs = new int[startcontigs.length];
+ System.arraycopy(startcontigs, 0, scontigs, 0, startcontigs.length);
// allocate a roughly sized buffer for the protein sequence
StringBuilder protein = new StringBuilder(seqstring.length() / 2);
else
{
int screenY = 0;
- int blockStart = startRes;
- int blockEnd = endRes;
+ int blockStart;
+ int blockEnd;
HiddenColumns hidden = av.getAlignment().getHiddenColumns();
VisibleBlocksVisBoundsIterator regions = (VisibleBlocksVisBoundsIterator) hidden
private List<int[]> localHidden = new ArrayList<>();
- private int lasthiddenregion;
+ private int nexthiddenregion;
VisibleColsIterator(int firstcol, int lastcol, boolean useCopy)
{
last = lastcol;
current = firstcol;
next = firstcol;
- lasthiddenregion = -1;
+ nexthiddenregion = 0;
try
{
{
int i = 0;
for (i = 0; i < hiddenColumns.size()
- && (current < hiddenColumns.get(i)[0]); ++i)
+ && (current <= hiddenColumns.get(i)[0]); ++i)
{
if (current >= hiddenColumns.get(i)[0]
&& current <= hiddenColumns.get(i)[1])
// current is hidden, move to right
current = hiddenColumns.get(i)[1] + 1;
next = current;
+ nexthiddenregion = i + 1;
}
}
- lasthiddenregion = i - 1;
-
for (i = hiddenColumns.size() - 1; i >= 0
- && (last > hiddenColumns.get(i)[1]); --i)
+ && (last >= hiddenColumns.get(i)[1]); --i)
{
if (last >= hiddenColumns.get(i)[0]
&& last <= hiddenColumns.get(i)[1])
}
// make a local copy of the bit we need
- i = lasthiddenregion + 1;
+ i = nexthiddenregion;
while (i < hiddenColumns.size()
&& hiddenColumns.get(i)[0] <= last)
{
localHidden.add(region);
i++;
}
- lasthiddenregion = -1;
}
} finally
{
}
current = next;
if ((localHidden != null)
- && (lasthiddenregion + 1 < localHidden.size()))
+ && (nexthiddenregion < localHidden.size()))
{
// still some more hidden regions
- if (next + 1 < localHidden.get(lasthiddenregion + 1)[0])
+ if (next + 1 < localHidden.get(nexthiddenregion)[0])
{
// next+1 is still before the next hidden region
next++;
}
- else if ((next + 1 >= localHidden.get(lasthiddenregion + 1)[0])
- && (next + 1 <= localHidden.get(lasthiddenregion + 1)[1]))
+ else if ((next + 1 >= localHidden.get(nexthiddenregion)[0])
+ && (next + 1 <= localHidden.get(nexthiddenregion)[1]))
{
// next + 1 is in the next hidden region
- next = localHidden.get(lasthiddenregion + 1)[1] + 1;
- lasthiddenregion++;
+ next = localHidden.get(nexthiddenregion)[1] + 1;
+ nexthiddenregion++;
}
}
else
int blockEnd = end;
int hiddenSoFar = 0;
int visSoFar = 0;
- int maxVisible = end - start;
endsAtHidden = false;
// iterate until a region begins within (start,end]
i++;
}
- if (visSoFar < maxVisible)
+ if (visSoFar < end - start)
{
- blockEnd = blockStart + maxVisible - visSoFar;
+ blockEnd = blockStart + end - start - visSoFar;
int[] contig = new int[] { blockStart, blockEnd };
vcontigs.add(contig);
else
{
int screenY = 0;
- int blockStart = startRes;
- int blockEnd = endRes;
+ int blockStart;
+ int blockEnd;
HiddenColumns hidden = av.getAlignment().getHiddenColumns();
VisibleBlocksVisBoundsIterator regions = (VisibleBlocksVisBoundsIterator) hidden
{
// package into blocks of visible columns
int screenY = 0;
- int blockStart = startRes;
- int blockEnd = endRes;
+ int blockStart;
+ int blockEnd;
HiddenColumns hidden = av.getAlignment().getHiddenColumns();
VisibleBlocksVisBoundsIterator regions = (VisibleBlocksVisBoundsIterator) hidden
int count = 0;
while (it.hasNext())
{
- it.next();
+ int result = it.next();
+ System.out.println(result);
count++;
}
assertTrue(count == 4, "hasNext() is false after 4 iterations");