1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package fr.ens.transcriptome.doelan.algorithms;
23
24 import fr.ens.transcriptome.doelan.Defaults;
25 import fr.ens.transcriptome.doelan.DoelanRegistery;
26 import fr.ens.transcriptome.doelan.data.DoelanDataUtils;
27 import fr.ens.transcriptome.doelan.data.TestSuiteResult;
28 import fr.ens.transcriptome.nividic.om.BioAssay;
29 import fr.ens.transcriptome.nividic.om.DefaultSpotEmptyTester;
30 import fr.ens.transcriptome.nividic.om.SpotEmptyTester;
31 import fr.ens.transcriptome.nividic.platform.PlatformException;
32 import fr.ens.transcriptome.nividic.platform.module.AboutModule;
33 import fr.ens.transcriptome.nividic.platform.module.Module;
34 import fr.ens.transcriptome.nividic.platform.module.ModuleDescription;
35 import fr.ens.transcriptome.nividic.platform.workflow.Container;
36 import fr.ens.transcriptome.nividic.platform.workflow.SimpleAlgorithmEvent;
37 import fr.ens.transcriptome.nividic.util.SystemUtils;
38 import fr.ens.transcriptome.nividic.util.parameter.FixedParameters;
39 import fr.ens.transcriptome.nividic.util.parameter.Parameter;
40 import fr.ens.transcriptome.nividic.util.parameter.ParameterBuilder;
41 import fr.ens.transcriptome.nividic.util.parameter.ParameterException;
42 import fr.ens.transcriptome.nividic.util.parameter.Parameters;
43
44 /***
45 * Configure Defaults for the test suite.
46 * @author Laurent Jourdren
47 */
48 public class DoelanConfigure extends QualityTest implements Module {
49
50 private static final String IDENTIFIER_COLUMN = "Identifier";
51 private static final String DESCRIPTION_COLUMN = "Description";
52
53 /***
54 * Get the description of the module.
55 * @return The description of the module
56 */
57 public AboutModule aboutModule() {
58
59 ModuleDescription md = null;
60 try {
61 md = new ModuleDescription("DoelanConfigure",
62 "Configure global parameters for the test suite");
63 md.setStability(AboutModule.STATE_STABLE);
64 md.setWebsite(DoelanRegistery.getAppURL());
65 md.setHTMLDocumentation(SystemUtils.readTextRessource("/files/test-"
66 + SystemUtils.getClassShortName(this.getClass()) + ".html"));
67 md.setVersion(Defaults.DEFAULT_TEST_VERSION);
68 } catch (PlatformException e) {
69 getLogger().error("Unable to create the module description");
70 }
71 return md;
72 }
73
74 /***
75 * Set the parameters of the element.
76 * @return The defaults parameters to set.
77 */
78 protected Parameters defineParameters() {
79
80 try {
81
82 final Parameter emptyIds = new ParameterBuilder().withName("emptyIds")
83 .withLongName("Empty identifiers").withType(
84 Parameter.DATATYPE_ARRAY_STRING).withDescription(
85 "Identifiers for empty spots").withDefaultValue("\"empty\"")
86 .getParameter();
87
88 final Parameter emptyIdColumn = new ParameterBuilder().withName(
89 "emptyIdColumn").withLongName("Empty identifiers column").withType(
90 Parameter.DATATYPE_STRING).withDescription(
91 "Column for empty identifiers").withChoices(
92 new String[] {IDENTIFIER_COLUMN, DESCRIPTION_COLUMN})
93 .withDefaultValue(IDENTIFIER_COLUMN).getParameter();
94
95 final Parameter rejectedlId = new ParameterBuilder().withName(
96 "rejectedlId").withLongName("New identifier for rejected spots")
97 .withType(Parameter.DATATYPE_STRING).withDescription(
98 "New identifier for rejected spots").withDefaultValue(
99 Defaults.REJECTED_SPOT_IDENTIFIER).getParameter();
100
101 final FixedParameters params = new FixedParameters();
102 params.addParameter(emptyIds);
103 params.addParameter(emptyIdColumn);
104 params.addParameter(rejectedlId);
105
106 return params;
107
108 } catch (ParameterException e) {
109 getLogger().error("Error while creating parameters: " + e);
110 }
111
112 return null;
113 }
114
115 /***
116 * Test if the test is deletable().
117 * @return true if the test is deletable
118 */
119 public boolean isDeletable() {
120 return false;
121 }
122
123 /***
124 * Test if only one instance of the test could be created.
125 * @return true if only one instance of the test could be created
126 */
127 public boolean isUniqueInstance() {
128 return true;
129 }
130
131 /***
132 * Test if the test is modifiable.
133 * @return true if the test is modifiable
134 */
135 public boolean isModifiable() {
136 return true;
137 }
138
139 /***
140 * Test if the test could be showed.
141 * @return true if the test could be showed
142 */
143 public boolean isShowable() {
144 return true;
145 }
146
147 /***
148 * Test if the test could be diplayed in the list of tests to add.
149 * @return true if the test could be showed
150 */
151 public boolean isAddable() {
152 return false;
153 }
154
155 protected void doIt(final Container c, final Parameters parameters)
156 throws PlatformException {
157
158
159 BioAssay bioAssay = DoelanDataUtils.getBioAssay(c);
160 BioAssay gal = DoelanDataUtils.getArrayList(c);
161
162 TestSuiteResult tsr = DoelanDataUtils.getTestSuiteResult(c);
163
164 String[] emptyIds;
165 try {
166 emptyIds = parameters.getParameter("emptyIds").getArrayStringValues();
167 final String rejectedlId = parameters.getParameter("rejectedlId")
168 .getStringValue();
169 final String emptyIdColumn = parameters.getParameter("emptyIdColumn")
170 .getStringValue();
171
172 tsr.setSpotRejectedId(rejectedlId);
173 tsr.setEmptySpotIds(emptyIds);
174
175 if (emptyIds != null) {
176 SpotEmptyTester set = new DefaultSpotEmptyTester(emptyIds,
177 DESCRIPTION_COLUMN.equals(emptyIdColumn));
178
179 bioAssay.setSpotEmptyTester(set);
180
181 if (gal != null)
182 gal.setSpotEmptyTester(bioAssay.getSpotEmptyTester());
183
184 }
185
186 } catch (ParameterException e) {
187 getLogger().error(
188 "Error while creating parameters (" + this.getClass().getName()
189 + "): " + e.getMessage());
190 }
191
192 sendEvent(new SimpleAlgorithmEvent(this, CONFIGURE_TEST_EVENT,
193 this.getId(), "set configure global parameters"));
194 }
195
196
197
198
199 /***
200 * Public constructor.
201 * @throws PlatformException If the name or the version of the element is
202 * <b>null </b>.
203 */
204 public DoelanConfigure() throws PlatformException {
205
206 }
207
208 }