+ protected final JobId submit(List<SequenceI> sequences,
+ WsParamSetI preset, List<ArgumentI> args) throws Throwable
+ {
+ SlivkaForm form = service.getForm();
+ Optional<FormField> inputField = form.getFields().stream()
+ .filter(f -> f.getType() == FieldType.FILE).findFirst();
+ if (inputField.isPresent())
+ {
+ StringBuilder builder = new StringBuilder();
+ for (SequenceI seq : sequences)
+ {
+ builder.append(">").append(seq.getName()).append("\n")
+ .append(seq.getSequence()).append("\n");
+ }
+ InputStream stream = new ByteArrayInputStream(
+ builder.toString().getBytes());
+ RemoteFile file = client.uploadFile(stream, "input.fa",
+ "application/fasta");
+ form.insert(inputField.get().getName(), file);
+ }
+ if (args != null)
+ {
+ for (ArgumentI arg : args)
+ {
+ // multiple choice field names are name$number to avoid duplications
+ // the number is stripped here
+ String fieldName = arg.getName().split("\\$", 2)[0];
+ FormField field = form.getField(fieldName);
+ if (field.getType() == FieldType.BOOLEAN)
+ {
+ form.insert(fieldName,
+ (arg.getValue() != null && !arg.getValue().isBlank())
+ ? true
+ : false);
+ }
+ else
+ {
+ form.insert(fieldName, arg.getValue());
+ }
+ }
+ }
+ return new JobId(service.getName(), service.getName(), form.submit());
+ }
+