+ // reset job counter
+ nrj = initnrj;
+ // and finally add in annotation and any trees for each job
+ for (int ncnt = 0; ncnt < contigs.length; ncnt += 2)
+ {
+ if (!hsepjobs)
+ {
+ // single alignment for any job that gets mapped back on to input
+ // data.
+ }
+ else
+ {
+ // each job maps to a single visible contig, and all need to be
+ // stitched back together.
+ if (ncnt > 0)
+ {
+ nrj++;
+ }
+ }
+
+ // merge alignmentAnnotation into one row
+ if (alan[nrj] != null)
+ {
+ for (int an = 0; an < alan[nrj].length; an++)
+ {
+ SequenceI sqass = null;
+ SequenceGroup grass = null;
+ if (alan[nrj][an].sequenceRef != null)
+ {
+ // TODO: ensure this relocates sequence reference to local
+ // context.
+ sqass = getNewSeq(alan[nrj][an].sequenceRef, rseqs[nrj],
+ ordermap[nrj], destAl);
+ }
+ if (alan[nrj][an].groupRef != null)
+ {
+ // TODO: verify relocate group reference to local context
+ // works correctly
+ grass = groupNames.get(alan[nrj][an].groupRef.getName());
+ if (grass == null)
+ {
+ Console.error(
+ "Couldn't relocate group referemce for group "
+ + alan[nrj][an].groupRef.getName());
+ }
+ }
+ if (visAlAn == null)
+ {
+ visAlAn = new ArrayList<AlignmentAnnotation>();
+ }
+ AlignmentAnnotation visan = null;
+ for (AlignmentAnnotation v : visAlAn)
+ {
+ if (v.label != null
+ && v.label.equals(alan[nrj][an].label))
+ {
+ visan = v;
+ }
+ }
+ if (visan == null)
+ {
+ visan = new AlignmentAnnotation(alan[nrj][an]);
+ // copy annotations, and wipe out/update refs.
+ visan.annotations = new Annotation[input.getWidth()];
+ visan.groupRef = grass;
+ visan.sequenceRef = sqass;
+ visAlAn.add(visan);
+ }
+ if (contigs[ncnt]
+ + alan[nrj][an].annotations.length > visan.annotations.length)
+ {
+ // increase width of annotation row
+ Annotation[] newannv = new Annotation[contigs[ncnt]
+ + alan[nrj][an].annotations.length];
+ System.arraycopy(visan.annotations, 0, newannv, 0,
+ visan.annotations.length);
+ visan.annotations = newannv;
+ }
+ // now copy local annotation data into correct position
+ System.arraycopy(alan[nrj][an].annotations, 0,
+ visan.annotations, contigs[ncnt],
+ alan[nrj][an].annotations.length);
+
+ }
+ }
+ // Trees
+ if (trees.get(nrj).size() > 0)
+ {
+ for (NewickFile nf : trees.get(nrj))
+ {
+ // TODO: process each newick file, lifting over sequence refs to
+ // current alignment, if necessary.
+ Console.error(
+ "Tree recovery from restjob not yet implemented.");
+ }
+ }
+ }
+ }
+ } // end of vseps loops.
+ if (visAlAn != null)
+ {
+ for (AlignmentAnnotation v : visAlAn)
+ {
+ destAls.get(als).addAnnotation(v);
+ }
+ }
+ if (visgrps != null)
+ {
+ for (SequenceGroup sg : visgrps)
+ {
+ destAls.get(als).addGroup(sg);