2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ws.rest.params;
23 import jalview.datamodel.AlignmentI;
24 import jalview.datamodel.SequenceI;
25 import jalview.ws.params.OptionI;
26 import jalview.ws.params.simple.Option;
27 import jalview.ws.rest.InputType;
28 import jalview.ws.rest.NoValidInputDataException;
29 import jalview.ws.rest.RestJob;
31 import java.io.UnsupportedEncodingException;
32 import java.util.ArrayList;
33 import java.util.Arrays;
34 import java.util.List;
36 import org.apache.http.entity.mime.content.ContentBody;
37 import org.apache.http.entity.mime.content.StringBody;
40 * input a list of sequence IDs separated by some separator
45 public class SeqIdVector extends InputType
49 super(new Class[] { AlignmentI.class });
53 * separator for list of sequence IDs - default is ','
60 public ContentBody formatForInput(RestJob rj)
61 throws UnsupportedEncodingException, NoValidInputDataException
63 StringBuffer idvector = new StringBuffer();
65 for (SequenceI seq : rj.getSequencesForInput(token, type))
71 idvector.append(seq.getName());
73 return new StringBody(idvector.toString());
77 public List<String> getURLEncodedParameter()
79 ArrayList<String> prms = new ArrayList<String>();
80 super.addBaseParams(prms);
81 prms.add("sep='" + sep + "'");
84 prms.add("type='" + type + "'");
90 public String getURLtokenPrefix()
96 public boolean configureProperty(String tok, String val,
97 StringBuffer warnings)
99 if (tok.startsWith("sep"))
104 if (tok.startsWith("type"))
108 type = molType.valueOf(val);
110 } catch (Exception x)
113 "Invalid molecule type '" + val + "'. Must be one of (");
114 for (molType v : molType.values())
116 warnings.append(" " + v);
118 warnings.append(")\n");
125 public List<OptionI> getOptions()
127 List<OptionI> lst = getBaseOptions();
128 lst.add(new Option("sep",
129 "Separator character between elements of vector", true, ",",
130 sep, Arrays.asList(new String[]
131 { " ", ",", ";", "\t", "|" }), null));
132 lst.add(createMolTypeOption("type", "Sequence type", false, type,