From: Jim Procter Date: Sun, 19 Jun 2016 07:29:58 +0000 (+0100) Subject: JAL-2110 JAL-2131 JAL-1765 remove reference to jalview.datamodel.Alignment from Align... X-Git-Tag: Release_2_10_0~140^2~5^2~49^2~9 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=36dceb54710feb97a81f4bd69ad051f316141dc3;p=jalview.git JAL-2110 JAL-2131 JAL-1765 remove reference to jalview.datamodel.Alignment from AlignmentI --- diff --git a/src/jalview/analysis/Dna.java b/src/jalview/analysis/Dna.java index be138f3..d1901c3 100644 --- a/src/jalview/analysis/Dna.java +++ b/src/jalview/analysis/Dna.java @@ -69,7 +69,7 @@ public class Dna final private int dnaWidth; - final private Alignment dataset; + final private AlignmentI dataset; /* * Working variables for the translation. diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index ed1c92e..34f8f6e 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -45,7 +45,7 @@ import java.util.Vector; */ public class Alignment implements AlignmentI { - protected Alignment dataset; + private Alignment dataset; protected List sequences; @@ -987,7 +987,7 @@ public class Alignment implements AlignmentI } @Override - public void setDataset(Alignment data) + public void setDataset(AlignmentI data) { if (dataset == null && data == null) { @@ -995,7 +995,12 @@ public class Alignment implements AlignmentI } else if (dataset == null && data != null) { - dataset = data; + if (!(data instanceof Alignment)) + { + throw new Error( + "Implementation Error: jalview.datamodel.Alignment does not yet support other implementations of AlignmentI as its dataset reference"); + } + dataset = (Alignment) data; for (int i = 0; i < getHeight(); i++) { SequenceI currentSeq = getSequenceAt(i); diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 4ae8ba2..f1238ff 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -305,7 +305,7 @@ public interface AlignmentI extends AnnotatedCollectionI * @return Alignment containing dataset sequences or null of this is a * dataset. */ - Alignment getDataset(); + AlignmentI getDataset(); /** * Set the associated dataset for the alignment, or create one. @@ -313,7 +313,7 @@ public interface AlignmentI extends AnnotatedCollectionI * @param dataset * The dataset alignment or null to construct one. */ - void setDataset(Alignment dataset); + void setDataset(AlignmentI dataset); /** * pads sequences with gaps (to ensure the set looks like an alignment) diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index a3604d6..dfd2119 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -2697,7 +2697,7 @@ public class Jalview2XML SequenceI[] orderedSeqs = tmpseqs .toArray(new SequenceI[tmpseqs.size()]); - Alignment al = new Alignment(orderedSeqs); + AlignmentI al = new Alignment(orderedSeqs); // / Add the alignment properties for (int i = 0; i < vamsasSet.getSequenceSetPropertiesCount(); i++) @@ -4076,7 +4076,7 @@ public class Jalview2XML } AlignFrame loadViewport(String file, JSeq[] JSEQ, - List hiddenSeqs, Alignment al, + List hiddenSeqs, AlignmentI al, JalviewModelSequence jms, Viewport view, String uniqueSeqSetId, String viewId, List autoAlan) { @@ -4415,7 +4415,7 @@ public class Jalview2XML } private ColourSchemeI constructAnnotationColour( - AnnotationColours viewAnnColour, AlignFrame af, Alignment al, + AnnotationColours viewAnnColour, AlignFrame af, AlignmentI al, JalviewModelSequence jms, boolean checkGroupAnnColour) { boolean propagateAnnColour = false; @@ -4539,7 +4539,7 @@ public class Jalview2XML return cs; } - private void reorderAutoannotation(AlignFrame af, Alignment al, + private void reorderAutoannotation(AlignFrame af, AlignmentI al, List autoAlan) { // copy over visualization settings for autocalculated annotation in the @@ -4694,10 +4694,11 @@ public class Jalview2XML } } - private void recoverDatasetFor(SequenceSet vamsasSet, Alignment al, + private void recoverDatasetFor(SequenceSet vamsasSet, AlignmentI al, boolean ignoreUnrefed) { - jalview.datamodel.Alignment ds = getDatasetFor(vamsasSet.getDatasetId()); + jalview.datamodel.AlignmentI ds = getDatasetFor(vamsasSet + .getDatasetId()); Vector dseqs = null; if (ds == null) { @@ -4847,15 +4848,15 @@ public class Jalview2XML * TODO use AlignmentI here and in related methods - needs * AlignmentI.getDataset() changed to return AlignmentI instead of Alignment */ - Hashtable datasetIds = null; + Hashtable datasetIds = null; - IdentityHashMap dataset2Ids = null; + IdentityHashMap dataset2Ids = null; - private Alignment getDatasetFor(String datasetId) + private AlignmentI getDatasetFor(String datasetId) { if (datasetIds == null) { - datasetIds = new Hashtable(); + datasetIds = new Hashtable(); return null; } if (datasetIds.containsKey(datasetId)) @@ -4865,11 +4866,11 @@ public class Jalview2XML return null; } - private void addDatasetRef(String datasetId, Alignment dataset) + private void addDatasetRef(String datasetId, AlignmentI dataset) { if (datasetIds == null) { - datasetIds = new Hashtable(); + datasetIds = new Hashtable(); } datasetIds.put(datasetId, dataset); } @@ -4880,7 +4881,7 @@ public class Jalview2XML * @param dataset * @return */ - private String getDatasetIdRef(Alignment dataset) + private String getDatasetIdRef(AlignmentI dataset) { if (dataset.getDataset() != null) { @@ -4892,7 +4893,7 @@ public class Jalview2XML // make a new datasetId and record it if (dataset2Ids == null) { - dataset2Ids = new IdentityHashMap(); + dataset2Ids = new IdentityHashMap(); } else { diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index 47add28..2b09eb6 100644 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -21,6 +21,7 @@ package jalview.gui; import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; import jalview.datamodel.ColumnSelection; import jalview.datamodel.SeqCigar; @@ -383,8 +384,8 @@ public class PCAPanel extends GPCAPanel implements Runnable, { // AlignmentOrder origorder = new AlignmentOrder(alAndColsel[0]); - Alignment al = new Alignment((SequenceI[]) alAndColsel[0]); - Alignment dataset = (av != null && av.getAlignment() != null) ? av + AlignmentI al = new Alignment((SequenceI[]) alAndColsel[0]); + AlignmentI dataset = (av != null && av.getAlignment() != null) ? av .getAlignment().getDataset() : null; if (dataset != null) { diff --git a/src/jalview/gui/TreePanel.java b/src/jalview/gui/TreePanel.java index d78350d..fafa610 100755 --- a/src/jalview/gui/TreePanel.java +++ b/src/jalview/gui/TreePanel.java @@ -520,8 +520,8 @@ public class TreePanel extends GTreePanel { // AlignmentOrder origorder = new AlignmentOrder(alAndColsel[0]); - Alignment al = new Alignment((SequenceI[]) alAndColsel[0]); - Alignment dataset = (av != null && av.getAlignment() != null) ? av + AlignmentI al = new Alignment((SequenceI[]) alAndColsel[0]); + AlignmentI dataset = (av != null && av.getAlignment() != null) ? av .getAlignment().getDataset() : null; if (dataset != null) { diff --git a/src/jalview/ws/jws1/MsaWSClient.java b/src/jalview/ws/jws1/MsaWSClient.java index 95f5527..aad72b1 100644 --- a/src/jalview/ws/jws1/MsaWSClient.java +++ b/src/jalview/ws/jws1/MsaWSClient.java @@ -20,7 +20,7 @@ */ package jalview.ws.jws1; -import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; import jalview.gui.AlignFrame; import jalview.gui.Desktop; @@ -34,7 +34,6 @@ import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JOptionPane; -import ext.vamsas.MuscleWS; import ext.vamsas.MuscleWSServiceLocator; import ext.vamsas.MuscleWSSoapBindingStub; import ext.vamsas.ServiceHandle; @@ -72,7 +71,7 @@ public class MsaWSClient extends WS1Client public MsaWSClient(ext.vamsas.ServiceHandle sh, String altitle, jalview.datamodel.AlignmentView msa, boolean submitGaps, - boolean preserveOrder, Alignment seqdataset, + boolean preserveOrder, AlignmentI seqdataset, AlignFrame _alignFrame) { super(); @@ -109,7 +108,7 @@ public class MsaWSClient extends WS1Client } private void startMsaWSClient(String altitle, AlignmentView msa, - boolean submitGaps, boolean preserveOrder, Alignment seqdataset) + boolean submitGaps, boolean preserveOrder, AlignmentI seqdataset) { if (!locateWebService()) { @@ -159,7 +158,7 @@ public class MsaWSClient extends WS1Client try { - this.server = (MuscleWS) loc.getMuscleWS(new java.net.URL(WsURL)); + this.server = loc.getMuscleWS(new java.net.URL(WsURL)); ((MuscleWSSoapBindingStub) this.server).setTimeout(60000); // One minute // timeout } catch (Exception ex) @@ -201,6 +200,7 @@ public class MsaWSClient extends WS1Client return (WebServiceName.indexOf("lustal") > -1); // cheat! } + @Override public void attachWSMenuEntry(JMenu msawsmenu, final ServiceHandle serviceHandle, final AlignFrame alignFrame) { @@ -209,6 +209,7 @@ public class MsaWSClient extends WS1Client method.setToolTipText(WsURL); method.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { AlignmentView msa = alignFrame.gatherSequencesForAlignment(); @@ -228,6 +229,7 @@ public class MsaWSClient extends WS1Client methodR.setToolTipText(WsURL); methodR.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { AlignmentView msa = alignFrame.gatherSequencesForAlignment(); diff --git a/src/jalview/ws/jws1/MsaWSThread.java b/src/jalview/ws/jws1/MsaWSThread.java index be21de7..3fd7c5a 100644 --- a/src/jalview/ws/jws1/MsaWSThread.java +++ b/src/jalview/ws/jws1/MsaWSThread.java @@ -23,6 +23,7 @@ package jalview.ws.jws1; import jalview.analysis.AlignSeq; import jalview.bin.Cache; import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentOrder; import jalview.datamodel.AlignmentView; import jalview.datamodel.ColumnSelection; @@ -147,6 +148,7 @@ class MsaWSThread extends JWS1Thread implements WSClientI * * @return true if getAlignment will return a valid alignment result. */ + @Override public boolean hasResults() { if (subjobComplete && result != null && result.isFinished() @@ -273,6 +275,7 @@ class MsaWSThread extends JWS1Thread implements WSClientI * * @return boolean true if job can be submitted. */ + @Override public boolean hasValidInput() { if (seqs.getSeqs() != null) @@ -285,7 +288,7 @@ class MsaWSThread extends JWS1Thread implements WSClientI String alTitle; // name which will be used to form new alignment window. - Alignment dataset; // dataset to which the new alignment will be + AlignmentI dataset; // dataset to which the new alignment will be // associated. @@ -327,7 +330,7 @@ class MsaWSThread extends JWS1Thread implements WSClientI MsaWSThread(ext.vamsas.MuscleWS server, String wsUrl, WebserviceInfo wsinfo, jalview.gui.AlignFrame alFrame, String wsname, String title, AlignmentView _msa, boolean subgaps, - boolean presorder, Alignment seqset) + boolean presorder, AlignmentI seqset) { this(server, wsUrl, wsinfo, alFrame, _msa, wsname, subgaps, presorder); OutputHeader = wsInfo.getProgressText(); @@ -359,11 +362,13 @@ class MsaWSThread extends JWS1Thread implements WSClientI } } + @Override public boolean isCancellable() { return true; } + @Override public void cancelJob() { if (!jobComplete && jobs != null) @@ -430,11 +435,13 @@ class MsaWSThread extends JWS1Thread implements WSClientI } } + @Override public void pollJob(AWsJob job) throws Exception { ((MsaWSJob) job).result = server.getResult(((MsaWSJob) job).getJobId()); } + @Override public void StartJob(AWsJob job) { if (!(job instanceof MsaWSJob)) @@ -521,6 +528,7 @@ class MsaWSThread extends JWS1Thread implements WSClientI return msa; } + @Override public void parseResult() { int results = 0; // number of result sets received @@ -571,6 +579,7 @@ class MsaWSThread extends JWS1Thread implements WSClientI wsInfo.showResultsNewFrame .addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(java.awt.event.ActionEvent evt) { displayResults(true); @@ -579,6 +588,7 @@ class MsaWSThread extends JWS1Thread implements WSClientI wsInfo.mergeResults .addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(java.awt.event.ActionEvent evt) { displayResults(false); @@ -661,7 +671,7 @@ class MsaWSThread extends JWS1Thread implements WSClientI while (j < l) { if (((AlignmentOrder) alorders.get(i)) - .equals(((AlignmentOrder) alorders.get(j)))) + .equals((alorders.get(j)))) { alorders.remove(j); l--; @@ -704,6 +714,7 @@ class MsaWSThread extends JWS1Thread implements WSClientI } } + @Override public boolean canMergeResults() { return false; diff --git a/src/jalview/ws/jws1/SeqSearchWSClient.java b/src/jalview/ws/jws1/SeqSearchWSClient.java index d731ced..2d83bf9 100644 --- a/src/jalview/ws/jws1/SeqSearchWSClient.java +++ b/src/jalview/ws/jws1/SeqSearchWSClient.java @@ -20,7 +20,7 @@ */ package jalview.ws.jws1; -import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; import jalview.gui.AlignFrame; import jalview.gui.Desktop; @@ -39,7 +39,6 @@ import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JOptionPane; -import ext.vamsas.SeqSearchI; import ext.vamsas.SeqSearchServiceLocator; import ext.vamsas.SeqSearchServiceSoapBindingStub; import ext.vamsas.ServiceHandle; @@ -77,7 +76,7 @@ public class SeqSearchWSClient extends WS1Client public SeqSearchWSClient(ext.vamsas.ServiceHandle sh, String altitle, jalview.datamodel.AlignmentView msa, String db, - Alignment seqdataset, AlignFrame _alignFrame) + AlignmentI seqdataset, AlignFrame _alignFrame) { super(); alignFrame = _alignFrame; @@ -128,7 +127,7 @@ public class SeqSearchWSClient extends WS1Client } private void startSeqSearchClient(String altitle, AlignmentView msa, - String db, Alignment seqdataset) + String db, AlignmentI seqdataset) { if (!locateWebService()) { @@ -173,7 +172,7 @@ public class SeqSearchWSClient extends WS1Client try { - this.server = (SeqSearchI) loc.getSeqSearchService(new java.net.URL( + this.server = loc.getSeqSearchService(new java.net.URL( WsURL)); ((SeqSearchServiceSoapBindingStub) this.server).setTimeout(60000); // One // minute @@ -241,6 +240,7 @@ public class SeqSearchWSClient extends WS1Client return dbs; } + @Override public void attachWSMenuEntry(JMenu wsmenu, final ServiceHandle sh, final AlignFrame af) { @@ -281,6 +281,7 @@ public class SeqSearchWSClient extends WS1Client method.setToolTipText(sh.getEndpointURL()); method.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { // use same input gatherer as for secondary structure prediction @@ -305,6 +306,7 @@ public class SeqSearchWSClient extends WS1Client final String searchdb = dbs[db]; method.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { AlignmentView msa = af.gatherSeqOrMsaForSecStrPrediction(); diff --git a/src/jalview/ws/jws1/SeqSearchWSThread.java b/src/jalview/ws/jws1/SeqSearchWSThread.java index b2e9b35..86c2b9f 100644 --- a/src/jalview/ws/jws1/SeqSearchWSThread.java +++ b/src/jalview/ws/jws1/SeqSearchWSThread.java @@ -23,6 +23,7 @@ package jalview.ws.jws1; import jalview.analysis.AlignSeq; import jalview.bin.Cache; import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; @@ -171,7 +172,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI * * @return null or { Alignment(+features and annotation), NewickFile)} */ - public Object[] getAlignment(Alignment dataset, + public Object[] getAlignment(AlignmentI dataset, Map featureColours) { @@ -302,7 +303,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI String alTitle; // name which will be used to form new alignment window. - Alignment dataset; // dataset to which the new alignment will be + AlignmentI dataset; // dataset to which the new alignment will be // associated. @@ -344,7 +345,7 @@ class SeqSearchWSThread extends JWS1Thread implements WSClientI SeqSearchWSThread(ext.vamsas.SeqSearchI server, String wsUrl, WebserviceInfo wsinfo, jalview.gui.AlignFrame alFrame, String wsname, String title, AlignmentView _msa, String db, - Alignment seqset) + AlignmentI seqset) { this(server, wsUrl, wsinfo, alFrame, _msa, wsname, db); OutputHeader = wsInfo.getProgressText(); diff --git a/src/jalview/ws/jws2/MsaWSClient.java b/src/jalview/ws/jws2/MsaWSClient.java index c83ef0f..758d941 100644 --- a/src/jalview/ws/jws2/MsaWSClient.java +++ b/src/jalview/ws/jws2/MsaWSClient.java @@ -20,7 +20,7 @@ */ package jalview.ws.jws2; -import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; import jalview.gui.AlignFrame; import jalview.gui.Desktop; @@ -58,7 +58,7 @@ public class MsaWSClient extends Jws2Client public MsaWSClient(Jws2Instance sh, String altitle, jalview.datamodel.AlignmentView msa, boolean submitGaps, - boolean preserveOrder, Alignment seqdataset, + boolean preserveOrder, AlignmentI seqdataset, AlignFrame _alignFrame) { this(sh, null, null, false, altitle, msa, submitGaps, preserveOrder, @@ -68,7 +68,7 @@ public class MsaWSClient extends Jws2Client public MsaWSClient(Jws2Instance sh, WsParamSetI preset, String altitle, jalview.datamodel.AlignmentView msa, boolean submitGaps, - boolean preserveOrder, Alignment seqdataset, + boolean preserveOrder, AlignmentI seqdataset, AlignFrame _alignFrame) { this(sh, preset, null, false, altitle, msa, submitGaps, preserveOrder, @@ -95,7 +95,7 @@ public class MsaWSClient extends Jws2Client public MsaWSClient(Jws2Instance sh, WsParamSetI preset, List arguments, boolean editParams, String altitle, jalview.datamodel.AlignmentView msa, boolean submitGaps, - boolean preserveOrder, Alignment seqdataset, + boolean preserveOrder, AlignmentI seqdataset, AlignFrame _alignFrame) { super(_alignFrame, preset, arguments); @@ -138,7 +138,7 @@ public class MsaWSClient extends Jws2Client } private void startMsaWSClient(String altitle, AlignmentView msa, - boolean submitGaps, boolean preserveOrder, Alignment seqdataset) + boolean submitGaps, boolean preserveOrder, AlignmentI seqdataset) { // if (!locateWebService()) // { diff --git a/src/jalview/ws/jws2/MsaWSThread.java b/src/jalview/ws/jws2/MsaWSThread.java index e2f3a7c..bfae384 100644 --- a/src/jalview/ws/jws2/MsaWSThread.java +++ b/src/jalview/ws/jws2/MsaWSThread.java @@ -176,6 +176,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI * * @return true if getAlignment will return a valid alignment result. */ + @Override public boolean hasResults() { if (subjobComplete @@ -316,6 +317,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI * * @return boolean true if job can be submitted. */ + @Override public boolean hasValidInput() { // TODO: get attributes for this MsaWS instance to check if it can do two @@ -436,7 +438,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI String alTitle; // name which will be used to form new alignment window. - Alignment dataset; // dataset to which the new alignment will be + AlignmentI dataset; // dataset to which the new alignment will be // associated. @@ -479,7 +481,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI String wsUrl, WebserviceInfo wsinfo, jalview.gui.AlignFrame alFrame, String wsname, String title, AlignmentView _msa, boolean subgaps, boolean presorder, - Alignment seqset) + AlignmentI seqset) { this(server2, wsUrl, wsinfo, alFrame, _msa, wsname, subgaps, presorder); OutputHeader = wsInfo.getProgressText(); @@ -530,11 +532,13 @@ class MsaWSThread extends AWS2Thread implements WSClientI return validInput; } + @Override public boolean isCancellable() { return true; } + @Override public void cancelJob() { if (!jobComplete && jobs != null) @@ -605,6 +609,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI } } + @Override public void pollJob(AWsJob job) throws Exception { // TODO: investigate if we still need to cast here in J1.6 @@ -650,6 +655,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI return changed; } + @Override public void StartJob(AWsJob job) { Exception lex = null; @@ -775,6 +781,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI } } + @Override public void parseResult() { long progbar = System.currentTimeMillis(); @@ -889,6 +896,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI wsInfo.showResultsNewFrame .addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(java.awt.event.ActionEvent evt) { displayResults(true); @@ -897,6 +905,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI wsInfo.mergeResults .addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(java.awt.event.ActionEvent evt) { displayResults(false); @@ -1101,6 +1110,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI } } + @Override public boolean canMergeResults() { return false; diff --git a/test/jalview/datamodel/AlignmentTest.java b/test/jalview/datamodel/AlignmentTest.java index 5a45176..5753e97 100644 --- a/test/jalview/datamodel/AlignmentTest.java +++ b/test/jalview/datamodel/AlignmentTest.java @@ -436,8 +436,7 @@ public class AlignmentTest // TODO promote this method to AlignmentI ((Alignment) protein).createDatasetAlignment(); - // TODO this method should return AlignmentI not Alignment !! - Alignment ds = protein.getDataset(); + AlignmentI ds = protein.getDataset(); // side-effect: dataset created on second sequence assertNotNull(protein.getSequenceAt(1).getDatasetSequence());