| 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 SeqIdVector extends InputType |
| 46 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 47 |
0 |
public SeqIdVector()... |
| 48 |
|
{ |
| 49 |
0 |
super(new Class[] { AlignmentI.class }); |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
String sep = ","; |
| 56 |
|
|
| 57 |
|
molType type; |
| 58 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 59 |
0 |
@Override... |
| 60 |
|
public ContentBody formatForInput(RestJob rj) |
| 61 |
|
throws UnsupportedEncodingException, NoValidInputDataException |
| 62 |
|
{ |
| 63 |
0 |
StringBuffer idvector = new StringBuffer(); |
| 64 |
0 |
boolean list = false; |
| 65 |
0 |
for (SequenceI seq : rj.getSequencesForInput(token, type)) |
| 66 |
|
{ |
| 67 |
0 |
if (list) |
| 68 |
|
{ |
| 69 |
0 |
idvector.append(sep); |
| 70 |
|
} |
| 71 |
0 |
idvector.append(seq.getName()); |
| 72 |
|
} |
| 73 |
0 |
return new StringBody(idvector.toString()); |
| 74 |
|
} |
| 75 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 76 |
0 |
@Override... |
| 77 |
|
public List<String> getURLEncodedParameter() |
| 78 |
|
{ |
| 79 |
0 |
ArrayList<String> prms = new ArrayList<String>(); |
| 80 |
0 |
super.addBaseParams(prms); |
| 81 |
0 |
prms.add("sep='" + sep + "'"); |
| 82 |
0 |
if (type != null) |
| 83 |
|
{ |
| 84 |
0 |
prms.add("type='" + type + "'"); |
| 85 |
|
} |
| 86 |
0 |
return prms; |
| 87 |
|
} |
| 88 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 89 |
0 |
@Override... |
| 90 |
|
public String getURLtokenPrefix() |
| 91 |
|
{ |
| 92 |
0 |
return "SEQIDS"; |
| 93 |
|
} |
| 94 |
|
|
| |
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 95 |
0 |
@Override... |
| 96 |
|
public boolean configureProperty(String tok, String val, |
| 97 |
|
StringBuffer warnings) |
| 98 |
|
{ |
| 99 |
0 |
if (tok.startsWith("sep")) |
| 100 |
|
{ |
| 101 |
0 |
sep = val; |
| 102 |
0 |
return true; |
| 103 |
|
} |
| 104 |
0 |
if (tok.startsWith("type")) |
| 105 |
|
{ |
| 106 |
0 |
try |
| 107 |
|
{ |
| 108 |
0 |
type = molType.valueOf(val); |
| 109 |
0 |
return true; |
| 110 |
|
} catch (Exception x) |
| 111 |
|
{ |
| 112 |
0 |
warnings.append( |
| 113 |
|
"Invalid molecule type '" + val + "'. Must be one of ("); |
| 114 |
0 |
for (molType v : molType.values()) |
| 115 |
|
{ |
| 116 |
0 |
warnings.append(" " + v); |
| 117 |
|
} |
| 118 |
0 |
warnings.append(")\n"); |
| 119 |
|
} |
| 120 |
|
} |
| 121 |
0 |
return false; |
| 122 |
|
} |
| 123 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 124 |
0 |
@Override... |
| 125 |
|
public List<OptionI> getOptions() |
| 126 |
|
{ |
| 127 |
0 |
List<OptionI> lst = getBaseOptions(); |
| 128 |
0 |
lst.add(new Option("sep", |
| 129 |
|
"Separator character between elements of vector", true, ",", |
| 130 |
|
sep, Arrays.asList(new String[] |
| 131 |
|
{ " ", ",", ";", "\t", "|" }), null)); |
| 132 |
0 |
lst.add(createMolTypeOption("type", "Sequence type", false, type, |
| 133 |
|
null)); |
| 134 |
0 |
return lst; |
| 135 |
|
} |
| 136 |
|
} |