import jalview.datamodel.SequenceI;
import jalview.gui.WebserviceInfo;
+import jalview.io.FileFormat;
+import jalview.io.FormatAdapter;
import jalview.ws.api.JalviewServiceEndpointProviderI;
import jalview.ws.api.JalviewWebServiceI;
import jalview.ws.api.JobId;
import java.util.Set;
import uk.ac.dundee.compbio.slivkaclient.FieldType;
+import uk.ac.dundee.compbio.slivkaclient.FileField;
import uk.ac.dundee.compbio.slivkaclient.FormField;
import uk.ac.dundee.compbio.slivkaclient.FormValidationException;
import uk.ac.dundee.compbio.slivkaclient.JobState;
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())
+ for (FormField field : form.getFields())
{
- StringBuilder builder = new StringBuilder();
- for (SequenceI seq : sequences)
+ if (field.getType() == FieldType.FILE)
{
- builder.append(">").append(seq.getName()).append("\n")
- .append(seq.getSequence()).append("\n");
+ FormatAdapter fa = new FormatAdapter();
+ fa.setNewlineString("\r\n");
+ FileField fileField = (FileField) field;
+ FileFormat format;
+ switch (fileField.getMediaType())
+ {
+ case "application/pfam":
+ format = FileFormat.Pfam;
+ break;
+ case "application/stockholm":
+ format = FileFormat.Stockholm;
+ break;
+ default:
+ case "application/fasta":
+ format = FileFormat.Fasta;
+ break;
+ }
+ InputStream stream = new ByteArrayInputStream(
+ fa.formatSequences(format, sequences.toArray(new SequenceI[0]))
+ .getBytes());
+ RemoteFile rf = client.uploadFile(stream, "input",
+ fileField.getMediaType());
+ form.insert(field.getName(), rf);
}
- 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)
{