Changeset 1292
- Timestamp:
- Feb 24, 2011, 9:52:28 AM (12 years ago)
- Location:
- plugins/base2/net.sf.basedb.examples/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/base2/net.sf.basedb.examples/trunk/META-INF/base-plugins.xml
r647 r1292 3 3 <plugins jarname="%%plugins.jar%%"> 4 4 <pluginclass classname="net.sf.basedb.exampleplugins.ExampleAnalyzer"> 5 <minbaseversion>2. 6</minbaseversion>5 <minbaseversion>2.17</minbaseversion> 6 6 <hasconfigurations/> 7 7 </pluginclass> 8 8 <pluginclass classname="net.sf.basedb.exampleplugins.ExampleImporter"> 9 <minbaseversion>2. 6</minbaseversion>9 <minbaseversion>2.17</minbaseversion> 10 10 <hasconfigurations/> 11 11 </pluginclass> -
plugins/base2/net.sf.basedb.examples/trunk/README
r1291 r1292 1 1 == Requirements == 2 2 3 1. BASE 2. 6.0 or later.3 1. BASE 2.17.0 or later. 4 4 5 5 == Introduction == -
plugins/base2/net.sf.basedb.examples/trunk/build.xml
r1291 r1292 21 21 <property name="javac.target" value="1.6" /> 22 22 <property name="javac.encoding" value="UTF-8" /> 23 <property name="depend.jars" value="http://base2.thep.lu.se/base/jars/2. 6.0" />23 <property name="depend.jars" value="http://base2.thep.lu.se/base/jars/2.17.0" /> 24 24 25 25 <!-- set up classpath for compiling --> -
plugins/base2/net.sf.basedb.examples/trunk/src/net/sf/basedb/exampleplugins/ExampleAnalyzer.java
r647 r1292 26 26 import net.sf.basedb.core.DbControl; 27 27 import net.sf.basedb.core.DynamicSpotQuery; 28 import net.sf.basedb.core.Experiment;29 28 import net.sf.basedb.core.Item; 30 import net.sf.basedb.core.ItemParameterType;31 29 import net.sf.basedb.core.Job; 32 30 import net.sf.basedb.core.FloatParameterType; 33 import net.sf.basedb.core.Permission;34 31 import net.sf.basedb.core.PluginParameter; 35 32 import net.sf.basedb.core.ProgressReporter; … … 50 47 import net.sf.basedb.core.plugin.About; 51 48 import net.sf.basedb.core.plugin.AboutImpl; 52 import net.sf.basedb.core.plugin.Abstract Plugin;49 import net.sf.basedb.core.plugin.AbstractAnalysisPlugin; 53 50 import net.sf.basedb.core.plugin.InteractivePlugin; 54 51 import net.sf.basedb.core.plugin.GuiContext; 55 import net.sf.basedb.core.plugin.Plugin;56 52 import net.sf.basedb.core.plugin.Request; 57 53 import net.sf.basedb.core.plugin.Response; … … 74 70 */ 75 71 public class ExampleAnalyzer 76 extends Abstract Plugin72 extends AbstractAnalysisPlugin 77 73 implements InteractivePlugin, SignalTarget 78 74 { … … 85 81 "by multiplying each intensitity value with the same factor, filtering " + 86 82 "out intensities below a cutoff value.", 87 "2. 6",83 "2.17", 88 84 "2006, Base 2 development team", 89 85 null, … … 99 95 private RequestInformation configureJob; 100 96 101 // The selected source bioassay set102 private PluginParameter<BioAssaySet> bioAssaySetParameter;103 104 97 // Intensities below this value will be filtered out 105 98 private PluginParameter<Float> cutoffParameter; … … 121 114 ------------------------------------------- 122 115 */ 116 @Override 123 117 public About getAbout() 124 118 { 125 119 return about; 126 120 } 127 public Plugin.MainType getMainType() 128 { 129 return Plugin.MainType.ANALYZE; 130 } 121 @Override 131 122 public boolean supportsConfigurations() 132 123 { 133 124 return false; 134 125 } 126 @Override 135 127 public boolean requiresConfiguration() 136 128 { 137 129 return false; 138 130 } 131 @Override 139 132 public void run(Request request, Response response, ProgressReporter progress) 140 133 { … … 150 143 float cutoff = (Float)job.getValue("cutoff"); 151 144 float factor = (Float)job.getValue("factor"); 152 BioAssaySet source = (BioAssaySet)job.getValue("bioAssaySet"); 153 154 // Reload with current DbControl 155 source = BioAssaySet.getById(dc, source.getId()); 145 BioAssaySet source = getSourceBioAssaySet(dc); 156 146 int channels = source.getRawDataType().getChannels(); 157 147 … … 177 167 for (int ch = 1; ch <= channels; ch++) 178 168 { 179 Expression chExpression = Dynamic.column(VirtualColumn.channel (ch));169 Expression chExpression = Dynamic.column(VirtualColumn.channelRaw(ch)); 180 170 // Selects: ch * factor for each channel 181 171 query.select( … … 189 179 SpotBatcher batcher = result.getSpotBatcher(); 190 180 // Check for the ABORT signal before a lengthy operation 191 checkInterrupted();181 ThreadSignalHandler.checkInterrupted(); 192 182 int spotsCopied = batcher.insert(query); 193 183 batcher.close(); … … 220 210 Return a set containing the context [BIOASSAYSET, ITEM]. 221 211 */ 212 @Override 222 213 public Set<GuiContext> getGuiContexts() 223 214 { … … 226 217 /** 227 218 Check if the item is a {@link BioAssaySet} and the logged in 228 user has USE permission to the experiment. 229 */ 219 user has USE permission to the experiment. Also verify that 220 the bioassay set has data stored in the database. 221 */ 222 @Override 230 223 public String isInContext(GuiContext context, Object item) 231 224 { 232 String message = null; 233 if (item == null) 234 { 235 message = "The item is null"; 236 } 237 else if (!(item instanceof BioAssaySet)) 238 { 239 message = "The item is not a BioAssaySet: " + item; 240 } 241 else 242 { 243 // Without USE permission we will not be able 244 // to create new bioassay sets 245 Experiment e = ((BioAssaySet)item).getExperiment(); 246 e.checkPermission(Permission.USE); 225 String message = super.isInContext(context, item); 226 if (message == null) 227 { 228 BioAssaySet bas = (BioAssaySet)item; 229 if (bas.getNumSpots() <= 0) 230 { 231 message = "This plug-in requires spot data in the database"; 232 } 247 233 } 248 234 return message; … … 255 241 a bioassay set, a multiplcation factor and a cutoff value. 256 242 */ 243 @Override 257 244 public RequestInformation getRequestInformation(GuiContext context, String command) 258 245 throws BaseException … … 269 256 {@link Request#COMMAND_CONFIGURE_JOB}. 270 257 */ 258 @Override 271 259 public void configure(GuiContext context, Request request, Response response) 272 260 { … … 276 264 if (command.equals(Request.COMMAND_CONFIGURE_JOB)) 277 265 { 266 RequestInformation ri = getConfigureJob(context); 278 267 List<Throwable> errors = 279 validateRequestParameters( getConfigureJob(context).getParameters(), request);268 validateRequestParameters(ri.getParameters(), request); 280 269 if (errors != null) 281 270 { … … 284 273 } 285 274 286 storeValue(job, request, bioAssaySetParameter); 275 // Source bioassay set 276 storeValue(job, request, ri.getParameter(SOURCE_BIOASSAYSET)); 277 278 // Other options 287 279 storeValue(job, request, factorParameter); 288 280 storeValue(job, request, cutoffParameter); 281 BioAssaySet bioAssaySet = (BioAssaySet)job.getValue(SOURCE_BIOASSAYSET); 282 response.setSuggestedJobName("Example analysis on bioassay set '" + 283 bioAssaySet.getName() + "'"); 289 284 response.setDone("Job configuration complete", Job.ExecutionTime.SHORT); 290 285 // TODO - maybe check file size to make a better estimate … … 301 296 ------------------------------------------- 302 297 */ 298 @Override 303 299 public SignalHandler getSignalHandler() 304 300 { … … 311 307 private RequestInformation getConfigureJob(GuiContext context) 312 308 { 313 if (configureJob == null) 314 { 315 // Create bioassay set parameter 316 // A value is automatically assigned by the web client 317 bioAssaySetParameter = new PluginParameter<BioAssaySet>( 318 "bioAssaySet", 319 "Bioassay set", 320 "The bioassay set used as the source for this plugin", 321 new ItemParameterType<BioAssaySet>(BioAssaySet.class, null, true, 1, null) 322 ); 323 324 // Create multiplication factor parameter 325 factorParameter = new PluginParameter<Float>( 326 "factor", 327 "Multiplication factor", 328 "The factor to multiply each spot intensity with.", 329 new FloatParameterType(0.0f, 100.0f, 1.0f, true) 330 ); 331 332 // Create cutoff parameter 333 cutoffParameter = new PluginParameter<Float>( 334 "cutoff", 335 "Cut-off value", 336 "Original intensities falling below this value are filtered out.", 337 new FloatParameterType(null, null, 0.0f, true) 338 ); 339 340 // Create parameter list and request informaion 341 List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(); 342 parameters.add(bioAssaySetParameter); 343 parameters.add(factorParameter); 344 parameters.add(cutoffParameter); 345 346 configureJob = new RequestInformation 347 ( 348 Request.COMMAND_CONFIGURE_JOB, 349 "Specify multiplication factor and cutoff", 350 about.getDescription(), 351 parameters 352 ); 309 DbControl dc = null; 310 try 311 { 312 if (configureJob == null) 313 { 314 dc = sc.newDbControl(); 315 BioAssaySet bas = getCurrentBioAssaySet(dc); 316 // Create parameter list and request informaion 317 List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(); 318 319 // Source bioassay set parameter 320 parameters.add(getSourceBioAssaySetParameter(null, null)); 321 322 // Other parameters 323 // Create multiplication factor parameter 324 factorParameter = new PluginParameter<Float>( 325 "factor", 326 "Multiplication factor", 327 "The factor to multiply each spot intensity with.", 328 new FloatParameterType(0.0f, 100.0f, 1.0f, true) 329 ); 330 331 // Create cutoff parameter 332 cutoffParameter = new PluginParameter<Float>( 333 "cutoff", 334 "Cut-off value", 335 "Original intensities falling below this value are filtered out.", 336 new FloatParameterType(null, null, 0.0f, true) 337 ); 338 parameters.add(factorParameter); 339 parameters.add(cutoffParameter); 340 341 configureJob = new RequestInformation 342 ( 343 Request.COMMAND_CONFIGURE_JOB, 344 "Specify multiplication factor and cutoff", 345 about.getDescription(), 346 parameters 347 ); 348 } 349 } 350 finally 351 { 352 if (dc != null) dc.close(); 353 353 } 354 354 return configureJob; -
plugins/base2/net.sf.basedb.examples/trunk/src/net/sf/basedb/exampleplugins/ExampleImporter.java
r647 r1292 78 78 "or not. It won't actually import any samples, but will report that a few samples " + 79 79 "has been imported.", 80 "2. 6",80 "2.17", 81 81 "2006, Base 2 development team", 82 82 null, … … 114 114 ------------------------------------------- 115 115 */ 116 @Override 116 117 public About getAbout() 117 118 { 118 119 return about; 119 120 } 121 @Override 120 122 public Plugin.MainType getMainType() 121 123 { 122 124 return Plugin.MainType.IMPORT; 123 125 } 126 @Override 124 127 public boolean supportsConfigurations() 125 128 { 126 129 return false; 127 130 } 131 @Override 128 132 public boolean requiresConfiguration() 129 133 { 130 134 return false; 131 135 } 136 @Override 132 137 public void run(Request request, Response response, ProgressReporter progress) 133 138 { … … 175 180 Return a set containing the context [SAMPLE, LIST]. 176 181 */ 182 @Override 177 183 public Set<GuiContext> getGuiContexts() 178 184 { … … 182 188 Always null, we are not dealing with individual items. 183 189 */ 190 @Override 184 191 public String isInContext(GuiContext context, Object item) 185 192 { … … 193 200 a file and if existing samples should be updated or ignored. 194 201 */ 202 @Override 195 203 public RequestInformation getRequestInformation(GuiContext context, String command) 196 204 throws BaseException … … 207 215 {@link Request#COMMAND_CONFIGURE_JOB}. 208 216 */ 217 @Override 209 218 public void configure(GuiContext context, Request request, Response response) 210 219 { … … 224 233 storeValue(job, request, fileParameter); 225 234 storeValue(job, request, updateExistingParameter); 235 File importFile = (File)job.getValue(fileParameter.getName()); 236 response.setSuggestedJobName("Import samples from '" + importFile.getName() + "'"); 226 237 response.setDone("Job configuration complete", Job.ExecutionTime.SHORT); 227 238 // TODO - maybe check file size to make a better estimate … … 243 254 Always true, since we accept all files. 244 255 */ 256 @Override 245 257 public boolean isImportable(InputStream in) 246 258 throws BaseException … … 251 263 We don't do anything in this method. 252 264 */ 265 @Override 253 266 public void doImport(InputStream in, ProgressReporter progress) 254 267 throws BaseException 255 268 { 256 269 // Check if the ABORT signal has been sent 257 checkInterrupted();270 ThreadSignalHandler.checkInterrupted(); 258 271 /* 259 272 Pseudo code: 260 273 Parse input stream, for each found sample: 261 checkInterrupted(); // Do this as the first thing in a loop274 ThreadSignalHandler.checkInterrupted(); // Do this as the first thing in a loop 262 275 String name = ... 263 276 String externalId = ... … … 267 280 { 268 281 s = Sample.getNew(dc); 282 s.setName(name) // and other properites 269 283 dc.saveItem(s); 270 284 isNew = true; … … 283 297 ------------------------------------------- 284 298 */ 299 @Override 285 300 public SignalHandler getSignalHandler() 286 301 {
Note: See TracChangeset
for help on using the changeset viewer.