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;
17 import java.util.regex.Matcher;
18 import java.util.regex.Pattern;
20 import org.apache.http.entity.mime.content.ContentBody;
21 import org.apache.http.entity.mime.content.StringBody;
24 * input a list of sequence IDs separated by some separator
29 public class SeqIdVector extends InputType
34 { AlignmentI.class });
38 * separator for list of sequence IDs - default is ','
45 public ContentBody formatForInput(RestJob rj)
46 throws UnsupportedEncodingException, NoValidInputDataException
48 StringBuffer idvector = new StringBuffer();
50 for (SequenceI seq : rj.getSequencesForInput(token, type))
56 idvector.append(seq.getName());
58 return new StringBody(idvector.toString());
62 public List<String> getURLEncodedParameter()
64 ArrayList<String> prms = new ArrayList<String>();
65 super.addBaseParams(prms);
66 prms.add("sep='" + sep + "'");
69 prms.add("type='"+type+"'");
75 public String getURLtokenPrefix()
81 public boolean configureProperty(String tok, String val,
82 StringBuffer warnings)
84 if (tok.startsWith("sep"))
89 if (tok.startsWith("type"))
93 type = molType.valueOf(val);
97 warnings.append("Invalid molecule type '" + val
98 + "'. Must be one of (");
99 for (molType v : molType.values())
101 warnings.append(" " + v);
103 warnings.append(")\n");
110 public List<OptionI> getOptions()
112 List<OptionI> lst = getBaseOptions();
113 lst.add(new Option("sep",
114 "Separator character between elements of vector", true, ",",
115 sep, Arrays.asList(new String[]
116 { " ", ",", ";", "\t", "|" }), null));
117 lst.add(createMolTypeOption("type", "Sequence type", false, type,