1 package jalview.ws.rest.params;
3 import jalview.datamodel.AlignmentI;
4 import jalview.ws.rest.InputType;
5 import jalview.ws.rest.NoValidInputDataException;
6 import jalview.ws.rest.RestJob;
7 import jalview.ws.rest.InputType.molType;
9 import java.io.UnsupportedEncodingException;
11 import org.apache.http.entity.mime.content.ContentBody;
12 import org.apache.http.entity.mime.content.StringBody;
15 * format a jalview annotation file for input to a rest service.
19 public class AnnotationFile extends InputType {
20 public AnnotationFile()
22 super(new Class[] { AlignmentI.class} );
25 * standard jalview annotation file
27 final String JVANNOT="JalviewAnnotation";
29 * export annotation row as simple csv
31 final String CSVANNOT="CsvAnnotationRow";
33 * format of annotation file
35 String format=JVANNOT;
36 // TODO verify annotation file format enumeration
38 public ContentBody formatForInput(RestJob rj) throws UnsupportedEncodingException, NoValidInputDataException
40 AlignmentI al = rj.getAlignmentForInput(token,molType.MIX);
41 if (format.equals(JVANNOT))
42 {return new StringBody(new jalview.io.AnnotationFile().printAnnotations(al.getAlignmentAnnotation(),
43 al.getGroups(),al.getProperties()));
45 if (!format.equals(CSVANNOT))
47 throw new UnsupportedEncodingException("Unrecognised format for exporting Annotation ("+format+")");
49 return new StringBody(new jalview.io.AnnotationFile().printCSVAnnotations(al.getAlignmentAnnotation()));