From: Jim Procter Date: Mon, 17 Nov 2014 14:41:56 +0000 (+0000) Subject: JAL-1587 propagate JPred annotation from legacy jpred service to the dataset X-Git-Tag: Jalview_2_9~149^2~7 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5c3e1272c6bf1e145a65050c0cc73737eee788b5;p=jalview.git JAL-1587 propagate JPred annotation from legacy jpred service to the dataset --- 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