4 * <p>Title: JalviewX</p>
5 * <p>Description: Jalview Re-engineered</p>
6 * <p>Copyright: Copyright (c) 2004</p>
7 * <p>Company: Dundee University</p>
8 * @author not attributable
10 * Commenced 14th January 2005, Jim Procter
11 * Contains and depends on GPL-2 jemboss classes
12 * see http://www.rfcgr.mrc.ac.uk/Software/EMBOSS/Jemboss/index.html
17 * Jemboss webservices are implemented here as re-entrant synchronous SOAP
18 * exchanges. It is up to the user of the class whether these exchanges
19 * are executed in their own thread to effect background processing
24 * Standardise the exceptions (currently errors are output on stdout)
25 * Allow server configuration
29 import jalview.datamodel.*;
31 import ext.jemboss.soap.*;
34 import java.util.Hashtable;
35 import java.util.Enumeration;
36 import java.security.Security;
41 private static ext.jemboss.JembossParams vamsas_server;
45 // Set up default jalview-jemboss server properties
47 vamsas_server = new JembossParams();
48 System.out.println("Jemboss Server Init\n"
49 + vamsas_server.serverDescription()
50 + "\nUser Authorisation ? "
51 + vamsas_server.getUseAuth()
55 /* public void updateServer(JembossParams props)
57 vamsas_server.updateJembossPropStrings (
58 props.getEmbossEnvironmentArray());
62 public SequenceI[] clustalW(SequenceI[] sequences)
65 // Simplest client call - with gumph from jemboss.server.TestPrivateServer
66 if (vamsas_server.getPublicSoapURL().startsWith("https"))
69 // System.setProperty ("javax.net.debug", "all");
70 com.sun.net.ssl.internal.ssl.Provider p =
71 new com.sun.net.ssl.internal.ssl.Provider();
72 Security.addProvider(p);
74 //have to do it this way to work with JNLP
75 URL.setURLStreamHandlerFactory( new URLStreamHandlerFactory()
77 public URLStreamHandler createURLStreamHandler(final String protocol)
79 if(protocol != null && protocol.compareTo("https") == 0)
81 return new com.sun.net.ssl.internal.www.protocol.https.Handler();
87 //location of keystore
88 System.setProperty("javax.net.ssl.trustStore",
89 "resources/client.keystore");
91 String jembossClientKeyStore = System.getProperty("user.home") +
92 "/.jembossClientKeystore";
96 new JembossJarUtil("resources/client.jar").writeByteFile(
97 "client.keystore",jembossClientKeyStore);
98 System.setProperty("javax.net.ssl.trustStore",
99 jembossClientKeyStore);
101 catch(Exception exp){}
105 Hashtable filesToMove = new Hashtable();
106 String embossCommand = "emma -sequence jalseqs.fasta -auto";
107 // Load sequence file into hash
108 filesToMove.put("jalseqs.fasta",
109 jalview.io.FastaFile.print(sequences,124,false).getBytes());
111 if(vamsas_server.getUseAuth() == true)
112 if(vamsas_server.getServiceUserName() == null)
113 System.out.println("jalview.Jemboss: OOPS! Authentication required!");
115 // submit to private server
118 JembossRun thisrun = new JembossRun(embossCommand,"",
119 filesToMove,vamsas_server);
120 Hashtable h = thisrun.hash();
121 Enumeration enum = h.keys();
122 // Find the alignment generated and parse it
123 while (enum.hasMoreElements())
125 String thiskey = (String)enum.nextElement().toString();
126 if (thiskey.endsWith(".aln"))
128 // FormatAdapter, and IdentifyFile use a protocol string
129 // to work out what 'file' is - file/url/Alignmentasastring
130 String alfile = h.get(thiskey).toString();
131 String format = IdentifyFile.Identify(alfile, "Paste");
132 SequenceI[] alignment = null;
134 if (FormatProperties.contains(format))
135 alignment = FormatAdapter.read(alfile, "Paste", format);
137 System.out.println("jalview.Jemboss: Unknown format "+format+"\n");
138 if (alignment == null)
139 System.out.println("jalview.Jemboss: Couldn't read response:\n"
140 + alfile + "\n---EOF\n");
148 catch (JembossSoapException eae)
150 System.out.println("jalview.Jemboss: SOAP ERROR :"+embossCommand
153 catch (Exception e) {
154 System.out.println("jalview.Jemboss: Some other failure :\n"
155 +e.getMessage()+"\n");