From: BobHanson Date: Sat, 6 Jun 2020 17:23:19 +0000 (-0500) Subject: JAL-3446 adds Jmol viewer embedding. X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8b0617c76b66093a9488b896debab24de4dba6fe;p=jalview.git JAL-3446 adds Jmol viewer embedding. --- diff --git a/doc/JalviewJS-API.md b/doc/JalviewJS-API.md index 0f198d8..3386b2a 100644 --- a/doc/JalviewJS-API.md +++ b/doc/JalviewJS-API.md @@ -1,9 +1,8 @@ ## public interface JalviewJSApi -# full list of available methods: +# full list of available methods (from JalviewLiteJsApi): public boolean addPdbFile(AlignFrame alFrame, String sequenceId, String pdbEntryString, String pdbFile); - public String arrayToSeparatorList(String[] array); public String getAlignment(String format); public String getAlignment(String format, String suffix); public String getAlignmentFrom(AlignFrame alf, String format); @@ -59,7 +58,6 @@ public void select(String sequenceIds, String columns, String sep); public void selectIn(AlignFrame alf, String sequenceIds, String columns); public void selectIn(AlignFrame alf, String sequenceIds, String columns, String sep); - public String[] separatorListToArray(String list); public void setFeatureGroupState(String groups, boolean state); public void setFeatureGroupState(String[] groups, boolean state); public void setFeatureGroupStateOn(AlignFrame alf, String groups, boolean state); @@ -69,6 +67,14 @@ public void showOverview(); public void updateForAnnotations(); +# addition available methods (from JalviewLite): + + public static String getBuildDate() + public static String getInstallation() + public static String getVersion() + + + # proposed alias list: - remove overloaded methods @@ -114,9 +120,6 @@ # unknown methods/shouldn't be in interface? - public String arrayToSeparatorList(String[] array); public Object getFrameForSource(VamsasSource source); - public String getSeparator(); - public String[] separatorListToArray(String list); public void setSeparator(String separator); \ No newline at end of file diff --git a/src/jalview/api/JalviewJSApp.java b/src/jalview/api/JalviewJSApp.java index 879beff..d6c2ec6 100644 --- a/src/jalview/api/JalviewJSApp.java +++ b/src/jalview/api/JalviewJSApp.java @@ -5,7 +5,6 @@ import java.awt.EventQueue; import java.io.IOException; import java.net.URL; import java.util.ArrayList; -import java.util.Hashtable; import java.util.List; import java.util.StringTokenizer; import java.util.Vector; @@ -24,7 +23,6 @@ import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; import jalview.gui.AlignViewport; -import jalview.gui.AlignmentPanel; import jalview.gui.CalculationChooser; import jalview.gui.Desktop; import jalview.gui.StructureViewer; @@ -39,7 +37,6 @@ import jalview.io.IdentifyFile; import jalview.io.JPredFile; import jalview.io.JnetAnnotationMaker; import jalview.io.NewickFile; -import jalview.renderer.seqfeatures.FeatureRenderer; import jalview.structure.SelectionListener; import jalview.structure.SelectionSource; import jalview.structure.StructureSelectionManager; @@ -167,12 +164,6 @@ public class JalviewJSApp implements JalviewJSApi } @Override - public FeatureRenderer getNewFeatureRenderer(AlignViewportI vp) - { - return new jalview.gui.FeatureRenderer((AlignmentPanel) vp); - } - - @Override public Object[] getSelectionForListener(SequenceGroup seqsel, ColumnSelection colsel, HiddenColumns hidden, SelectionSource source, Object alignFrame) @@ -229,6 +220,47 @@ public class JalviewJSApp implements JalviewJSApi } + /** + * @j2sAlias showStructure + */ + @Override + public void showStructure(AlignFrame af, String pdbID, String fileType) { + if (af == null) + af = Jalview.getCurrentAlignFrame(); + PDBEntry pe = null; + SequenceI[] seqs = null; + if (pdbID == null) { + seqs = af.getViewport().getSequenceSelection(); + if (seqs.length == 0) + seqs = af.getViewport().getAlignment().getSequencesArray(); + for (int i = 0; i < seqs.length; i++) { + Vector list = seqs[i].getAllPDBEntries(); + if (list.size() > 0) { + pe = list.get(0); + break; + } + } + } + if (pe == null) { + if (pdbID == null) + return; + pe = new PDBEntry(pdbID, null, fileType); + List list = af.getViewport().getAlignment().getSequences(); + List tmp = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + SequenceI seq = list.get(i); + if (seq.getPDBEntry(pdbID) != null) { + tmp.add(seq); + } + } + seqs = tmp.toArray(new SequenceI[tmp.size()]); + af.alignPanel.selectSequences(tmp); + } + StructureViewer.launchStructureViewer( + af.alignPanel, + pe, seqs); + } + public void newStructureView(AlignFrame af, PDBEntry pdb, SequenceI[] seqs, String[] chains, DataSourceType protocol) { @@ -279,55 +311,42 @@ public class JalviewJSApp implements JalviewJSApi } @Override - public boolean addPdbFile(AlignFrame alf, String sequenceId, - String pdbEntryString, String pdbFile) + public boolean addPdbFile(AlignFrame alf, String sequenceId, String pdbId, + String pdbFile) { if (alf == null) { alf = Jalview.getCurrentAlignFrame(); } - SequenceI toaddpdb = alf.getViewport().getAlignment() - .findName(sequenceId); - boolean needtoadd = false; - if (toaddpdb != null) + SequenceI seq = alf.getViewport().getAlignment().findName(sequenceId); + if (seq != null) { - Vector pdbe = toaddpdb.getAllPDBEntries(); + Vector pdbe = seq.getAllPDBEntries(); PDBEntry pdbentry = null; if (pdbe != null && pdbe.size() > 0) { for (int pe = 0, peSize = pdbe.size(); pe < peSize; pe++) { pdbentry = pdbe.elementAt(pe); - if (!pdbentry.getId().equals(pdbEntryString) - && !pdbentry.getFile().equals(pdbFile)) + if (!pdbentry.getId().equals(pdbId) + || pdbFile != null && !pdbentry.getFile().equals(pdbFile)) { pdbentry = null; } - else - { - continue; - } } } if (pdbentry == null) { - pdbentry = new PDBEntry(); - pdbentry.setId(pdbEntryString); - pdbentry.setFile(pdbFile); - needtoadd = true; // add this new entry to sequence. - } - // resolve data source - // TODO: this code should be a refactored to an io package - DataSourceType protocol = AppletFormatAdapter.resolveProtocol(pdbFile, - FileFormat.PDB); - if (protocol == null) - { - return false; - } - if (needtoadd) - { - pdbentry.setProperty("protocol", protocol); - toaddpdb.addPDBId(pdbentry); + pdbentry = new PDBEntry(pdbId, null, pdbFile); + if (pdbFile != null) + { + DataSourceType protocol = AppletFormatAdapter + .resolveProtocol(pdbFile, FileFormat.PDB); + if (protocol == null) + return false; + pdbentry.setProperty("protocol", protocol); + } + seq.addPDBId(pdbentry); alf.alignPanel.getStructureSelectionManager() .registerPDBEntry(pdbentry); } @@ -335,51 +354,51 @@ public class JalviewJSApp implements JalviewJSApi return true; } - @Override - public String arrayToSeparatorList(String[] array) - { - return arrayToSeparatorList(array, separator); - } - - /** - * concatenate the list with separator - * - * @param list - * @param separator - * @return concatenated string - */ - public static String arrayToSeparatorList(String[] list, String separator) - { - // TODO use StringUtils version - StringBuffer v = new StringBuffer(); - if (list != null && list.length > 0) - { - for (int i = 0, iSize = list.length; i < iSize; i++) - { - if (list[i] != null) - { - if (i > 0) - { - v.append(separator); - } - v.append(list[i]); - } - } - // if (debug) - // { - // System.err - // .println("Returning '" + separator + "' separated List:\n"); - // System.err.println(v); - // } - return v.toString(); - } - // if (debug) - // { - // System.err.println( - // "Returning empty '" + separator + "' separated List\n"); - // } - return "" + separator; - } +// @Override +// public String arrayToSeparatorList(String[] array) +// { +// return arrayToSeparatorList(array, separator); +// } + +// /** +// * concatenate the list with separator +// * +// * @param list +// * @param separator +// * @return concatenated string +// */ +// public static String arrayToSeparatorList(String[] list, String separator) +// { +// // TODO use StringUtils version +// StringBuffer v = new StringBuffer(); +// if (list != null && list.length > 0) +// { +// for (int i = 0, iSize = list.length; i < iSize; i++) +// { +// if (list[i] != null) +// { +// if (i > 0) +// { +// v.append(separator); +// } +// v.append(list[i]); +// } +// } +// // if (debug) +// // { +// // System.err +// // .println("Returning '" + separator + "' separated List:\n"); +// // System.err.println(v); +// // } +// return v.toString(); +// } +// // if (debug) +// // { +// // System.err.println( +// // "Returning empty '" + separator + "' separated List\n"); +// // } +// return "" + separator; +// } @Override public String getAlignment(String format) @@ -436,13 +455,7 @@ public class JalviewJSApp implements JalviewJSApi } @Override - public String getAlignmentOrderFrom(AlignFrame alf) - { - return getAlignmentFrom(alf, null); - } - - @Override - public String getAlignmentOrderFrom(AlignFrame alf, String sep) + public String[] getAlignmentOrderFrom(AlignFrame alf) { if (alf == null) { @@ -454,7 +467,7 @@ public class JalviewJSApp implements JalviewJSApi { order[i] = alorder.getSequenceAt(i).getName(); } - return arrayToSeparatorList(order, sep); + return order;// arrayToSeparatorList(order, sep); } @Override @@ -476,35 +489,35 @@ public class JalviewJSApp implements JalviewJSApi } @Override - public String getFeatureGroups() + public String[] getFeatureGroups() { return getFeatureGroupsOn(null); } @Override - public String getFeatureGroupsOfState(boolean visible) + public String[] getFeatureGroupsOfState(boolean visible) { return getFeatureGroupsOfStateOn(null, visible); } @Override - public String getFeatureGroupsOfStateOn(AlignFrame alf, boolean visible) + public String[] getFeatureGroupsOfStateOn(AlignFrame alf, boolean visible) { if (alf == null) { alf = Jalview.getCurrentAlignFrame(); } - return arrayToSeparatorList(alf.getFeatureGroupsOfState(visible)); + return alf.getFeatureGroupsOfState(visible); } @Override - public String getFeatureGroupsOn(AlignFrame alf) + public String[] getFeatureGroupsOn(AlignFrame alf) { if (alf == null) { alf = Jalview.getCurrentAlignFrame(); } - return arrayToSeparatorList(alf.getFeatureGroups()); + return alf.getFeatureGroups(); } @Override @@ -732,14 +745,7 @@ public class JalviewJSApp implements JalviewJSApi cols[0] = "" + (1 + strt) + "-" + (1 + end); } } - return new Object[] { src, setid, arrayToSeparatorList(seqs), - arrayToSeparatorList(cols) }; - } - - @Override - public String getSeparator() - { - return separator; + return new Object[] { src, setid, seqs, cols }; } /** @@ -1275,6 +1281,8 @@ public class JalviewJSApp implements JalviewJSApi } /** + * @j2sAlias openPcaPanel + * * public static method for JalviewJS API to open a PCAPanel without * necessarily using a dialog. * @@ -1294,6 +1302,8 @@ public class JalviewJSApp implements JalviewJSApi } /** + * @j2sAlias openTreePanel + * * Open a new Tree panel on the desktop statically. Params are standard (not * set by Groovy). No dialog is opened. * @@ -1314,22 +1324,22 @@ public class JalviewJSApp implements JalviewJSApi return CalculationChooser.openTreePanel(af, treeType, modelName, null); } + @Override - public String orderAlignmentBy(AlignFrame alf, String order, - String undoName, String sep) + public String orderBy(String[] ids, String undoName) { - if (sep == null || sep.length() == 0) - { - sep = separator; - } - String[] ids = separatorListToArray(order, sep); + return orderAlignmentBy(null, ids, undoName); + } + + @Override + public String orderAlignmentBy(AlignFrame alf, String[] ids, + String undoName) + { + if (alf == null) + alf = Jalview.getCurrentAlignFrame(); SequenceI[] sqs = null; if (ids != null && ids.length > 0) { - if (alf == null) - { - alf = Jalview.getCurrentAlignFrame(); - } jalview.analysis.SequenceIdMatcher matcher = new jalview.analysis.SequenceIdMatcher( alf.getViewport().getAlignment().getSequencesArray()); int s = 0; @@ -1374,19 +1384,6 @@ public class JalviewJSApp implements JalviewJSApi return alf.sortBy(aorder, _undoName) ? "true" : ""; } - @Override - public String orderBy(String order, String undoName) - { - return orderBy(order, undoName, null); - } - - @Override - public String orderBy(String order, String undoName, String sep) - { - return orderAlignmentBy(Jalview.getCurrentAlignFrame(), order, undoName, - sep); - } - /** * Allow an outside entity to initiate the second half of argument parsing * (only). @@ -1769,17 +1766,6 @@ public class JalviewJSApp implements JalviewJSApi } } - // public AlignFrame newViewFrom(AlignFrame alf, String name) - // { - // return (AlignFrame) alf.newView(name, true); - // } - // - @Override - public String[] separatorListToArray(String list) - { - return separatorListToArray(list, separator); - } - @Override public void setFeatureGroupState(String[] groups, boolean state) { @@ -1829,12 +1815,6 @@ public class JalviewJSApp implements JalviewJSApi } @Override - public void setSeparator(String separator) - { - this.separator = separator; - } - - @Override public void showOverview() { Jalview.getCurrentAlignFrame().overviewMenuItem_actionPerformed(null); @@ -2153,7 +2133,7 @@ public class JalviewJSApp implements JalviewJSApi if (seqsel != null && seqsel.getSize() > 0) { // send a valid range, otherwise we send the empty selection - cols = new String[2]; + cols = new String[1]; cols[0] = "" + (1 + strt) + "-" + (1 + end); } ; @@ -2162,8 +2142,7 @@ public class JalviewJSApp implements JalviewJSApi doSendCallback(_listener, new Object[] - { src, setid, arrayToSeparatorList(seqs), - arrayToSeparatorList(cols) }); + { src, setid, seqs, cols }); } public boolean isFor(AlignFrame af, String listener) diff --git a/src/jalview/bin/JalviewJSApi.java b/src/jalview/bin/JalviewJSApi.java index 3f5dba0..0512841 100644 --- a/src/jalview/bin/JalviewJSApi.java +++ b/src/jalview/bin/JalviewJSApi.java @@ -2,7 +2,6 @@ package jalview.bin; import java.io.IOException; import java.net.URL; -import java.util.Hashtable; import jalview.api.AlignViewportI; import jalview.datamodel.ColumnSelection; @@ -34,26 +33,22 @@ public interface JalviewJSApi * - null or specific AlignFrame. This specifies the dataset that * will be searched for a seuqence called sequenceId * @param sequenceId - * - sequenceId within the dataset. - * @param pdbEntryString - * - the short name for the PDB file + * - sequenceId within the dataset or null + * @param pdbId + * - the four-character PDB ID * @param pdbFile - * - pdb file - either a URL or a valid PDB file. - * @return true if binding was as success TODO: consider making an exception - * structure for indicating when PDB parsing or sequenceId location - * fails. + * - pdb file - either a URL or a valid PDB file or null. + * @return true if binding was success */ - public boolean addPdbFile(AlignFrame alFrame, String sequenceId, String pdbEntryString, String pdbFile); - - public String arrayToSeparatorList(String[] array); + public boolean addPdbFile(AlignFrame alFrame, String sequenceId, + String pdbId, String pdbFile); /** * The following public methods may be called externally, eg via javascript in * an HTML page. * *
- * TODO: introduce interface for - * jalview.appletgui.AlignFrame
+ * TODO: introduce interface for jalview.appletgui.AlignFrame
* * Most function arguments are strings, which contain serialised versions of * lists. Lists of things are separated by a separator character - either the @@ -108,7 +103,8 @@ public interface JalviewJSApi * @param suffix * @return */ - public String getAlignmentFrom(AlignFrame alf, String format, String suffix); + public String getAlignmentFrom(AlignFrame alf, String format, + String suffix); /** * get a separator separated list of sequence IDs reflecting the order of the @@ -126,18 +122,7 @@ public interface JalviewJSApi * @param alf * @return */ - public String getAlignmentOrderFrom(AlignFrame alf); - - /** - * get a sep separated list of sequence IDs reflecting the order of the - * alignment in alf - * - * @param alf - * @param sep - * - separator to use - * @return - */ - public String getAlignmentOrderFrom(AlignFrame alf, String sep); + public String[] getAlignmentOrderFrom(AlignFrame alf); /** * get current alignment's annotation as an annotation file @@ -167,7 +152,7 @@ public interface JalviewJSApi * @see jalview.appletgui.AlignFrame#getFeatureGroups(); */ - public String getFeatureGroups(); + public String[] getFeatureGroups(); /** * @param visible @@ -175,7 +160,7 @@ public interface JalviewJSApi * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean); */ - public String getFeatureGroupsOfState(boolean visible); + public String[] getFeatureGroupsOfState(boolean visible); /** * @param alf @@ -184,7 +169,8 @@ public interface JalviewJSApi * @return * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean); */ - public String getFeatureGroupsOfStateOn(AlignFrame alf, boolean visible); + public String[] getFeatureGroupsOfStateOn(AlignFrame alf, + boolean visible); /** * @param alf @@ -192,7 +178,7 @@ public interface JalviewJSApi * @return * @see jalview.appletgui.AlignFrame#getFeatureGroups(); */ - public String getFeatureGroupsOn(AlignFrame alf); + public String[] getFeatureGroupsOn(AlignFrame alf); /** * get the sequence features in the given format (Jalview or GFF); @@ -214,8 +200,6 @@ public interface JalviewJSApi public Object getFrameForSource(VamsasSource source); - public jalview.renderer.seqfeatures.FeatureRenderer getNewFeatureRenderer(AlignViewportI vp); - public String getParameter(String name); /** @@ -248,7 +232,8 @@ public interface JalviewJSApi * current selection */ - public String getSelectedSequencesAsAlignment(String format, String suffix); + public String getSelectedSequencesAsAlignment(String format, + String suffix); /** * get sequences selected in alf and return their alignment in format 'format' @@ -263,7 +248,8 @@ public interface JalviewJSApi * @return selected sequences as flat file or empty string if there was no * current selection */ - public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf, String format, String suffix); + public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf, + String format, String suffix); /** * @param alf @@ -322,15 +308,9 @@ public interface JalviewJSApi */ public SequenceI[] getSelectedSequencesFrom(AlignFrame alf, String sep); - public Object[] getSelectionForListener(SequenceGroup seqsel, ColumnSelection colsel, HiddenColumns hidden, SelectionSource source, Object alignFrame); - - /** - * List separator string - * - * @return the separator - */ - - public String getSeparator(); + public Object[] getSelectionForListener(SequenceGroup seqsel, + ColumnSelection colsel, HiddenColumns hidden, + SelectionSource source, Object alignFrame); public AlignViewportI getViewport(); @@ -345,7 +325,8 @@ public interface JalviewJSApi * column or unaligned sequence position */ - public void highlight(String sequenceId, String position, String alignedPosition); + public void highlight(String sequenceId, String position, + String alignedPosition); /** * @@ -357,7 +338,8 @@ public interface JalviewJSApi * false, blank or something else - indicate if position is an * alignment column or unaligned sequence position */ - public void highlightIn(AlignFrame alf, String sequenceId, String position, String alignedPosition); + public void highlightIn(AlignFrame alf, String sequenceId, + String position, String alignedPosition); /** * @@ -411,38 +393,15 @@ public interface JalviewJSApi * be parsed from the string. * @return true if data parsed as features */ - public boolean loadFeaturesFrom(AlignFrame alf, String features, boolean autoenabledisplay); + public boolean loadFeaturesFrom(AlignFrame alf, String features, + boolean autoenabledisplay); public boolean loadScoreFile(String sScoreFile) throws IOException; public void newFeatureSettings(); - public void newStructureView(PDBEntry pdb, SequenceI[] seqs, String[] chains, DataSourceType protocol); - - /** - * public static method for JalviewJS API to open a PCAPanel without - * necessarily using a dialog. - * - * @param af - * may be null - * @param modelName - * @return the PCAPanel, or the string "label.you_need_at_least_n_sequences" - * if number of sequences selected is inappropriate - */ - public Object openPcaPanel(AlignFrame af, String modelName); - - /** - * Open a new Tree panel on the desktop statically. Params are standard (not - * set by Groovy). No dialog is opened. - * - * @param af - * may be null - * @param treeType - * @param modelName - * @return null, or the string "label.you_need_at_least_n_sequences" if number - * of sequences selected is inappropriate - */ - public Object openTreePanel(AlignFrame af, String treeType, String modelName); + public void newStructureView(PDBEntry pdb, SequenceI[] seqs, + String[] chains, DataSourceType protocol); /// in http://www.jalview.org/examples/jalviewLiteJs.html but missing here @@ -450,41 +409,38 @@ public interface JalviewJSApi // suffix /** - * re-order the given alignment using the given list of sequence IDs separated - * by sep + * re-order the given alignment using the given array of sequence IDs * * @param alf - * @param order - * - sep separated list + * @param ids + * array of sequence IDs * @param undoName * - string to use when referring to ordering action in undo buffer - * @param sep * @return 'true' if alignment was actually reordered. empty string if * alignment did not contain sequences. */ - public String orderAlignmentBy(AlignFrame alf, String order, String undoName, String sep); + String orderAlignmentBy(AlignFrame alf, String[] ids, String undoName); // get a string array from a list /** * re-order the current alignment using the given list of sequence IDs * - * @param order - * - sep separated list + * @param ids + * array of sequence IDs * @param undoName * - string to use when referring to ordering action in undo buffer * @return 'true' if alignment was actually reordered. empty string if * alignment did not contain sequences. */ - public String orderBy(String order, String undoName); + public String orderBy(String[] ids, String undoName); /** * re-order the current alignment using the given list of sequence IDs - * separated by sep * - * @param order - * - sep separated list + * @param ids + * array of sequence IDs * @param undoName * - string to use when referring to ordering action in undo buffer * @param sep @@ -492,15 +448,8 @@ public interface JalviewJSApi * alignment did not contain sequences. */ - public String orderBy(String order, String undoName, String sep); - - /** - * process commandline arguments after the JavaScript application has started - * - * @param args - * @return - */ - public Object parseArguments(String[] args); + // public String orderBy(String[] ids, String undoName, String sep); + // // public boolean getDefaultParameter(String name, boolean def); @@ -536,7 +485,8 @@ public interface JalviewJSApi * @param topRow * @param leftHandColumn */ - public void scrollViewToIn(AlignFrame alf, String topRow, String leftHandColumn); + public void scrollViewToIn(AlignFrame alf, String topRow, + String leftHandColumn); /** * adjust vertical scroll to make the given row the top one for given view @@ -589,9 +539,8 @@ public interface JalviewJSApi * @param sep * separator between toselect fields */ - public void selectIn(AlignFrame alf, String sequenceIds, String columns, String sep); - - public String[] separatorListToArray(String list); + public void selectIn(AlignFrame alf, String sequenceIds, String columns, + String sep); public void setFeatureGroupState(String groups, boolean state); @@ -608,7 +557,8 @@ public interface JalviewJSApi * @see jalview.appletgui.AlignFrame#setFeatureGroupState(java.lang.String[], * boolean); */ - public void setFeatureGroupStateOn(AlignFrame alf, String groups, boolean state); + public void setFeatureGroupStateOn(AlignFrame alf, String groups, + boolean state); public void setSelectionListener(AlignFrame af, String listener); @@ -627,17 +577,46 @@ public interface JalviewJSApi public void setSelectionListener(String listener); + public void updateForAnnotations(); + + // Bob's additions: + /** - * List separator string + * public static method for JalviewJS API to open a PCAPanel without + * necessarily using a dialog. * - * @param separator - * the separator to set. empty string will reset separator to default + * @param af + * may be null + * @param modelName + * @return the PCAPanel, or the string "label.you_need_at_least_n_sequences" + * if number of sequences selected is inappropriate */ + public Object openPcaPanel(AlignFrame af, String modelName); - public void setSeparator(String separator); + /** + * Open a new Tree panel on the desktop statically. Params are standard (not + * set by Groovy). No dialog is opened. + * + * @param af + * may be null + * @param treeType + * @param modelName + * @return null, or the string "label.you_need_at_least_n_sequences" if number + * of sequences selected is inappropriate + */ + public Object openTreePanel(AlignFrame af, String treeType, + String modelName); - public void showOverview(); + /** + * process commandline arguments after the JavaScript application has started + * + * @param args + * @return + */ + public Object parseArguments(String[] args); - public void updateForAnnotations(); + public void showStructure(AlignFrame af, String pdbID, String fileType); + + public void showOverview(); } diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index c4098e2..8d81a34 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -591,7 +591,8 @@ public class Alignment implements AlignmentI, AutoCloseable @Override public SequenceI findName(SequenceI startAfter, String token, boolean b) { - + if (token == null) + return null; int i = 0; SequenceI sq = null; String sqname = null; diff --git a/src/jalview/datamodel/PDBEntry.java b/src/jalview/datamodel/PDBEntry.java index c1dc77c..d39e9f1 100755 --- a/src/jalview/datamodel/PDBEntry.java +++ b/src/jalview/datamodel/PDBEntry.java @@ -21,6 +21,7 @@ package jalview.datamodel; import jalview.util.CaseInsensitiveString; +import jalview.ws.params.InvalidArgumentException; import java.util.Collections; import java.util.Enumeration; @@ -152,6 +153,32 @@ public class PDBEntry { } + /** + * Entry point when file is not known and fileType may be string + * @param pdbId + * @param chain may be null + * @param fileType "pdb", "mmcif", or "bcif"; null defaults to mmcif + */ + public PDBEntry(String pdbId, String chain, String fileType) { + this.id = pdbId.toLowerCase(); + setChainCode(chain); // I note that PDB Chains ARE case-sensitive now + if (fileType == null) + fileType = "mmcif"; + switch (fileType.toLowerCase()) { + case "pdb": + this.type = Type.PDB.toString(); + break; + case "mmcif": + this.type = Type.MMCIF.toString(); + break; + default: + case "bcif": + System.out.println("format " + fileType + " has not been implemented; using mmCIF"); + this.type = Type.MMCIF.toString(); + break; + } + } + public PDBEntry(String pdbId, String chain, PDBEntry.Type type, String filePath) { @@ -253,6 +280,12 @@ public class PDBEntry return id; } + /** + * TODO + * + * @param key "protocol" + * @param value + */ public void setProperty(String key, Object value) { if (this.properties == null) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 22d10c1..1850984 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -553,7 +553,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { case 27: // escape key - deselectAllSequenceMenuItem_actionPerformed(null); + alignPanel.deselectAllSequences(); break; @@ -2486,18 +2486,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e) { - SequenceGroup sg = new SequenceGroup( - viewport.getAlignment().getSequences()); - - sg.setEndRes(viewport.getAlignment().getWidth() - 1); - viewport.setSelectionGroup(sg); - viewport.isSelectionGroupChanged(true); - viewport.sendSelection(); - // JAL-2034 - should delegate to - // alignPanel to decide if overview needs - // updating. - alignPanel.paintAlignment(false, false); - PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId()); + alignPanel.selectAllSequences(); } /** @@ -2509,21 +2498,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e) { - if (viewport.cursorMode) - { - alignPanel.getSeqPanel().keyboardNo1 = null; - alignPanel.getSeqPanel().keyboardNo2 = null; - } - viewport.setSelectionGroup(null); - viewport.getColumnSelection().clear(); - viewport.setSelectionGroup(null); - alignPanel.getIdPanel().getIdCanvas().searchResults = null; - // JAL-2034 - should delegate to - // alignPanel to decide if overview needs - // updating. - alignPanel.paintAlignment(false, false); - PaintRefresher.Refresh(alignPanel, viewport.getSequenceSetId()); - viewport.sendSelection(); + alignPanel.deselectAllSequences(); } /** @@ -2539,7 +2514,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, if (sg == null) { - selectAllSequenceMenuItem_actionPerformed(null); + alignPanel.selectAllSequences(); return; } diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 91b773e..5696c3a 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -63,6 +63,7 @@ import java.beans.PropertyChangeListener; import java.io.File; import java.io.FileWriter; import java.io.PrintWriter; +import java.util.ArrayList; import java.util.List; import javax.swing.SwingUtilities; @@ -1895,5 +1896,42 @@ public class AlignmentPanel extends GAlignmentPanel implements super.repaint(); } + public void selectAllSequences() + { + selectSequences(av.getAlignment().getSequences()); + } + + public void deselectAllSequences() + { + if (av.cursorMode) + { + getSeqPanel().keyboardNo1 = null; + getSeqPanel().keyboardNo2 = null; + } + av.setSelectionGroup(null); + av.getColumnSelection().clear(); + av.setSelectionGroup(null); + getIdPanel().getIdCanvas().searchResults = null; + av.sendSelection(); + // JAL-2034 - should delegate to + // alignPanel to decide if overview needs + // updating. + paintAlignment(false, false); + PaintRefresher.Refresh(this, av.getSequenceSetId()); + } + + public void selectSequences(List seqs) + { + SequenceGroup sg = new SequenceGroup(seqs); + sg.setEndRes(av.getAlignment().getWidth() - 1); + av.setSelectionGroup(sg); + av.isSelectionGroupChanged(true); + av.sendSelection(); + // JAL-2034 - should delegate to + // alignPanel to decide if overview needs + // updating. + paintAlignment(false, false); + PaintRefresher.Refresh(this, av.getSequenceSetId()); + } } diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 2af17a9..5b94831 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -886,11 +886,9 @@ public class StructureChooser extends GStructureChooser public void showStructures(boolean waitUntilFinished) { - final StructureSelectionManager ssm = ap.getStructureSelectionManager(); - final int preferredHeight = pnl_filter.getHeight(); - final StructureViewer theViewer = getTargetedStructureViewer(ssm); + final StructureViewer theViewer = getTargetedStructureViewer(); boolean superimpose = chk_superpose.isSelected(); Runnable viewStruc = new Runnable() @@ -929,9 +927,7 @@ public class StructureChooser extends GStructureChooser if (pdbEntry == null) { - pdbEntry = new PDBEntry(); - pdbEntry.setId(pdbIdStr); - pdbEntry.setType(PDBEntry.Type.PDB); + pdbEntry = new PDBEntry(pdbIdStr, null, "pdb"); selectedSeq.getDatasetSequence().addPDBId(pdbEntry); } pdbEntriesToView[count++] = pdbEntry; @@ -1066,11 +1062,9 @@ public class StructureChooser extends GStructureChooser * @param ssm * @return */ - StructureViewer getTargetedStructureViewer(StructureSelectionManager ssm) + StructureViewer getTargetedStructureViewer() { - Object sv = targetView.getSelectedItem(); - - return sv == null ? new StructureViewer(ssm) : (StructureViewer) sv; + return (StructureViewer) targetView.getSelectedItem(); } /** diff --git a/src/jalview/gui/StructureViewer.java b/src/jalview/gui/StructureViewer.java index e0c33e5..e7a30f9 100644 --- a/src/jalview/gui/StructureViewer.java +++ b/src/jalview/gui/StructureViewer.java @@ -433,6 +433,8 @@ public class StructureViewer StructureViewer theViewer, IProgressIndicator pb) { final StructureSelectionManager ssm = ap.getStructureSelectionManager(); + if (theViewer == null) + theViewer = new StructureViewer(ssm); long progressId = sequences.hashCode(); if (pb != null) pb.setProgressBar(MessageManager.getString(