From: jprocter Date: Sun, 22 May 2005 17:56:13 +0000 (+0000) Subject: Added alignment ordering option to 'Sort by' and implemented generic X-Git-Tag: Release_2_0~241 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=33c59ebddbc51bbd26bc4c8576ec17c1498b19e8;p=jalview.git Added alignment ordering option to 'Sort by' and implemented generic MsaWS client. --- diff --git a/src/ext/jemboss/JembossJarUtil.java b/src/ext/jemboss/JembossJarUtil.java deleted file mode 100755 index ad10cd2..0000000 --- a/src/ext/jemboss/JembossJarUtil.java +++ /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 index b9580b5..0000000 --- a/src/ext/jemboss/JembossParams.java +++ /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') - 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 index 892db3a..0000000 --- a/src/ext/jemboss/soap/PrivateRequest.java +++ /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;iTitle:

+ * + *

Description:

+ * + *

Copyright: Copyright (c) 2004

+ * + *

Company: Dundee University

+ * + * @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 index 0000000..445671d --- /dev/null +++ b/src/jalview/datamodel/AlignmentOrder.java @@ -0,0 +1,117 @@ +package jalview.datamodel; + +import java.util.*; + +/** + *

Title:

+ * + *

Description:

+ * + *

Copyright: Copyright (c) 2004

+ * + *

Company: Dundee University

+ * + * @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(); i0) - { - 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 -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 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 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; i0) - || 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); - } - - 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) - { - 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 - 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; - SequenceI[] msa = new SequenceI[sz=seqs.getSize()]; - for (int i = 0; i < sz; i++) - { - msa[i] = (SequenceI) seqs.getSequenceAt(i); - } - - MsaWSClient ct = new jalview.ws.MsaWSClient(msa); - } - else - { - Vector seqs = viewport.getAlignment().getSequences(); - - if (seqs.size() > 1) { - SequenceI[] msa = new SequenceI[seqs.size()]; - for (int i = 0; i < seqs.size(); i++) - { - msa[i] = (SequenceI) seqs.elementAt(i); - } - - MsaWSClient ct = new MsaWSClient(msa); - } - - } - } - - 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();} - } - - -} +/******************** + * 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 -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 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 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; i0) + || 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 index a2e97f6..0000000 --- a/src/jalview/ws/Jemboss.java +++ /dev/null @@ -1,181 +0,0 @@ -package jalview.ws; - -/** - *

Title: JalviewX

- *

Description: Jalview Re-engineered

- *

Copyright: Copyright (c) 2004

- *

Company: Dundee University

- * @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; iTitle: MsaWServices

+ * + *

Description: Registry of MsaWSI style services

+ * + *

Copyright: Copyright (c) 2004

+ * + *

Company: Dundee University

+ * + * @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." + }); + }; +}