new ajax api methods for linking existing jmol viewers with sequences in an alignframe
[jalview.git] / src / jalview / bin / JalviewLite.java
index af6e1a5..338b319 100755 (executable)
@@ -1,20 +1,19 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
  * 
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
  * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  */
 package jalview.bin;
 
@@ -26,6 +25,7 @@ import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.util.*;
 
+import jalview.api.SequenceStructureBinding;
 import jalview.appletgui.*;
 import jalview.datamodel.*;
 import jalview.io.*;
@@ -310,7 +310,8 @@ public class JalviewLite extends Applet
   private boolean checkForJmol = true;
 
   private boolean checkedForJmol = false; // ensure we don't check for jmol
-                                          // every time the app is re-inited
+
+  // every time the app is re-inited
 
   public boolean jmolAvailable = false;
 
@@ -380,10 +381,10 @@ public class JalviewLite extends Applet
     }
     if (debug)
     {
-      
-      System.err.println("JalviewLite Version "+getVersion());
-      System.err.println("Build Date : "+getBuildDate());
-      
+
+      System.err.println("JalviewLite Version " + getVersion());
+      System.err.println("Build Date : " + getBuildDate());
+
     }
     /**
      * if true disable the check for jmol
@@ -1291,4 +1292,53 @@ public class JalviewLite extends Applet
     }
     return false;
   }
+  /**
+   * bind a pdb file to a sequence in the given alignFrame.  
+   * @param alFrame - 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
+   * @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 seqeunceId location fails.
+   */
+  public boolean addPdbFile(AlignFrame alFrame, String sequenceId, String pdbEntryString, String pdbFile)
+  {
+    System.err.println("addPdbFile not yet implemented.");
+      return true;
+  }
+  /**
+   * bind the viewer instance to the pdbFile associated with sequences in the given alFrame.
+   * @param alFrame
+   * @param pdbFile - pdbFile URI as given via applet's parameters or by addPdb 
+   * @param viewer
+   * @return binding for viewer 
+   * TODO: consider making an exception structure for indicating when binding fails
+   */
+  public SequenceStructureBinding addJmolInstance(AlignFrame alFrame, String pdbFile, org.jmol.api.JmolViewer viewer) 
+  {
+    System.err.println("addJmolInstance not yet implemented.");
+    /**
+     */
+    return null;
+  }
+  /**
+   * bind structures in a viewer to any matching sequences in an alignFrame (use seuqenceIds to limit scope of search to specific sequences)
+   * @param alFrame
+   * @param viewer
+   * @param sequenceIds
+   * @return
+   */
+  public SequenceStructureBinding addJmolInstance(AlignFrame alFrame, org.jmol.api.JmolViewer viewer, String sequenceIds) 
+  {
+    if (viewer!=null)
+    {
+      if (sequenceIds!=null && sequenceIds.length()>0)
+      {
+        return alFrame.addJmolInstance(viewer, separatorListToArray(sequenceIds));
+      } else {
+        return alFrame.addJmolInstance(viewer, null);
+      }
+    }
+    return null;
+  }
 }