--- /dev/null
+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
+ * Test threadability
+ * Standardise the exceptions (currently errors are output on stdout)
+ * Allow server configuration
+ */
+
+import jalview.io.*;
+import jalview.datamodel.*;
+import ext.jemboss.*;
+import ext.jemboss.soap.*;
+import java.io.*;
+import java.net.*;
+import java.util.Hashtable;
+import java.util.Enumeration;
+import java.security.Security;
+
+
+public class Jemboss
+{
+ private static ext.jemboss.JembossParams vamsas_server;
+
+ public Jemboss()
+ {
+ // Set up default jalview-jemboss server properties
+ //
+ vamsas_server = new JembossParams();
+ 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)
+ {
+
+ // 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";
+ // Load sequence file into hash
+ filesToMove.put("jalseqs.fasta",
+ jalview.io.FastaFile.print(sequences,124,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 enum = h.keys();
+ // Find the alignment generated and parse it
+ while (enum.hasMoreElements())
+ {
+ String thiskey = (String)enum.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 (FormatProperties.contains(format))
+ alignment = FormatAdapter.read(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
+ 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;
+ }
+}
+