Changeset 2155
- Timestamp:
- Apr 7, 2006, 2:56:14 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/build.xml
r2154 r2155 638 638 srcdir="${exampledir}/src" 639 639 destdir="${exampledir}/bin" 640 debug="true" 640 641 > 641 642 <classpath> … … 660 661 /> 661 662 </tar> 663 <delete file="${exampledir}/ExamplePlugins.jar" /> 664 <delete includeemptydirs="true"> 665 <fileset dir="${exampledir}/bin" includes="**/*"/> 666 </delete> 662 667 </target> 663 668 -
trunk/doc/development/index.html
r2154 r2155 300 300 and if existing samples should be updated or not, but doesn't 301 301 actually import anything. 302 303 <li>ExampleAnalyzer: Asks for a multiplication factor and a cut-off value. 304 It will create a child bioassay set by multiplying the original intensities 305 with the given factor and filter out those with original intensities less than 306 the cut-off. It works for any number of channels. 307 302 308 </ul> 303 309 <br> -
trunk/doc/development/plugins/analysis/index.html
r734 r2155 3 3 $Id$ 4 4 5 BioArray Software Environment (BASE) - http://base.thep.lu.se/ 6 Copyright (C) 2002-2004 Lao Saal, Carl Troein, 7 Johan Vallon-Christersson, Jari Häkkinen, Nicklas Nordborg 8 9 This file is part of BASE. 5 Copyright (C) 2006 Nicklas Nordborg 6 7 This file is part of BASE - BioArray Software Environment. 8 Available at http://base.thep.lu.se/ 10 9 11 10 BASE is free software; you can redistribute it and/or … … 44 43 <div class="abstract"> 45 44 46 TODO 45 <p> 46 This document contains information specific for writing analysis plugins. 47 </p> 47 48 48 49 <p> … … 50 51 </p> 51 52 <ol> 52 <li> 53 53 <li><a href="#analysis">Analysis plugins</a> 54 54 </ol> 55 55 56 <p> 56 57 <b>See also</b> 58 </p> 59 57 60 <ul> 58 <li> 61 <li><a href="../index.html">How to write plug-ins</a> 62 <li><a href="../../overview/dynamic/index.html">Dynamic API for experiments and analysis</a> 59 63 </ul> 60 </p>61 64 62 65 <p class="authors"> 63 <b>Last updated:</b> $Date$ 66 <b>Last updated:</b> $Date$<br> 67 <b>Copyright ©</b> 2006 The respective authors. All rights reserved. 64 68 </p> 65 69 </div> 66 70 71 <a name="analysis"></a> 72 <h2>1. Analysis plugins</h2> 73 74 <p> 75 A plugin becoms an analysis plugin simply by returning <code>Plugin.MainType.ANALYSIS</code> 76 from the <code>Plugin.getMainType()</code> method. 77 </p> 78 79 <p> 80 The information return from <code>InteractivePlugin.getGuiContexts()</code> 81 must include: <code>GuiContext = [Item.BIOASSAYSET, Type.ITEM]</code> 82 since this is the only place where the web client looks for analysis plugins. 83 </p> 84 85 <pre class="code"> 86 private static final Set<GuiContext> guiContexts = 87 Collections.singleton(new GuiContext(Item.BIOASSAYSET, GuiContext.Type.ITEM)); 88 89 public Set<GuiContext> getGuiContexts() 90 { 91 return guiContexts; 92 } 93 </pre> 94 95 <p> 96 If the plugin depends on a specific raw data type or on the number of 97 channels, it should check that the current bioassayset is of the 98 correct type in the <code>InteractivePlugin.isInContext()</code> method: 99 </p> 100 101 <pre class="code"> 102 /** 103 Check if the item is a bioassay set with a 2-channel raw data type 104 */ 105 public boolean isInContext(GuiContext context, Object item) 106 { 107 if (item instanceof BioAssaySet) 108 { 109 BioAssaySet bas = (BioAssaySet)item; 110 RawDataType rdt = bas.getRawDataType(); 111 int channels = rdt.getChannels(); 112 return channels == 2; 113 } 114 return false; 115 } 116 </pre> 117 118 <p> 119 The plugin should always include a parameter asking for the current 120 bioassay set when the <code>InteractivePlugin.getRequestInformation()</code> 121 is called with the <code>command = Request.COMMAND_CONFIGURE_JOB</code>. 122 </p> 123 124 <pre class="code"> 125 private static final RequestInformation configurePlugin; 126 private RequestInformation configureJob; 127 private PluginParameter<BioAssaySet> bioAssaySetParameter; 128 129 public RequestInformation getRequestInformation(GuiContext context, String command) 130 throws BaseException 131 { 132 RequestInformation requestInformation = null; 133 if (command.equals(Request.COMMAND_CONFIGURE_PLUGIN)) 134 { 135 requestInformation = getConfigurePlugin(guiContext); 136 } 137 else if (command.equals(Request.COMMAND_CONFIGURE_JOB)) 138 { 139 requestInformation = getConfigureJob(guiContext); 140 } 141 return requestInformation; 142 } 143 144 private RequestInformation getConfigureJob(GuiContext context) 145 { 146 if (configureJob == null) 147 { 148 bioAssaySetParameter; = new PluginParameter<BioAssaySet>( 149 "bioAssaySet", 150 "Bioassay set", 151 "The bioassay set used as the source for this analysis plugin", 152 new ItemParameterType<BioAssaySet>(BioAssaySet.class, null, true, 1, null) 153 ); 154 155 List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(); 156 parameters.add(bioAssaySetParameter); 157 // Add more plugin-specific parameters... 158 159 configureJob = new RequestInformation( 160 Request.COMMAND_CONFIGURE_JOB, 161 "Configure job", 162 "TODO - description", 163 parameters 164 ); 165 } 166 return configureJob; 167 } 168 private RequestInformation getConfigurePlugin(GuiContext context) 169 { 170 if (configurePlugin == null) 171 { 172 // TODO - Add plugin-specific parameters 173 configurePlugin = new RequestInformation( 174 Request.COMMAND_CONFIGURE_PLUGIN, 175 "Configure plugin", 176 "This plugin has no configuration options.", 177 null 178 ); 179 } 180 } 181 </pre> 182 183 <p> 184 Of course, the <code>configure</code> method needs to validate and store 185 the bioassay set parameter as well: 186 </p> 187 188 <pre class="code"> 189 public void configure(GuiContext context, Request request, Response response) 190 { 191 String command = request.getCommand(); 192 try 193 { 194 if (command.equals(Request.COMMAND_CONFIGURE_PLUGIN)) 195 { 196 // Validate and store configuration parameters 197 response.setDone("Plugin configuration complete"); 198 } 199 else if (command.equals(Request.COMMAND_CONFIGURE_JOB)) 200 { 201 List<Throwable> errors = 202 validateRequestParameters(configureJob.getParameters(), request); 203 if (errors != null) 204 { 205 response.setError(errors.size() + 206 " invalid parameter(s) were found in the request", errors); 207 return; 208 } 209 storeValue(job, request, bioAssaySetParameter); 210 // Store other plugin-specific parameters 211 212 response.setDone("Job configuration complete", Job.ExecutionTime.SHORT); 213 // TODO - better estimate of execution time!! 214 } 215 } 216 catch (Throwable ex) 217 { 218 // Never throw exception, always set response! 219 response.setError(ex.getMessage(), Arrays.asList(ex)); 220 } 221 } 222 </pre> 223 224 <p> 225 Now, the typical <code>run()</code> method loads the specfied bioassay set 226 and it's spot data. It may do some filtering and recalculation of the spot 227 intensity value(s). In most cases it will store the result as a child bioassay 228 set with one bioassay for each bioassay in the parent bioassay set. 229 Here is an example, which just copies the intensity values, while 230 removing those with a negative value in either channel. 231 </p> 232 233 <pre class="code"> 234 public void run(Request request, Response response, ProgressReporter progress) 235 { 236 DbControl dc = sc.newDbControl(); 237 try 238 { 239 BioAssaySet source = (BioAssaySet)job.getParameter("bioAssaySet"); 240 // Reload with current DbControl 241 source = BioAssaySet.getById(dc, source.getId()); 242 int channels = source.getRawDataType().getChannels(); 243 244 // Create transformation and new bioassay set 245 Job j = Job.getById(dc, job.getId()); 246 Transformation t = source.newTransformation(j); 247 t.setName("Copy spot intensities >= 0"); 248 BioAssaySet result = t.newProduct(null, "new"); 249 result.setName("After: Copying spot intensities"); 250 dc.saveItem(t); 251 dc.saveItem(result); 252 253 // Create child bioassays for each source bioassay 254 for (BioAssay ba : source.getBioAssays.list(dc)) 255 { 256 dc.saveItem(result.newBioAssay(ba)); 257 } 258 259 // Get query for source data 260 DynamicSpotQuery query = source.getSpotData(); 261 262 // Do not return spots with intensities < 0 263 for (int ch = 1; ch <= channels; ++ch) 264 { 265 query.restrict( 266 Restrictions.gteq( 267 Dynamic.column(VirtualColumn.channel(ch)), 268 Expressions.integer(0) 269 ) 270 ); 271 } 272 273 // Create batcher and copy data 274 SpotBatcher batcher = result.getSpotBatcher(); 275 int spotsCopied = batcher.insert(query); 276 batcher.close(); 277 278 // Commit and return 279 dc.commit(); 280 response.setDone("Copied " + spotsCopied + " spots."); 281 } 282 catch (Throwable t) 283 { 284 response.setError(t.getMessage(), Arrays.asList(t)); 285 } 286 finally 287 { 288 if (dc != null) dc.close(); 289 } 290 } 291 </pre> 292 293 <p> 294 See the <a href="../../overview/dynamic/index.html">Dynamic API for experiments and analysis</a> 295 for more examples of using the analysis API. 296 </p> 297 67 298 </body> 68 299 </html> -
trunk/src/examples/plugins/build.xml
r2154 r2155 27 27 srcdir="${src}" 28 28 destdir="${bin}" 29 debug="true" 29 30 classpathref="classpath"> 30 31 </javac>
Note: See TracChangeset
for help on using the changeset viewer.