+ private void prepareJobResult(JPredJob job) throws Exception
+ {
+ HiddenColumns hiddenCols = null;
+ int firstSeq = -1;
+ AlignmentI alignment;
+ var prediction = server.getPrediction(job.getJobHandle());
+ var preds = prediction.getSeqsAsArray();
+
+ if (job.delMap != null)
+ {
+ Object[] alandcolsel = input
+ .getAlignmentAndHiddenColumns(getGapChar());
+ alignment = new Alignment((SequenceI[]) alandcolsel[0]);
+ hiddenCols = (HiddenColumns) alandcolsel[1];
+ }
+ else
+ {
+ alignment = server.getAlignment(job.getJobHandle());
+ var seqs = new SequenceI[alignment.getHeight()];
+ for (int i = 0; i < alignment.getHeight(); i++)
+ {
+ seqs[i] = alignment.getSequenceAt(i);
+ }
+ if (!SeqsetUtils.deuniquify(sequenceInfo, seqs))
+ {
+ throw (new Exception(MessageManager.getString(
+ "exception.couldnt_recover_sequence_properties_for_alignment")));
+ }
+ }
+ firstSeq = 0;
+ if (currentView.getDataset() != null)
+ {
+ alignment.setDataset(currentView.getDataset());
+ }
+ else
+ {
+ alignment.setDataset(null);
+ }
+ JnetAnnotationMaker.add_annotation(prediction, alignment, firstSeq, false,
+ job.delMap);
+
+ for (var annot : alignment.getAlignmentAnnotation())
+ {
+ if (annot.sequenceRef != null)
+ {
+ replaceAnnotationOnAlignmentWith(annot, annot.label,
+ "jalview.ws.JPred", annot.sequenceRef);
+ }
+ }
+ job.alignment = alignment;
+ job.hiddenCols = hiddenCols;
+ }
+
+ private static void replaceAnnotationOnAlignmentWith(
+ AlignmentAnnotation newAnnot, String typeName, String calcId,
+ SequenceI aSeq)
+ {
+ SequenceI dsseq = aSeq.getDatasetSequence();
+ while (dsseq.getDatasetSequence() != null)
+ {
+ dsseq = dsseq.getDatasetSequence();
+ }
+ // look for same annotation on dataset and lift this one over
+ List<AlignmentAnnotation> dsan = dsseq.getAlignmentAnnotations(calcId,
+ typeName);
+ if (dsan != null && dsan.size() > 0)
+ {
+ for (AlignmentAnnotation dssan : dsan)
+ {
+ dsseq.removeAlignmentAnnotation(dssan);
+ }
+ }
+ AlignmentAnnotation dssan = new AlignmentAnnotation(newAnnot);
+ dsseq.addAlignmentAnnotation(dssan);
+ dssan.adjustForAlignment();
+ }