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 java.security.*;
33 import ext.jemboss.soap.*;
34 import jalview.datamodel.*;
40 private static ext.jemboss.JembossParams vamsas_server;
44 // Set up default jalview-jemboss server properties
46 vamsas_server = new JembossParams();
47 System.out.println("Jemboss Server Init\n"
48 + vamsas_server.serverDescription()
49 + "\nUser Authorisation ? "
50 + vamsas_server.getUseAuth()
54 /* public void updateServer(JembossParams props)
56 vamsas_server.updateJembossPropStrings (
57 props.getEmbossEnvironmentArray());
61 public SequenceI[] clustalW(SequenceI[] sequences)
64 // Simplest client call - with gumph from jemboss.server.TestPrivateServer
65 if (vamsas_server.getPublicSoapURL().startsWith("https"))
68 // System.setProperty ("javax.net.debug", "all");
69 com.sun.net.ssl.internal.ssl.Provider p =
70 new com.sun.net.ssl.internal.ssl.Provider();
71 Security.addProvider(p);
73 //have to do it this way to work with JNLP
74 URL.setURLStreamHandlerFactory( new URLStreamHandlerFactory()
76 public URLStreamHandler createURLStreamHandler(final String protocol)
78 if(protocol != null && protocol.compareTo("https") == 0)
80 return new com.sun.net.ssl.internal.www.protocol.https.Handler();
86 //location of keystore
87 System.setProperty("javax.net.ssl.trustStore",
88 "resources/client.keystore");
90 String jembossClientKeyStore = System.getProperty("user.home") +
91 "/.jembossClientKeystore";
95 new JembossJarUtil("resources/client.jar").writeByteFile(
96 "client.keystore",jembossClientKeyStore);
97 System.setProperty("javax.net.ssl.trustStore",
98 jembossClientKeyStore);
100 catch(Exception exp){}
104 Hashtable filesToMove = new Hashtable();
105 String embossCommand = "emma -sequence jalseqs.fasta -auto";
106 // Load sequence file into hash
107 filesToMove.put("jalseqs.fasta",
108 jalview.io.FastaFile.print(sequences,124,false).getBytes());
110 if(vamsas_server.getUseAuth() == true)
111 if(vamsas_server.getServiceUserName() == null)
112 System.out.println("jalview.Jemboss: OOPS! Authentication required!");
114 // submit to private server
117 JembossRun thisrun = new JembossRun(embossCommand,"",
118 filesToMove,vamsas_server);
119 Hashtable h = thisrun.hash();
120 Enumeration enum = h.keys();
121 // Find the alignment generated and parse it
122 while (enum.hasMoreElements())
124 String thiskey = (String)enum.nextElement().toString();
125 if (thiskey.endsWith(".aln"))
127 // FormatAdapter, and IdentifyFile use a protocol string
128 // to work out what 'file' is - file/url/Alignmentasastring
129 String alfile = h.get(thiskey).toString();
130 String format = IdentifyFile.Identify(alfile, "Paste");
131 SequenceI[] alignment = null;
133 if (FormatProperties.contains(format))
134 alignment = FormatAdapter.read(alfile, "Paste", format);
136 System.out.println("jalview.Jemboss: Unknown format "+format+"\n");
137 if (alignment == null)
138 System.out.println("jalview.Jemboss: Couldn't read response:\n"
139 + alfile + "\n---EOF\n");
147 catch (JembossSoapException eae)
149 System.out.println("jalview.Jemboss: SOAP ERROR :"+embossCommand
152 catch (Exception e) {
153 System.out.println("jalview.Jemboss: Some other failure :\n"
154 +e.getMessage()+"\n");