package jalview.ws.slivkaws;
import jalview.api.FeatureColourI;
+import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.SequenceI;
import jalview.ws.params.WsParamSetI;
import jalview.ws.uimodel.AlignAnalysisUIText;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
import java.io.IOError;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.util.Arrays;
-import java.util.HashMap;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
-import uk.ac.dundee.compbio.slivkaclient.FormField;
+import compbio.data.msa.Category;
import uk.ac.dundee.compbio.slivkaclient.RemoteFile;
import uk.ac.dundee.compbio.slivkaclient.SlivkaClient;
-import uk.ac.dundee.compbio.slivkaclient.SlivkaForm;
import uk.ac.dundee.compbio.slivkaclient.SlivkaService;
public class SlivkaAnnotationServiceInstance extends SlivkaWSInstance implements SequenceAnnotationServiceI
{
public SlivkaAnnotationServiceInstance(SlivkaClient client,
- SlivkaService service, boolean conservation)
+ SlivkaService service, String category)
{
- super(client, service, !conservation ? "Annotations disorder"
- : "Alignment Conservation");
- if (conservation)
+ super(client, service, category);
+ if (category == Category.CATEGORY_CONSERVATION)
{
- setAlignAnalysisUI(new AlignAnalysisUIText(getServiceType(),
+ /* FIXME: the category name is hardcoded for AACon, names other than
+ * "AAConWS" doesn't work. */
+ setAlignAnalysisUI(new AlignAnalysisUIText(getName(),
SlivkaAnnotationServiceInstance.class,
"Slivka.AACons", false, true, true, true, true, 2,
MessageManager.getString("label.aacon_calculations"),
MessageManager.getString("label.aacon_settings"),
MessageManager.getString("tooltip.aacon_settings")));
}
+ style = ServiceClient.SEQUENCEANNOTATIONWSCLIENT;
}
@Override
public JobId submitToService(List<SequenceI> seqs, WsParamSetI preset, List<ArgumentI> paramset) throws Throwable
{
- StringBuilder builder = new StringBuilder();
- for (SequenceI seq : seqs)
- {
- builder.append(">").append(seq.getName()).append("\n");
- builder.append(seq.getSequence()).append("\n");
- }
- InputStream stream = new ByteArrayInputStream(builder.toString().getBytes());
- RemoteFile file = client.uploadFile(stream, "input.fasta", "application/fasta");
- SlivkaForm form = service.getForm();
- HashMap<String, String> values = new HashMap<>(paramset != null ? paramset.size() : 0);
- if (paramset != null)
- {
- for (ArgumentI arg : paramset)
- {
- values.put(arg.getName(), arg.getValue());
- }
- }
- for (FormField field : form.getFields())
- {
- switch (field.getType())
- {
- case FILE:
- form.insert(field.getName(), file);
- break;
- case BOOLEAN:
- String value = values.get(field.getName());
- form.insert(field.getName(), value != null && !value.isBlank() ? true : false);
- break;
- default:
- form.insert(field.getName(), field.valueOf(values.get(field.getName())));
- }
- }
- return new JobId(service.getName(), service.getName(), form.submit());
+ return super.submit(seqs, preset, paramset);
}
@Override
- public List<AlignmentAnnotation> getAnnotationResult(JobId job,
+ public List<AlignmentAnnotation> getAnnotationResult(JobId jobId,
List<SequenceI> seqs, Map<String, FeatureColourI> featureColours,
Map<String, FeatureMatcherSetI> featureFilters) throws Throwable
{
RemoteFile featFile = null;
try
{
- List<RemoteFile> files = client.getJobResults(job.getJobId());
+ var slivkaJob = client.getJob(jobId.getJobId());
+ Collection<RemoteFile> files = slivkaJob.getResults();
for (RemoteFile f : files)
{
- if (f.getMimeType().equals("application/jalview-annotations"))
+ if (f.getMediaType().equals("application/jalview-annotations"))
{
annotFile = f;
}
- else if (f.getMimeType().equals("application/jalview-features"))
+ else if (f.getMediaType().equals("application/jalview-features"))
{
featFile = f;
}
throw new IOError(e);
}
Alignment aln = new Alignment(seqs.toArray(new SequenceI[0]));
- BufferedReader readerIn = new BufferedReader(new InputStreamReader(annotFile.getContent()));
- new AnnotationFile().parseAnnotationFrom(aln, null, readerIn);
- if (featFile != null)
+ if (annotFile == null
+ || !new AnnotationFile().readAnnotationFileWithCalcId(aln, service.getId(), annotFile.getContentUrl().toString(), DataSourceType.URL))
{
- new FeaturesFile(featFile.getURL().toString(), DataSourceType.URL).parse(aln, featureColours, true);
+ Cache.log.debug("No annotation from slivka job\n" + annotFile);
+ }
+ else {
+ Cache.log.debug("Annotation file loaded " + annotFile);
+ }
+ if (featFile == null
+ || !new FeaturesFile(featFile.getContentUrl().toString(), DataSourceType.URL).parse(aln, featureColours, true))
+ {
+ Cache.log.debug("No features from slivka job\n" + featFile);
+ }
+ else {
+ Cache.log.debug("Features feil loaded " + featFile);
}
return Arrays.asList(aln.getAlignmentAnnotation());
}