From ca9ab48d85c35112da4d9bf6273a41e734d0872b Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Wed, 6 Oct 2021 18:32:51 +0200 Subject: [PATCH] JAL-3899 Update usages of uniquify and deuniquify. --- src/jalview/datamodel/SeqCigar.java | 3 ++- src/jalview/hmmer/HMMAlign.java | 4 +++- src/jalview/hmmer/HMMBuild.java | 4 +++- src/jalview/hmmer/HmmerCommand.java | 10 ++++++---- src/jalview/hmmer/Search.java | 4 +++- src/jalview/io/packed/JalviewDataset.java | 9 +++++---- src/jalview/ws/AWsJob.java | 3 ++- src/jalview/ws/jws1/JPredClient.java | 14 ++++++++------ src/jalview/ws/jws1/JPredThread.java | 20 +++++++++++--------- src/jalview/ws/jws2/JPredThread.java | 14 ++++++++------ src/jalview/ws/rest/RestJob.java | 3 ++- 11 files changed, 53 insertions(+), 35 deletions(-) diff --git a/src/jalview/datamodel/SeqCigar.java b/src/jalview/datamodel/SeqCigar.java index c2a6a9c..07a62c9 100644 --- a/src/jalview/datamodel/SeqCigar.java +++ b/src/jalview/datamodel/SeqCigar.java @@ -22,6 +22,7 @@ package jalview.datamodel; import jalview.analysis.AlignSeq; import jalview.analysis.SeqsetUtils; +import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.util.MessageManager; import jalview.util.ShiftList; @@ -37,7 +38,7 @@ public class SeqCigar extends CigarSimple private SequenceI refseq = null; - private Hashtable seqProps; + private SequenceInfo seqProps; /** * Reference dataset sequence for the cigar string diff --git a/src/jalview/hmmer/HMMAlign.java b/src/jalview/hmmer/HMMAlign.java index d66ec33..dd85c74 100644 --- a/src/jalview/hmmer/HMMAlign.java +++ b/src/jalview/hmmer/HMMAlign.java @@ -1,6 +1,7 @@ package jalview.hmmer; import jalview.analysis.AlignmentSorter; +import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentOrder; @@ -24,6 +25,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import java.util.Map; import javax.swing.JInternalFrame; @@ -80,7 +82,7 @@ public class HMMAlign extends HmmerCommand int job = 0; for (SequenceI[] seqs : subAlignments) { - Hashtable sequencesHash = stashSequences(seqs); + Map sequencesHash = stashSequences(seqs); try { File modelFile = FileUtils.createTempFile("hmm", ".hmm"); diff --git a/src/jalview/hmmer/HMMBuild.java b/src/jalview/hmmer/HMMBuild.java index 0c47c1d..fa9cd92 100644 --- a/src/jalview/hmmer/HMMBuild.java +++ b/src/jalview/hmmer/HMMBuild.java @@ -1,5 +1,6 @@ package jalview.hmmer; +import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.api.AlignViewportI; import jalview.bin.Cache; import jalview.datamodel.Alignment; @@ -22,6 +23,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import java.util.Map; /** * A class that runs the hmmbuild command as a separate process. @@ -201,7 +203,7 @@ public class HMMBuild extends HmmerCommand // at import level ? SequenceI[] copyArray = copy.toArray(new SequenceI[copy.size()]); - Hashtable sequencesHash = stashSequences(copyArray); + Map sequencesHash = stashSequences(copyArray); exportStockholm(copyArray, alignmentFile, ac); diff --git a/src/jalview/hmmer/HmmerCommand.java b/src/jalview/hmmer/HmmerCommand.java index 0240352..e241008 100644 --- a/src/jalview/hmmer/HmmerCommand.java +++ b/src/jalview/hmmer/HmmerCommand.java @@ -1,6 +1,7 @@ package jalview.hmmer; import jalview.analysis.SeqsetUtils; +import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.bin.Cache; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; @@ -30,6 +31,7 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; +import java.util.Map; /** * Base class for hmmbuild, hmmalign and hmmsearch @@ -127,7 +129,7 @@ public abstract class HmmerCommand implements Runnable * * @param seqs */ - protected Hashtable stashSequences(SequenceI[] seqs) + protected Map stashSequences(SequenceI[] seqs) { return SeqsetUtils.uniquify(seqs, true); } @@ -135,12 +137,12 @@ public abstract class HmmerCommand implements Runnable /** * Restores the sequence data lost by uniquifying * - * @param hashtable + * @param sequencesHash * @param seqs */ - protected void recoverSequences(Hashtable hashtable, SequenceI[] seqs) + protected void recoverSequences(Map sequencesHash, SequenceI[] seqs) { - SeqsetUtils.deuniquify(hashtable, seqs); + SeqsetUtils.deuniquify(sequencesHash, seqs); } /** diff --git a/src/jalview/hmmer/Search.java b/src/jalview/hmmer/Search.java index ceb79e5..6c3a71d 100644 --- a/src/jalview/hmmer/Search.java +++ b/src/jalview/hmmer/Search.java @@ -1,5 +1,6 @@ package jalview.hmmer; +import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; @@ -15,6 +16,7 @@ import java.io.FileReader; import java.io.IOException; import java.util.Hashtable; import java.util.List; +import java.util.Map; import java.util.Scanner; public abstract class Search extends HmmerCommand @@ -34,7 +36,7 @@ public abstract class Search extends HmmerCommand boolean searchAlignment = true; - Hashtable sequencesHash; + Map sequencesHash; public Search(AlignFrame alignFrame, List args) { diff --git a/src/jalview/io/packed/JalviewDataset.java b/src/jalview/io/packed/JalviewDataset.java index 9f84c16..d4047d1 100644 --- a/src/jalview/io/packed/JalviewDataset.java +++ b/src/jalview/io/packed/JalviewDataset.java @@ -20,6 +20,7 @@ */ package jalview.io.packed; +import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.analysis.TreeModel; import jalview.api.FeatureColourI; import jalview.datamodel.AlignmentI; @@ -76,7 +77,7 @@ public class JalviewDataset /** * @return the seqDetails */ - public Hashtable getSeqDetails() + public Map getSeqDetails() { return seqDetails; } @@ -193,7 +194,7 @@ public class JalviewDataset /** * original identity of each sequence in results */ - Hashtable seqDetails; + Map seqDetails; public boolean relaxedIdMatching = false; @@ -211,7 +212,7 @@ public class JalviewDataset * @param parentAlignment */ public JalviewDataset(AlignmentI aldataset, - Map fc, Hashtable seqDets) + Map fc, Map seqDets) { // TODO not used - remove? this(aldataset, fc, seqDets, null); @@ -233,7 +234,7 @@ public class JalviewDataset * with. */ public JalviewDataset(AlignmentI aldataset, - Map fc, Hashtable seqDets, + Map fc, Map seqDets, AlignmentI parentAlignment) { this(); diff --git a/src/jalview/ws/AWsJob.java b/src/jalview/ws/AWsJob.java index 4a9cb74..ed88ea9 100644 --- a/src/jalview/ws/AWsJob.java +++ b/src/jalview/ws/AWsJob.java @@ -20,6 +20,7 @@ */ package jalview.ws; +import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.ws.params.ArgumentI; import jalview.ws.params.WsParamSetI; @@ -156,7 +157,7 @@ public abstract class AWsJob protected List arguments = null; - protected Hashtable SeqNames = new Hashtable(); + protected Hashtable SeqNames = new Hashtable(); public AWsJob() { diff --git a/src/jalview/ws/jws1/JPredClient.java b/src/jalview/ws/jws1/JPredClient.java index 1c625fa..4af83f1 100644 --- a/src/jalview/ws/jws1/JPredClient.java +++ b/src/jalview/ws/jws1/JPredClient.java @@ -21,6 +21,7 @@ package jalview.ws.jws1; import jalview.analysis.AlignSeq; +import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.bin.Cache; import jalview.datamodel.AlignmentView; import jalview.datamodel.SeqCigar; @@ -34,6 +35,7 @@ import jalview.util.MessageManager; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Hashtable; +import java.util.Map; import javax.swing.JMenu; import javax.swing.JMenuItem; @@ -127,8 +129,8 @@ public class JPredClient extends WS1Client aln[i] = msf[i].getSeq('-'); } - Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln, - true); + Map SequenceInfo = + jalview.analysis.SeqsetUtils.uniquify(aln, true); if (viewonly) { // Remove hidden regions from sequence objects. @@ -161,7 +163,7 @@ public class JPredClient extends WS1Client + (viewonly ? "visible " : "") + "sequence " + seq.getName() + " from " + title; String seqname = seq.getName(); - Hashtable SequenceInfo = jalview.analysis.SeqsetUtils + SequenceInfo SequenceInfo = jalview.analysis.SeqsetUtils .SeqCharacterHash(seq); if (viewonly) { @@ -249,8 +251,8 @@ public class JPredClient extends WS1Client aln[i] = new jalview.datamodel.Sequence(msf[i]); } - Hashtable SequenceInfo = jalview.analysis.SeqsetUtils.uniquify(aln, - true); + Map SequenceInfo = + jalview.analysis.SeqsetUtils.uniquify(aln, true); Jpred server = locateWebService(); if (server == null) @@ -278,7 +280,7 @@ public class JPredClient extends WS1Client String altitle = "JPred prediction for sequence " + seq.getName() + " from " + title; - Hashtable SequenceInfo = jalview.analysis.SeqsetUtils + SequenceInfo SequenceInfo = jalview.analysis.SeqsetUtils .SeqCharacterHash(seq); Jpred server = locateWebService(); diff --git a/src/jalview/ws/jws1/JPredThread.java b/src/jalview/ws/jws1/JPredThread.java index 23d9eb0..b7b8e5f 100644 --- a/src/jalview/ws/jws1/JPredThread.java +++ b/src/jalview/ws/jws1/JPredThread.java @@ -22,6 +22,7 @@ package jalview.ws.jws1; import jalview.analysis.AlignSeq; import jalview.analysis.SeqsetUtils; +import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.bin.Cache; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; @@ -47,6 +48,7 @@ import jalview.ws.WSClientI; import java.util.Hashtable; import java.util.List; +import java.util.Map; import vamsas.objects.simple.JpredResult; @@ -66,7 +68,7 @@ class JPredThread extends JWS1Thread implements WSClientI vamsas.objects.simple.Msfalignment msa; - java.util.Hashtable SequenceInfo = null; + Object SequenceInfo = null; int msaIndex = 0; // the position of the original sequence in the array of @@ -156,7 +158,7 @@ class JPredThread extends JWS1Thread implements WSClientI { sqs[i] = al.getSequenceAt(i); } - if (!SeqsetUtils.deuniquify(SequenceInfo, sqs)) + if (!SeqsetUtils.deuniquify((Map)SequenceInfo, sqs)) { throw (new Exception(MessageManager.getString( "exception.couldnt_recover_sequence_properties_for_alignment"))); @@ -211,7 +213,7 @@ class JPredThread extends JWS1Thread implements WSClientI } if (!jalview.analysis.SeqsetUtils.SeqCharacterUnhash( - al.getSequenceAt(FirstSeq), SequenceInfo)) + al.getSequenceAt(FirstSeq), (SequenceInfo)SequenceInfo)) { throw (new Exception(MessageManager.getString( "exception.couldnt_recover_sequence_props_for_jnet_query"))); @@ -332,7 +334,7 @@ class JPredThread extends JWS1Thread implements WSClientI } } - public JPredJob(Hashtable SequenceInfo, SequenceI seq, int[] delMap) + public JPredJob(Object SequenceInfo, SequenceI seq, int[] delMap) { super(); this.predMap = delMap; @@ -351,7 +353,7 @@ class JPredThread extends JWS1Thread implements WSClientI } } - public JPredJob(Hashtable SequenceInfo, SequenceI[] msf, int[] delMap) + public JPredJob(Object SequenceInfo, SequenceI[] msf, int[] delMap) { this(SequenceInfo, msf[0], delMap); if (sequence != null) @@ -387,7 +389,7 @@ class JPredThread extends JWS1Thread implements WSClientI } JPredThread(WebserviceInfo wsinfo, String altitle, - ext.vamsas.Jpred server, String wsurl, Hashtable SequenceInfo, + ext.vamsas.Jpred server, String wsurl, SequenceInfo SequenceInfo, SequenceI seq, int[] delMap, AlignmentView alview, AlignFrame alframe) { @@ -406,9 +408,9 @@ class JPredThread extends JWS1Thread implements WSClientI } JPredThread(WebserviceInfo wsinfo, String altitle, - ext.vamsas.Jpred server, Hashtable SequenceInfo, SequenceI[] msf, - int[] delMap, AlignmentView alview, AlignFrame alframe, - String wsurl) + ext.vamsas.Jpred server, Map SequenceInfo, + SequenceI[] msf, int[] delMap, AlignmentView alview, + AlignFrame alframe, String wsurl) { this(wsinfo, altitle, server, wsurl, alview, alframe); JPredJob job = new JPredJob(SequenceInfo, msf, delMap); diff --git a/src/jalview/ws/jws2/JPredThread.java b/src/jalview/ws/jws2/JPredThread.java index 67f44fa..f4ad8b2 100644 --- a/src/jalview/ws/jws2/JPredThread.java +++ b/src/jalview/ws/jws2/JPredThread.java @@ -4,8 +4,10 @@ import static java.lang.String.format; import java.util.Hashtable; import java.util.List; +import java.util.Map; import jalview.analysis.SeqsetUtils; +import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.bin.Cache; import jalview.commands.RemoveGapsCommand; import jalview.datamodel.Alignment; @@ -34,13 +36,13 @@ public class JPredThread extends AWSThread implements WSClientI private static class JPredJob extends WsJob { - private final Hashtable sequenceInfo; + private final Object sequenceInfo; private final List msf; private final int[] delMap; private AlignmentI alignment = null; private HiddenColumns hiddenCols = null; - private JPredJob(Hashtable sequenceInfo, SequenceI[] msf, int[] delMap) + private JPredJob(Object sequenceInfo, SequenceI[] msf, int[] delMap) { this.sequenceInfo = sequenceInfo; this.msf = List.of(msf); @@ -68,12 +70,12 @@ public class JPredThread extends AWSThread implements WSClientI private JPredServiceI server; private String title; - private Hashtable sequenceInfo; + private Object sequenceInfo; private SequenceI[] msf; private int[] delMap; public JPredThread(WebserviceInfo wsInfo, String title, - JPredServiceI server, Hashtable sequenceInfo, + JPredServiceI server, Object sequenceInfo, SequenceI[] msf, int[] delMap, AlignmentView view, AlignFrame frame, String wsURL) { @@ -261,7 +263,7 @@ public class JPredThread extends AWSThread implements WSClientI { seqs[i] = alignment.getSequenceAt(i); } - if (!SeqsetUtils.deuniquify(sequenceInfo, seqs)) + if (!SeqsetUtils.deuniquify((Map)sequenceInfo, seqs)) { throw (new Exception(MessageManager.getString( "exception.couldnt_recover_sequence_properties_for_alignment"))); @@ -293,7 +295,7 @@ public class JPredThread extends AWSThread implements WSClientI profileSeq.setSequence(seqs[msaIndex].getSequenceAsString()); } if (!SeqsetUtils.SeqCharacterUnhash( - alignment.getSequenceAt(firstSeq), sequenceInfo)) + alignment.getSequenceAt(firstSeq), (SequenceInfo)sequenceInfo)) { throw new Exception(MessageManager.getString( "exception.couldnt_recover_sequence_props_for_jnet_query")); diff --git a/src/jalview/ws/rest/RestJob.java b/src/jalview/ws/rest/RestJob.java index 824af90..67f11c2 100644 --- a/src/jalview/ws/rest/RestJob.java +++ b/src/jalview/ws/rest/RestJob.java @@ -20,6 +20,7 @@ */ package jalview.ws.rest; +import jalview.analysis.SeqsetUtils.SequenceInfo; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentOrder; @@ -52,7 +53,7 @@ public class RestJob extends AWsJob boolean gotresult; - Hashtable squniq; + Map squniq; /** * dataset associated with this input data. -- 1.7.10.2