From: Mateusz Warowny Date: Wed, 18 Oct 2023 11:39:37 +0000 (+0200) Subject: JAL-1601 Move job class as inner task class X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4988ed19828c905d40e5a69d4a0fdb72f241bcad;p=jalview.git JAL-1601 Move job class as inner task class --- diff --git a/src/jalview/ws2/actions/secstructpred/SecStructPredJob.java b/src/jalview/ws2/actions/secstructpred/SecStructPredJob.java deleted file mode 100644 index 2df2f25..0000000 --- a/src/jalview/ws2/actions/secstructpred/SecStructPredJob.java +++ /dev/null @@ -1,37 +0,0 @@ -package jalview.ws2.actions.secstructpred; - -import java.util.List; -import java.util.Map; - -import jalview.analysis.SeqsetUtils.SequenceInfo; -import jalview.datamodel.SequenceI; -import jalview.ws2.actions.BaseJob; - -public class SecStructPredJob extends BaseJob -{ - private final int[] delMap; - - private final SequenceI refSeq; - - final Map seqNames; - - SecStructPredJob(List sequences, SequenceI refSeq, int[] delMap, - Map seqNames) - { - super(sequences); - this.refSeq = refSeq; - this.delMap = delMap; - this.seqNames = seqNames; - } - - @Override - public boolean isInputValid() - { - 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 b0a924c..fb904a8 100644 --- a/src/jalview/ws2/actions/secstructpred/SecStructPredTask.java +++ b/src/jalview/ws2/actions/secstructpred/SecStructPredTask.java @@ -3,9 +3,11 @@ package jalview.ws2.actions.secstructpred; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Map; import jalview.analysis.AlignmentAnnotationUtils; import jalview.analysis.SeqsetUtils; +import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.api.AlignViewportI; import jalview.bin.Console; import jalview.datamodel.Alignment; @@ -18,7 +20,6 @@ import jalview.datamodel.SequenceI; import jalview.io.AlignFile; import jalview.io.JPredFile; import jalview.io.JnetAnnotationMaker; -import jalview.util.Comparison; import jalview.ws.params.ArgumentI; import jalview.ws2.actions.BaseJob; import jalview.ws2.actions.BaseTask; @@ -27,7 +28,8 @@ 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; @@ -37,8 +39,9 @@ public class SecStructPredTask extends BaseTask private final char gapChar; - SecStructPredTask(SecStructPredWebServiceClientI client, List args, - Credentials credentials, AlignViewportI viewport) + SecStructPredTask(SecStructPredWebServiceClientI client, + List args, Credentials credentials, + AlignViewportI viewport) { super(client, args, credentials); this.client = client; @@ -49,11 +52,12 @@ public class SecStructPredTask extends BaseTask @Override protected List prepareJobs() - throws ServiceInputInvalidException + throws ServiceInputInvalidException { SeqCigar[] msf = alignmentView.getSequences(); SequenceI referenceSeq = msf[0].getSeq('-'); - int[] delMap = alignmentView.getVisibleContigMapFor(referenceSeq.gapMap()); + int[] delMap = alignmentView + .getVisibleContigMapFor(referenceSeq.gapMap()); // TODO: assume MSA for now SequenceI[] sequences = new SequenceI[msf.length]; @@ -65,7 +69,7 @@ public class SecStructPredTask extends BaseTask sequences[i].setSequence(alignmentView.getASequenceString('-', i)); var sequencesList = filterEmptySequences(sequences); var job = new SecStructPredJob(sequencesList, referenceSeq, delMap, - sequenceInfo); + sequenceInfo); job.setStatus(JobStatus.READY); return List.of(job); } @@ -81,28 +85,27 @@ public class SecStructPredTask extends BaseTask @Override protected AlignmentI collectResult(List jobs) - throws IOException + throws IOException { var job = jobs.get(0); // There shouldn't be more than one job var status = job.getStatus(); - Console - .info(String - .format("sec str pred job \"%s\" finished with status %s", - job.getServerJob().getJobId(), status)); + Console.info( + String.format("sec str pred job \"%s\" finished with status %s", + job.getServerJob().getJobId(), status)); if (status != JobStatus.COMPLETED) return null; JPredFile predictionFile = client.getPredictionFile(job.getServerJob()); AlignFile alignmentFile = client.getAlignmentFile(job.getServerJob()); Object[] alnAndHiddenCols = alignmentView - .getAlignmentAndHiddenColumns(gapChar); + .getAlignmentAndHiddenColumns(gapChar); Alignment aln = new Alignment((SequenceI[]) alnAndHiddenCols[0]); aln.setDataset(currentView.getDataset()); aln.setHiddenColumns((HiddenColumns) alnAndHiddenCols[1]); try { - JnetAnnotationMaker - .add_annotation(predictionFile, aln, 0, false, job.getDelMap()); + JnetAnnotationMaker.add_annotation(predictionFile, aln, 0, false, + job.getDelMap()); } catch (Exception e) { throw new IOException(e); @@ -112,13 +115,41 @@ public class SecStructPredTask extends BaseTask { if (alnAnnot.sequenceRef != null) { - AlignmentAnnotationUtils - .replaceAnnotationOnAlignmentWith(alnAnnot, alnAnnot.label, - getClass().getSimpleName()); + AlignmentAnnotationUtils.replaceAnnotationOnAlignmentWith(alnAnnot, + alnAnnot.label, getClass().getSimpleName()); } } aln.setSeqrep(aln.getSequenceAt(0)); return aln; } + public static class SecStructPredJob extends BaseJob + { + private final int[] delMap; + + private final SequenceI refSeq; + + final Map seqNames; + + SecStructPredJob(List sequences, SequenceI refSeq, + int[] delMap, Map seqNames) + { + super(sequences); + this.refSeq = refSeq; + this.delMap = delMap; + this.seqNames = seqNames; + } + + @Override + public boolean isInputValid() + { + return true; + } + + public int[] getDelMap() + { + return this.delMap; + } + } + }