1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.rest.params; |
22 |
|
|
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; |
30 |
|
|
31 |
|
import java.io.UnsupportedEncodingException; |
32 |
|
import java.util.ArrayList; |
33 |
|
import java.util.Arrays; |
34 |
|
import java.util.List; |
35 |
|
|
36 |
|
import org.apache.http.entity.mime.content.ContentBody; |
37 |
|
import org.apache.http.entity.mime.content.StringBody; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@author |
43 |
|
|
44 |
|
|
|
|
| 0% |
Uncovered Elements: 45 (45) |
Complexity: 11 |
Complexity Density: 0.35 |
|
45 |
|
public class SeqVector extends InputType |
46 |
|
{ |
47 |
|
String sep; |
48 |
|
|
49 |
|
molType type; |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
51 |
0 |
public SeqVector()... |
52 |
|
{ |
53 |
0 |
super(new Class[] { AlignmentI.class }); |
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
56 |
0 |
@Override... |
57 |
|
public ContentBody formatForInput(RestJob rj) |
58 |
|
throws UnsupportedEncodingException, NoValidInputDataException |
59 |
|
{ |
60 |
0 |
StringBuffer idvector = new StringBuffer(); |
61 |
0 |
boolean list = false; |
62 |
0 |
for (SequenceI seq : rj.getSequencesForInput(token, type)) |
63 |
|
{ |
64 |
0 |
if (list) |
65 |
|
{ |
66 |
0 |
idvector.append(sep); |
67 |
|
} |
68 |
0 |
idvector.append(seq.getSequenceAsString()); |
69 |
|
} |
70 |
0 |
return new StringBody(idvector.toString()); |
71 |
|
} |
72 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
73 |
0 |
@Override... |
74 |
|
public List<String> getURLEncodedParameter() |
75 |
|
{ |
76 |
0 |
ArrayList<String> prms = new ArrayList<String>(); |
77 |
0 |
super.addBaseParams(prms); |
78 |
0 |
prms.add("sep='" + sep + "'"); |
79 |
0 |
if (type != null) |
80 |
|
{ |
81 |
0 |
prms.add("type='" + type + "'"); |
82 |
|
} |
83 |
0 |
return prms; |
84 |
|
} |
85 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
86 |
0 |
@Override... |
87 |
|
public String getURLtokenPrefix() |
88 |
|
{ |
89 |
0 |
return "SEQS"; |
90 |
|
} |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.33 |
|
92 |
0 |
@Override... |
93 |
|
public boolean configureProperty(String tok, String val, |
94 |
|
StringBuffer warnings) |
95 |
|
{ |
96 |
|
|
97 |
0 |
if (tok.startsWith("sep")) |
98 |
|
{ |
99 |
0 |
sep = val; |
100 |
0 |
return true; |
101 |
|
} |
102 |
0 |
if (tok.startsWith("type")) |
103 |
|
{ |
104 |
0 |
try |
105 |
|
{ |
106 |
0 |
type = molType.valueOf(val); |
107 |
0 |
return true; |
108 |
|
} catch (Exception x) |
109 |
|
{ |
110 |
0 |
warnings.append( |
111 |
|
"Invalid molecule type '" + val + "'. Must be one of ("); |
112 |
0 |
for (molType v : molType.values()) |
113 |
|
{ |
114 |
0 |
warnings.append(" " + v); |
115 |
|
} |
116 |
0 |
warnings.append(")\n"); |
117 |
|
} |
118 |
|
} |
119 |
0 |
return false; |
120 |
|
} |
121 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
122 |
0 |
@Override... |
123 |
|
public List<OptionI> getOptions() |
124 |
|
{ |
125 |
0 |
List<OptionI> lst = getBaseOptions(); |
126 |
0 |
lst.add(new Option("sep", |
127 |
|
"Separator character between elements of vector", true, ",", |
128 |
|
sep, Arrays.asList(new String[] |
129 |
|
{ " ", ",", ";", "\t", "|" }), null)); |
130 |
0 |
lst.add(createMolTypeOption("type", "Sequence type", false, type, |
131 |
|
molType.MIX)); |
132 |
|
|
133 |
0 |
return lst; |
134 |
|
} |
135 |
|
|
136 |
|
} |