1 package jalview.ws.rest.params;
3 import jalview.datamodel.AlignmentI;
4 import jalview.datamodel.SequenceI;
5 import jalview.ws.params.OptionI;
6 import jalview.ws.params.simple.Option;
7 import jalview.ws.rest.InputType;
8 import jalview.ws.rest.NoValidInputDataException;
9 import jalview.ws.rest.RestJob;
10 import jalview.ws.rest.RestServiceDescription;
11 import jalview.ws.rest.InputType.molType;
13 import java.io.UnsupportedEncodingException;
14 import java.util.ArrayList;
15 import java.util.Arrays;
16 import java.util.List;
18 import org.apache.http.entity.mime.content.ContentBody;
19 import org.apache.http.entity.mime.content.StringBody;
20 import org.jmol.util.ArrayUtil;
23 * input a list of sequences separated by some separator
27 public class SeqVector extends InputType {
32 super(new Class[] { AlignmentI.class} );
36 public ContentBody formatForInput(RestJob rj) throws UnsupportedEncodingException, NoValidInputDataException
38 StringBuffer idvector = new StringBuffer();
40 for (SequenceI seq:rj.getSequencesForInput(token, type))
46 idvector.append(seq.getSequence());
48 return new StringBody(idvector.toString());
51 public List<String> getURLEncodedParameter()
53 ArrayList<String> prms = new ArrayList<String>();
54 super.addBaseParams(prms);
55 prms.add("sep='"+ sep+"'");
58 prms.add("type='"+type+"'");
64 public String getURLtokenPrefix()
70 public boolean configureProperty(String tok, String val,
71 StringBuffer warnings)
74 if (tok.startsWith("sep"))
79 if (tok.startsWith("type"))
82 type=molType.valueOf(val);
86 warnings.append("Invalid molecule type '"+val+"'. Must be one of (");
87 for (molType v:molType.values())
89 warnings.append(" "+v);
91 warnings.append(")\n");
98 public List<OptionI> getOptions()
100 List<OptionI> lst = getBaseOptions();
101 lst.add(new Option("sep",
102 "Separator character between elements of vector", true, ",",
103 sep, Arrays.asList(new String[]
104 { " ", ",", ";", "\t", "|" }), null));
105 lst.add(createMolTypeOption("type", "Sequence type", false, type,