From 5c3e1272c6bf1e145a65050c0cc73737eee788b5 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 17 Nov 2014 14:41:56 +0000 Subject: [PATCH] JAL-1587 propagate JPred annotation from legacy jpred service to the dataset --- src/jalview/ws/jws1/JPredThread.java | 60 ++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/src/jalview/ws/jws1/JPredThread.java b/src/jalview/ws/jws1/JPredThread.java index 85969fc..dc245ae 100644 --- a/src/jalview/ws/jws1/JPredThread.java +++ b/src/jalview/ws/jws1/JPredThread.java @@ -144,8 +144,15 @@ class JPredThread extends JWS1Thread implements WSClientI } } FirstSeq = 0; - al.setDataset(null); + if (currentView.getDataset() != null) + { + al.setDataset(currentView.getDataset()); + } + else + { + al.setDataset(null); + } jalview.io.JnetAnnotationMaker.add_annotation(prediction, al, FirstSeq, false, predMap); @@ -187,7 +194,15 @@ class JPredThread extends JWS1Thread implements WSClientI } else { - al.setDataset(null); + if (currentView.getDataset() != null) + { + al.setDataset(currentView.getDataset()); + + } + else + { + al.setDataset(null); + } jalview.io.JnetAnnotationMaker.add_annotation(prediction, al, FirstSeq, true, predMap); SequenceI profileseq = al.getSequenceAt(0); // this includes any gaps. @@ -201,11 +216,52 @@ class JPredThread extends JWS1Thread implements WSClientI } } } + // transfer to dataset + for (AlignmentAnnotation alant : al.getAlignmentAnnotation()) + { + if (alant.sequenceRef != null) + { + replaceAnnotationOnAlignmentWith(alant, alant.label, + "jalview.jws1.Jpred", alant.sequenceRef); + } + } return new Object[] { al, alcsel }; // , FirstSeq, noMsa}; } /** + * copied from JabawsCalcWorker + * + * @param newAnnot + * @param typeName + * @param calcId + * @param aSeq + */ + protected 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 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(); + } + + /** * Given an alignment where all other sequences except profileseq are * aligned to the ungapped profileseq, insert gaps in the other sequences to * realign them with the residues in profileseq -- 1.7.10.2