import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import uk.ac.dundee.compbio.slivkaclient.FileHandler; import uk.ac.dundee.compbio.slivkaclient.HttpException; import uk.ac.dundee.compbio.slivkaclient.ServerError; import uk.ac.dundee.compbio.slivkaclient.Service; import uk.ac.dundee.compbio.slivkaclient.SlivkaClient; import uk.ac.dundee.compbio.slivkaclient.TaskHandler; import uk.ac.dundee.compbio.slivkaclient.form.Form; import uk.ac.dundee.compbio.slivkaclient.form.FormField; import uk.ac.dundee.compbio.slivkaclient.form.FormValidationException; import uk.ac.dundee.compbio.slivkaclient.form.ValidationException; public class Main { public static void main(String[] args) { SlivkaClient cli; try { cli = new SlivkaClient("localhost", 8000); } catch (URISyntaxException e) { throw new Error(e); } Service service = null; Form form; try { for (Service s : cli.getServices()) { if (s.getName().equals("Clustalw")) { service = s; } } form = service.getForm(); } catch (IOException | ServerError | HttpException e) { throw new Error(e); } File input = new File("examples/estrogenReceptorProtein.fa"); if (!input.exists()) { throw new Error("no file"); } TaskHandler th; try { FileHandler fh = cli.uploadFile(input, "text/plain", "input.txt"); th = form.create() .insert("input", fh) .insert("matrix", "blosum") .insert("outorder", "aligned") .submit(); } catch (IOException | HttpException | ServerError e) { throw new Error(e); } catch (FormValidationException e) { for (ValidationException e1 : e.getErrors()) { System.err.println(e1); } throw new Error(e); } try { while (!th.getStatus().isReady()) { Thread.sleep(1000); } } catch (IOException | HttpException | Error | InterruptedException e) { throw new Error(e); } try { for (FileHandler fh : th.getResult()) { System.out.println(fh.getTitle()); fh.writeTo(System.out); } } catch (IOException | HttpException | ServerError e) { throw new Error(e); } } }