Merge branch 'patchJAL-674_offset' into Release_2_8_2_Branch
authorJim Procter <jprocter@dundee.ac.uk>
Thu, 27 Nov 2014 14:39:32 +0000 (14:39 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Thu, 27 Nov 2014 14:39:32 +0000 (14:39 +0000)
help/html/features/chimera.html
help/html/features/viewingpdbs.html
resources/lang/Messages.properties
src/ext/edu/ucsf/rbvi/strucviz2/StructureManager.java
src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java
src/jalview/gui/AlignFrame.java
src/jalview/gui/ChimeraViewFrame.java
src/jalview/gui/Help.java
src/jalview/gui/Preferences.java
src/jalview/jbgui/GPreferences.java
src/jalview/ws/jws2/MsaWSClient.java

index 236701a..dbaad73 100644 (file)
@@ -24,7 +24,7 @@
 </head>
 <body>
 <p><strong>The Chimera Viewer</strong></p>
-<p>Since Jalview 2.8.2, <a href="https://www.cgl.ucsf.edu/chimera/">Chimera</a>
+<p>Since Jalview 2.8.2, <a href="http://www.cgl.ucsf.edu/chimera/">Chimera</a> (http://www.cgl.ucsf.edu/chimera/)
 has been integrated into Jalview for interactively viewing structures
 opened by entries in the <strong>&quot;Structure&quot;</strong> submenu in the <a href="../menus/popupMenu.html">sequence
 id pop-up menu</a> (if you can't see this, then you need to <a
@@ -69,7 +69,8 @@ residue number and chain code
 ([RES]Num:Chain). Moving the mouse over an
 associated residue in an alignment window highlights the associated
 atoms in the displayed structures. For comprehensive details of Chimera's commands, refer to the tool's Help menu.</p>
-<p>Basic screen operations (see <a href="https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/mouse.html">Chimera help</a> for full details).
+<p>Basic screen operations (see <a href="http://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/mouse.html">Chimera help</a> 
+(http://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/mouse.html) for full details).
 <table border="1">
        <tr>
                <td><strong>Action</strong></td>
index 75a5c9c..99f17fe 100755 (executable)
@@ -31,8 +31,7 @@
        </p>
        The
        <a href="jmol.html">Jmol viewer</a> has been included since Jalview
-       2.3. Jalview 2.8.2 included support for
-       <a href="https://www.cgl.ucsf.edu/chimera/">Chimera</a>, provided it is
+       2.3. Jalview 2.8.2 included support for <a href="chimera.html">Chimera</a>, provided it is
        installed and can be launched by Jalview. The default viewer can be
        configured in the
        <a href="preferences.html#structure">Structure tab</a> in the
index cabee76..795dfa0 100644 (file)
@@ -251,6 +251,7 @@ label.structure_viewer = Default structure viewer
 label.chimera_path = Path to Chimera program
 label.chimera_path_tip = Jalview will first try any path entered here, else standard installation locations.<br>Double-click to browse for file.
 label.invalid_chimera_path = Chimera path not found or not executable
+label.chimera_missing = Chimera structure viewer not found.<br/>Please enter the path to Chimera (if installed),<br/>or download and install UCSF Chimera.
 label.min_colour = Minimum Colour
 label.max_colour = Maximum Colour
 label.use_original_colours = Use Original Colours
index 1208638..4797b37 100644 (file)
@@ -864,22 +864,24 @@ public class StructureManager
   StructureSettings defaultSettings = null;
 
   // TODO: [Optional] Change priority of Chimera paths
-  public List<String> getChimeraPaths()
+  public static List<String> getChimeraPaths()
   {
     List<String> pathList = new ArrayList<String>();
 
     // if no network is available and the settings have been modified by the
     // user, check for a
     // path to chimera
-    if (defaultSettings != null)
-    {
-      String defaultPath = defaultSettings.getChimeraPath();
-      if (defaultPath != null && !defaultPath.equals(""))
-      {
-        pathList.add(defaultPath);
-        return pathList;
-      }
-    }
+    //
+    // For Jalview, Preferences/Cache plays this role instead
+    // if (defaultSettings != null)
+    // {
+    // String defaultPath = defaultSettings.getChimeraPath();
+    // if (defaultPath != null && !defaultPath.equals(""))
+    // {
+    // pathList.add(defaultPath);
+    // return pathList;
+    // }
+    // }
 
     /*
      * Jalview addition: check if path set in user preferences.
@@ -887,7 +889,7 @@ public class StructureManager
     String userPath = Cache.getDefault(Preferences.CHIMERA_PATH, null);
     if (userPath != null)
     {
-      pathList.add(userPath);
+      pathList.add(0, userPath);
     }
 
     // Add default installation paths
index fb03f04..82f5e5c 100644 (file)
@@ -782,7 +782,7 @@ public abstract class JalviewChimeraBinding extends
 
   private void waitForChimera()
   {
-    while (viewer.isBusy())
+    while (viewer != null && viewer.isBusy())
     {
       try {
         Thread.sleep(15);
@@ -954,7 +954,7 @@ public abstract class JalviewChimeraBinding extends
     }
   }
 
-  boolean debug = true;
+  boolean debug = false;
 
   private void log(String message)
   {
@@ -963,8 +963,8 @@ public abstract class JalviewChimeraBinding extends
 
   private void viewerCommandHistory(boolean enable)
   {
-    log("(Not yet implemented) History "
-            + ((debug || enable) ? "on" : "off"));
+    // log("(Not yet implemented) History "
+    // + ((debug || enable) ? "on" : "off"));
   }
 
   public void loadInline(String string)
index 0087e8d..31652c1 100644 (file)
@@ -4186,6 +4186,21 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
        */
       msa = viewport.getAlignmentView(true);
     }
+    else if (viewport.getSelectionGroup() != null
+            && viewport.getSelectionGroup().getSize() == 1)
+    {
+      int option = JOptionPane
+              .showConfirmDialog(
+this,
+                      "More than one sequece group selection is required for this Job, click \n'Cancel' to edit your selection or 'Ok' to submit the entire sequence.",
+                      "Invalid selection",
+                      JOptionPane.OK_CANCEL_OPTION);
+      if (option == JOptionPane.OK_OPTION)
+      {
+        msa = viewport.getAlignmentView(false);
+      }
+
+    }
     else
     {
       /*
index 02865e1..513659f 100644 (file)
@@ -840,8 +840,13 @@ public class ChimeraViewFrame extends GStructureViewer implements Runnable,
     {
       if (progressBar != null)
       {
-        progressBar.setProgressBar(
-                MessageManager.getString("label.state_completed"), hdl);
+        progressBar
+                .setProgressBar(
+                        pdbid
+                                + " "
+                                + MessageManager
+                                        .getString("label.state_completed"),
+                        hdl);
       }
     }
     /*
index ae3f457..b07cc4e 100644 (file)
@@ -17,7 +17,8 @@ public class Help
 {
   public enum HelpId
   {
-    Home("home"), SequenceFeatureSettings("seqfeatures.settings");
+    Home("home"), SequenceFeatureSettings("seqfeatures.settings"), StructureViewer(
+            "viewingpdbs");
 
     private String id;
 
index b082bc6..bdc83e5 100755 (executable)
@@ -22,6 +22,7 @@ package jalview.gui;
 
 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.bin.Cache;
+import jalview.gui.Help.HelpId;
 import jalview.gui.StructureViewer.Viewer;
 import jalview.io.JalviewFileChooser;
 import jalview.io.JalviewFileView;
@@ -39,15 +40,19 @@ import java.awt.event.ActionListener;
 import java.awt.event.MouseEvent;
 import java.io.File;
 import java.util.Collection;
+import java.util.List;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
+import javax.help.HelpSetException;
 import javax.swing.JColorChooser;
 import javax.swing.JFileChooser;
 import javax.swing.JInternalFrame;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 
+import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
+
 /**
  * DOCUMENT ME!
  * 
@@ -596,7 +601,8 @@ public class Preferences extends GPreferences
   }
 
   /**
-   * Do any necessary validation before saving settings.
+   * Do any necessary validation before saving settings. Return focus to the
+   * first tab which fails validation.
    * 
    * @return
    */
@@ -879,4 +885,53 @@ public class Preferences extends GPreferences
     return true;
   }
 
+  /**
+   * If Chimera is selected, check it can be found on default or user-specified
+   * path, if not show a warning/help dialog.
+   */
+  @Override
+  protected void structureViewer_actionPerformed(String selectedItem)
+  {
+    if (!selectedItem.equals(Viewer.CHIMERA.name()))
+    {
+      return;
+    }
+    boolean found = false;
+
+    /*
+     * Try user-specified and standard paths for Chimera executable.
+     */
+    List<String> paths = StructureManager.getChimeraPaths();
+    paths.add(0, chimeraPath.getText());
+    for (String path : paths)
+    {
+      if (new File(path.trim()).canExecute())
+      {
+        found = true;
+        break;
+      }
+    }
+    if (!found)
+    {
+      String[] options =
+      { "OK", "Help" };
+      int showHelp = JOptionPane.showInternalOptionDialog(
+              Desktop.desktop,
+              JvSwingUtils.wrapTooltip(true,
+                      MessageManager.getString("label.chimera_missing")),
+              "", JOptionPane.YES_NO_OPTION,
+              JOptionPane.WARNING_MESSAGE, null, options, options[0]);
+      if (showHelp == JOptionPane.NO_OPTION)
+      {
+        try
+        {
+          Help.showHelpWindow(HelpId.StructureViewer);
+        } catch (HelpSetException e)
+        {
+          e.printStackTrace();
+        }
+      }
+    }
+  }
+
 }
index 5569c24..610f32e 100755 (executable)
@@ -782,6 +782,15 @@ public class GPreferences extends JPanel
     structViewer.setBounds(new Rectangle(160, ypos, 120, height));
     structViewer.addItem(Viewer.JMOL.name());
     structViewer.addItem(Viewer.CHIMERA.name());
+    structViewer.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        structureViewer_actionPerformed((String) structViewer
+                .getSelectedItem());
+      }
+    });
     structureTab.add(structViewer);
 
     ypos += lineSpacing;
@@ -819,6 +828,15 @@ public class GPreferences extends JPanel
   }
 
   /**
+   * Action on choosing a structure viewer from combobox options.
+   * 
+   * @param selectedItem
+   */
+  protected void structureViewer_actionPerformed(String selectedItem)
+  {
+  }
+
+  /**
    * Show a dialog for the user to choose a file. Returns the chosen path, or
    * null on Cancel.
    * 
index 09a6d8d..39be454 100644 (file)
@@ -22,6 +22,7 @@ package jalview.ws.jws2;
 
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentView;
+import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
 import jalview.gui.Desktop;
 import jalview.gui.JvSwingUtils;
@@ -127,8 +128,10 @@ public class MsaWSClient extends Jws2Client
 
       return;
     }
+
     startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
 
+
   }
 
   public MsaWSClient()
@@ -173,9 +176,55 @@ public class MsaWSClient extends Jws2Client
             WsURL, wsInfo, alignFrame, WebServiceName, jobtitle, msa,
             submitGaps, preserveOrder, seqdataset);
     wsInfo.setthisService(msathread);
+
     msathread.start();
+
   }
 
+  private boolean isValidAlignment(AlignmentView av)
+  {
+    int validSeqCount = 0;
+    List<SequenceI> seqs = av.getVisibleAlignment('c').getSequences(); // .getSequences();
+    if (seqs.size() < 2)
+    {
+      JOptionPane
+              .showMessageDialog(
+                      alignFrame,
+                      "A minimum of two sequences is required to perform this operation",
+                      "Invalid selection", JOptionPane.INFORMATION_MESSAGE);
+
+      return false;
+    }
+
+    for (SequenceI seq : seqs)
+    {
+
+      if (seq.getSequenceAsString().matches("(-*[a-zA-Z]-*){3}[a-zA-Z-]*"))
+      {
+        ++validSeqCount;
+      }
+      if (validSeqCount > 1)
+      {
+        return true;
+      }
+    }
+
+    JOptionPane
+            .showMessageDialog(
+                    alignFrame,
+                    "All selected sequence for this job must have a  minimum of \nthree non-gap character to perform this operation",
+                    "Invalid selection", JOptionPane.INFORMATION_MESSAGE);
+
+    return false;
+  }
+
+  public static void main(String[] args)
+  {
+    System.out.println("A".matches("(-*[a-zA-Z]-*){1}[a-zA-Z-]*"));
+  }
+
+
+
   protected String getServiceActionKey()
   {
     return "MsaWS";
@@ -250,9 +299,13 @@ public class MsaWSClient extends Jws2Client
         public void actionPerformed(ActionEvent e)
         {
           AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+
+          if (msa != null && isValidAlignment(msa))
+          {
           new MsaWSClient(service, alignFrame.getTitle(), msa, withGaps,
                   true, alignFrame.getViewport().getAlignment()
                           .getDataset(), alignFrame);
+          }
 
         }
       });
@@ -271,9 +324,13 @@ public class MsaWSClient extends Jws2Client
           public void actionPerformed(ActionEvent e)
           {
             AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+
+            if (msa != null && isValidAlignment(msa))
+            {
             new MsaWSClient(service, null, null, true, alignFrame
                     .getTitle(), msa, withGaps, true, alignFrame
                     .getViewport().getAlignment().getDataset(), alignFrame);
+            }
 
           }
         });
@@ -324,9 +381,13 @@ public class MsaWSClient extends Jws2Client
               {
                 AlignmentView msa = alignFrame
                         .gatherSequencesForAlignment();
+
+                if (msa != null && isValidAlignment(msa))
+                {
                 new MsaWSClient(service, preset, alignFrame.getTitle(),
                         msa, false, true, alignFrame.getViewport()
                                 .getAlignment().getDataset(), alignFrame);
+                }
 
               }