From 5bf9dbf63ff6ea586fd92ca01b6b24be6b39421d Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Mon, 16 Oct 2023 17:41:52 +0200 Subject: [PATCH] JAL-1601 Propagate representative sequence to the final output alignment --- .../actions/secstructpred/SecStructPredJob.java | 5 ++++ .../actions/secstructpred/SecStructPredTask.java | 27 +++++++++++--------- src/jalview/ws2/gui/SearchServiceGuiHandler.java | 6 +++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/jalview/ws2/actions/secstructpred/SecStructPredJob.java b/src/jalview/ws2/actions/secstructpred/SecStructPredJob.java index 506b8a5..2df2f25 100644 --- a/src/jalview/ws2/actions/secstructpred/SecStructPredJob.java +++ b/src/jalview/ws2/actions/secstructpred/SecStructPredJob.java @@ -29,4 +29,9 @@ public class SecStructPredJob extends BaseJob { return true; } + + public int[] getDelMap() + { + return this.delMap; + } } diff --git a/src/jalview/ws2/actions/secstructpred/SecStructPredTask.java b/src/jalview/ws2/actions/secstructpred/SecStructPredTask.java index 1c53904..cf6ef73 100644 --- a/src/jalview/ws2/actions/secstructpred/SecStructPredTask.java +++ b/src/jalview/ws2/actions/secstructpred/SecStructPredTask.java @@ -12,6 +12,7 @@ import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; +import jalview.datamodel.HiddenColumns; import jalview.datamodel.SeqCigar; import jalview.datamodel.SequenceI; import jalview.io.AlignFile; @@ -26,7 +27,7 @@ import jalview.ws2.api.Credentials; import jalview.ws2.api.JobStatus; import jalview.ws2.client.api.SecStructPredWebServiceClientI; -public class SecStructPredTask extends BaseTask +public class SecStructPredTask extends BaseTask { private final SecStructPredWebServiceClientI client; @@ -47,7 +48,8 @@ public class SecStructPredTask extends BaseTask } @Override - protected List prepareJobs() throws ServiceInputInvalidException + protected List prepareJobs() + throws ServiceInputInvalidException { SeqCigar[] msf = alignmentView.getSequences(); SequenceI referenceSeq = msf[0].getSeq('-'); @@ -78,7 +80,8 @@ public class SecStructPredTask extends BaseTask } @Override - protected AlignmentI collectResult(List jobs) throws IOException + protected AlignmentI collectResult(List jobs) + throws IOException { var job = jobs.get(0); // There shouldn't be more than one job var status = job.getStatus(); @@ -90,17 +93,17 @@ public class SecStructPredTask extends BaseTask return null; JPredFile predictionFile = client.getPredictionFile(job.getServerJob()); AlignFile alignmentFile = client.getAlignmentFile(job.getServerJob()); - // Object[] alnAndHiddenCols = - // alignmentView.getAlignmentAndHiddenColumns(gapChar); - // SequenceI[] sequences = (SequenceI[]) alnAndHiddenCols[0]; - var sequences = alignmentFile.getSeqsAsArray(); - // HiddenColumns hiddenCols = (HiddenColumns) alnAndHiddenCols[1]; - var aln = new Alignment(sequences); - int firstSeq = 0; + + Object[] alnAndHiddenCols = alignmentView + .getAlignmentAndHiddenColumns(gapChar); + SequenceI[] sequences = (SequenceI[]) alnAndHiddenCols[0]; + Alignment aln = new Alignment(sequences); + HiddenColumns alhidden = (HiddenColumns) alnAndHiddenCols[1]; aln.setDataset(currentView.getDataset()); try { - JnetAnnotationMaker.add_annotation(predictionFile, aln, firstSeq, false); + JnetAnnotationMaker + .add_annotation(predictionFile, aln, 0, false, job.getDelMap()); } catch (Exception e) { throw new IOException(e); @@ -115,7 +118,7 @@ public class SecStructPredTask extends BaseTask getClass().getSimpleName()); } } - aln.setSeqrep(aln.getSequenceAt(firstSeq)); + aln.setSeqrep(aln.getSequenceAt(0)); return aln; } diff --git a/src/jalview/ws2/gui/SearchServiceGuiHandler.java b/src/jalview/ws2/gui/SearchServiceGuiHandler.java index 49df466..a57db1d 100644 --- a/src/jalview/ws2/gui/SearchServiceGuiHandler.java +++ b/src/jalview/ws2/gui/SearchServiceGuiHandler.java @@ -142,6 +142,12 @@ class SearchServiceGuiHandler implements TaskEventListener alnCpy.setDataset(result.getDataset()); for (AlignmentAnnotation annotation : result.getAlignmentAnnotation()) alnCpy.addAnnotation(new AlignmentAnnotation(annotation)); + if (result.hasSeqrep()) + { + int idx = result.findIndex(result.getSeqrep()); + if (idx >= 0) + alnCpy.setSeqrep(alnCpy.getSequenceAt(idx)); + } displayResultsNewFrame(alnCpy); }); SwingUtilities.invokeLater(infoPanel::setResultsReady); -- 1.7.10.2