Added alignment ordering option to 'Sort by' and implemented generic
authorjprocter <Jim Procter>
Sun, 22 May 2005 17:56:13 +0000 (17:56 +0000)
committerjprocter <Jim Procter>
Sun, 22 May 2005 17:56:13 +0000 (17:56 +0000)
MsaWS client.

14 files changed:
src/ext/jemboss/JembossJarUtil.java [deleted file]
src/ext/jemboss/JembossParams.java [deleted file]
src/ext/jemboss/soap/JembossRun.java [deleted file]
src/ext/jemboss/soap/JembossSoapException.java [deleted file]
src/ext/jemboss/soap/MakeFileSafe.java [deleted file]
src/ext/jemboss/soap/PrivateRequest.java [deleted file]
src/ext/jemboss/soap/PublicRequest.java [deleted file]
src/jalview/analysis/AlignmentSorter.java
src/jalview/analysis/SeqsetUtils.java [new file with mode: 0755]
src/jalview/datamodel/AlignmentOrder.java [new file with mode: 0755]
src/jalview/gui/AlignFrame.java
src/jalview/ws/Jemboss.java [deleted file]
src/jalview/ws/MsaWSClient.java
src/jalview/ws/MsaWServices.java [new file with mode: 0755]

diff --git a/src/ext/jemboss/JembossJarUtil.java b/src/ext/jemboss/JembossJarUtil.java
deleted file mode 100755 (executable)
index ad10cd2..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/***************************************************************
-*
-* 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 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.
-*
-* 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-*
-*  @author: Copyright (C) Tim Carver
-*
-***************************************************************/
-
-package ext.jemboss;
-
-import java.util.*;
-import java.util.zip.*;
-import java.io.*;
-
-
-/**
-*
-* Unpacks a Jar file into a Hashtable
-*
-*/
-public class JembossJarUtil
-{
-
-  /** Hashtable containing the unpacked contents of the jar file */
-  private Hashtable jarStore = new Hashtable();
-
-  /**
-  *
-  * Given the path to a jar file unpack to a hashtable
-  * @param jarFile     path to jar file to unpack
-  * @throws Exception          if it is not possible to read jar file
-  *
-  */
-  public JembossJarUtil(String jarFile) throws Exception
-  {
-
-    try
-    {
-      // extracts just sizes only
-      ClassLoader cl = this.getClass().getClassLoader();
-      ZipInputStream zis= new ZipInputStream(
-                     cl.getResourceAsStream(jarFile));
-      ZipEntry ze=null;
-      Hashtable htSizes = new Hashtable();
-
-      while((ze=zis.getNextEntry())!=null)
-      {
-        int ret=0;
-        int cnt=0;
-        int rb = 0;
-        while(ret != -1)
-        {
-          byte[] b1 = new byte[1];
-          ret=zis.read(b1,rb,1);
-          cnt++;
-        }
-        htSizes.put(ze.getName(),new Integer(cnt));
-      }
-      zis.close();
-
-      // extract resources and put them into the hashtable
-      zis = new ZipInputStream(cl.getResourceAsStream(jarFile));
-      ze=null;
-      while ((ze=zis.getNextEntry())!=null)
-      {
-        if(ze.isDirectory())
-          continue;
-
-        int size=(int)ze.getSize(); // -1 means unknown size
-        if(size==-1)
-          size=((Integer)htSizes.get(ze.getName())).intValue();
-
-        byte[] b=new byte[(int)size];
-        int rb=0;
-        int chunk=0;
-        while (((int)size - rb) > 0)
-        {
-          chunk=zis.read(b,rb,(int)size - rb);
-          if(chunk==-1)
-            break;
-          rb+=chunk;
-        }
-
-        // add to internal resource hashtable
-        jarStore.put(ze.getName(),b);
-
-//      System.out.println(ze.getName());
-      }
-      zis.close();
-    }
-    catch (Exception e) { throw new Exception();}
-
-//  catch (NullPointerException e)
-//  {
-//    System.out.println("JembossJarUtil Error: jarStore");
-//  }
-//  catch (FileNotFoundException e)
-//  {
-//    e.printStackTrace();
-//  }
-//  catch (IOException e)
-//  {
-//    e.printStackTrace();
-//  }
-  }
-
-
-  /**
-  *
-  * Return the hashtable
-  * @return jarStore   the hashtable containing the contents
-  *                    of the jar
-  *
-  */
-  public Hashtable getHash()
-  {
-    return jarStore;
-  }
-
-  /**
-  *
-  * Return an element of the hashtable
-  * @param el  key of an element in the hashtable
-  * @return    the hashtable containing the contents
-  *                    of the jar
-  *
-  */
-  public Object getElement(String el)
-  {
-    return jarStore.get(el);
-  }
-
-  /**
-  *
-  * Write contents of an element in the hashtable
-  * @param el   key of an element in the hashtable
-  * @param f    path of file to write to
-  * @return     true if written file
-  *
-  */
-  public boolean writeByteFile(String el, String f)
-  {
-    try
-    {
-      FileOutputStream out = new FileOutputStream(f);
-      out.write((byte []) jarStore.get(el));
-      out.close();
-    }
-    catch(FileNotFoundException fnfe) {return false;}
-    catch(IOException ioe) {return false;}
-
-    return true;
-  }
-
-}
diff --git a/src/ext/jemboss/JembossParams.java b/src/ext/jemboss/JembossParams.java
deleted file mode 100755 (executable)
index b9580b5..0000000
+++ /dev/null
@@ -1,1295 +0,0 @@
-/***************************************************************
-*
-* 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 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.
-*
-* 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-*
-*  @author: Copyright (C) Tim Carver
-*
-***************************************************************/
-
-package ext.jemboss;
-
-import java.util.*;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.net.InetAddress;
-
-
-/**
-*
-* Contains all property information about the client
-* and the server.
-*
-*/
-public class JembossParams
-{
-
-/** denotes a server is OK             */
-  static public final int SERVER_OK = 0;
-/** denotes a server is giving errors  */
-  static public final int SERVER_ERR = 1;
-/** denotes a server is not responding */
-  static public final int SERVER_DOWN = 2;
-
-  // these are the things that could be set
-  private boolean useHTTPSProxy = false;
-  private String useHTTPSProxyName = "useHTTPSProxy";
-
-  private boolean useProxy = false;
-  private String useProxyName = "proxy.use";
-
-  private String proxyHost = "wwwcache";
-  private String proxyHostName = "proxy.host";
-
-  private int proxyPortNum = 8080;
-  private String proxyPortNumName = "proxy.port";
-
-//browser proxy
-
-  /** use a separate proxy for browsing the web                        */
-  private boolean useBrowserProxy = false;
-  /** property name for using separate proxy for browsing the web */
-  private String useBrowserProxyName = "browserProxy.use";
-  /** browser proxy host                   */
-  private String browserProxyHost = "wwwcache";
-  /** property name for browser proxy host  */
-  private String browserProxyHostName = "browserProxy.host";
-  /** browser proxy port                   */
-  private int browserProxyPort = 8080;
-  /** property name for browser proxy port */
-  private String browserProxyPortName = "browserProxy.port";
-
-  private boolean useTFM;
-  private String useTFMName = "tfm.use";
-
-  /** use proxy authentication                          */
-  private boolean useProxyAuth = false;
-  /** property name for using proxy authentication */
-  private String useProxyAuthName = "proxy.auth";
-
-  private String proxyAuthUser = "";
-  private String proxyAuthUserName = "proxy.user";
-
-  private String proxyAuthPasswd = "";
-  private String proxyAuthPasswdName = "proxy.passwd";
-
-  private boolean proxyOverride = false;
-  private String proxyOverrideName = "proxy.override";
-
-  /** use unix authentication to run applications on the server */
-  private boolean useAuth = false;
-  /** property name for using unix authentication               */
-  private String useAuthName = "user.auth";
-
-  /** public services URL                    */
-  private String publicSoapURL =
-             "http://anaplog.compbio.dundee.ac.uk:8080/axis/services";
-  /** property name for public services URL  */
-  private String publicSoapURLName = "server.public";
-
-  /** private services URL                   */
-  private String privateSoapURL =
-             "http://anaplog.compbio.dundee.ac.uk:8080/axis/services";
-  /** property name for private services URL */
-  private String privateSoapURLName = "server.private";
-
-  /** service name */
-  private String soapService = "JembossServer";
-  /** property name for service name */
-  private String soapServiceName = "VAMSAS Services";
-
-  /** private service name                   */
-  private String privateSoapService = "JembossServer";
-  /** property name for private service name */
-  private String privateSoapServiceName = "VAMSAS Services";
-
-  /** public service name                    */
-  private String publicSoapService = "JembossServer";
-  /** property name for public service name  */
-  private String publicSoapServiceName = "VAMSAS Services";
-
-  //soap options
-  private boolean debug = false;
-  private String debugName = "jemboss.debug";
-
-  /** batch mode support                   */
-  private boolean hasBatchMode = true;
-  /** property name for batch mode support */
-  private String hasBatchModeName = "jemboss.hasbatchmode";
-  /** interactive mode support                   */
-  private boolean hasInteractiveMode = true;
-  /** property name for interactive mode support */
-  private String hasInteractiveModeName = "jemboss.hasinteractivemode";
-  /** current mode for running an application    */
-  private String currentMode = "interactive";
-  /** property name for current mode             */
-  private String currentModeName = "jemboss.mode";
-
-  // server lists for redundancy
-  private String serverPublicList = "";
-  private String serverPublicListName = "server.publiclist";
-
-  private String serverPrivateList = "";
-  private String serverPrivateListName = "server.privatelist";
-
-  // we don't remember these perhaps we should for captive systems
-  private String serviceUserName = "jalview";
-  private String serviceUserNameName = "user.name";
-  private char[] servicePasswd = null;
-  /** services password */
-  private byte[] servicePasswdByte = null;
-
-  Properties jembossSettings;
-
-  // Internal flags to help in the dynamic evaluation of properties
-  private boolean useJavaProxy = false;
-  private String javaProxyPort = "";
-  private String javaProxyHost = "";
-  private boolean useJavaNoProxy = false;
-  private String javaNoProxy = "";
-  private Vector javaNoProxyEntries;
-  private int javaProxyPortNum = 8080;
-
-  // structures for server redundancy
-  private boolean publicServerFailOver = false;
-  private boolean privateServerFailOver = false;
-  private Hashtable serverStatusHash;
-  private Vector publicServers;
-  private Vector privateServers;
-
-  /** Jemboss java server                   */
-  private static boolean jembossServer = false;
-  /** property name for Jemboss java server */
-  private String jembossServerName = "jemboss.server";
-
-  /** cygwin */
-  private static String cygwin = null;
-  /** property name for Jemboss java server */
-  private String cygwinName = "cygwin";
-
-  //EMBOSS directories
-  /** plplot library location                            */
-  private String plplot = "/usr/local/share/EMBOSS/";
-  /** property name for plplot library location          */
-  private String plplotName = "plplot";
-  /** emboss data location                               */
-  private String embossData = "/usr/local/share/EMBOSS/data/";
-  /** property name for emboss data location             */
-  private String embossDataName = "embossData";
-  /** emboss binary location                             */
-  private String embossBin = "/usr/local/bin/";
-  /** property name for emboss binary location           */
-  private String embossBinName = "embossBin";
-  /** emboss path environment variable                   */
-  private String embossPath = "/usr/bin/:/bin";
-  /** property name for emboss path environment variable */
-  private String embossPathName = "embossPath";
-  /** emboss environment                                 */
-  private String embossEnvironment = "";
-  /** property name for emboss environment               */
-  private String embossEnvironmentName = "embossEnvironment";
-  /** acd file location                                  */
-  private String acdDirToParse = "/usr/local/share/EMBOSS/acd/";
-  /** property name for acd file location                */
-  private String acdDirToParseName = "acdDirToParse";
-
-  //EMBOSS Application pages
-  /** documentation URL                      */
-  private String embURL = "http://www.uk.embnet.org/Software/EMBOSS/Apps/";
-  /** property name for documentation URL    */
-  private String embossURL = "embossURL";
-
-  // user properties
-  /** user home directory                    */
-  private String userHome = System.getProperty("user.home");
-  /** property name for user home directory  */
-  private String userHomeName = "user.home";
-
-
-/**
-*
-* Loads and holds the properties
-*
-*/
-  public JembossParams()
-  {
-    Properties defaults = new Properties();
-    ClassLoader cl = this.getClass().getClassLoader();
-
-    // initialize data structures
-    serverStatusHash = new Hashtable();
-    publicServers = new Vector();
-    privateServers = new Vector();
-
-    // initialize settings from table above
-    defaults.put(userHomeName,userHome);
-    defaults.put(embossURL,embURL);
-    defaults.put(plplotName,plplot);
-    defaults.put(embossDataName,embossData);
-    defaults.put(embossBinName,embossBin);
-    defaults.put(embossPathName,embossPath);
-    defaults.put(embossEnvironmentName,embossEnvironment);
-    defaults.put(acdDirToParseName,acdDirToParse);
-
-    defaults.put(useBrowserProxyName, new Boolean(useBrowserProxy).toString());
-    defaults.put(browserProxyHostName,browserProxyHost);
-    defaults.put(browserProxyPortName,new Integer(browserProxyPort).toString());
-
-    defaults.put(useTFMName,new Boolean(useTFM).toString());
-
-    defaults.put(useProxyName, new Boolean(useProxy).toString());
-    defaults.put(useHTTPSProxyName, new Boolean(useHTTPSProxy).toString());
-    defaults.put(proxyHostName,proxyHost);
-    defaults.put(proxyPortNumName, new Integer(proxyPortNum).toString());
-    defaults.put(useProxyAuthName, new Boolean(useProxyAuth).toString());
-    defaults.put(proxyAuthUserName, proxyAuthUser);
-    defaults.put(proxyAuthPasswdName, proxyAuthPasswd);
-    defaults.put(proxyOverrideName, new Boolean(proxyOverride).toString());
-    defaults.put(useAuthName, new Boolean(useAuth).toString());
-    defaults.put(publicSoapURLName, publicSoapURL);
-    defaults.put(privateSoapURLName, privateSoapURL);
-    defaults.put(privateSoapServiceName, privateSoapService);
-    defaults.put(publicSoapServiceName, publicSoapService);
-    defaults.put(debugName, new Boolean(debug).toString());
-    defaults.put(hasBatchModeName, new Boolean(hasBatchMode).toString());
-    defaults.put(hasInteractiveModeName, new Boolean(hasInteractiveMode).toString());
-    defaults.put(currentModeName, currentMode);
-    defaults.put(serverPublicListName, serverPublicList);
-    defaults.put(serverPrivateListName, serverPrivateList);
-    defaults.put(serviceUserNameName, serviceUserName);
-
-    // load into real settings
-    jembossSettings = new Properties(defaults);
-
-    // try out of the classpath
-    try
-    {
-      jembossSettings.load(cl.getResourceAsStream("resources/jemboss.properties"));
-    }
-    catch (Exception e)
-    {
-      if(debug)
-        System.out.println("Didn't find properties file in classpath.");
-    }
-
-    // override with local system settings
-    loadIn(System.getProperty("user.dir"));
-
-    // override with local user settings
-    loadIn(System.getProperty("user.home"));
-
-    // update our settings
-    updateSettingsFromProperties();
-
-    if(System.getProperty("useHTTPSProxy") != null)
-      if(System.getProperty("useHTTPSProxy").equalsIgnoreCase("true"))
-        useHTTPSProxy=true;
-
-    // set up for overrides
-    javaNoProxyEntries = new Vector();
-    if(System.getProperty("proxyPort") != null)
-    {
-      if(System.getProperty("proxyHost") != null)
-      {
-       useJavaProxy = true;
-        useProxy = useJavaProxy;
-        useBrowserProxy = useJavaProxy;
-
-       javaProxyPort = System.getProperty("proxyPort");
-       javaProxyPortNum = Integer.parseInt(javaProxyPort);
-       javaProxyHost = System.getProperty("proxyHost");
-
-        browserProxyHost = javaProxyHost;
-        browserProxyPort = javaProxyPortNum;
-
-       if(System.getProperty("http.nonProxyHosts") != null)
-        {
-         useJavaNoProxy = true;
-         javaNoProxy = System.getProperty("http.nonProxyHosts");
-         StringTokenizer tok = new StringTokenizer(javaNoProxy,"|");
-         while (tok.hasMoreTokens())
-          {
-           String toks = tok.nextToken() + "/";
-           javaNoProxyEntries.add(toks);
-         }
-       }
-      }
-    }
-
-  }
-
-  /**
-  *
-  * Load a property from the jemboss.property file.
-  * @param folder      location of jemboss.property
-  *
-  */
-  private void loadIn(String folder)
-  {
-    FileInputStream in = null;
-    try
-    {
-      String fs = System.getProperty("file.separator");
-      in = new FileInputStream(folder + fs + "jemboss.properties");
-      jembossSettings.load(in);
-    }
-    catch (java.io.FileNotFoundException e)
-    {
-      in = null;
-      if(debug)
-        System.out.println("Can't find properties file in"+folder+"."+
-                           " Using defaults.");
-    }
-    catch (java.io.IOException e)
-    {
-      if(debug)
-        System.out.println("Can't read properties file. " +
-                           "Using defaults.");
-    }
-    finally
-    {
-      if (in != null)
-      {
-        try { in.close(); } catch (java.io.IOException e) { }
-        in = null;
-      }
-    }
-
-  }
-
-  /**
-  *
-  * Update the property settings for jembossSettings.
-  *
-  */
-  protected void updateSettingsFromProperties()
-  {
-
-    try
-    {
-      String tmp;
-
-      userHome = jembossSettings.getProperty(userHomeName);
-      embURL = jembossSettings.getProperty(embossURL);
-      plplot = jembossSettings.getProperty(plplotName);
-      embossData = jembossSettings.getProperty(embossDataName);
-      embossBin = jembossSettings.getProperty(embossBinName);
-      embossPath = jembossSettings.getProperty(embossPathName);
-      embossEnvironment = jembossSettings.getProperty(embossEnvironmentName);
-      acdDirToParse = jembossSettings.getProperty(acdDirToParseName);
-      tmp = jembossSettings.getProperty(jembossServerName);
-      jembossServer = new Boolean(tmp).booleanValue();
-
-      cygwin = jembossSettings.getProperty(cygwinName);
-
-      tmp = jembossSettings.getProperty(useHTTPSProxyName);
-      useHTTPSProxy = new Boolean(tmp).booleanValue();
-      tmp = jembossSettings.getProperty(useProxyName);
-      useProxy = new Boolean(tmp).booleanValue();
-      proxyHost = jembossSettings.getProperty(proxyHostName);
-      tmp = jembossSettings.getProperty(proxyPortNumName);
-      proxyPortNum = Integer.parseInt(tmp);
-
-      tmp = jembossSettings.getProperty(useBrowserProxyName);
-      useBrowserProxy = new Boolean(tmp).booleanValue();
-      browserProxyHost = jembossSettings.getProperty(browserProxyHostName);
-      tmp = jembossSettings.getProperty(browserProxyPortName);
-      browserProxyPort = Integer.parseInt(tmp);
-
-      tmp = jembossSettings.getProperty(useTFMName);
-      useTFM = new Boolean(tmp).booleanValue();
-
-      tmp = jembossSettings.getProperty(useProxyAuthName);
-      useProxyAuth = new Boolean(tmp).booleanValue();
-      proxyAuthUser = jembossSettings.getProperty(proxyAuthUserName);
-      proxyAuthPasswd = jembossSettings.getProperty(proxyAuthPasswdName);
-      tmp = jembossSettings.getProperty(proxyOverrideName);
-      proxyOverride = new Boolean(tmp).booleanValue();
-      tmp = jembossSettings.getProperty(useAuthName);
-      useAuth = new Boolean(tmp).booleanValue();
-      publicSoapURL = jembossSettings.getProperty(publicSoapURLName);
-      privateSoapURL = jembossSettings.getProperty(privateSoapURLName);
-      soapService = jembossSettings.getProperty(soapServiceName);
-      privateSoapService = jembossSettings.getProperty(privateSoapServiceName);
-      publicSoapService = jembossSettings.getProperty(publicSoapServiceName);
-      tmp = jembossSettings.getProperty(debugName);
-      debug = new Boolean(tmp).booleanValue();
-      tmp = jembossSettings.getProperty(hasBatchModeName);
-      hasBatchMode = new Boolean(tmp).booleanValue();
-      tmp = jembossSettings.getProperty(hasInteractiveModeName);
-      hasInteractiveMode = new Boolean(tmp).booleanValue();
-      currentMode = jembossSettings.getProperty(currentModeName);
-      serverPublicList = jembossSettings.getProperty(serverPublicListName);
-      serverPrivateList = jembossSettings.getProperty(serverPrivateListName);
-//    serviceUserName = jembossSettings.getProperty(serviceUserNameName);
-    }
-    catch (Exception e) {  }
-  }
-
-/**
-*
-* Initialize the server redundancy data. This is a separate
-* method because the server info might not be initialized in
-* the constructor, but may be imported later from the command line.
-*
-*/
-  protected void setupServerRedundancy()
-  {
-    if (!serverPublicList.equals(""))
-    {
-      if(debug)
-       System.out.println("JembossParams: Redundant public servers\n  "
-                          +serverPublicList);
-
-      publicServerFailOver = true;
-      StringTokenizer tok = new StringTokenizer(serverPublicList,"|");
-      while (tok.hasMoreTokens())
-      {
-       String toks = tok.nextToken();
-       publicServers.add(toks);
-       if(debug)
-         System.out.println(" Entry " + toks);
-
-       serverStatusHash.put(toks, new Integer(SERVER_OK));
-      }
-    }
-
-    if(!serverPrivateList.equals(""))
-    {
-      if(debug)
-       System.out.println("JembossParams: Redundant private servers\n  "
-                          +serverPrivateList);
-
-      privateServerFailOver = true;
-      StringTokenizer tok = new StringTokenizer(serverPrivateList,"|");
-      while (tok.hasMoreTokens())
-      {
-       String toks = tok.nextToken();
-       privateServers.add(toks);
-       if(debug)
-         System.out.println(" Entry " + toks);
-
-       serverStatusHash.put(toks,new Integer(SERVER_OK));
-      }
-    }
-  }
-
-
-/**
-*
-* If using a proxy server
-*
-*/
-  public boolean getUseProxy()
-  {
-    return useProxy;
-  }
-
-
-/**
-*
-* If using an https proxy server
-*
-*/
-  public boolean getUseHTTPSProxy()
-  {
-    return useHTTPSProxy;
-  }
-
-
-/**
-*
-* If using a proxy server for a given URL
-* @param s     the URL we wish to connect to
-*
-*/
-  public boolean getUseProxy(String s)
-  {
-    if(proxyOverride)
-      return useProxy;
-    else
-    {
-      if(!useJavaProxy)
-       return useProxy;
-      else
-      {
-       boolean jp = true;
-       if (useJavaNoProxy)
-        {
-         int ip = javaNoProxyEntries.size();
-         for(int j = 0 ; j<ip ; ++j)
-           if(s.indexOf((String)javaNoProxyEntries.get(j).toString()) != -1)
-             jp = false;
-       }
-       return jp;
-      }
-    }
-  }
-
-/**
-*
-* The name of the proxy server
-* @return      name of the proxy host
-*
-*/
-  public String getProxyHost()
-  {
-    if (proxyOverride)
-      return proxyHost;
-    else
-    {
-      if(!useJavaProxy)
-       return proxyHost;
-      else
-       return javaProxyHost;
-    }
-  }
-
-/**
-*
-* The port the proxy server listens on
-* @return      proxy port number
-*
-*/
-  public int getProxyPortNum()
-  {
-    if(proxyOverride)
-      return proxyPortNum;
-    else
-    {
-      if(!useJavaProxy)
-       return proxyPortNum;
-      else
-       return javaProxyPortNum;
-    }
-  }
-
-/**
-*
-* Determine if the a proxy server is being used for web browsing
-* @return      true if using a proxy server for the browser
-*
-*/
-  public boolean isBrowserProxy()
-  {
-    return useBrowserProxy;
-  }
-
-/**
-*
-* Get the name of the proxy server for the browser
-* @return      the name of the proxy host
-*
-*/
-  public String getBrowserProxyHost()
-  {
-    return browserProxyHost;
-  }
-
-
-/**
-*
-* The port number of the proxy server for the browser
-* @return      proxy port number
-*
-*/
-  public int getBrowserProxyPort()
-  {
-    return browserProxyPort;
-  }
-
-
-  public boolean isUseTFM() { return useTFM; }
-
-
-/**
-*
-* If using authenticate with the proxy
-* @return      true if unix authentication used
-*
-*/
-  public boolean getUseProxyAuth()
-  {
-    return useProxyAuth;
-  }
-
-/**
-*
-* Username needed to use for the proxy server
-*
-*/
-  public String getProxyAuthUser()
-  {
-    return proxyAuthUser;
-  }
-
-/**
-*
-* Password needed to use for the proxy server
-*
-*/
-  public String getProxyAuthPasswd()
-  {
-    return proxyAuthPasswd;
-  }
-
-/**
-*
-* A description of the proxy settings
-* @return      a description of the proxy settings
-*
-*/
-  public String proxyDescription()
-  {
-    String pdesc = "";
-    if (proxyOverride)
-    {
-      if(useProxy)
-      {
-       String spnum = new Integer(proxyPortNum).toString();
-       pdesc = "Current Settings: " + "Proxy Host: " + proxyHost +
-                                           " Proxy Port: " + spnum;
-      }
-      else
-       pdesc = "No proxies, connecting direct.";
-    }
-    else
-    {
-      if (useJavaProxy)
-      {
-       pdesc = "Settings Imported from Java: " + "Proxy Host: " + javaProxyHost
-                                             + " Proxy Port: " + javaProxyPort;
-       if(useJavaNoProxy)
-         pdesc = pdesc + "\nNo Proxy On: " + javaNoProxy;
-      }
-      else
-      {
-       if(useProxy)
-        {
-         String spnum = new Integer(proxyPortNum).toString();
-         pdesc = "Current Settings: " + "Proxy Host: " + proxyHost +
-                                             " Proxy Port: " + spnum;
-       }
-        else
-         pdesc = "No proxies, connecting direct.";
-      }
-    }
-    return pdesc;
-  }
-
-/**
-*
-* Whether the main service requires authentication
-* @return      true if the server is using unix authentication
-*
-*/
-  public boolean getUseAuth()
-  {
-    return useAuth;
-  }
-
-/**
-*
-* Returns the URL of the public soap server
-* @return      the public services URL
-*
-*/
-  public String getPublicSoapURL()
-  {
-    return publicSoapURL;
-  }
-
-/**
-*
-*  @return     true if using a Jemboss server
-*
-*/
-  public static boolean isJembossServer()
-  {
-    return jembossServer;
-  }
-
-/**
-*
-*  @return      true if using cygwin
-*
-*/
-  public static boolean isCygwin()
-  {
-    if(cygwin == null || cygwin.equals(""))
-      return false;
-    else
-      return true;
-  }
-
-
-/**
-*
-*  Get the cygwin root
-*  @return      cygwin root
-*
-*/
-  public String getCygwinRoot()
-  {
-    return cygwin;
-  }
-
-
-
-/**
-*
-* Get the location of plplot
-* @return      the location of plplot
-*
-*/
-  public String getPlplot()
-  {
-    return plplot;
-  }
-
-/**
-*
-* Get the user home directory
-* @return      the user home directory
-*
-*/
-  public String getUserHome()
-  {
-    return userHome;
-  }
-
-/**
-*
-* Set the user home directory property
-* @param s     the user home directory
-*
-*/
-  public void setUserHome(String s)
-  {
-    userHome = s;
-  }
-
-/**
-*
-* @return      the documentation URL
-*
-*/
-  public String getembURL()
-  {
-    return embURL;
-  }
-
-/**
-*
-* @return      the location of the emboss data
-*
-*/
-  public String getEmbossData()
-  {
-    return embossData;
-  }
-
-/**
-*
-* @return      the location of the emboss binaries
-*
-*/
-  public String getEmbossBin()
-  {
-    return embossBin;
-  }
-
-/**
-*
-* Get the path for emboss
-* @return      the path for emboss
-*
-*/
-  public String getEmbossPath()
-  {
-    return embossPath;
-  }
-
-/**
-*
-* Get the environment for emboss
-* @return      the environment for emboss
-*
-*/
-  public String getEmbossEnvironment()
-  {
-    embossEnvironment = embossEnvironment.trim();
-    embossEnvironment = embossEnvironment.replace(':',' ');
-    embossEnvironment = embossEnvironment.replace(',',' ');
-    return embossEnvironment;
-  }
-
-/**
-*
-* Get the emboss environment as a String array
-* @return      the emboss environment as a String array
-*
-*/
-  public String[] getEmbossEnvironmentArray(String[] envp)
-  {
-    embossEnvironment = embossEnvironment.trim();
-    embossEnvironment = embossEnvironment.replace(':',' ');
-    embossEnvironment = embossEnvironment.replace(',',' ');
-
-    if(embossEnvironment.equals(""))
-      return envp;
-
-    StringTokenizer st = new StringTokenizer(embossEnvironment," ");
-    int n=0;
-    while(st.hasMoreTokens())
-    {
-      st.nextToken();
-      n++;
-    }
-
-    int sizeEnvp = envp.length;
-    String environ[] = new String[n+sizeEnvp];
-    st = new StringTokenizer(embossEnvironment," ");
-    for(int i=0;i<sizeEnvp;i++)
-      environ[i] = envp[i];
-
-    n=sizeEnvp;
-    while(st.hasMoreTokens())
-    {
-      environ[n] = new String(st.nextToken());
-      n++;
-    }
-
-    return environ;
-  }
-
-/**
-*
-* Acd file location
-* @return      acd file location
-*
-*/
-  public String getAcdDirToParse()
-  {
-    return acdDirToParse;
-  }
-
-/**
-*
-* Set the URL of the public soap server
-* @param s     URL of the public services
-*
-*/
-  public void setPublicSoapURL(String s)
-  {
-    publicSoapURL = s;
-  }
-
-/**
-*
-* Returns the URL of the private soap server
-* @return      URL of the private services
-*
-*/
-  public String getPrivateSoapURL()
-  {
-    return privateSoapURL;
-  }
-
-/**
-*
-* Set the URL of the private soap server
-* @param s     URL of the private services
-*
-*/
-  public void setPrivateSoapURL(String s)
-  {
-    privateSoapURL = s;
-  }
-
-/**
-*
-* Return whether we have failover on the public server
-*
-*/
-  public boolean getPublicServerFailover()
-  {
-    return publicServerFailOver;
-  }
-
-/**
-*
-* Return whether we have failover on the private server
-*
-*/
-  public boolean getPrivateServerFailover()
-  {
-    return privateServerFailOver;
-  }
-
-/**
-*
-* Return a vector containing the list of public servers
-*
-*/
-  public Vector getPublicServers()
-  {
-    return publicServers;
-  }
-
-/**
-*
-* Return a vector containing the list of private servers
-*
-*/
-  public Vector getPrivateServers()
-  {
-    return privateServers;
-  }
-
-/**
-*
-* Mark a server as bad
-*
-*/
-  public void setServerStatus(String server, int i)
-  {
-    serverStatusHash.put(server, new Integer(i));
-  }
-
-/**
-*
-* Return the username needed for the remote service
-* @return      the username
-*
-*/
-  public String getServiceUserName()
-  {
-    return serviceUserName;
-  }
-
-/**
-*
-* Save the username needed for the remote service
-* @param newUserName   the username
-*
-*/
-  public void setServiceUserName(String newUserName)
-  {
-    serviceUserName = newUserName;
-  }
-
-/**
-*
-* Return the password needed for the remote service
-* @return      password
-*
-*/
-  public char[] getServicePasswd()
-  {
-    return servicePasswd;
-  }
-
-/**
-*
-* Return the password needed for the remote service
-* @return      password
-*
-*/
-  public byte[] getServicePasswdByte()
-  {
-    return servicePasswdByte;
-  }
-
-/**
-*
-* Return the password as byte array
-*
-*/
-  private static byte[] toByteArr(char ch[])
-  {
-    int len = ch.length;
-    byte msb[] = new byte[len];
-
-    for(int i=0;i<len;i++)
-      msb[i] = (byte)(ch[i]);
-    return msb;
-  }
-
-
-/**
-*
-* Save the password needed for the remote service
-* @param newPasswd     the username
-*
-*/
-  public void setServicePasswd(char[] newPasswd)
-  {
-    int csize = newPasswd.length;
-    servicePasswd = new char[csize];
-
-    for(int i=0;i<csize;i++)
-      servicePasswd[i] = newPasswd[i];
-
-    servicePasswdByte = toByteArr(newPasswd);
-  }
-
-/**
-*
-* Get the name of the soap service
-* @return      soap service name
-*
-*/
-  public String getSoapService()
-  {
-    return soapService;
-  }
-
-/**
-*
-* Get the name of the private soap service
-* @return      private service name
-*
-*/
-  public String getPrivateSoapService()
-  {
-    return privateSoapService;
-  }
-
-/**
-*
-* Set the name of the private soap service
-* @param s     private service name
-*
-*/
-  public void setPrivateSoapService(String s)
-  {
-    privateSoapService = s;
-  }
-
-/**
-*
-* Get the name of the public soap service we're using
-* @return      public service name
-*
-*/
-  public String getPublicSoapService()
-  {
-    return publicSoapService;
-  }
-
-/**
-*
-* Set the name of the public soap service we're using
-* @param s     public service name
-*
-*/
-  public void setPublicSoapService(String s)
-  {
-    publicSoapService = s;
-  }
-
-/**
-*
-* A description of the server settings
-* @return      description of the services
-*
-*/
-  public String serverDescription()
-  {
-    String serverdesc = "Current Settings:"
-      +"\nPublic Server: "+publicSoapURL
-      +"\nPrivate Server: "+privateSoapURL
-      +"\nPublic SOAP service: "+publicSoapService
-      +"\nPrivate SOAP service: "+privateSoapService;
-    return serverdesc;
-  }
-
-/**
-*
-* Whether to show debugging information
-*
-*/
-  public boolean getDebug()
-  {
-    return debug;
-  }
-
-/**
-*
-* Whether this service supports batch mode
-* @return      true if batch mode supported
-*
-*/
-  public boolean getHasBatchMode()
-  {
-    return hasBatchMode;
-  }
-
-/**
-*
-* Whether this service supports interactive mode
-* @return      true if interactive mode supported
-*
-*/
-  public boolean getHasInteractiveMode()
-  {
-    return hasInteractiveMode;
-  }
-
-/**
-*
-* The current mode (interactive or batch).
-* @return      a String containing the current mode
-*
-*/
-  public String getCurrentMode()
-  {
-    if(hasInteractiveMode)
-    {
-      if (hasBatchMode)
-       return currentMode;
-      else
-       return "interactive";
-    }
-    else
-    {
-      if (hasBatchMode)
-       return "batch";
-      else
-       return currentMode;
-    }
-  }
-
-/**
-*
-* Set the current mode (interactive or batch).
-* @param newMode The new execution mode
-*
-*/
-  public void setCurrentMode(String newMode)
-  {
-    currentMode = newMode;
-  }
-
-/**
-*
-* Return the mode list as a vector, suitable for loading into
-* a combobox.
-* @return      mode list
-*
-*/
-  public Vector modeVector()
-  {
-    Vector mv = new Vector();
-    if (hasInteractiveMode)
-    {
-      if (hasBatchMode)
-      {
-       if (currentMode.equals("interactive"))
-        {
-         mv.add("interactive");
-         mv.add("batch");
-       }
-        else if (currentMode.equals("batch"))
-        {
-         mv.add("batch");
-         mv.add("interactive");
-       }
-        else
-        {
-         mv.add(currentMode);
-         mv.add("interactive");
-         mv.add("batch");
-       }
-      }
-      else
-       mv.add("interactive");
-    }
-    else
-    {
-      if(hasBatchMode)
-       mv.add("batch");
-    }
-    return mv;
-  }
-
-/**
-*
-* Update the properties structure.
-* This doesn't update the actual properties, just the Properties object
-* so you must call updateSettingsFromProperties yoursefl
-*
-* @param  name   A String naming the property to be updated
-* @param  newvalue  A String containing the new value of the property
-*
-*/
-  public void updateJembossProperty(String name, String newvalue)
-  {
-    if (jembossSettings.getProperty(name) != null)
-      jembossSettings.setProperty(name,newvalue);
-  }
-
-/**
-*
-* Parse a key=value string to update the properties structure
-* @param entry String containing a key=value message
-*
-*/
-  public void updateJembossPropString(String entry)
-  {
-    int isep = entry.indexOf('=');
-    if(isep != -1)
-    {
-      String pkey = entry.substring(0,isep);
-      String pvalue = entry.substring(isep+1);
-      updateJembossProperty(pkey, pvalue);
-    }
-  }
-
-/**
-*
-* Parse an array of key=value strings to update the properties structure
-* @param entries Array of Strings containing key=value messages
-*
-*/
-  public void updateJembossPropStrings(String[] entries)
-  {
-    for (int i=0; i < entries.length; ++i)
-      updateJembossPropString(entries[i]);
-
-    updateSettingsFromProperties();
-    setupServerRedundancy();
-  }
-
-/**
-*
-* Update properties from a Hashtable
-* @param hash Hashtable containg properties
-*
-*/
-  public void updateJembossPropHash(Hashtable hash)
-  {
-    Enumeration enumer = hash.keys();
-    while(enumer.hasMoreElements())
-    {
-      String thiskey = (String)enumer.nextElement().toString();
-      String thisval = (String)hash.get(thiskey);
-      updateJembossProperty(thiskey,thisval);
-    }
-    updateSettingsFromProperties();
-  }
-
-}
-
diff --git a/src/ext/jemboss/soap/JembossRun.java b/src/ext/jemboss/soap/JembossRun.java
deleted file mode 100755 (executable)
index 8697b19..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/********************************************************************
-*
-*  This library is free software; you can redistribute it and/or
-*  modify it under the terms of the GNU Library General Public
-*  License as published by the Free Software Foundation; either
-*  version 2 of the License, or (at your option) any later version.
-*
-*  This library 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
-*  Library General Public License for more details.
-*
-*  You should have received a copy of the GNU Library General Public
-*  License along with this library; if not, write to the
-*  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-*  Boston, MA  02111-1307, USA.
-*
-*  Based on EmbreoRun
-*
-*  @author: Copyright (C) Tim Carver
-*
-********************************************************************/
-
-
-package ext.jemboss.soap;
-
-import java.io.*;
-import java.util.*;
-
-import ext.jemboss.JembossParams;
-
-/**
-*
-* Executes an application on a server
-*
-*/
-public class JembossRun
-{
-
-  /** status message */
-  private String statusmsg;
-  /** status of the request */
-  private String status;
-  /** program result */
-  private Hashtable proganswer;
-
-  /**
-  *
-  * @param appl        defining command
-  * @param options     defining options
-  * @param filesToMove  Hashtable of filenames and contents
-  * @param mysettings  jemboss properties
-  * @throws JembossSoapException if authentication fails
-  *
-  */
-  public JembossRun(String appl, String options, Hashtable filesToMove,
-                    JembossParams mysettings) throws JembossSoapException
-  {
-
-    String fulloptions;
-
-    Vector params = new Vector();
-    params.addElement(appl);
-
-     //construct a full options string
-    fulloptions = "mode="+mysettings.getCurrentMode()+" "+options;
-//   if (mysettings.getUseX11())
-//     fulloptions = "display="+mysettings.getX11display()+" "+fulloptions;
-    params.addElement(fulloptions);
-
-    // just pass the hash
-    params.addElement(filesToMove);
-
-    PrivateRequest eRun;
-    try
-    {
-      eRun = new PrivateRequest(mysettings,
-                              "run_prog", params);
-    }
-    catch (JembossSoapException e)
-    {
-      throw new JembossSoapException("Authentication Failed");
-    }
-
-    proganswer = eRun.getHash();
-    status = proganswer.get("status").toString();
-    statusmsg = proganswer.get("msg").toString();
-
-    proganswer.remove("status");  // delete the status/msg
-    proganswer.remove("msg");
-  }
-
-
-  /**
-  *
-  * The status of the request
-  * @return    0 for success
-  *
-  */
-  public String getStatus()
-  {
-    return status;
-  }
-
-  /**
-  *
-  * A status message or description of a error
-  * @return    status message
-  *
-  */
-  public String getStatusMsg()
-  {
-    return statusmsg;
-  }
-
-  /**
-  *
-  * Get a Hashtable of filenames and their contents generated by
-  * running the application
-  * @return    results
-  *
-  */
-  public Hashtable hash()
-  {
-    return proganswer;
-  }
-
-
-  /**
-  *
-  * Get a result from the result Hashtable
-  * @param key key into the results Hashtable
-  * @return    element in the results Hashtable
-  *
-  */
-  public Object get(Object key)
-  {
-    return proganswer.get(key);
-  }
-
-}
-
diff --git a/src/ext/jemboss/soap/JembossSoapException.java b/src/ext/jemboss/soap/JembossSoapException.java
deleted file mode 100755 (executable)
index cf702b3..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/****************************************************************
-*
-*  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 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.
-*
-*  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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-*
-*  Based on EmbreoResList
-*
-*  @author: Copyright (C) Tim Carver
-*
-***************************************************************/
-
-package ext.jemboss.soap;
-
-
-public class JembossSoapException extends Exception
-{
-
-/**
-*
-* When trown indicates a communication error with the server.
-* Note that authentication errors should throw and JembossException
-* and transport errors we can't sort out should throw a SOAPException.
-*
-*/
-  public JembossSoapException()
-  {
-    super();
-  }
-
-  public JembossSoapException(String s)
-  {
-    super(s);
-  }
-
-}
diff --git a/src/ext/jemboss/soap/MakeFileSafe.java b/src/ext/jemboss/soap/MakeFileSafe.java
deleted file mode 100755 (executable)
index 6020611..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************
-*
-*  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 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.
-*
-*  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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-*
-*  Based on EmbreoMakeFileSafe
-*
-*  @author: Copyright (C) Tim Carver
-*
-***************************************************************/
-
-package ext.jemboss.soap;
-
-import java.io.*;
-
-/**
-*
-* Create a sanitised filename. All undesirable characters in the
-* filename are replaced by underscores.
-*
-*/
-public class MakeFileSafe
-{
-
-  private String safeFileName;
-
-  /**
-  *
-  * @param unSafeFileName unsanitised name of the file
-  *
-  */
-  public MakeFileSafe(String unSafeFileName)
-  {
-    char c;
-    int len = unSafeFileName.length();
-    StringBuffer dest = new StringBuffer(len);
-
-    for(int i=0 ; i<len; i++)
-    {
-      c = unSafeFileName.charAt(i);
-      if(c == ':')
-       dest.append('_');
-      else if(c == '/')
-       dest.append('_');
-      else if(c == ' ')
-       dest.append('_');
-      else if(c == '>')
-       dest.append('_');
-      else if(c == '<')
-       dest.append('_');
-      else if(c == ';')
-       dest.append('_');
-      else if(c == '\\')
-       dest.append('_');
-      else
-       dest.append(c);
-
-    }
-    safeFileName = dest.toString();
-  }
-
-  /**
-  *
-  * Get the safe/sanitised file name
-  * @return    sanitised file name
-  *
-  */
-  public String getSafeFileName()
-  {
-    return safeFileName;
-  }
-}
diff --git a/src/ext/jemboss/soap/PrivateRequest.java b/src/ext/jemboss/soap/PrivateRequest.java
deleted file mode 100755 (executable)
index 892db3a..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-/****************************************************************
-*
-*  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 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.
-*
-*  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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-*
-*  @author: Copyright (C) Tim Carver
-*
-***************************************************************/
-
-package ext.jemboss.soap;
-
-import java.io.*;
-import java.util.*;
-
-import ext.jemboss.JembossParams;
-import javax.swing.JOptionPane;
-//AXIS
-import org.apache.axis.client.Call;
-import org.apache.axis.client.Service;
-import javax.xml.namespace.QName;
-import org.apache.axis.encoding.XMLType;
-
-/**
-*
-* Make a axis call to a private server, using the default service
-*
-*/
-public class PrivateRequest
-{
-
-  /** results from calling the web service */
-  private Hashtable proganswer;
-
-  /**
-  *
-  * @param mysettings jemboss properties
-  * @param method     method to call
-  * @param args       arguments
-  * @throws JembossSoapException if authentication fails
-  *
-  */
-   public PrivateRequest(JembossParams mysettings, String method, Vector args)
-                throws JembossSoapException
-   {
-     this(mysettings, mysettings.getPrivateSoapService(), method, args);
-   }
-
-  /**
-  *
-  * @param mysettings jemboss properties
-  * @param service    service to call
-  * @param method     method to call
-  * @throws JembossSoapException If authentication fails
-  *
-  */
-   public PrivateRequest(JembossParams mysettings, String service, String method)
-                throws JembossSoapException
-   {
-     this(mysettings, service, method, (Vector) null);
-   }
-
-  /**
-  *
-  * @param mysettings jemboss properties
-  * @param service    service to call
-  * @param method     method to call
-  * @param args       arguments
-  * @throws JembossSoapException if authentication fails
-  */
-   public PrivateRequest(JembossParams mysettings, String service, String method,
-                         Vector args) throws JembossSoapException
-   {
-     try
-     {
-       String  endpoint = mysettings.getPublicSoapURL()+"/"+service;
-       org.apache.axis.client.Service serv =
-                               new org.apache.axis.client.Service();
-       Call    call     = (Call) serv.createCall();
-       QName   qn       = new QName(service, method);
-       call.setTargetEndpointAddress( new java.net.URL(endpoint) );
-       call.setOperationName(new QName(service, method));
-       call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP12_ENC);
-
-       int nargs = 0;
-       Object params[] = null;
-       if(args != null)
-       {
-         if(mysettings.getUseAuth())
-           nargs = args.size()+2;
-         else
-           nargs = args.size()+1;
-
-         params = new Object[nargs];
-         Enumeration e = args.elements();
-         for(int i=0;i<args.size();i++)
-         {
-           Object obj = e.nextElement();
-           params[i] = obj;
-           if(obj.getClass().equals(String.class))
-           {
-             call.addParameter("Args"+i, XMLType.XSD_STRING,
-                             javax.xml.rpc.ParameterMode.IN);
-           }
-           else if(obj.getClass().equals(Hashtable.class))
-           {
-             params[i] = getVector((Hashtable)obj);
-
-             call.addParameter("Args"+i, XMLType.SOAP_VECTOR,
-                             javax.xml.rpc.ParameterMode.IN);
-           }
-           else    // byte[]
-           {
-             call.addParameter("ByteArray", XMLType.XSD_BASE64,
-                               javax.xml.rpc.ParameterMode.IN);
-             params[i] = obj;
-           }
-
-         }
-       }
-
-       if(mysettings.getUseAuth() == true)
-       {
-         if(args == null)
-         {
-           nargs = 2;
-           params = new Object[nargs];
-         }
-         call.addParameter("Door", XMLType.XSD_STRING,
-                           javax.xml.rpc.ParameterMode.IN);
-         params[nargs-2] = mysettings.getServiceUserName();
-
-         call.addParameter("Key", XMLType.XSD_BASE64,
-                           javax.xml.rpc.ParameterMode.IN);
-         params[nargs-1] = mysettings.getServicePasswdByte();
-       }
-       else       //No authorization reqd, so use user name here
-       {          //to create own sand box on server
-         if(nargs == 0)
-         {
-            nargs = 1;
-            params = new Object[nargs];
-         }
-
-         if(args == null)
-           args = new Vector();
-         call.addParameter("Door", XMLType.XSD_STRING,
-                           javax.xml.rpc.ParameterMode.IN);
-         params[nargs-1] = System.getProperty("user.name");
-       }
-
-       call.setReturnType(org.apache.axis.Constants.SOAP_VECTOR);
-       Vector vans = (Vector)call.invoke( params );
-
-       proganswer = new Hashtable();
-       // assumes it's even sized
-       int n = vans.size();
-       for(int j=0;j<n;j+=2)
-       {
-         String s = (String)vans.get(j);
-         if(s.equals("msg"))
-         {
-           String msg = (String)vans.get(j+1);
-           if(msg.startsWith("Failed Authorisation"))
-             throw new JembossSoapException("Authentication Failed");
-           else if(msg.startsWith("Error"))
-             throw new JembossSoapException(msg);
-         }
-         proganswer.put(s,vans.get(j+1));
-       }
-     }
-     catch (Exception e)
-     {
-        System.out.println("Exception in PrivateRequest "+
-                            e.getMessage ()
-                           );
-        e.printStackTrace();
-        throw new JembossSoapException("  Fault Code   = " + e);
-     }
-
-   }
-
-  /**
-  *
-  * Change the contents of a hashtable to a vector
-  * @return    contents of the hash
-  *
-  */
-  private Vector getVector(Hashtable h)
-  {
-    Vector v = new Vector();
-    for(Enumeration e = h.keys() ; e.hasMoreElements() ;)
-    {
-      String s = (String)e.nextElement();
-      v.add(s);
-      v.add(h.get(s));
-    }
-
-    return v;
-  }
-
-
-  /**
-  *
-  * Gets an element out of the embreo result hash
-  * @param val         key to look up
-  * @return    the element, or an empty String if there is no
-  *            element that matches the key
-  *
-  */
-  public Object getVal(String val)
-  {
-    if (proganswer.containsKey(val))
-      return proganswer.get(val);
-    else
-      return "";
-  }
-
-  /**
-  *
-  * Get the results returned by the server call
-  * @return    results
-  *
-  */
-  public Hashtable getHash()
-  {
-    return proganswer;
-  }
-}
-
diff --git a/src/ext/jemboss/soap/PublicRequest.java b/src/ext/jemboss/soap/PublicRequest.java
deleted file mode 100755 (executable)
index a247030..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************
-*
-*  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 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.
-*
-*  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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-*
-*  Based on EmbreoPublicRequest
-*
-*  @author: Copyright (C) Tim Carver
-*
-***************************************************************/
-
-package ext.jemboss.soap;
-
-import java.io.*;
-import java.util.*;
-
-import ext.jemboss.JembossParams;
-
-//AXIS
-import org.apache.axis.client.Call;
-import org.apache.axis.client.Service;
-import javax.xml.namespace.QName;
-import org.apache.axis.encoding.XMLType;
-
-/**
-*
-* Make a axis call to a public server, using the default service
-*
-*/
-public class PublicRequest
-{
-
-  private Hashtable proganswer;
-
-  /**
-  *
-  * @param mysettings  jemboss properties
-  * @param method      method to call
-  * @throws JembossSoapException if call to web service fails
-  *
-  */
-   public PublicRequest(JembossParams mysettings, String method)
-               throws JembossSoapException
-   {
-     this(mysettings, mysettings.getPublicSoapService(), method);
-   }
-
-  /**
-  *
-  * @param mysettings  jemboss properties
-  * @param method      method to call
-  * @param args        arguments
-  * @throws JembossSoapException if call to web service fails
-  *
-  */
-   public PublicRequest(JembossParams mysettings, String method, Vector args)
-               throws JembossSoapException
-   {
-     this(mysettings, mysettings.getPublicSoapService(), method, args);
-   }
-
-  /**
-  *
-  * @param mysettings  jemboss properties
-  * @param service     web service to call
-  * @param method      method to call
-  * @throws JembossSoapException if call to web service fails
-  *
-  */
-   public PublicRequest(JembossParams mysettings, String service, String method)
-               throws JembossSoapException
-   {
-     this(mysettings, service, method, (Vector) null);
-   }
-
-  /**
-  *
-  * @param mysettings  jemboss properties
-  * @param service     web service to call
-  * @param method      method to call
-  * @param args        arguments
-  * @throws JembossSoapException if call to web service fails
-  *
-  */
-   public PublicRequest(JembossParams mysettings, String service,
-                        String method, Vector args)
-               throws JembossSoapException
-   {
-
-     try
-     {
-       String  endpoint = mysettings.getPublicSoapURL();
-       org.apache.axis.client.Service serv =
-                        new org.apache.axis.client.Service();
-
-       Call    call     = (Call) serv.createCall();
-       call.setTargetEndpointAddress( new java.net.URL(endpoint) );
-       call.setOperationName(new QName(service, method));
-
-       Object params[] = null;
-       if(args != null)
-       {
-         params = new Object[args.size()];
-         Enumeration e = args.elements();
-         for(int i=0;i<args.size();i++)
-         {
-           Object obj = e.nextElement();
-           if(obj.getClass().equals(String.class))
-           {
-             params[i] = (String)obj;
-             call.addParameter("Args", XMLType.XSD_STRING,
-                             javax.xml.rpc.ParameterMode.IN);
-           }
-           else
-           {
-             params[i] = (byte[])obj;
-             call.addParameter("Args", XMLType.XSD_BYTE,
-                             javax.xml.rpc.ParameterMode.IN);
-           }
-         }
-       }
-       call.setReturnType(org.apache.axis.Constants.SOAP_VECTOR);
-
-       Vector vans;
-       if(args != null)
-         vans = (Vector)call.invoke( params );
-       else
-         vans = (Vector)call.invoke( new Object[] {});
-
-       proganswer = new Hashtable();
-       // assumes it's even sized
-       int n = vans.size();
-       for(int j=0;j<n;j+=2)
-       {
-         String s = (String)vans.get(j);
-         proganswer.put(s,vans.get(j+1));
-       }
-     }
-     catch (Exception e)
-     {
-       throw new JembossSoapException("Connection failed");
-     }
-
-   }
-
-
-  /**
-  *
-  * Gets an element out of the Jemboss result hash
-  * @param val         key to look up
-  * @return    element, or an empty String if there isn't
-  *            an element that matches the key
-  *
-  */
-  public String getVal(String val)
-  {
-    if (proganswer.containsKey(val))
-      return (String)proganswer.get(val);
-    else
-      return "";
-  }
-
-
-  /**
-  *
-  * The hash returned by the Jemboss call.
-  * @param     result
-  *
-  */
-  public Hashtable getHash()
-  {
-    return proganswer;
-  }
-
-}
index 48e771e..58fd444 100755 (executable)
@@ -172,10 +172,10 @@ public class AlignmentSorter {
 \r
 \r
   public static void sortBy(AlignmentI align, AlignmentOrder order) {\r
-    // Get an order vector that is a proper permutation of the positions in align\r
+    // Get an ordered vector of sequences which may also be present in align\r
     Vector tmp = order.getOrder();\r
-    if (tmp.size()<align.getHeight())\r
-      addStrays(align, tmp);\r
+//    if (tmp.size()<align.getHeight())\r
+//      addStrays(align, tmp);\r
     setOrder(align, tmp);\r
   }\r
 \r
diff --git a/src/jalview/analysis/SeqsetUtils.java b/src/jalview/analysis/SeqsetUtils.java
new file mode 100755 (executable)
index 0000000..cdcecc0
--- /dev/null
@@ -0,0 +1,52 @@
+package jalview.analysis;
+
+import jalview.datamodel.SequenceI;
+import java.util.Hashtable;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2004</p>
+ *
+ * <p>Company: Dundee University</p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class SeqsetUtils
+{
+  public static Hashtable uniquify(SequenceI[] sequences)
+  {
+    // Generate a safely named sequence set and a hash to recover the sequence names
+    Hashtable map = new Hashtable();
+    for (int i = 0; i < sequences.length; i++)
+    {
+      String safename = new String("Sequence" + i);
+      map.put(safename, sequences[i].getName());
+      sequences[i].setName(safename);
+    }
+    return map;
+  }
+
+  public static boolean deuniquify(Hashtable map, SequenceI[] sequences)
+  {
+    // recover unsafe sequence names for a sequence set
+    boolean allfound = true;
+    for (int i = 0; i < sequences.length; i++)
+    {
+      if (map.containsKey(sequences[i].getName()))
+      {
+        String unsafename = (String) map.get(sequences[i].getName());
+        sequences[i].setName(unsafename);
+      }
+      else
+      {
+        allfound = false;
+      }
+    }
+    return allfound;
+  }
+
+}
diff --git a/src/jalview/datamodel/AlignmentOrder.java b/src/jalview/datamodel/AlignmentOrder.java
new file mode 100755 (executable)
index 0000000..445671d
--- /dev/null
@@ -0,0 +1,117 @@
+package jalview.datamodel;
+
+import java.util.*;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2004</p>
+ *
+ * <p>Company: Dundee University</p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class AlignmentOrder
+{
+  public AlignmentOrder()
+  {
+  }
+
+  public void setType(int Type)
+  {
+    this.Type = Type;
+  }
+
+  public int getType()
+  {
+    return Type;
+  }
+
+  public void setName(String Name)
+  {
+    this.Name = Name;
+  }
+
+  public String getName()
+  {
+    return Name;
+  }
+
+  public void setOrder(Vector Order)
+  {
+    this.Order = Order;
+  }
+
+  public Vector getOrder()
+  {
+
+    return Order;
+  }
+// JBPNote : this method would return a vector containing all sequences in seqset
+// with those also contained in order at the beginning of the vector in the order
+// given by order. AlignmentSorter.vectorSubsetToArray already does this, but that method
+// should be here for completeness.
+
+/*  public Vector getOrder(AlignmentI seqset)
+  {
+    Vector perm = new Vector(seqset.getHeight());
+    for (i=0, o = 0, n=seqset.getHeight(), p = Order.size(); i<n; i++)
+      perm.setElement(i,...).
+    return Order;
+  }
+ */
+  public static final int FILE = 0;
+  public static final int MSA = 1;
+  public static final int USER = 2;
+
+  private int Type = 0;
+  private String Name;
+  private Vector Order = null;
+
+  /**
+   * AlignmentOrder
+   *
+   * @param anOrder Vector
+   */
+  public AlignmentOrder(Vector anOrder)
+  {
+    Order = anOrder;
+  }
+
+  /**
+   * AlignmentOrder
+   *
+   * @param orderFrom AlignmentI
+   */
+  public AlignmentOrder(AlignmentI orderFrom)
+  {
+    Order = new Vector();
+
+    for (int i=0,ns=orderFrom.getHeight(); i<ns; i++)
+      Order.addElement(orderFrom.getSequenceAt(i));
+  }
+  public AlignmentOrder(SequenceI[] orderFrom) {
+    Order = new Vector();
+    for (int i=0,ns=orderFrom.length; i<ns; i++)
+      Order.addElement(orderFrom[i]);
+  }
+
+
+
+  /**
+   * AlignmentOrder
+   *
+   * @param orderThis AlignmentI
+   * @param byThat AlignmentI
+   */
+  /* public AlignmentOrder(AlignmentI orderThis, AlignmentI byThat)
+  {
+    // Vector is an ordering of this alignment using the order of sequence objects in byThat,
+    // where ids and unaligned sequences must match
+
+  } */
+
+}
index 725a702..1ff77e6 100755 (executable)
-/********************\r
- * 2004 Jalview Reengineered\r
- * Barton Group\r
- * Dundee University\r
- *\r
- * AM Waterhouse\r
- *******************/\r
-\r
-\r
-\r
-\r
-package jalview.gui;\r
-\r
-import jalview.jbgui.GAlignFrame;\r
-import jalview.schemes.*;\r
-import jalview.datamodel.*;\r
-import jalview.analysis.*;\r
-import jalview.io.*;\r
-import jalview.ws.*;\r
-import java.awt.*;\r
-import java.awt.event.*;\r
-import java.awt.print.*;\r
-import javax.swing.*;\r
-import javax.swing.event.*;\r
-import java.util.*;\r
-import java.awt.datatransfer.*;\r
-\r
-\r
-public class AlignFrame extends GAlignFrame\r
-{\r
-  final AlignmentPanel alignPanel;\r
-  final AlignViewport viewport;\r
-  public static final int NEW_WINDOW_WIDTH = 700;\r
-  public static final int NEW_WINDOW_HEIGHT = 500;\r
-  public String currentFileFormat = "Jalview";\r
-\r
-  public AlignFrame(AlignmentI al)\r
-  {\r
-    viewport = new AlignViewport(al);\r
-\r
-    alignPanel = new AlignmentPanel(this, viewport);\r
-    alignPanel.annotationPanel.adjustPanelHeight();\r
-    alignPanel.annotationSpaceFillerHolder.setPreferredSize(alignPanel.annotationPanel.getPreferredSize());\r
-    alignPanel.annotationScroller.setPreferredSize(alignPanel.annotationPanel.getPreferredSize());\r
-    alignPanel.setAnnotationVisible( viewport.getShowAnnotation() );\r
-\r
-    getContentPane().add(alignPanel, java.awt.BorderLayout.CENTER);\r
-\r
-    addInternalFrameListener(new InternalFrameAdapter()\r
-   {\r
-     public void internalFrameActivated(InternalFrameEvent evt)\r
-     {\r
-          javax.swing.SwingUtilities.invokeLater(new Runnable()\r
-          {\r
-            public void run()\r
-            {      alignPanel.requestFocus();    }\r
-          });\r
-\r
-     }\r
-   });\r
-\r
-  }\r
-\r
-  public void saveAlignmentMenu_actionPerformed(ActionEvent e)\r
-  {\r
-    JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY")\r
-        ,  new String[]{"fa, fasta, fastq", "aln",  "pfam", "msf", "pir","blc","jar"},\r
-          new String[]{"Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview"},\r
-          currentFileFormat);\r
-\r
-    chooser.setAcceptAllFileFilterUsed(false);\r
-    chooser.setFileView(new JalviewFileView());\r
-    chooser.setDialogTitle("Save Alignment to file");\r
-    chooser.setToolTipText("Save");\r
-    int value = chooser.showSaveDialog(this);\r
-    if(value == JalviewFileChooser.APPROVE_OPTION)\r
-    {\r
-      currentFileFormat  = chooser.getSelectedFormat();\r
-\r
-      if (currentFileFormat.equals("Jalview"))\r
-      {\r
-        String shortName = title.replace('/', '_');\r
-        title = title.replace('\\', '_');\r
-        String choice = chooser.getSelectedFile().getPath();\r
-        Jalview2XML.SaveState(this, System.currentTimeMillis(), shortName,\r
-                              choice);\r
-        // USE Jalview2XML to save this file\r
-        return;\r
-      }\r
-\r
-      String choice =  chooser.getSelectedFile().getPath();\r
-      jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);\r
-      String output = FormatAdapter.formatSequences(currentFileFormat, viewport.getAlignment().getSequences());\r
-      try{\r
-        java.io.PrintWriter out = new java.io.PrintWriter( new java.io.FileWriter( choice )  );\r
-        out.println(output);\r
-        out.close();\r
-      }\r
-      catch(Exception ex){}\r
-    }\r
-\r
-  }\r
-\r
-  protected void outputText_actionPerformed(ActionEvent e)\r
-  {\r
-     CutAndPasteTransfer cap = new CutAndPasteTransfer(false);\r
-     JInternalFrame frame = new JInternalFrame();\r
-     cap.formatForOutput();\r
-     frame.setContentPane(cap);\r
-     Desktop.addInternalFrame(frame, "Alignment output - "+e.getActionCommand(), 600, 500);\r
-     cap.setText( FormatAdapter.formatSequences(e.getActionCommand(), viewport.getAlignment().getSequences()));\r
-  }\r
-\r
-  protected void htmlMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    HTMLOutput htmlOutput = new HTMLOutput(viewport);\r
-    htmlOutput = null;\r
-  }\r
-\r
-  protected void createPNG_actionPerformed(ActionEvent e)\r
-  {\r
-    alignPanel.makePNG();\r
-  }\r
-\r
-  protected void epsFile_actionPerformed(ActionEvent e)\r
-  {\r
-    alignPanel.makeEPS();\r
-  }\r
-\r
-\r
-  public void printMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    //Putting in a thread avoids Swing painting problems\r
-    PrintThread thread = new PrintThread();\r
-    thread.start();\r
-  }\r
-\r
-  class PrintThread extends Thread\r
-  {\r
-    public void run()\r
-    {\r
-      PrinterJob printJob = PrinterJob.getPrinterJob();\r
-      PageFormat pf = printJob.pageDialog(printJob.defaultPage());\r
-      printJob.setPrintable(alignPanel, pf);\r
-      if (printJob.printDialog())\r
-      {\r
-        try\r
-        {\r
-          printJob.print();\r
-        }\r
-        catch (Exception PrintException)\r
-        {\r
-          PrintException.printStackTrace();\r
-        }\r
-      }\r
-    }\r
-\r
-  }\r
-\r
-\r
-\r
-\r
-  public void closeMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    try{\r
-      this.setClosed(true);\r
-    }catch(Exception ex){}\r
-  }\r
-\r
-  Stack historyList = new Stack();\r
-  Stack redoList = new Stack();\r
-\r
-  void updateEditMenuBar()\r
-  {\r
-    if(historyList.size()>0)\r
-     {\r
-       undoMenuItem.setEnabled(true);\r
-       Object [] history = (Object[])historyList.get(0);\r
-       undoMenuItem.setText("Undo "+history[0]);\r
-     }\r
-    else\r
-    {\r
-      undoMenuItem.setEnabled(false);\r
-      undoMenuItem.setText("Undo");\r
-    }\r
-\r
-    if(redoList.size()>0)\r
-     {\r
-       redoMenuItem.setEnabled(true);\r
-       Object [] history = (Object[])redoList.get(0);\r
-       redoMenuItem.setText("Redo "+history[0]);\r
-     }\r
-    else\r
-    {\r
-      redoMenuItem.setEnabled(false);\r
-      redoMenuItem.setText("Redo");\r
-    }\r
-  }\r
-\r
-  public void addHistoryItem(String type)\r
-  {\r
-    // must make sure we add new sequence objects her, not refs to the existing sequences\r
-    redoList.clear();\r
-\r
-    SequenceI[] seq = new SequenceI[viewport.getAlignment().getHeight()];\r
-    for(int i=0; i<viewport.getAlignment().getHeight(); i++)\r
-    {\r
-      seq[i] = new Sequence( viewport.getAlignment().getSequenceAt(i).getName(),\r
-                             viewport.getAlignment().getSequenceAt(i).getSequence());\r
-    }\r
-\r
-\r
-    historyList.add(0, new Object[]{type,  seq} );\r
-    updateEditMenuBar();\r
-  }\r
-\r
-  protected void undoMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    Object [] history = (Object[])historyList.remove(0);\r
-    // add the redo state before continuing!!\r
-    SequenceI[] seq = new SequenceI[viewport.getAlignment().getHeight()];\r
-    for (int i = 0; i < viewport.getAlignment().getHeight(); i++)\r
-    {\r
-      seq[i] = new Sequence(viewport.getAlignment().getSequenceAt(i).getName(),\r
-                            viewport.getAlignment().getSequenceAt(i).\r
-                            getSequence());\r
-    }\r
-    /////////\r
-\r
-    redoList.add(0, new Object[] {history[0], seq});\r
-\r
-      seq = (SequenceI[]) history[1];\r
-      AlignmentAnnotation [] old = viewport.alignment.getAlignmentAnnotation();\r
-      viewport.setAlignment( new Alignment(seq) );\r
-      viewport.alignment.setGapCharacter( Preferences.gapSymbol );\r
-      updateEditMenuBar();\r
-      for(int i=0; i<old.length; i++)\r
-        viewport.alignment.addAnnotation(old[i]);\r
-      viewport.updateConsensus();\r
-      viewport.updateConservation();\r
-      alignPanel.repaint();\r
-  }\r
-\r
-  public void moveSelectedSequences(boolean up)\r
-  {\r
-    SequenceGroup sg = viewport.getSelectionGroup();\r
-    if (sg == null)\r
-      return;\r
-\r
-    if (up)\r
-    {\r
-      for (int i = 1; i < viewport.alignment.getHeight(); i++)\r
-      {\r
-        SequenceI seq = viewport.alignment.getSequenceAt(i);\r
-        if (!sg.sequences.contains(seq))\r
-          continue;\r
-\r
-        SequenceI temp = viewport.alignment.getSequenceAt(i - 1);\r
-        if (sg.sequences.contains(temp))\r
-          continue;\r
-\r
-        viewport.alignment.getSequences().setElementAt(temp, i);\r
-        viewport.alignment.getSequences().setElementAt(seq, i - 1);\r
-      }\r
-    }\r
-    else\r
-    {\r
-      for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)\r
-      {\r
-        SequenceI seq = viewport.alignment.getSequenceAt(i);\r
-        if (!sg.sequences.contains(seq))\r
-          continue;\r
-\r
-        SequenceI temp = viewport.alignment.getSequenceAt(i + 1);\r
-        if (sg.sequences.contains(temp))\r
-          continue;\r
-\r
-        viewport.alignment.getSequences().setElementAt(temp, i);\r
-        viewport.alignment.getSequences().setElementAt(seq, i + 1);\r
-      }\r
-    }\r
-\r
-    alignPanel.repaint();\r
-  }\r
-\r
-\r
-\r
-  protected void copy_actionPerformed(ActionEvent e)\r
-  {\r
-     if(viewport.getSelectionGroup()==null)\r
-       return;\r
-\r
-     SequenceGroup sg = viewport.getSelectionGroup();\r
-\r
-     Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();\r
-     StringBuffer buffer= new StringBuffer();\r
-\r
-     Hashtable orderedSeqs = new Hashtable();\r
-     for(int i=0; i<sg.getSize(); i++)\r
-     {\r
-        SequenceI seq = sg.getSequenceAt(i);\r
-        int index = viewport.alignment.findIndex(seq);\r
-        orderedSeqs.put(index+"", seq);\r
-     }\r
-\r
-     int index=0;\r
-     for(int i=0; i<sg.getSize(); i++)\r
-     {\r
-       SequenceI seq = null;\r
-       while( seq == null )\r
-       {\r
-         if(orderedSeqs.containsKey(index+""))\r
-         {\r
-           seq = (SequenceI) orderedSeqs.get(index + "");\r
-           index++;\r
-           break;\r
-         }\r
-         else\r
-           index++;\r
-       }\r
-\r
-         buffer.append( seq.getName()+"\t"+seq.findPosition( sg.getStartRes() ) +"\t"\r
-                        +seq.findPosition( sg.getEndRes() )+ "\t"\r
-                        +sg.getSequenceAt(i).getSequence(sg.getStartRes(), sg.getEndRes()+1)+"\n");\r
-     }\r
-     c.setContents( new StringSelection( buffer.toString()) , null ) ;\r
-\r
-  }\r
-\r
-\r
-  protected void pasteNew_actionPerformed(ActionEvent e)\r
-  {\r
-    paste(true);\r
-  }\r
-\r
-  protected void pasteThis_actionPerformed(ActionEvent e)\r
-  {\r
-    addHistoryItem("Paste");\r
-    paste(false);\r
-  }\r
-\r
-  void paste(boolean newAlignment)\r
-  {\r
-    try{\r
-      Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();\r
-      Transferable contents = c.getContents(this);\r
-      if (contents == null)\r
-        return;\r
-\r
-      String str = (String) contents.getTransferData(DataFlavor.stringFlavor);\r
-      StringTokenizer st = new StringTokenizer(str);\r
-      ArrayList seqs = new ArrayList();\r
-      while (st.hasMoreElements())\r
-      {\r
-        String name = st.nextToken();\r
-        int start = Integer.parseInt(st.nextToken());\r
-        int end = Integer.parseInt(st.nextToken());\r
-        Sequence sequence = new Sequence(name,st.nextToken(), start, end);\r
-\r
-        if(!newAlignment)\r
-          viewport.alignment.addSequence(sequence);\r
-        else\r
-          seqs.add(sequence);\r
-      }\r
-\r
-      if(newAlignment)\r
-      {\r
-        SequenceI[] newSeqs = new SequenceI[seqs.size()];\r
-        seqs.toArray(newSeqs);\r
-        AlignFrame af = new AlignFrame(new Alignment(newSeqs));\r
-        String newtitle = new String("Copied sequences");\r
-        if( title.startsWith("Copied sequences"))\r
-         newtitle = title;\r
-       else\r
-         newtitle = newtitle.concat("- from "+title);\r
-\r
-        Desktop.addInternalFrame(af, newtitle, NEW_WINDOW_WIDTH, NEW_WINDOW_HEIGHT);\r
-      }\r
-      else\r
-      {\r
-        viewport.setEndSeq(viewport.alignment.getHeight());\r
-        viewport.alignment.getWidth();\r
-        viewport.updateConservation();\r
-        viewport.updateConsensus();\r
-        alignPanel.repaint();\r
-      }\r
-\r
-    }catch(Exception ex){}// could be anything being pasted in here\r
-\r
-  }\r
-\r
-\r
-  protected void cut_actionPerformed(ActionEvent e)\r
-  {\r
-    copy_actionPerformed(null);\r
-    delete_actionPerformed(null);\r
-  }\r
-\r
-  protected void delete_actionPerformed(ActionEvent e)\r
-  {\r
-    addHistoryItem("Delete");\r
-    if (viewport.getSelectionGroup() == null)\r
-      return;\r
-\r
-     SequenceGroup sg = viewport.getSelectionGroup();\r
-     for (int i=0;i < sg.sequences.size(); i++)\r
-     {\r
-       SequenceI seq = sg.getSequenceAt(i);\r
-       int index = viewport.getAlignment().findIndex(seq);\r
-       seq.deleteChars(sg.getStartRes(), sg.getEndRes()+1);\r
-\r
-       if(seq.getSequence().length()<1)\r
-          viewport.getAlignment().deleteSequence(seq);\r
-      else\r
-          viewport.getAlignment().getSequences().setElementAt(seq, index);\r
-     }\r
-\r
-     viewport.setSelectionGroup(null);\r
-     viewport.alignment.deleteGroup(sg);\r
-     viewport.resetSeqLimits( alignPanel.seqPanel.seqCanvas.getHeight());\r
-     if(viewport.getAlignment().getHeight()<1)\r
-     try\r
-     {\r
-       this.setClosed(true);\r
-     }catch(Exception ex){}\r
-   viewport.updateConservation();\r
-   viewport.updateConsensus();\r
-     alignPanel.repaint();\r
-\r
-  }\r
-\r
-\r
-\r
-  protected void redoMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-     Object [] history = (Object[])redoList.remove(0);\r
-     SequenceI[] seq = (SequenceI[]) history[1];\r
-     viewport.setAlignment( new Alignment(seq) );\r
-     viewport.alignment.setGapCharacter( Preferences.gapSymbol );\r
-     updateEditMenuBar();\r
-     viewport.updateConsensus();\r
-     alignPanel.repaint();\r
-     alignPanel.repaint();\r
-  }\r
-\r
-\r
-  protected void deleteGroups_actionPerformed(ActionEvent e)\r
-  {\r
-    viewport.alignment.deleteAllGroups();\r
-    viewport.setSelectionGroup(null);\r
-    alignPanel.repaint();\r
-  }\r
-\r
-\r
-\r
-  public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    SequenceGroup sg = new SequenceGroup();\r
-    for (int i=0; i<viewport.getAlignment().getSequences().size(); i++)\r
-      sg.addSequence( viewport.getAlignment().getSequenceAt(i));\r
-    sg.setEndRes(viewport.alignment.getWidth());\r
-    viewport.setSelectionGroup(sg);\r
-    PaintRefresher.Refresh(null);\r
-  }\r
-\r
-  public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    viewport.setSelectionGroup(null);\r
-    viewport.getColumnSelection().clear();\r
-    viewport.setSelectionGroup(null);\r
-    PaintRefresher.Refresh(null);\r
-  }\r
-\r
-  public void invertSequenceMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    SequenceGroup sg = viewport.getSelectionGroup();\r
-    for (int i=0; i<viewport.getAlignment().getSequences().size(); i++)\r
-      sg.addOrRemove (viewport.getAlignment().getSequenceAt(i));\r
-\r
-    PaintRefresher.Refresh(null);\r
-  }\r
-\r
-  public void remove2LeftMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    addHistoryItem("delete columns");\r
-    ColumnSelection colSel = viewport.getColumnSelection();\r
-    if (colSel.size() > 0)\r
-    {\r
-      int min = colSel.getMin();\r
-      viewport.getAlignment().trimLeft(min);\r
-      colSel.compensateForEdit(0,min);\r
-\r
-      if(viewport.getSelectionGroup()!=null)\r
-        viewport.getSelectionGroup().adjustForRemoveLeft(min);\r
-\r
-      Vector groups = viewport.alignment.getGroups();\r
-      for(int i=0; i<groups.size(); i++)\r
-      {\r
-        SequenceGroup sg = (SequenceGroup) groups.get(i);\r
-        if(!sg.adjustForRemoveLeft(min))\r
-          viewport.alignment.deleteGroup(sg);\r
-      }\r
-\r
-      alignPanel.repaint();\r
-    }\r
-  }\r
-\r
-  public void remove2RightMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    addHistoryItem("delete columns");\r
-    ColumnSelection colSel = viewport.getColumnSelection();\r
-    if (colSel.size() > 0)\r
-    {\r
-      int max = colSel.getMax();\r
-      viewport.getAlignment().trimRight(max);\r
-      if(viewport.getSelectionGroup()!=null)\r
-        viewport.getSelectionGroup().adjustForRemoveRight(max);\r
-\r
-      Vector groups = viewport.alignment.getGroups();\r
-      for(int i=0; i<groups.size(); i++)\r
-      {\r
-        SequenceGroup sg = (SequenceGroup) groups.get(i);\r
-        if(!sg.adjustForRemoveRight(max))\r
-          viewport.alignment.deleteGroup(sg);\r
-      }\r
-\r
-\r
-\r
-      alignPanel.repaint();\r
-    }\r
-\r
-  }\r
-\r
-  public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    addHistoryItem("delete gapped columns");\r
-    viewport.getAlignment().removeGaps();\r
-    viewport.updateConservation();\r
-    viewport.updateConsensus();\r
-    alignPanel.repaint();\r
-  }\r
-\r
-  public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    addHistoryItem("delete all gaps");\r
-    SequenceI current;\r
-    int jSize;\r
-    for (int i=0; i < viewport.getAlignment().getSequences().size();i++)\r
-    {\r
-      current = viewport.getAlignment().getSequenceAt(i);\r
-      jSize = current.getLength();\r
-      for (int j=0; j < jSize; j++)\r
-        if(jalview.util.Comparison.isGap(current.getCharAt(j)))\r
-        {\r
-          current.deleteCharAt(j);\r
-          j--;\r
-          jSize--;\r
-        }\r
-    }\r
-    viewport.updateConservation();\r
-    viewport.updateConsensus();\r
-    alignPanel.repaint();\r
-  }\r
-\r
-\r
-  public void findMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    JInternalFrame frame = new JInternalFrame();\r
-    Finder finder = new Finder(viewport, alignPanel, frame);\r
-    frame.setContentPane(finder);\r
-    Desktop.addInternalFrame(frame, "Find", 340,110);\r
-    frame.setLayer(JLayeredPane.PALETTE_LAYER);\r
-\r
-  }\r
-\r
-\r
-  public void font_actionPerformed(ActionEvent e)\r
-  {\r
-    FontChooser fc = new FontChooser( alignPanel );\r
-  }\r
-\r
-  protected void fullSeqId_actionPerformed(ActionEvent e)\r
-  {\r
-    viewport.setShowFullId( fullSeqId.isSelected() );\r
-\r
-    alignPanel.idPanel.idCanvas.setPreferredSize( alignPanel.calculateIdWidth() );\r
-    alignPanel.repaint();\r
-  }\r
-\r
-  protected void colourTextMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-      viewport.setColourText( colourTextMenuItem.isSelected() );\r
-      alignPanel.repaint();\r
-  }\r
-\r
-  protected void wrapMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    viewport.setWrapAlignment( wrapMenuItem.isSelected() );\r
-    alignPanel.setWrapAlignment( wrapMenuItem.isSelected() );\r
-    scaleAbove.setVisible( wrapMenuItem.isSelected() );\r
-    scaleLeft.setVisible( wrapMenuItem.isSelected() );\r
-    scaleRight.setVisible( wrapMenuItem.isSelected() );\r
-    alignPanel.repaint();\r
-  }\r
-\r
-  protected void scaleAbove_actionPerformed(ActionEvent e)\r
-  {\r
-    viewport.setScaleAboveWrapped(scaleAbove.isSelected());\r
-    alignPanel.repaint();\r
-  }\r
-\r
-  protected void scaleLeft_actionPerformed(ActionEvent e)\r
-  {\r
-    viewport.setScaleLeftWrapped(scaleLeft.isSelected());\r
-    alignPanel.repaint();\r
-  }\r
-\r
-  protected void scaleRight_actionPerformed(ActionEvent e)\r
-  {\r
-    viewport.setScaleRightWrapped(scaleRight.isSelected());\r
-    alignPanel.repaint();\r
-  }\r
-\r
-\r
-\r
-  public void viewBoxesMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    viewport.setShowBoxes( viewBoxesMenuItem.isSelected() );\r
-    alignPanel.repaint();\r
-  }\r
-\r
-  public void viewTextMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    viewport.setShowText( viewTextMenuItem.isSelected() );\r
-    alignPanel.repaint();\r
-  }\r
-\r
-\r
-  protected void renderGapsMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    viewport.setRenderGaps(renderGapsMenuItem.isSelected());\r
-    alignPanel.repaint();\r
-  }\r
-\r
-  public void sequenceFeatures_actionPerformed(ActionEvent evt)\r
-  {\r
-    viewport.showSequenceFeatures(sequenceFeatures.isSelected());\r
-    if(viewport.showSequenceFeatures && !((Alignment)viewport.alignment).featuresAdded)\r
-    {\r
-         SequenceFeatureFetcher sft = new SequenceFeatureFetcher(viewport.alignment, alignPanel);\r
-         ((Alignment)viewport.alignment).featuresAdded = true;\r
-    }\r
-    alignPanel.repaint();\r
-  }\r
-\r
-  public void annotationPanelMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    if(annotationPanelMenuItem.isSelected() && viewport.getWrapAlignment())\r
-    {\r
-      annotationPanelMenuItem.setSelected(false);\r
-      return;\r
-    }\r
-    viewport.setShowAnnotation( annotationPanelMenuItem.isSelected() );\r
-    alignPanel.setAnnotationVisible( annotationPanelMenuItem.isSelected() );\r
-  }\r
-\r
-  public void overviewMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    if (alignPanel.overviewPanel != null)\r
-      return;\r
-\r
-    JInternalFrame frame = new JInternalFrame();\r
-    OverviewPanel overview = new OverviewPanel(alignPanel);\r
-     frame.setContentPane(overview);\r
-    Desktop.addInternalFrame(frame, "Overview " + this.getTitle(),\r
-                             frame.getWidth(), frame.getHeight());\r
-    frame.pack();\r
-    frame.setLayer(JLayeredPane.PALETTE_LAYER);\r
-    frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()\r
-    { public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt)\r
-      {\r
-            alignPanel.setOverviewPanel(null);\r
-      };\r
-    });\r
-\r
-    alignPanel.setOverviewPanel( overview );\r
-\r
-\r
-  }\r
-\r
-  protected void noColourmenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    changeColour( null );\r
-  }\r
-\r
-\r
-  public void clustalColour_actionPerformed(ActionEvent e)\r
-  {\r
-    abovePIDThreshold.setSelected(false);\r
-    changeColour(new ClustalxColourScheme(viewport.alignment.getSequences(), viewport.alignment.getWidth()));\r
-  }\r
-\r
-  public void zappoColour_actionPerformed(ActionEvent e)\r
-  {\r
-    changeColour(new ZappoColourScheme());\r
-  }\r
-\r
-  public void taylorColour_actionPerformed(ActionEvent e)\r
-  {\r
-    changeColour(new TaylorColourScheme());\r
-  }\r
-\r
-\r
-  public void hydrophobicityColour_actionPerformed(ActionEvent e)\r
-  {\r
-    changeColour( new HydrophobicColourScheme() );\r
-  }\r
-\r
-  public void helixColour_actionPerformed(ActionEvent e)\r
-  {\r
-    changeColour(new HelixColourScheme() );\r
-  }\r
-\r
-\r
-  public void strandColour_actionPerformed(ActionEvent e)\r
-  {\r
-    changeColour(new StrandColourScheme());\r
-  }\r
-\r
-\r
-  public void turnColour_actionPerformed(ActionEvent e)\r
-  {\r
-    changeColour(new TurnColourScheme());\r
-  }\r
-\r
-\r
-  public void buriedColour_actionPerformed(ActionEvent e)\r
-  {\r
-    changeColour(new BuriedColourScheme() );\r
-  }\r
-\r
-  public void nucleotideColour_actionPerformed(ActionEvent e)\r
-  {\r
-    changeColour(new NucleotideColourScheme());\r
-  }\r
-\r
-\r
-  protected void applyToAllGroups_actionPerformed(ActionEvent e)\r
-  {\r
-    viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());\r
-  }\r
-\r
-\r
-\r
-  void changeColour(ColourSchemeI cs)\r
-  {\r
-    int threshold = 0;\r
-\r
-    if ( viewport.getAbovePIDThreshold() )\r
-    {\r
-      threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, "Background");\r
-\r
-      if (cs instanceof ResidueColourScheme)\r
-        ( (ResidueColourScheme) cs).setThreshold(threshold);\r
-      else if (cs instanceof ScoreColourScheme)\r
-        ( (ScoreColourScheme) cs).setThreshold(threshold);\r
-\r
-      viewport.setGlobalColourScheme(cs);\r
-    }\r
-    else if (cs instanceof ResidueColourScheme)\r
-      ( (ResidueColourScheme) cs).setThreshold(0);\r
-    else if (cs instanceof ScoreColourScheme)\r
-      ( (ScoreColourScheme) cs).setThreshold(0);\r
-\r
-\r
-\r
-    if (viewport.getConservationSelected())\r
-    {\r
-      ConservationColourScheme ccs = null;\r
-\r
-      Alignment al = (Alignment) viewport.alignment;\r
-      Conservation c = new Conservation("All",\r
-                                        ResidueProperties.propHash, 3,\r
-                                        al.getSequences(), 0,\r
-                                        al.getWidth() - 1);\r
-\r
-      c.calculate();\r
-      c.verdict(false, viewport.ConsPercGaps);\r
-\r
-      ccs = new ConservationColourScheme(c, cs);\r
-\r
-      // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
-      ccs.setConsensus( viewport.vconsensus );\r
-      viewport.setGlobalColourScheme(ccs);\r
-\r
-      SliderPanel.setConservationSlider(alignPanel, ccs, "Background");\r
-\r
-    }\r
-    else\r
-    {\r
-        // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
-        if (cs != null)\r
-          cs.setConsensus(viewport.vconsensus);\r
-        viewport.setGlobalColourScheme(cs);\r
-    }\r
-\r
-\r
-    if(viewport.getColourAppliesToAllGroups())\r
-    {\r
-      Vector groups = viewport.alignment.getGroups();\r
-      for(int i=0; i<groups.size(); i++)\r
-      {\r
-        SequenceGroup sg = (SequenceGroup)groups.elementAt(i);\r
-\r
-        if (cs instanceof ClustalxColourScheme)\r
-        {\r
-          sg.cs = new ClustalxColourScheme(sg.sequences, sg.getWidth());\r
-        }\r
-        else if(cs!=null)\r
-        {\r
-          try{\r
-            sg.cs = (ColourSchemeI) cs.getClass().newInstance();\r
-          }catch(Exception ex){ex.printStackTrace();}\r
-        }\r
-\r
-        if(viewport.getAbovePIDThreshold())\r
-        {\r
-          if (sg.cs instanceof ResidueColourScheme)\r
-            ( (ResidueColourScheme) sg.cs).setThreshold(threshold);\r
-          else if (sg.cs instanceof ScoreColourScheme)\r
-            ( (ScoreColourScheme) sg.cs).setThreshold(threshold);\r
-\r
-           sg.cs.setConsensus( AAFrequency.calculate(sg.sequences, 0, sg.getWidth()) );\r
-        }\r
-\r
-        if( viewport.getConservationSelected() )\r
-        {\r
-          Conservation c = new Conservation("Group",\r
-                                            ResidueProperties.propHash, 3,\r
-                                            sg.sequences, 0, viewport.alignment.getWidth()-1);\r
-          c.calculate();\r
-          c.verdict(false, viewport.ConsPercGaps);\r
-          ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs);\r
-\r
-          // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
-          ccs.setConsensus( AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));\r
-          sg.cs = ccs;\r
-        }\r
-        else if(cs!=null)\r
-        {\r
-          // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
-          sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));\r
-        }\r
-\r
-      }\r
-    }\r
-\r
-    if(alignPanel.getOverviewPanel()!=null)\r
-      alignPanel.getOverviewPanel().updateOverviewImage();\r
-    alignPanel.repaint();\r
-  }\r
-\r
-  protected void modifyPID_actionPerformed(ActionEvent e)\r
-  {\r
-      if(viewport.getAbovePIDThreshold())\r
-      {\r
-        SliderPanel.setPIDSliderSource(alignPanel, viewport.getGlobalColourScheme(),\r
-                                   "Background");\r
-        SliderPanel.showPIDSlider();\r
-      }\r
-  }\r
-\r
-  protected void modifyConservation_actionPerformed(ActionEvent e)\r
-  {\r
-    if(viewport.getConservationSelected())\r
-    {\r
-      SliderPanel.setConservationSlider(alignPanel, viewport.globalColourScheme,\r
-                                        "Background");\r
-      SliderPanel.showConservationSlider();\r
-    }\r
-  }\r
-\r
-\r
-  protected  void conservationMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    viewport.setConservationSelected(conservationMenuItem.isSelected());\r
-\r
-    viewport.setAbovePIDThreshold(false);\r
-    abovePIDThreshold.setSelected(false);\r
-\r
-   ColourSchemeI cs = viewport.getGlobalColourScheme();\r
-   if(cs instanceof ConservationColourScheme )\r
-     changeColour( ((ConservationColourScheme)cs).cs );\r
-    else\r
-      changeColour( cs );\r
-\r
-    modifyConservation_actionPerformed(null);\r
-  }\r
-\r
-  public void abovePIDThreshold_actionPerformed(ActionEvent e)\r
-  {\r
-    viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());\r
-\r
-    conservationMenuItem.setSelected(false);\r
-    viewport.setConservationSelected(false);\r
-\r
-    ColourSchemeI cs = viewport.getGlobalColourScheme();\r
-\r
-    if(cs instanceof ConservationColourScheme )\r
-        changeColour( ((ConservationColourScheme)cs).cs );\r
-    else\r
-        changeColour( cs );\r
-\r
-    modifyPID_actionPerformed(null);\r
-  }\r
-\r
-\r
-\r
-  public void userDefinedColour_actionPerformed(ActionEvent e)\r
-  {\r
-    UserDefinedColours chooser = new UserDefinedColours( alignPanel, null);\r
-  }\r
-\r
-  public void PIDColour_actionPerformed(ActionEvent e)\r
-  {\r
-    changeColour( new PIDColourScheme() );\r
-  }\r
-\r
-\r
-  public void BLOSUM62Colour_actionPerformed(ActionEvent e)\r
-  {\r
-    changeColour(new Blosum62ColourScheme() );\r
-  }\r
-\r
-\r
-\r
-  public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    addHistoryItem("sort");\r
-    AlignmentSorter.sortByPID(viewport.getAlignment(), viewport.getAlignment().getSequenceAt(0));\r
-    alignPanel.repaint();\r
-  }\r
-\r
-  public void sortIDMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    addHistoryItem("sort");\r
-    AlignmentSorter.sortByID( viewport.getAlignment() );\r
-    alignPanel.repaint();\r
-  }\r
-\r
-  public void sortGroupMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    addHistoryItem("sort");\r
-    AlignmentSorter.sortByGroup(viewport.getAlignment());\r
-    AlignmentSorter.sortGroups(viewport.getAlignment());\r
-    alignPanel.repaint();\r
-  }\r
-\r
-  public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    RedundancyPanel sp = new RedundancyPanel(alignPanel);\r
-    JInternalFrame frame = new JInternalFrame();\r
-    frame.setContentPane(sp);\r
-    Desktop.addInternalFrame(frame, "Redundancy threshold selection", 400, 100, false);\r
-\r
-  }\r
-\r
-  public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    if(viewport.getSelectionGroup().getSize()<2)\r
-      JOptionPane.showInternalMessageDialog(this, "You must select at least 2 sequences.", "Invalid Selection", JOptionPane.WARNING_MESSAGE);\r
-    else\r
-    {\r
-      JInternalFrame frame = new JInternalFrame();\r
-      frame.setContentPane(new PairwiseAlignPanel(viewport));\r
-      Desktop.addInternalFrame(frame, "Pairwise Alignment", 600, 500);\r
-    }\r
-  }\r
-\r
-  public void PCAMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-\r
-    if( (viewport.getSelectionGroup()!=null && viewport.getSelectionGroup().getSize()<4 && viewport.getSelectionGroup().getSize()>0)\r
-       || viewport.getAlignment().getHeight()<4)\r
-    {\r
-      JOptionPane.showInternalMessageDialog(this, "Principal component analysis must take\n"\r
-                                    +"at least 4 input sequences.",\r
-                                    "Sequence selection insufficient",\r
-                                    JOptionPane.WARNING_MESSAGE);\r
-      return;\r
-    }\r
-\r
-    try{\r
-      PCAPanel pcaPanel = new PCAPanel(viewport, null);\r
-      JInternalFrame frame = new JInternalFrame();\r
-      frame.setContentPane(pcaPanel);\r
-      Desktop.addInternalFrame(frame, "Principal component analysis", 400, 400);\r
-   }catch(java.lang.OutOfMemoryError ex)\r
-   {\r
-     JOptionPane.showInternalMessageDialog(this, "Too many sequences selected\nfor Principal Component Analysis!!",\r
-                                   "Out of memory", JOptionPane.WARNING_MESSAGE);\r
-   }\r
-\r
-\r
-  }\r
-\r
-  public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    NewTreePanel("AV", "PID", "Average distance tree using PID");\r
-  }\r
-\r
-  public void neighbourTreeMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");\r
-  }\r
-\r
-\r
-  protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");\r
-  }\r
-\r
-  protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62PID");\r
-  }\r
-\r
-  void NewTreePanel(String type, String pwType, String title)\r
-  {\r
-    //are the sequences aligned?\r
-    if(!viewport.alignment.isAligned())\r
-    {\r
-      JOptionPane.showMessageDialog(Desktop.desktop, "The sequences must be aligned before creating a tree.",\r
-                                    "Sequences not aligned", JOptionPane.WARNING_MESSAGE);\r
-      return;\r
-    }\r
-\r
-    final TreePanel tp;\r
-    if (viewport.getSelectionGroup() != null &&\r
-        viewport.getSelectionGroup().getSize() > 3)\r
-    {\r
-      tp = new TreePanel(viewport, viewport.getSelectionGroup().sequences, type,\r
-                         pwType,\r
-                         0, viewport.alignment.getWidth());\r
-    }\r
-    else\r
-    {\r
-      tp = new TreePanel(viewport, viewport.getAlignment().getSequences(),\r
-                         type, pwType, 0, viewport.alignment.getWidth());\r
-    }\r
-\r
-   addTreeMenuItem(tp, title);\r
-\r
-   Desktop.addInternalFrame(tp, title, 600, 500);\r
-  }\r
-\r
-  void addTreeMenuItem(final TreePanel treePanel, String title)\r
-  {\r
-    final JMenuItem item = new JMenuItem(title);\r
-    sortByTreeMenu.add(item);\r
-    item.addActionListener(new java.awt.event.ActionListener()\r
-    {\r
-      public void actionPerformed(ActionEvent e)\r
-      {\r
-        addHistoryItem("sort");\r
-        AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel.getTree());\r
-        alignPanel.repaint();\r
-      }\r
-    });\r
-\r
-    treePanel.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()\r
-    {\r
-      public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt)\r
-      {\r
-        sortByTreeMenu.remove(item);\r
-      };\r
-    });\r
-\r
-  }\r
-\r
-\r
-  public void clustalAlignMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-     WebserviceInfo info = new WebserviceInfo("Clustal web service",\r
-     "\"Thompson, J.D., Higgins, D.G. and Gibson, T.J. (1994) CLUSTAL W: improving the sensitivity of progressive multiple"+\r
-     " sequence alignment through sequence weighting, position specific gap penalties and weight matrix choice."\r
-    +" Nucleic Acids Research, submitted, June 1994.",\r
-     450, 150);\r
-\r
-    ClustalThread thread = new ClustalThread(info);\r
-    thread.start();\r
-  }\r
-\r
-    class ClustalThread extends Thread\r
-    {\r
-      WebserviceInfo info;\r
-      public ClustalThread(WebserviceInfo info)\r
-      {this.info = info; }\r
-\r
-      public void run()\r
-      {\r
-        info.setStatus(WebserviceInfo.STATE_RUNNING);\r
-        jalview.ws.Jemboss jemboss = new jalview.ws.Jemboss();\r
-        Vector sv = viewport.getAlignment().getSequences();\r
-        SequenceI[] seqs = new SequenceI[sv.size()];\r
-\r
-        int i = 0;\r
-        do\r
-        {\r
-          seqs[i] = (SequenceI) sv.elementAt(i);\r
-        }\r
-        while (++i < sv.size());\r
-\r
-        SequenceI[] alignment = jemboss.clustalW(seqs); // gaps removed within method\r
-        if (alignment != null)\r
-        {\r
-          AlignFrame af = new AlignFrame(new Alignment(alignment));\r
-          Desktop.addInternalFrame(af, title.concat(" - ClustalW Alignment"),\r
-                                   NEW_WINDOW_WIDTH, NEW_WINDOW_HEIGHT);\r
-          af.clustalColour_actionPerformed(null);\r
-          af.clustalColour.setSelected(true);\r
-          info.setStatus(WebserviceInfo.STATE_STOPPED_OK);\r
-        }\r
-        else\r
-        {\r
-            info.setStatus(WebserviceInfo.STATE_STOPPED_ERROR);\r
-            info.appendProgressText("Problem obtaining clustal alignment");\r
-        }\r
-      }\r
-    }\r
-\r
-  protected void jpred_actionPerformed(ActionEvent e)\r
-{\r
-\r
-    if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize()>0)\r
-    {\r
-      // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!\r
-      SequenceGroup seqs = viewport.getSelectionGroup();\r
-      if (seqs.getSize() == 1 || !viewport.alignment.isAligned())\r
-      {\r
-        JPredClient ct = new JPredClient( (SequenceI)seqs.getSequenceAt(0));\r
-      }\r
-      else\r
-      {\r
-        int sz;\r
-        SequenceI[] msa = new SequenceI[sz=seqs.getSize()];\r
-        for (int i = 0; i < sz; i++)\r
-        {\r
-          msa[i] = (SequenceI) seqs.getSequenceAt(i);\r
-        }\r
-\r
-        JPredClient ct = new JPredClient(msa);\r
-      }\r
-\r
-    }\r
-    else\r
-    {\r
-      Vector seqs = viewport.getAlignment().getSequences();\r
-\r
-      if (seqs.size() == 1 || !viewport.alignment.isAligned())\r
-      {\r
-        JPredClient ct = new JPredClient( (SequenceI)\r
-                                         seqs.elementAt(0));\r
-      }\r
-      else\r
-      {\r
-        SequenceI[] msa = new SequenceI[seqs.size()];\r
-        for (int i = 0; i < seqs.size(); i++)\r
-        {\r
-          msa[i] = (SequenceI) seqs.elementAt(i);\r
-        }\r
-\r
-        JPredClient ct = new JPredClient(msa);\r
-      }\r
-\r
-    }\r
-  }\r
-  protected void msaAlignMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    // TODO:resolve which menu item was actually selected\r
-    // Now, check we have enough sequences\r
-      if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize()>1)\r
-      {\r
-        // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!\r
-        SequenceGroup seqs = viewport.getSelectionGroup();\r
-        int sz;\r
-        SequenceI[] msa = new SequenceI[sz=seqs.getSize()];\r
-        for (int i = 0; i < sz; i++)\r
-        {\r
-          msa[i] = (SequenceI) seqs.getSequenceAt(i);\r
-        }\r
-\r
-        MsaWSClient ct = new jalview.ws.MsaWSClient(msa);\r
-      }\r
-      else\r
-      {\r
-        Vector seqs = viewport.getAlignment().getSequences();\r
-\r
-        if (seqs.size() > 1) {\r
-          SequenceI[] msa = new SequenceI[seqs.size()];\r
-          for (int i = 0; i < seqs.size(); i++)\r
-          {\r
-            msa[i] = (SequenceI) seqs.elementAt(i);\r
-          }\r
-\r
-          MsaWSClient ct = new MsaWSClient(msa);\r
-        }\r
-\r
-      }\r
-    }\r
-\r
-    protected void LoadtreeMenuItem_actionPerformed(ActionEvent e) {\r
-    // Pick the tree file\r
-    JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.\r
-        getProperty("LAST_DIRECTORY"));\r
-    chooser.setFileView(new JalviewFileView());\r
-    chooser.setDialogTitle("Select a newick-like tree file");\r
-    chooser.setToolTipText("Load a tree file");\r
-    int value = chooser.showOpenDialog(null);\r
-    if (value == JalviewFileChooser.APPROVE_OPTION)\r
-    {\r
-      String choice = chooser.getSelectedFile().getPath();\r
-      jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);\r
-      try\r
-      {\r
-        jalview.io.NewickFile fin = new jalview.io.NewickFile(choice, "File");\r
-        ShowNewickTree(fin, choice);\r
-      }\r
-      catch (Exception ex)\r
-      {\r
-        JOptionPane.showMessageDialog(Desktop.desktop,\r
-                                      "Problem reading tree file",\r
-                                      ex.getMessage(),\r
-                                      JOptionPane.WARNING_MESSAGE);\r
-        ex.printStackTrace();\r
-      }\r
-    }\r
-  }\r
-\r
-  public void ShowNewickTree(NewickFile nf, String title)\r
-  {\r
-    try{\r
-      nf.parse();\r
-      if (nf.getTree() != null)\r
-      {\r
-        TreePanel tp = new TreePanel(viewport,\r
-                                     viewport.getAlignment().getSequences(),\r
-                                     nf, "FromFile", title);\r
-        Desktop.addInternalFrame(tp, title, 600, 500);\r
-        addTreeMenuItem(tp, title);\r
-        viewport.setCurrentTree(tp.getTree());\r
-      }\r
-     }catch(Exception ex){ex.printStackTrace();}\r
-  }\r
-\r
-\r
-}\r
+/********************
+ * 2004 Jalview Reengineered
+ * Barton Group
+ * Dundee University
+ *
+ * AM Waterhouse
+ *******************/
+
+
+
+
+package jalview.gui;
+
+import jalview.jbgui.GAlignFrame;
+import jalview.schemes.*;
+import jalview.datamodel.*;
+import jalview.analysis.*;
+import jalview.io.*;
+import jalview.ws.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import java.util.*;
+import java.awt.datatransfer.*;
+
+
+public class AlignFrame extends GAlignFrame
+{
+  final AlignmentPanel alignPanel;
+  final AlignViewport viewport;
+  public static final int NEW_WINDOW_WIDTH = 700;
+  public static final int NEW_WINDOW_HEIGHT = 500;
+  public String currentFileFormat = "Jalview";
+
+  public AlignFrame(AlignmentI al)
+  {
+    viewport = new AlignViewport(al);
+
+    alignPanel = new AlignmentPanel(this, viewport);
+    alignPanel.annotationPanel.adjustPanelHeight();
+    alignPanel.annotationSpaceFillerHolder.setPreferredSize(alignPanel.annotationPanel.getPreferredSize());
+    alignPanel.annotationScroller.setPreferredSize(alignPanel.annotationPanel.getPreferredSize());
+    alignPanel.setAnnotationVisible( viewport.getShowAnnotation() );
+
+    getContentPane().add(alignPanel, java.awt.BorderLayout.CENTER);
+
+    addInternalFrameListener(new InternalFrameAdapter()
+   {
+     public void internalFrameActivated(InternalFrameEvent evt)
+     {
+          javax.swing.SwingUtilities.invokeLater(new Runnable()
+          {
+            public void run()
+            {      alignPanel.requestFocus();    }
+          });
+
+     }
+   });
+
+  }
+
+  public void saveAlignmentMenu_actionPerformed(ActionEvent e)
+  {
+    JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY")
+        ,  new String[]{"fa, fasta, fastq", "aln",  "pfam", "msf", "pir","blc","jar"},
+          new String[]{"Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview"},
+          currentFileFormat);
+
+    chooser.setAcceptAllFileFilterUsed(false);
+    chooser.setFileView(new JalviewFileView());
+    chooser.setDialogTitle("Save Alignment to file");
+    chooser.setToolTipText("Save");
+    int value = chooser.showSaveDialog(this);
+    if(value == JalviewFileChooser.APPROVE_OPTION)
+    {
+      currentFileFormat  = chooser.getSelectedFormat();
+
+      if (currentFileFormat.equals("Jalview"))
+      {
+        String shortName = title.replace('/', '_');
+        title = title.replace('\\', '_');
+        String choice = chooser.getSelectedFile().getPath();
+        Jalview2XML.SaveState(this, System.currentTimeMillis(), shortName,
+                              choice);
+        // USE Jalview2XML to save this file
+        return;
+      }
+
+      String choice =  chooser.getSelectedFile().getPath();
+      jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
+      String output = FormatAdapter.formatSequences(currentFileFormat, viewport.getAlignment().getSequences());
+      try{
+        java.io.PrintWriter out = new java.io.PrintWriter( new java.io.FileWriter( choice )  );
+        out.println(output);
+        out.close();
+      }
+      catch(Exception ex){}
+    }
+
+  }
+
+  protected void outputText_actionPerformed(ActionEvent e)
+  {
+     CutAndPasteTransfer cap = new CutAndPasteTransfer(false);
+     JInternalFrame frame = new JInternalFrame();
+     cap.formatForOutput();
+     frame.setContentPane(cap);
+     Desktop.addInternalFrame(frame, "Alignment output - "+e.getActionCommand(), 600, 500);
+     cap.setText( FormatAdapter.formatSequences(e.getActionCommand(), viewport.getAlignment().getSequences()));
+  }
+
+  protected void htmlMenuItem_actionPerformed(ActionEvent e)
+  {
+    HTMLOutput htmlOutput = new HTMLOutput(viewport);
+    htmlOutput = null;
+  }
+
+  protected void createPNG_actionPerformed(ActionEvent e)
+  {
+    alignPanel.makePNG();
+  }
+
+  protected void epsFile_actionPerformed(ActionEvent e)
+  {
+    alignPanel.makeEPS();
+  }
+
+
+  public void printMenuItem_actionPerformed(ActionEvent e)
+  {
+    //Putting in a thread avoids Swing painting problems
+    PrintThread thread = new PrintThread();
+    thread.start();
+  }
+
+  class PrintThread extends Thread
+  {
+    public void run()
+    {
+      PrinterJob printJob = PrinterJob.getPrinterJob();
+      PageFormat pf = printJob.pageDialog(printJob.defaultPage());
+      printJob.setPrintable(alignPanel, pf);
+      if (printJob.printDialog())
+      {
+        try
+        {
+          printJob.print();
+        }
+        catch (Exception PrintException)
+        {
+          PrintException.printStackTrace();
+        }
+      }
+    }
+
+  }
+
+
+
+
+  public void closeMenuItem_actionPerformed(ActionEvent e)
+  {
+    try{
+      this.setClosed(true);
+    }catch(Exception ex){}
+  }
+
+  Stack historyList = new Stack();
+  Stack redoList = new Stack();
+
+  void updateEditMenuBar()
+  {
+    if(historyList.size()>0)
+     {
+       undoMenuItem.setEnabled(true);
+       Object [] history = (Object[])historyList.get(0);
+       undoMenuItem.setText("Undo "+history[0]);
+     }
+    else
+    {
+      undoMenuItem.setEnabled(false);
+      undoMenuItem.setText("Undo");
+    }
+
+    if(redoList.size()>0)
+     {
+       redoMenuItem.setEnabled(true);
+       Object [] history = (Object[])redoList.get(0);
+       redoMenuItem.setText("Redo "+history[0]);
+     }
+    else
+    {
+      redoMenuItem.setEnabled(false);
+      redoMenuItem.setText("Redo");
+    }
+  }
+
+  public void addHistoryItem(String type)
+  {
+    // must make sure we add new sequence objects her, not refs to the existing sequences
+    redoList.clear();
+
+    SequenceI[] seq = new SequenceI[viewport.getAlignment().getHeight()];
+    for(int i=0; i<viewport.getAlignment().getHeight(); i++)
+    {
+      seq[i] = new Sequence( viewport.getAlignment().getSequenceAt(i).getName(),
+                             viewport.getAlignment().getSequenceAt(i).getSequence());
+    }
+
+
+    historyList.add(0, new Object[]{type,  seq} );
+    updateEditMenuBar();
+  }
+
+  protected void undoMenuItem_actionPerformed(ActionEvent e)
+  {
+    Object [] history = (Object[])historyList.remove(0);
+    // add the redo state before continuing!!
+    SequenceI[] seq = new SequenceI[viewport.getAlignment().getHeight()];
+    for (int i = 0; i < viewport.getAlignment().getHeight(); i++)
+    {
+      seq[i] = new Sequence(viewport.getAlignment().getSequenceAt(i).getName(),
+                            viewport.getAlignment().getSequenceAt(i).
+                            getSequence());
+    }
+    /////////
+
+    redoList.add(0, new Object[] {history[0], seq});
+
+      seq = (SequenceI[]) history[1];
+      AlignmentAnnotation [] old = viewport.alignment.getAlignmentAnnotation();
+      viewport.setAlignment( new Alignment(seq) );
+      viewport.alignment.setGapCharacter( Preferences.gapSymbol );
+      updateEditMenuBar();
+      for(int i=0; i<old.length; i++)
+        viewport.alignment.addAnnotation(old[i]);
+      viewport.updateConsensus();
+      viewport.updateConservation();
+      alignPanel.repaint();
+  }
+
+  public void moveSelectedSequences(boolean up)
+  {
+    SequenceGroup sg = viewport.getSelectionGroup();
+    if (sg == null)
+      return;
+
+    if (up)
+    {
+      for (int i = 1; i < viewport.alignment.getHeight(); i++)
+      {
+        SequenceI seq = viewport.alignment.getSequenceAt(i);
+        if (!sg.sequences.contains(seq))
+          continue;
+
+        SequenceI temp = viewport.alignment.getSequenceAt(i - 1);
+        if (sg.sequences.contains(temp))
+          continue;
+
+        viewport.alignment.getSequences().setElementAt(temp, i);
+        viewport.alignment.getSequences().setElementAt(seq, i - 1);
+      }
+    }
+    else
+    {
+      for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)
+      {
+        SequenceI seq = viewport.alignment.getSequenceAt(i);
+        if (!sg.sequences.contains(seq))
+          continue;
+
+        SequenceI temp = viewport.alignment.getSequenceAt(i + 1);
+        if (sg.sequences.contains(temp))
+          continue;
+
+        viewport.alignment.getSequences().setElementAt(temp, i);
+        viewport.alignment.getSequences().setElementAt(seq, i + 1);
+      }
+    }
+
+    alignPanel.repaint();
+  }
+
+
+
+  protected void copy_actionPerformed(ActionEvent e)
+  {
+     if(viewport.getSelectionGroup()==null)
+       return;
+
+     SequenceGroup sg = viewport.getSelectionGroup();
+
+     Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
+     StringBuffer buffer= new StringBuffer();
+
+     Hashtable orderedSeqs = new Hashtable();
+     for(int i=0; i<sg.getSize(); i++)
+     {
+        SequenceI seq = sg.getSequenceAt(i);
+        int index = viewport.alignment.findIndex(seq);
+        orderedSeqs.put(index+"", seq);
+     }
+
+     int index=0;
+     for(int i=0; i<sg.getSize(); i++)
+     {
+       SequenceI seq = null;
+       while( seq == null )
+       {
+         if(orderedSeqs.containsKey(index+""))
+         {
+           seq = (SequenceI) orderedSeqs.get(index + "");
+           index++;
+           break;
+         }
+         else
+           index++;
+       }
+
+         buffer.append( seq.getName()+"\t"+seq.findPosition( sg.getStartRes() ) +"\t"
+                        +seq.findPosition( sg.getEndRes() )+ "\t"
+                        +sg.getSequenceAt(i).getSequence(sg.getStartRes(), sg.getEndRes()+1)+"\n");
+     }
+     c.setContents( new StringSelection( buffer.toString()) , null ) ;
+
+  }
+
+
+  protected void pasteNew_actionPerformed(ActionEvent e)
+  {
+    paste(true);
+  }
+
+  protected void pasteThis_actionPerformed(ActionEvent e)
+  {
+    addHistoryItem("Paste");
+    paste(false);
+  }
+
+  void paste(boolean newAlignment)
+  {
+    try{
+      Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
+      Transferable contents = c.getContents(this);
+      if (contents == null)
+        return;
+
+      String str = (String) contents.getTransferData(DataFlavor.stringFlavor);
+      StringTokenizer st = new StringTokenizer(str);
+      ArrayList seqs = new ArrayList();
+      while (st.hasMoreElements())
+      {
+        String name = st.nextToken();
+        int start = Integer.parseInt(st.nextToken());
+        int end = Integer.parseInt(st.nextToken());
+        Sequence sequence = new Sequence(name,st.nextToken(), start, end);
+
+        if(!newAlignment)
+          viewport.alignment.addSequence(sequence);
+        else
+          seqs.add(sequence);
+      }
+
+      if(newAlignment)
+      {
+        SequenceI[] newSeqs = new SequenceI[seqs.size()];
+        seqs.toArray(newSeqs);
+        AlignFrame af = new AlignFrame(new Alignment(newSeqs));
+        String newtitle = new String("Copied sequences");
+        if( title.startsWith("Copied sequences"))
+         newtitle = title;
+       else
+         newtitle = newtitle.concat("- from "+title);
+
+        Desktop.addInternalFrame(af, newtitle, NEW_WINDOW_WIDTH, NEW_WINDOW_HEIGHT);
+      }
+      else
+      {
+        viewport.setEndSeq(viewport.alignment.getHeight());
+        viewport.alignment.getWidth();
+        viewport.updateConservation();
+        viewport.updateConsensus();
+        alignPanel.repaint();
+      }
+
+    }catch(Exception ex){}// could be anything being pasted in here
+
+  }
+
+
+  protected void cut_actionPerformed(ActionEvent e)
+  {
+    copy_actionPerformed(null);
+    delete_actionPerformed(null);
+  }
+
+  protected void delete_actionPerformed(ActionEvent e)
+  {
+    addHistoryItem("Delete");
+    if (viewport.getSelectionGroup() == null)
+      return;
+
+     SequenceGroup sg = viewport.getSelectionGroup();
+     for (int i=0;i < sg.sequences.size(); i++)
+     {
+       SequenceI seq = sg.getSequenceAt(i);
+       int index = viewport.getAlignment().findIndex(seq);
+       seq.deleteChars(sg.getStartRes(), sg.getEndRes()+1);
+
+       if(seq.getSequence().length()<1)
+          viewport.getAlignment().deleteSequence(seq);
+      else
+          viewport.getAlignment().getSequences().setElementAt(seq, index);
+     }
+
+     viewport.setSelectionGroup(null);
+     viewport.alignment.deleteGroup(sg);
+     viewport.resetSeqLimits( alignPanel.seqPanel.seqCanvas.getHeight());
+     if(viewport.getAlignment().getHeight()<1)
+     try
+     {
+       this.setClosed(true);
+     }catch(Exception ex){}
+   viewport.updateConservation();
+   viewport.updateConsensus();
+     alignPanel.repaint();
+
+  }
+
+
+
+  protected void redoMenuItem_actionPerformed(ActionEvent e)
+  {
+     Object [] history = (Object[])redoList.remove(0);
+     SequenceI[] seq = (SequenceI[]) history[1];
+     viewport.setAlignment( new Alignment(seq) );
+     viewport.alignment.setGapCharacter( Preferences.gapSymbol );
+     updateEditMenuBar();
+     viewport.updateConsensus();
+     alignPanel.repaint();
+     alignPanel.repaint();
+  }
+
+
+  protected void deleteGroups_actionPerformed(ActionEvent e)
+  {
+    viewport.alignment.deleteAllGroups();
+    viewport.setSelectionGroup(null);
+    alignPanel.repaint();
+  }
+
+
+
+  public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e)
+  {
+    SequenceGroup sg = new SequenceGroup();
+    for (int i=0; i<viewport.getAlignment().getSequences().size(); i++)
+      sg.addSequence( viewport.getAlignment().getSequenceAt(i));
+    sg.setEndRes(viewport.alignment.getWidth());
+    viewport.setSelectionGroup(sg);
+    PaintRefresher.Refresh(null);
+  }
+
+  public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e)
+  {
+    viewport.setSelectionGroup(null);
+    viewport.getColumnSelection().clear();
+    viewport.setSelectionGroup(null);
+    PaintRefresher.Refresh(null);
+  }
+
+  public void invertSequenceMenuItem_actionPerformed(ActionEvent e)
+  {
+    SequenceGroup sg = viewport.getSelectionGroup();
+    for (int i=0; i<viewport.getAlignment().getSequences().size(); i++)
+      sg.addOrRemove (viewport.getAlignment().getSequenceAt(i));
+
+    PaintRefresher.Refresh(null);
+  }
+
+  public void remove2LeftMenuItem_actionPerformed(ActionEvent e)
+  {
+    addHistoryItem("delete columns");
+    ColumnSelection colSel = viewport.getColumnSelection();
+    if (colSel.size() > 0)
+    {
+      int min = colSel.getMin();
+      viewport.getAlignment().trimLeft(min);
+      colSel.compensateForEdit(0,min);
+
+      if(viewport.getSelectionGroup()!=null)
+        viewport.getSelectionGroup().adjustForRemoveLeft(min);
+
+      Vector groups = viewport.alignment.getGroups();
+      for(int i=0; i<groups.size(); i++)
+      {
+        SequenceGroup sg = (SequenceGroup) groups.get(i);
+        if(!sg.adjustForRemoveLeft(min))
+          viewport.alignment.deleteGroup(sg);
+      }
+
+      alignPanel.repaint();
+    }
+  }
+
+  public void remove2RightMenuItem_actionPerformed(ActionEvent e)
+  {
+    addHistoryItem("delete columns");
+    ColumnSelection colSel = viewport.getColumnSelection();
+    if (colSel.size() > 0)
+    {
+      int max = colSel.getMax();
+      viewport.getAlignment().trimRight(max);
+      if(viewport.getSelectionGroup()!=null)
+        viewport.getSelectionGroup().adjustForRemoveRight(max);
+
+      Vector groups = viewport.alignment.getGroups();
+      for(int i=0; i<groups.size(); i++)
+      {
+        SequenceGroup sg = (SequenceGroup) groups.get(i);
+        if(!sg.adjustForRemoveRight(max))
+          viewport.alignment.deleteGroup(sg);
+      }
+
+
+
+      alignPanel.repaint();
+    }
+
+  }
+
+  public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e)
+  {
+    addHistoryItem("delete gapped columns");
+    viewport.getAlignment().removeGaps();
+    viewport.updateConservation();
+    viewport.updateConsensus();
+    alignPanel.repaint();
+  }
+
+  public void removeAllGapsMenuItem_actionPerformed(ActionEvent e)
+  {
+    addHistoryItem("delete all gaps");
+    SequenceI current;
+    int jSize;
+    for (int i=0; i < viewport.getAlignment().getSequences().size();i++)
+    {
+      current = viewport.getAlignment().getSequenceAt(i);
+      jSize = current.getLength();
+      for (int j=0; j < jSize; j++)
+        if(jalview.util.Comparison.isGap(current.getCharAt(j)))
+        {
+          current.deleteCharAt(j);
+          j--;
+          jSize--;
+        }
+    }
+    viewport.updateConservation();
+    viewport.updateConsensus();
+    alignPanel.repaint();
+  }
+
+
+  public void findMenuItem_actionPerformed(ActionEvent e)
+  {
+    JInternalFrame frame = new JInternalFrame();
+    Finder finder = new Finder(viewport, alignPanel, frame);
+    frame.setContentPane(finder);
+    Desktop.addInternalFrame(frame, "Find", 340,110);
+    frame.setLayer(JLayeredPane.PALETTE_LAYER);
+
+  }
+
+
+  public void font_actionPerformed(ActionEvent e)
+  {
+    FontChooser fc = new FontChooser( alignPanel );
+  }
+
+  protected void fullSeqId_actionPerformed(ActionEvent e)
+  {
+    viewport.setShowFullId( fullSeqId.isSelected() );
+
+    alignPanel.idPanel.idCanvas.setPreferredSize( alignPanel.calculateIdWidth() );
+    alignPanel.repaint();
+  }
+
+  protected void colourTextMenuItem_actionPerformed(ActionEvent e)
+  {
+      viewport.setColourText( colourTextMenuItem.isSelected() );
+      alignPanel.repaint();
+  }
+
+  protected void wrapMenuItem_actionPerformed(ActionEvent e)
+  {
+    viewport.setWrapAlignment( wrapMenuItem.isSelected() );
+    alignPanel.setWrapAlignment( wrapMenuItem.isSelected() );
+    scaleAbove.setVisible( wrapMenuItem.isSelected() );
+    scaleLeft.setVisible( wrapMenuItem.isSelected() );
+    scaleRight.setVisible( wrapMenuItem.isSelected() );
+    alignPanel.repaint();
+  }
+
+  protected void scaleAbove_actionPerformed(ActionEvent e)
+  {
+    viewport.setScaleAboveWrapped(scaleAbove.isSelected());
+    alignPanel.repaint();
+  }
+
+  protected void scaleLeft_actionPerformed(ActionEvent e)
+  {
+    viewport.setScaleLeftWrapped(scaleLeft.isSelected());
+    alignPanel.repaint();
+  }
+
+  protected void scaleRight_actionPerformed(ActionEvent e)
+  {
+    viewport.setScaleRightWrapped(scaleRight.isSelected());
+    alignPanel.repaint();
+  }
+
+
+
+  public void viewBoxesMenuItem_actionPerformed(ActionEvent e)
+  {
+    viewport.setShowBoxes( viewBoxesMenuItem.isSelected() );
+    alignPanel.repaint();
+  }
+
+  public void viewTextMenuItem_actionPerformed(ActionEvent e)
+  {
+    viewport.setShowText( viewTextMenuItem.isSelected() );
+    alignPanel.repaint();
+  }
+
+
+  protected void renderGapsMenuItem_actionPerformed(ActionEvent e)
+  {
+    viewport.setRenderGaps(renderGapsMenuItem.isSelected());
+    alignPanel.repaint();
+  }
+
+  public void sequenceFeatures_actionPerformed(ActionEvent evt)
+  {
+    viewport.showSequenceFeatures(sequenceFeatures.isSelected());
+    if(viewport.showSequenceFeatures && !((Alignment)viewport.alignment).featuresAdded)
+    {
+         SequenceFeatureFetcher sft = new SequenceFeatureFetcher(viewport.alignment, alignPanel);
+         ((Alignment)viewport.alignment).featuresAdded = true;
+    }
+    alignPanel.repaint();
+  }
+
+  public void annotationPanelMenuItem_actionPerformed(ActionEvent e)
+  {
+    if(annotationPanelMenuItem.isSelected() && viewport.getWrapAlignment())
+    {
+      annotationPanelMenuItem.setSelected(false);
+      return;
+    }
+    viewport.setShowAnnotation( annotationPanelMenuItem.isSelected() );
+    alignPanel.setAnnotationVisible( annotationPanelMenuItem.isSelected() );
+  }
+
+  public void overviewMenuItem_actionPerformed(ActionEvent e)
+  {
+    if (alignPanel.overviewPanel != null)
+      return;
+
+    JInternalFrame frame = new JInternalFrame();
+    OverviewPanel overview = new OverviewPanel(alignPanel);
+     frame.setContentPane(overview);
+    Desktop.addInternalFrame(frame, "Overview " + this.getTitle(),
+                             frame.getWidth(), frame.getHeight());
+    frame.pack();
+    frame.setLayer(JLayeredPane.PALETTE_LAYER);
+    frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+    { public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt)
+      {
+            alignPanel.setOverviewPanel(null);
+      };
+    });
+
+    alignPanel.setOverviewPanel( overview );
+
+
+  }
+
+  protected void noColourmenuItem_actionPerformed(ActionEvent e)
+  {
+    changeColour( null );
+  }
+
+
+  public void clustalColour_actionPerformed(ActionEvent e)
+  {
+    abovePIDThreshold.setSelected(false);
+    changeColour(new ClustalxColourScheme(viewport.alignment.getSequences(), viewport.alignment.getWidth()));
+  }
+
+  public void zappoColour_actionPerformed(ActionEvent e)
+  {
+    changeColour(new ZappoColourScheme());
+  }
+
+  public void taylorColour_actionPerformed(ActionEvent e)
+  {
+    changeColour(new TaylorColourScheme());
+  }
+
+
+  public void hydrophobicityColour_actionPerformed(ActionEvent e)
+  {
+    changeColour( new HydrophobicColourScheme() );
+  }
+
+  public void helixColour_actionPerformed(ActionEvent e)
+  {
+    changeColour(new HelixColourScheme() );
+  }
+
+
+  public void strandColour_actionPerformed(ActionEvent e)
+  {
+    changeColour(new StrandColourScheme());
+  }
+
+
+  public void turnColour_actionPerformed(ActionEvent e)
+  {
+    changeColour(new TurnColourScheme());
+  }
+
+
+  public void buriedColour_actionPerformed(ActionEvent e)
+  {
+    changeColour(new BuriedColourScheme() );
+  }
+
+  public void nucleotideColour_actionPerformed(ActionEvent e)
+  {
+    changeColour(new NucleotideColourScheme());
+  }
+
+
+  protected void applyToAllGroups_actionPerformed(ActionEvent e)
+  {
+    viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected());
+  }
+
+
+
+  void changeColour(ColourSchemeI cs)
+  {
+    int threshold = 0;
+
+    if ( viewport.getAbovePIDThreshold() )
+    {
+      threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, "Background");
+
+      if (cs instanceof ResidueColourScheme)
+        ( (ResidueColourScheme) cs).setThreshold(threshold);
+      else if (cs instanceof ScoreColourScheme)
+        ( (ScoreColourScheme) cs).setThreshold(threshold);
+
+      viewport.setGlobalColourScheme(cs);
+    }
+    else if (cs instanceof ResidueColourScheme)
+      ( (ResidueColourScheme) cs).setThreshold(0);
+    else if (cs instanceof ScoreColourScheme)
+      ( (ScoreColourScheme) cs).setThreshold(0);
+
+
+
+    if (viewport.getConservationSelected())
+    {
+      ConservationColourScheme ccs = null;
+
+      Alignment al = (Alignment) viewport.alignment;
+      Conservation c = new Conservation("All",
+                                        ResidueProperties.propHash, 3,
+                                        al.getSequences(), 0,
+                                        al.getWidth() - 1);
+
+      c.calculate();
+      c.verdict(false, viewport.ConsPercGaps);
+
+      ccs = new ConservationColourScheme(c, cs);
+
+      // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!
+      ccs.setConsensus( viewport.vconsensus );
+      viewport.setGlobalColourScheme(ccs);
+
+      SliderPanel.setConservationSlider(alignPanel, ccs, "Background");
+
+    }
+    else
+    {
+        // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!
+        if (cs != null)
+          cs.setConsensus(viewport.vconsensus);
+        viewport.setGlobalColourScheme(cs);
+    }
+
+
+    if(viewport.getColourAppliesToAllGroups())
+    {
+      Vector groups = viewport.alignment.getGroups();
+      for(int i=0; i<groups.size(); i++)
+      {
+        SequenceGroup sg = (SequenceGroup)groups.elementAt(i);
+
+        if (cs instanceof ClustalxColourScheme)
+        {
+          sg.cs = new ClustalxColourScheme(sg.sequences, sg.getWidth());
+        }
+        else if(cs!=null)
+        {
+          try{
+            sg.cs = (ColourSchemeI) cs.getClass().newInstance();
+          }catch(Exception ex){ex.printStackTrace();}
+        }
+
+        if(viewport.getAbovePIDThreshold())
+        {
+          if (sg.cs instanceof ResidueColourScheme)
+            ( (ResidueColourScheme) sg.cs).setThreshold(threshold);
+          else if (sg.cs instanceof ScoreColourScheme)
+            ( (ScoreColourScheme) sg.cs).setThreshold(threshold);
+
+           sg.cs.setConsensus( AAFrequency.calculate(sg.sequences, 0, sg.getWidth()) );
+        }
+
+        if( viewport.getConservationSelected() )
+        {
+          Conservation c = new Conservation("Group",
+                                            ResidueProperties.propHash, 3,
+                                            sg.sequences, 0, viewport.alignment.getWidth()-1);
+          c.calculate();
+          c.verdict(false, viewport.ConsPercGaps);
+          ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs);
+
+          // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!
+          ccs.setConsensus( AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));
+          sg.cs = ccs;
+        }
+        else if(cs!=null)
+        {
+          // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!
+          sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));
+        }
+
+      }
+    }
+
+    if(alignPanel.getOverviewPanel()!=null)
+      alignPanel.getOverviewPanel().updateOverviewImage();
+    alignPanel.repaint();
+  }
+
+  protected void modifyPID_actionPerformed(ActionEvent e)
+  {
+      if(viewport.getAbovePIDThreshold())
+      {
+        SliderPanel.setPIDSliderSource(alignPanel, viewport.getGlobalColourScheme(),
+                                   "Background");
+        SliderPanel.showPIDSlider();
+      }
+  }
+
+  protected void modifyConservation_actionPerformed(ActionEvent e)
+  {
+    if(viewport.getConservationSelected())
+    {
+      SliderPanel.setConservationSlider(alignPanel, viewport.globalColourScheme,
+                                        "Background");
+      SliderPanel.showConservationSlider();
+    }
+  }
+
+
+  protected  void conservationMenuItem_actionPerformed(ActionEvent e)
+  {
+    viewport.setConservationSelected(conservationMenuItem.isSelected());
+
+    viewport.setAbovePIDThreshold(false);
+    abovePIDThreshold.setSelected(false);
+
+   ColourSchemeI cs = viewport.getGlobalColourScheme();
+   if(cs instanceof ConservationColourScheme )
+     changeColour( ((ConservationColourScheme)cs).cs );
+    else
+      changeColour( cs );
+
+    modifyConservation_actionPerformed(null);
+  }
+
+  public void abovePIDThreshold_actionPerformed(ActionEvent e)
+  {
+    viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected());
+
+    conservationMenuItem.setSelected(false);
+    viewport.setConservationSelected(false);
+
+    ColourSchemeI cs = viewport.getGlobalColourScheme();
+
+    if(cs instanceof ConservationColourScheme )
+        changeColour( ((ConservationColourScheme)cs).cs );
+    else
+        changeColour( cs );
+
+    modifyPID_actionPerformed(null);
+  }
+
+
+
+  public void userDefinedColour_actionPerformed(ActionEvent e)
+  {
+    UserDefinedColours chooser = new UserDefinedColours( alignPanel, null);
+  }
+
+  public void PIDColour_actionPerformed(ActionEvent e)
+  {
+    changeColour( new PIDColourScheme() );
+  }
+
+
+  public void BLOSUM62Colour_actionPerformed(ActionEvent e)
+  {
+    changeColour(new Blosum62ColourScheme() );
+  }
+
+
+
+  public void sortPairwiseMenuItem_actionPerformed(ActionEvent e)
+  {
+    addHistoryItem("sort");
+    AlignmentSorter.sortByPID(viewport.getAlignment(), viewport.getAlignment().getSequenceAt(0));
+    alignPanel.repaint();
+  }
+
+  public void sortIDMenuItem_actionPerformed(ActionEvent e)
+  {
+    addHistoryItem("sort");
+    AlignmentSorter.sortByID( viewport.getAlignment() );
+    alignPanel.repaint();
+  }
+
+  public void sortGroupMenuItem_actionPerformed(ActionEvent e)
+  {
+    addHistoryItem("sort");
+    AlignmentSorter.sortByGroup(viewport.getAlignment());
+    AlignmentSorter.sortGroups(viewport.getAlignment());
+    alignPanel.repaint();
+  }
+
+  public void removeRedundancyMenuItem_actionPerformed(ActionEvent e)
+  {
+    RedundancyPanel sp = new RedundancyPanel(alignPanel);
+    JInternalFrame frame = new JInternalFrame();
+    frame.setContentPane(sp);
+    Desktop.addInternalFrame(frame, "Redundancy threshold selection", 400, 100, false);
+
+  }
+
+  public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e)
+  {
+    if(viewport.getSelectionGroup().getSize()<2)
+      JOptionPane.showInternalMessageDialog(this, "You must select at least 2 sequences.", "Invalid Selection", JOptionPane.WARNING_MESSAGE);
+    else
+    {
+      JInternalFrame frame = new JInternalFrame();
+      frame.setContentPane(new PairwiseAlignPanel(viewport));
+      Desktop.addInternalFrame(frame, "Pairwise Alignment", 600, 500);
+    }
+  }
+
+  public void PCAMenuItem_actionPerformed(ActionEvent e)
+  {
+
+    if( (viewport.getSelectionGroup()!=null && viewport.getSelectionGroup().getSize()<4 && viewport.getSelectionGroup().getSize()>0)
+       || viewport.getAlignment().getHeight()<4)
+    {
+      JOptionPane.showInternalMessageDialog(this, "Principal component analysis must take\n"
+                                    +"at least 4 input sequences.",
+                                    "Sequence selection insufficient",
+                                    JOptionPane.WARNING_MESSAGE);
+      return;
+    }
+
+    try{
+      PCAPanel pcaPanel = new PCAPanel(viewport, null);
+      JInternalFrame frame = new JInternalFrame();
+      frame.setContentPane(pcaPanel);
+      Desktop.addInternalFrame(frame, "Principal component analysis", 400, 400);
+   }catch(java.lang.OutOfMemoryError ex)
+   {
+     JOptionPane.showInternalMessageDialog(this, "Too many sequences selected\nfor Principal Component Analysis!!",
+                                   "Out of memory", JOptionPane.WARNING_MESSAGE);
+   }
+
+
+  }
+
+  public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e)
+  {
+    NewTreePanel("AV", "PID", "Average distance tree using PID");
+  }
+
+  public void neighbourTreeMenuItem_actionPerformed(ActionEvent e)
+  {
+    NewTreePanel("NJ", "PID", "Neighbour joining tree using PID");
+  }
+
+
+  protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e)
+  {
+    NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62");
+  }
+
+  protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e)
+  {
+    NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62PID");
+  }
+
+  void NewTreePanel(String type, String pwType, String title)
+  {
+    //are the sequences aligned?
+    if(!viewport.alignment.isAligned())
+    {
+      JOptionPane.showMessageDialog(Desktop.desktop, "The sequences must be aligned before creating a tree.",
+                                    "Sequences not aligned", JOptionPane.WARNING_MESSAGE);
+      return;
+    }
+
+    final TreePanel tp;
+    if (viewport.getSelectionGroup() != null &&
+        viewport.getSelectionGroup().getSize() > 3)
+    {
+      tp = new TreePanel(viewport, viewport.getSelectionGroup().sequences, type,
+                         pwType,
+                         0, viewport.alignment.getWidth());
+    }
+    else
+    {
+      tp = new TreePanel(viewport, viewport.getAlignment().getSequences(),
+                         type, pwType, 0, viewport.alignment.getWidth());
+    }
+
+   addTreeMenuItem(tp, title);
+
+   Desktop.addInternalFrame(tp, title, 600, 500);
+  }
+
+  public void addSortByOrderMenuItem(String title, final AlignmentOrder order) {
+    final JMenuItem item = new JMenuItem(title);
+    sortByTreeMenu.add(item);
+    item.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        addHistoryItem("sort");
+        AlignmentSorter.sortBy(viewport.getAlignment(), order);
+        alignPanel.repaint();
+      }
+    });
+  }
+
+  void addTreeMenuItem(final TreePanel treePanel, String title)
+  {
+    final JMenuItem item = new JMenuItem(title);
+    sortByTreeMenu.add(item);
+    item.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        addHistoryItem("sort");
+        AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel.getTree());
+        alignPanel.repaint();
+      }
+    });
+
+    treePanel.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()
+    {
+      public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt)
+      {
+        sortByTreeMenu.remove(item);
+      };
+    });
+
+  }
+
+
+  public void clustalAlignMenuItem_actionPerformed(ActionEvent e)
+  {
+      // TODO:resolve which menu item was actually selected
+      // Now, check we have enough sequences
+        SequenceI[] msa=null;
+        if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize()>1)
+        {
+          // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!
+          SequenceGroup seqs = viewport.getSelectionGroup();
+          int sz;
+          msa = new SequenceI[sz=seqs.getSize()];
+          for (int i = 0; i < sz; i++)
+          {
+            msa[i] = (SequenceI) seqs.getSequenceAt(i);
+          }
+
+          }
+        else
+        {
+          Vector seqs = viewport.getAlignment().getSequences();
+
+          if (seqs.size() > 1) {
+            msa = new SequenceI[seqs.size()];
+            for (int i = 0; i < seqs.size(); i++)
+            {
+              msa[i] = (SequenceI) seqs.elementAt(i);
+            }
+
+          }
+
+        }
+        if (msa!=null) {
+          jalview.ws.MsaWSClient ct = new jalview.ws.MsaWSClient("ClustalWS", title, msa, true, true);
+        }
+  }
+/* Old cLustalW
+       WebserviceInfo info = new WebserviceInfo("Clustal web service",
+     "\"Thompson, J.D., Higgins, D.G. and Gibson, T.J. (1994) CLUSTAL W: improving the sensitivity of progressive multiple"+
+     " sequence alignment through sequence weighting, position specific gap penalties and weight matrix choice."
+    +" Nucleic Acids Research, submitted, June 1994.",
+     450, 150);
+
+    ClustalThread thread = new ClustalThread(info);
+    thread.start();
+  }
+
+    class ClustalThread extends Thread
+    {
+      WebserviceInfo info;
+      public ClustalThread(WebserviceInfo info)
+      {this.info = info; }
+
+      public void run()
+      {
+        info.setStatus(WebserviceInfo.STATE_RUNNING);
+        jalview.ws.Jemboss jemboss = new jalview.ws.Jemboss();
+        Vector sv = viewport.getAlignment().getSequences();
+        SequenceI[] seqs = new SequenceI[sv.size()];
+
+        int i = 0;
+        do
+        {
+          seqs[i] = (SequenceI) sv.elementAt(i);
+        }
+        while (++i < sv.size());
+
+        SequenceI[] alignment = jemboss.clustalW(seqs); // gaps removed within method
+        if (alignment != null)
+        {
+          AlignFrame af = new AlignFrame(new Alignment(alignment));
+          Desktop.addInternalFrame(af, title.concat(" - ClustalW Alignment"),
+                                   NEW_WINDOW_WIDTH, NEW_WINDOW_HEIGHT);
+          af.clustalColour_actionPerformed(null);
+          af.clustalColour.setSelected(true);
+          info.setStatus(WebserviceInfo.STATE_STOPPED_OK);
+        }
+        else
+        {
+            info.setStatus(WebserviceInfo.STATE_STOPPED_ERROR);
+            info.appendProgressText("Problem obtaining clustal alignment");
+        }
+      }
+    }
+*/
+
+  protected void jpred_actionPerformed(ActionEvent e)
+{
+
+    if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize()>0)
+    {
+      // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!
+      SequenceGroup seqs = viewport.getSelectionGroup();
+      if (seqs.getSize() == 1 || !viewport.alignment.isAligned())
+      {
+        JPredClient ct = new JPredClient( (SequenceI)seqs.getSequenceAt(0));
+      }
+      else
+      {
+        int sz;
+        SequenceI[] msa = new SequenceI[sz=seqs.getSize()];
+        for (int i = 0; i < sz; i++)
+        {
+          msa[i] = (SequenceI) seqs.getSequenceAt(i);
+        }
+
+        JPredClient ct = new JPredClient(msa);
+      }
+
+    }
+    else
+    {
+      Vector seqs = viewport.getAlignment().getSequences();
+
+      if (seqs.size() == 1 || !viewport.alignment.isAligned())
+      {
+        JPredClient ct = new JPredClient( (SequenceI)
+                                         seqs.elementAt(0));
+      }
+      else
+      {
+        SequenceI[] msa = new SequenceI[seqs.size()];
+        for (int i = 0; i < seqs.size(); i++)
+        {
+          msa[i] = (SequenceI) seqs.elementAt(i);
+        }
+
+        JPredClient ct = new JPredClient(msa);
+      }
+
+    }
+  }
+  protected void msaAlignMenuItem_actionPerformed(ActionEvent e)
+  {
+    // TODO:resolve which menu item was actually selected
+    // Now, check we have enough sequences
+    SequenceI[] msa=null;
+    if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize()>1)
+      {
+        // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface!
+        SequenceGroup seqs = viewport.getSelectionGroup();
+        int sz;
+        msa = new SequenceI[sz=seqs.getSize()];
+        for (int i = 0; i < sz; i++)
+        {
+          msa[i] = (SequenceI) seqs.getSequenceAt(i);
+        }
+
+
+      }
+      else
+      {
+        Vector seqs = viewport.getAlignment().getSequences();
+
+        if (seqs.size() > 1) {
+          msa = new SequenceI[seqs.size()];
+          for (int i = 0; i < seqs.size(); i++)
+          {
+            msa[i] = (SequenceI) seqs.elementAt(i);
+          }
+
+        }
+
+      }
+      if (msa!=null) {
+        MsaWSClient ct = new jalview.ws.MsaWSClient("MuscleWS",title, msa, true, true);
+      }
+  }
+    protected void LoadtreeMenuItem_actionPerformed(ActionEvent e) {
+    // Pick the tree file
+    JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
+        getProperty("LAST_DIRECTORY"));
+    chooser.setFileView(new JalviewFileView());
+    chooser.setDialogTitle("Select a newick-like tree file");
+    chooser.setToolTipText("Load a tree file");
+    int value = chooser.showOpenDialog(null);
+    if (value == JalviewFileChooser.APPROVE_OPTION)
+    {
+      String choice = chooser.getSelectedFile().getPath();
+      jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
+      try
+      {
+        jalview.io.NewickFile fin = new jalview.io.NewickFile(choice, "File");
+        ShowNewickTree(fin, choice);
+      }
+      catch (Exception ex)
+      {
+        JOptionPane.showMessageDialog(Desktop.desktop,
+                                      "Problem reading tree file",
+                                      ex.getMessage(),
+                                      JOptionPane.WARNING_MESSAGE);
+        ex.printStackTrace();
+      }
+    }
+  }
+
+  public void ShowNewickTree(NewickFile nf, String title)
+  {
+    try{
+      nf.parse();
+      if (nf.getTree() != null)
+      {
+        TreePanel tp = new TreePanel(viewport,
+                                     viewport.getAlignment().getSequences(),
+                                     nf, "FromFile", title);
+        Desktop.addInternalFrame(tp, title, 600, 500);
+        addTreeMenuItem(tp, title);
+        viewport.setCurrentTree(tp.getTree());
+      }
+     }catch(Exception ex){ex.printStackTrace();}
+  }
+
+
+}
diff --git a/src/jalview/ws/Jemboss.java b/src/jalview/ws/Jemboss.java
deleted file mode 100755 (executable)
index a2e97f6..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-package jalview.ws;
-
-/**
- * <p>Title: JalviewX</p>
- * <p>Description: Jalview Re-engineered</p>
- * <p>Copyright: Copyright (c) 2004</p>
- * <p>Company: Dundee University</p>
- * @author not attributable
- * @version 1.0
- * Commenced 14th January 2005, Jim Procter
- * Contains and depends on GPL-2 jemboss classes
- * see http://www.rfcgr.mrc.ac.uk/Software/EMBOSS/Jemboss/index.html
- */
-
-/**
- * Philosophy
- * Jemboss webservices are implemented here as re-entrant synchronous SOAP
- * exchanges. It is up to the user of the class whether these exchanges
- * are executed in their own thread to effect background processing
- * functionality.
- *
- * Things to do
- * Standardise the exceptions (currently errors are output on stdout)
- * Allow server configuration
- * Throw away JembossParams and Jemboss dependence
- * Generalise results to return collections of objects - alignments, trees, annotations, etc.
- */
-
-import java.net.*;
-import java.security.*;
-import java.util.*;
-
-import ext.jemboss.*;
-import ext.jemboss.soap.*;
-import jalview.datamodel.*;
-import jalview.io.*;
-
-
-public class Jemboss
-{
-  private static ext.jemboss.JembossParams vamsas_server;
-
-  public Jemboss()
-  {
-    // Set up default jalview-jemboss server properties
-    //
-    vamsas_server = new JembossParams();
-    vamsas_server.setCurrentMode("interactive");
-    System.out.println("Jemboss Server Init\n"
-                       + vamsas_server.serverDescription()
-                       + "\nUser Authorisation ? "
-                       + vamsas_server.getUseAuth()
-                       +"\n");
-  }
-
-  /* public void updateServer(JembossParams props)
-  {
-    vamsas_server.updateJembossPropStrings (
-      props.getEmbossEnvironmentArray());
-  }
-  */
-    public SequenceI[] clustalW(SequenceI[] sequences) {
-      // Does the same as below but keeps initial sequence order.
-      return (this.clustalW(sequences, true));
-    }
-  public SequenceI[] clustalW(SequenceI[] sequences, boolean PreserveOrder)
-  {
-
-    // Simplest client call - with gumph from jemboss.server.TestPrivateServer
-    if (vamsas_server.getPublicSoapURL().startsWith("https"))
-    {
-      //SSL settings
-      //    System.setProperty ("javax.net.debug", "all");
-      com.sun.net.ssl.internal.ssl.Provider p =
-          new com.sun.net.ssl.internal.ssl.Provider();
-      Security.addProvider(p);
-
-      //have to do it this way to work with JNLP
-      URL.setURLStreamHandlerFactory( new URLStreamHandlerFactory()
-      {
-        public URLStreamHandler createURLStreamHandler(final String protocol)
-        {
-          if(protocol != null && protocol.compareTo("https") == 0)
-          {
-            return new com.sun.net.ssl.internal.www.protocol.https.Handler();
-          }
-          return null;
-        }
-      });
-
-      //location of keystore
-      System.setProperty("javax.net.ssl.trustStore",
-                         "resources/client.keystore");
-
-      String jembossClientKeyStore = System.getProperty("user.home") +
-          "/.jembossClientKeystore";
-
-      try
-      {
-        new JembossJarUtil("resources/client.jar").writeByteFile(
-      "client.keystore",jembossClientKeyStore);
-        System.setProperty("javax.net.ssl.trustStore",
-                           jembossClientKeyStore);
-      }
-      catch(Exception exp){}
-
-    }
-
-    Hashtable filesToMove = new Hashtable();
-    String embossCommand = "emma -sequence jalseqs.fasta -auto";
-    // Duplicate
-    SequenceI[] myseq = new SequenceI[sequences.length];
-    for (int i=0; i<sequences.length; i++) {
-        myseq[i] = new Sequence(sequences[i]);
-    }
-    // Uniqueify, and
-    Hashtable namemap = jalview.analysis.SeqsetUtils.uniquify(myseq);
-    // Load sequence file into hash
-
-    filesToMove.put("jalseqs.fasta",
-                    jalview.io.FastaFile.print(myseq,124,false, false).getBytes());
-
-    if(vamsas_server.getUseAuth() == true)
-      if(vamsas_server.getServiceUserName() == null)
-        System.out.println("jalview.Jemboss: OOPS! Authentication required!");
-
-    // submit to private server
-    try
-    {
-      JembossRun thisrun = new JembossRun(embossCommand,"",
-                                          filesToMove,vamsas_server);
-      Hashtable h = thisrun.hash();
-      Enumeration enumerator = h.keys();
-      // Find the alignment generated and parse it
-      while (enumerator.hasMoreElements())
-      {
-        String thiskey = (String)enumerator.nextElement().toString();
-        if (thiskey.endsWith(".aln"))
-        {
-          // FormatAdapter, and IdentifyFile use a protocol string
-          // to work out what 'file' is - file/url/Alignmentasastring
-          String alfile = h.get(thiskey).toString();
-          String format = IdentifyFile.Identify(alfile, "Paste");
-          SequenceI[] alignment = null;
-
-          if (FormatAdapter.formats.contains(format))
-            alignment = FormatAdapter.readFile(alfile, "Paste", format);
-          else
-            System.out.println("jalview.Jemboss: Unknown format "+format+"\n");
-          if (alignment == null)
-            System.out.println("jalview.Jemboss: Couldn't read response:\n"
-                               + alfile + "\n---EOF\n");
-          else {
-            if (PreserveOrder) {
-              jalview.analysis.AlignmentSorter.recoverOrder(alignment);
-            }
-            if (!jalview.analysis.SeqsetUtils.deuniquify(namemap, alignment)) {
-                  System.out.println("jalview.Jemboss: Warning: Some of the "
-                                     +"original sequence names have not been recovered!\n");
-            }
-            return alignment;
-          }
-        }
-
-      }
-
-    }
-    catch (JembossSoapException eae)
-    {
-      System.out.println("jalview.Jemboss: SOAP ERROR :"+embossCommand
-                         + "\n" + eae);
-    }
-    catch (Exception e) {
-      System.out.println("jalview.Jemboss: Some other failure :\n"
-                         +e.getMessage()+"\n");
-    }
-
-    return null;
-  }
-}
-
index 1fa9dac..13a3a9c 100755 (executable)
@@ -31,9 +31,9 @@ public class MsaWSClient
   String WebServiceReference;
   String WsURL;
   private boolean setWebService(String MsaWSName) {
-    if (MsaWServices.info.contains(MsaWSName.toUpperCase())) {
+    if (MsaWServices.info.containsKey(MsaWSName)) {
       WebServiceName = MsaWSName;
-      String[] wsinfo = (String[]) MsaWServices.info.get(MsaWSName.toUpperCase());
+      String[] wsinfo = (String[]) MsaWServices.info.get(MsaWSName);
       WsURL = wsinfo[0];
       WebServiceJobTitle = wsinfo[1];
       WebServiceReference = wsinfo[2];
@@ -47,7 +47,7 @@ public class MsaWSClient
 //    MsaWSClient(MsaWSName, msa, true);
 //  }
 
-  public MsaWSClient(String MsaWSName, SequenceI[] msa, boolean preserveOrder)
+  public MsaWSClient(String MsaWSName, String altitle, SequenceI[] msa, boolean submitGaps, boolean preserveOrder)
   {
     if (setWebService(MsaWSName)==false) {
       JOptionPane.showMessageDialog(Desktop.desktop, "The Multiple Sequence Alignment Service named "+MsaWSName+" is unknown",
@@ -57,7 +57,7 @@ public class MsaWSClient
 
     wsInfo = new jalview.gui.WebserviceInfo(WebServiceJobTitle, WebServiceReference);
 
-    wsInfo.setProgressText("Job details\n");
+    wsInfo.setProgressText("Alignment of "+altitle+"\nJob details\n");
 
     // TODO: MuscleWS transmuted to generic MsaWS client
     MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default
@@ -72,7 +72,7 @@ public class MsaWSClient
       ex.printStackTrace();
     }
 
-    MsaWSThread musclethread = new MsaWSThread(msa);
+    MsaWSThread musclethread = new MsaWSThread(WebServiceName+" alignment of "+altitle, msa, submitGaps, preserveOrder);
     wsInfo.setthisService(musclethread);
     musclethread.start();
   }
@@ -89,21 +89,39 @@ public class MsaWSClient
 
     String OutputHeader;
     vamsas.objects.simple.MsaResult result = null;
+
     vamsas.objects.simple.SequenceSet seqs = new vamsas.objects.simple.
         SequenceSet();
+
+    Hashtable SeqNames = null;
+    boolean submitGaps = false,// default is to strip gaps from sequences
+        preserveOrder = true; // and always store and recover sequence order
+
     String jobId;
+    String alTitle; // name which will be used to form new alignment window.
     int allowedServerExceptions = 3; // thread dies if too many exceptions.
-    MsaWSThread(SequenceI[] msa)
+    MsaWSThread(String title, SequenceI[] msa, boolean subgaps, boolean presorder)
     {
+      alTitle = title;
+      submitGaps = subgaps;
+      preserveOrder = presorder;
+
       OutputHeader = wsInfo.getProgressText();
+      SeqNames = new Hashtable();
       vamsas.objects.simple.Sequence[] seqarray = new vamsas.objects.simple.
           Sequence[msa.length];
+
       for (int i = 0; i < msa.length; i++)
       {
+        String newname = new String("Sequence"+i);
+        // uniquify as we go - JBPNote: TODO: this is a ubiquitous transformation
+        SeqNames.put(newname, msa[i].getName());
         seqarray[i] = new vamsas.objects.simple.Sequence();
-        seqarray[i].setId(msa[i].getName());
-        seqarray[i].setSeq(AlignSeq.extractGaps("-. ", msa[i].getSequence()));
+        seqarray[i].setId(new String("Sequence"+i));
+        seqarray[i].setSeq((submitGaps) ? msa[i].getSequence()
+                           : AlignSeq.extractGaps("-. ", msa[i].getSequence()));
       }
+
       this.seqs = new vamsas.objects.simple.SequenceSet();
       this.seqs.setSeqs(seqarray);
     }
@@ -247,13 +265,22 @@ public class MsaWSClient
 
         wsInfo.setProgressText(OutputHeader);
         if (seqs!=null) {
-          Alignment al;
-          al = new Alignment(seqs);
+          AlignmentOrder msaorder = new AlignmentOrder(seqs);
+
+          if (preserveOrder) {
+            jalview.analysis.AlignmentSorter.recoverOrder(seqs);
+          }
+
+          jalview.analysis.SeqsetUtils.deuniquify(SeqNames, seqs);
+
+          Alignment al = new Alignment(seqs);
 
           // TODO: JBPNote Should also rename the query sequence sometime...
           AlignFrame af = new AlignFrame(al);
+          af.addSortByOrderMenuItem(ServiceName+" Ordering", msaorder);
+
           Desktop.addInternalFrame(af,
-                                   ServiceName + " Alignment",
+                                   alTitle,
                                    AlignFrame.NEW_WINDOW_WIDTH,
                                    AlignFrame.NEW_WINDOW_HEIGHT);
         }
diff --git a/src/jalview/ws/MsaWServices.java b/src/jalview/ws/MsaWServices.java
new file mode 100755 (executable)
index 0000000..8ea666b
--- /dev/null
@@ -0,0 +1,39 @@
+package jalview.ws;
+import java.util.Hashtable;
+/**
+ * <p>Title: MsaWServices </p>
+ *
+ * <p>Description: Registry of MsaWSI style services </p>
+ *
+ * <p>Copyright: Copyright (c) 2004</p>
+ *
+ * <p>Company: Dundee University</p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class MsaWServices {
+  public static Hashtable info;
+  static
+  {
+    info = new Hashtable();
+    info.put("ClustalWS",
+             new String[]
+             {
+             "http://www.compbio.dundee.ac.uk/JalviewWS/services/ClustalWS",
+             "ClustalW Alignment job",
+             "\"Thompson, J.D., Higgins, D.G. and Gibson, T.J. (1994) CLUSTAL W: improving the sensitivity of progressive multiple" +
+             " sequence alignment through sequence weighting, position specific gap penalties and weight matrix choice."
+             + " Nucleic Acids Research, submitted, June 1994."
+    });
+    info.put("MuscleWS",
+             new String[]
+             {
+             "http://www.compbio.dundee.ac.uk/JalviewWS/services/MuscleWS",
+             "Muscle Alignment job",
+             "Edgar, Robert C. (2004), MUSCLE: multiple sequence alignment "
+             +
+             "with high accuracy and high throughput, Nucleic Acids Research 32(5), 1792-97."
+    });
+  };
+}