{
StartJob(jobs[j]);
}
-
+ Cache.log.debug("Job " + jobs[j] + " is " + (jobs[j].submitted ? "submitted" : "not submitted"));
if (jobs[j].submitted && !jobs[j].subjobComplete)
{
+ jalview.bin.Cache.log.debug(
+ "Polling Job " + j + " Result state was:" + jobs[j].getState() + "(ServerError=" + jobs[j].isServerError()
+ + ")"
+ );
try
{
pollJob(jobs[j]);
Cache.log.debug("Interrupted sleep waiting for next job poll.",
e);
}
- // System.out.println("I'm alive "+alTitle);
+ // System.out.println("I'm alive ?");
}
}
if (jobComplete && jobs != null)
.getCodonFrames();
if (cf != null)
{
- codonframe = new ArrayList<AlignedCodonFrame>();
+ codonframe = new ArrayList<>();
codonframe.addAll(cf);
}
}
import jalview.util.MessageManager;
import jalview.ws.api.ServiceWithParameters;
import jalview.ws.jws2.dm.AAConSettings;
-import jalview.ws.jws2.dm.JabaWsParamSet;
import jalview.ws.jws2.jabaws2.Jws2Instance;
import jalview.ws.params.ArgumentI;
import jalview.ws.params.WsParamSetI;
super(_alignFrame, preset, arguments);
if (preset != null)
{
- if (!((preset instanceof JabaPreset)
- || preset instanceof JabaWsParamSet))
- {
- /*
- * { this.preset = ((JabaPreset) preset).p; } else if (preset instanceof
- * JabaWsParamSet) { List<Argument> newargs = new ArrayList<Argument>();
- * JabaWsParamSet pset = ((JabaWsParamSet) preset); for (Option opt :
- * pset.getjabaArguments()) { newargs.add(opt); } if (arguments != null
- * && arguments.size() > 0) { // merge arguments with preset's own
- * arguments. for (Argument opt : arguments) { newargs.add(opt); } }
- * paramset = newargs; } else {
- */
- throw new Error(MessageManager.getString(
- "error.implementation_error_can_only_instantiate_jaba_param_sets"));
- }
+// if (!((preset instanceof JabaPreset)
+// || preset instanceof JabaWsParamSet))
+// {
+// /*
+// * { this.preset = ((JabaPreset) preset).p; } else if (preset instanceof
+// * JabaWsParamSet) { List<Argument> newargs = new ArrayList<Argument>();
+// * JabaWsParamSet pset = ((JabaWsParamSet) preset); for (Option opt :
+// * pset.getjabaArguments()) { newargs.add(opt); } if (arguments != null
+// * && arguments.size() > 0) { // merge arguments with preset's own
+// * arguments. for (Argument opt : arguments) { newargs.add(opt); } }
+// * paramset = newargs; } else {
+// */
+// throw new Error(MessageManager.getString(
+// "error.implementation_error_can_only_instantiate_jaba_param_sets"));
+// }
}
else
{
import jalview.ws.api.ServiceWithParameters;
import jalview.ws.gui.WsJob;
import jalview.ws.params.ArgumentI;
+import jalview.ws.params.ParamDatastoreI;
import jalview.ws.params.ParamManager;
import jalview.ws.params.WsParamSetI;
import java.io.IOException;
import java.io.InputStream;
import java.util.EnumMap;
+import java.util.HashMap;
import java.util.List;
-import org.apache.http.entity.ContentType;
-
+import uk.ac.dundee.compbio.slivkaclient.FieldType;
import uk.ac.dundee.compbio.slivkaclient.Form;
+import uk.ac.dundee.compbio.slivkaclient.FormField;
import uk.ac.dundee.compbio.slivkaclient.FormValidationException;
import uk.ac.dundee.compbio.slivkaclient.JobState;
import uk.ac.dundee.compbio.slivkaclient.RemoteFile;
import uk.ac.dundee.compbio.slivkaclient.Service;
import uk.ac.dundee.compbio.slivkaclient.SlivkaClient;
+import uk.ac.dundee.compbio.slivkaclient.ValidationException;
public class ClustaloWS extends ServiceWithParameters
implements MultipleSequenceAlignmentI, JalviewServiceEndpointProviderI
{
private SlivkaClient client;
private Service service;
+ private SlivkaDatastore store = null;
private EnumMap<JobState, WsJob.JobState> stateMap = new EnumMap<>(JobState.class);
{
ClustaloWS(SlivkaClient client)
{
- super("ClustalO", "Alignment", "ClustalO", "foo", "http://foo.foo");
+ super("ClustalO", "Alignment", "ClustalO", "Slivka", client.getUrl().toString());
this.client = client;
try
{
- service = client.getService("clustalo");
+ this.service = client.getService("clustalo");
} catch (IOException e)
{
throw new RuntimeException(e);
}
}
+ Service getService()
+ {
+ return service;
+ }
+
@Override
public boolean updateJobProgress(WsJob job)
{
}
@Override
- public JobId align(List<SequenceI> toalign, WsParamSetI parameters, List<ArgumentI> list) throws FormValidationException, IOException
+ public JobId align(List<SequenceI> toalign, WsParamSetI parameters, List<ArgumentI> list)
+ throws IOException
{
StringBuilder builder = new StringBuilder();
for (SequenceI seq : toalign)
{
builder.append(">").append(seq.getName()).append("\n");
- builder.append(seq.getSequence()).append("\n\n");
+ builder.append(seq.getSequence()).append("\n");
}
InputStream stream = new ByteArrayInputStream(builder.toString().getBytes());
- RemoteFile file = client.uploadFile(stream, "input.fasta", ContentType.create("application/fasta"));
+ RemoteFile file = client.uploadFile(stream, "input.fasta", "application/fasta");
Form form = service.getForm();
- form.insert("input", file);
- String jobUUID = form.submit();
- return new JobId("clustalo", "clustalo", jobUUID);
+ HashMap<String, String> values = new HashMap<>(list != null ? list.size() : 0);
+ if (list != null)
+ {
+ for (ArgumentI arg : list)
+ {
+ values.put(arg.getName(), arg.getValue());
+ }
+ }
+ for (FormField field : form.getFields())
+ {
+ if (field.getType() == FieldType.FILE)
+ {
+ form.insert(field.getName(), file);
+ } else
+ {
+ form.insert(field.getName(), field.valueOf(values.get(field.getName())));
+ }
+ }
+ try
+ {
+ return new JobId("clustalo", "clustalo", form.submit());
+ } catch (FormValidationException e)
+ {
+ for (ValidationException ve : e.getErrors())
+ {
+ System.out.format("%s: %s%n", ve.getField().getName(), ve.getMessage());
+ }
+ return null;
+ }
}
@Override
@Override
public void initParamStore(ParamManager userParameterStore)
{
+ if (store == null)
+ {
+ try
+ {
+ store = new SlivkaDatastore(service);
+ } catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ @Override
+ public boolean hasParameters()
+ {
+ return true;
+ }
+ @Override
+ public ParamDatastoreI getParamStore()
+ {
+ return store;
}
@Override
--- /dev/null
+package jalview.ws.slivkaws;
+
+import jalview.ws.params.ArgumentI;
+import jalview.ws.params.ParamDatastoreI;
+import jalview.ws.params.WsParamSetI;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import uk.ac.dundee.compbio.slivkaclient.Service;
+
+public class SlivkaDatastore implements ParamDatastoreI
+{
+ private SlivkaParamSet defaultPreset;
+ private List<WsParamSetI> presets = new ArrayList<>();
+
+ SlivkaDatastore(Service service) throws IOException {
+ defaultPreset = new SlivkaParamSet(service);
+ presets.add(defaultPreset);
+ }
+
+ @Override
+ public List<WsParamSetI> getPresets()
+ {
+ return presets;
+ }
+
+ @Override
+ public WsParamSetI getPreset(String name)
+ {
+ for (WsParamSetI preset : presets)
+ {
+ if (preset.getName().equals(name))
+ {
+ return preset;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public List<ArgumentI> getServiceParameters()
+ {
+ return new ArrayList<>(defaultPreset.getArguments());
+ }
+
+ @Override
+ public boolean presetExists(String name)
+ {
+ return name.equals(defaultPreset.getName());
+ }
+
+ @Override
+ public void deletePreset(String name)
+ {
+ }
+
+ @Override
+ public void storePreset(String presetName, String text, List<ArgumentI> jobParams)
+ {
+ }
+
+ @Override
+ public void updatePreset(String oldName, String presetName, String text, List<ArgumentI> jobParams)
+ {
+ }
+
+ @Override
+ public WsParamSetI parseServiceParameterFile(String name, String description, String[] serviceURL, String parameters)
+ throws IOException
+ {
+ return null;
+ }
+
+ @Override
+ public String generateServiceParameterFile(WsParamSetI pset) throws IOException
+ {
+ return null;
+ }
+
+}
--- /dev/null
+package jalview.ws.slivkaws;
+
+import jalview.ws.params.ArgumentI;
+import jalview.ws.params.WsParamSetI;
+import jalview.ws.params.simple.BooleanOption;
+import jalview.ws.params.simple.DoubleParameter;
+import jalview.ws.params.simple.IntegerParameter;
+import jalview.ws.params.simple.RadioChoiceParameter;
+import jalview.ws.params.simple.StringParameter;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import uk.ac.dundee.compbio.slivkaclient.BooleanField;
+import uk.ac.dundee.compbio.slivkaclient.ChoiceField;
+import uk.ac.dundee.compbio.slivkaclient.DecimalField;
+import uk.ac.dundee.compbio.slivkaclient.Form;
+import uk.ac.dundee.compbio.slivkaclient.FormField;
+import uk.ac.dundee.compbio.slivkaclient.IntegerField;
+import uk.ac.dundee.compbio.slivkaclient.Service;
+import uk.ac.dundee.compbio.slivkaclient.TextField;
+
+
+
+public class SlivkaParamSet implements WsParamSetI
+{
+ private Service service;
+ private List<ArgumentI> args = new ArrayList<>();
+
+ SlivkaParamSet(Service service) throws IOException {
+ this.service = service;
+ Form form = service.getForm();
+ for (FormField field : form.getFields())
+ {
+ ArgumentI arg;
+ switch (field.getType()) {
+ case BOOLEAN:
+ BooleanField boolField = (BooleanField) field;
+ arg = new BooleanOption(
+ field.getName(), field.getDescription(), field.isRequired(), boolField.getDefault(),
+ boolField.getDefault(), null
+ );
+ break;
+ case TEXT:
+ TextField textField = (TextField) field;
+ arg = new StringParameter(
+ field.getName(), field.getDescription(), field.isRequired(), textField.getDefault(),
+ textField.getDefault()
+ );
+ break;
+ case INTEGER:
+ IntegerField intField = (IntegerField) field;
+ arg = new IntegerParameter(
+ field.getName(), field.getDescription(), field.isRequired(), intField.getDefault(),
+ intField.getMin(), intField.getMax()
+ );
+ break;
+ case DECIMAL:
+ DecimalField doubleField = (DecimalField) field;
+ arg = new DoubleParameter(
+ field.getName(), field.getDescription(), field.isRequired(), doubleField.getDefault(),
+ doubleField.getMin(), doubleField.getMax()
+ );
+ break;
+ case CHOICE:
+ ChoiceField choiceField = (ChoiceField) field;
+ arg = new RadioChoiceParameter(
+ field.getName(), field.getDescription(), new ArrayList<>(choiceField.getChoices()), choiceField.getDefault()
+ );
+ break;
+ case FILE:
+ default:
+ continue;
+ }
+ args.add(arg);
+ }
+ }
+
+ @Override
+ public String getName()
+ {
+ return "Default";
+ }
+
+ @Override
+ public String getDescription()
+ {
+ return "";
+ }
+
+ @Override
+ public String[] getApplicableUrls()
+ {
+ return new String[] { service.getURL().toString() };
+ }
+
+ @Override
+ public String getSourceFile()
+ {
+ return null;
+ }
+
+ @Override
+ public void setSourceFile(String newfile)
+ {
+ }
+
+ @Override
+ public boolean isModifiable()
+ {
+ return true;
+ }
+
+ @Override
+ public List<ArgumentI> getArguments()
+ {
+ return args;
+ }
+
+ @Override
+ public void setArguments(List<ArgumentI> args)
+ {
+ throw new RuntimeException();
+ }
+
+}
import jalview.ws.jws2.MsaWSClient;
import java.awt.event.ActionEvent;
+import java.io.IOException;
import java.net.URISyntaxException;
import javax.swing.JMenu;
public void attachWSMenuEntry(JMenu wsmenu, final AlignFrame alignFrame)
{
JMenu submenu = new JMenu("Slivka");
- JMenuItem menuItem = new JMenuItem("ClustalO with defaults");
- menuItem.addActionListener((ActionEvent e) -> {
+ JMenuItem noParamMenuItem = new JMenuItem("ClustalO with defaults");
+ noParamMenuItem.addActionListener((ActionEvent e) -> {
AlignmentView msa = alignFrame.gatherSequencesForAlignment();
-
if (msa != null)
{
- new MsaWSClient(clustalo, alignFrame.getTitle(), msa, false,
- true,
+ new MsaWSClient(
+ clustalo, alignFrame.getTitle(), msa, false, true,
alignFrame.getViewport().getAlignment().getDataset(),
alignFrame);
}
-//
-// List<SequenceI> sequences = alignFrame.getViewport().getAlignment().getSequences();
-// try
-// {
-// clustalo.align(sequences, null, null);
-// } catch (FormValidationException | IOException exc)
-// {
-// throw new RuntimeException(exc);
-// }
});
- submenu.add(menuItem);
+ submenu.add(noParamMenuItem);
+
+ JMenuItem parametrisedMenuItem = new JMenuItem("ClustalO with custom parameters");
+ parametrisedMenuItem.addActionListener((ActionEvent evt) -> {
+ AlignmentView msa = alignFrame.gatherSequencesForAlignment();
+ if (msa != null)
+ {
+ try
+ {
+ SlivkaParamSet paramSet = new SlivkaParamSet(clustalo.getService());
+ new MsaWSClient(
+ clustalo, paramSet, null, true, alignFrame.getTitle(), msa, false, true,
+ alignFrame.getViewport().getAlignment().getDataset(), alignFrame
+ );
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+ submenu.add(parametrisedMenuItem);
+
wsmenu.add(submenu);
}