2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.ws.rest.params;
20 import jalview.datamodel.AlignmentI;
21 import jalview.datamodel.SequenceI;
22 import jalview.ws.params.OptionI;
23 import jalview.ws.params.simple.Option;
24 import jalview.ws.rest.InputType;
25 import jalview.ws.rest.NoValidInputDataException;
26 import jalview.ws.rest.RestJob;
28 import java.io.UnsupportedEncodingException;
29 import java.util.ArrayList;
30 import java.util.Arrays;
31 import java.util.List;
33 import org.apache.http.entity.mime.content.ContentBody;
34 import org.apache.http.entity.mime.content.StringBody;
37 * input a list of sequence IDs separated by some separator
42 public class SeqIdVector extends InputType
47 { AlignmentI.class });
51 * separator for list of sequence IDs - default is ','
58 public ContentBody formatForInput(RestJob rj)
59 throws UnsupportedEncodingException, NoValidInputDataException
61 StringBuffer idvector = new StringBuffer();
63 for (SequenceI seq : rj.getSequencesForInput(token, type))
69 idvector.append(seq.getName());
71 return new StringBody(idvector.toString());
75 public List<String> getURLEncodedParameter()
77 ArrayList<String> prms = new ArrayList<String>();
78 super.addBaseParams(prms);
79 prms.add("sep='" + sep + "'");
82 prms.add("type='" + type + "'");
88 public String getURLtokenPrefix()
94 public boolean configureProperty(String tok, String val,
95 StringBuffer warnings)
97 if (tok.startsWith("sep"))
102 if (tok.startsWith("type"))
106 type = molType.valueOf(val);
108 } catch (Exception x)
110 warnings.append("Invalid molecule type '" + val
111 + "'. Must be one of (");
112 for (molType v : molType.values())
114 warnings.append(" " + v);
116 warnings.append(")\n");
123 public List<OptionI> getOptions()
125 List<OptionI> lst = getBaseOptions();
126 lst.add(new Option("sep",
127 "Separator character between elements of vector", true, ",",
128 sep, Arrays.asList(new String[]
129 { " ", ",", ";", "\t", "|" }), null));
130 lst.add(createMolTypeOption("type", "Sequence type", false, type, null));