Changeset 2128
- Timestamp:
- Mar 30, 2006, 8:01:48 AM (18 years ago)
- Location:
- branches/rf1
- Files:
-
- 1 deleted
- 8 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/rf1/src/core/net/sf/basedb/plugins/IntensityCalculatorPlugin.java
r1972 r2128 27 27 import net.sf.basedb.core.ProgressReporter; 28 28 29 import net.sf.basedb.core.BaseException; 30 import net.sf.basedb.core.Formula; 31 import net.sf.basedb.core.Include; 32 import net.sf.basedb.core.InvalidDataException; 33 import net.sf.basedb.core.Item; 34 import net.sf.basedb.core.ItemParameterType; 35 import net.sf.basedb.core.ItemQuery; 36 import net.sf.basedb.core.PluginParameter; 37 import net.sf.basedb.core.RequestInformation; 38 import net.sf.basedb.core.StringParameterType; 29 39 import net.sf.basedb.core.Transformation; 30 40 import net.sf.basedb.core.BioAssaySet; … … 37 47 import net.sf.basedb.core.plugin.AboutImpl; 38 48 import net.sf.basedb.core.plugin.AbstractPlugin; 49 import net.sf.basedb.core.plugin.GuiContext; 39 50 import net.sf.basedb.core.plugin.Plugin; 51 import net.sf.basedb.core.plugin.InteractivePlugin; 40 52 import net.sf.basedb.core.plugin.Request; 41 53 import net.sf.basedb.core.plugin.Response; 42 import net.sf.basedb.core.IntensityFormula; 54 import net.sf.basedb.core.query.Hql; 55 import net.sf.basedb.core.query.Orders; 43 56 import net.sf.basedb.util.IntensityCalculator; 44 57 import net.sf.basedb.util.IntensityCalculatorUtil; 45 58 59 import java.util.ArrayList; 60 import java.util.Arrays; 61 import java.util.Collections; 46 62 import java.util.List; 63 import java.util.Set; 47 64 48 65 /** 49 This plugin provides methods to calculate the intensity for a root bioassayset using different formulas.50 It needs the following parameters66 This plugin provides methods to calculate the intensity for a root bioassayset 67 using different formulas. It needs the following parameters: 51 68 52 69 <pre> 53 String : name 54 Experiment : experiment 55 List<RawBioAssay> : rawBioAssays 56 String : formula 70 String : name; The name of the new bioassayset 71 Experiment : experiment; The experiment we are working on 72 List>RawBioAssay< : rawBioAssays; The raw bioassays to create bioassays for 73 (must be part of the experiment) 74 Formula : formula; The formula to use to for calculating intesities 57 75 </pre> 58 76 59 @author Gregory 77 @author Gregory, Nicklas 78 @version 2.0 79 @base.modified $Date$ 60 80 */ 61 81 public class IntensityCalculatorPlugin 62 82 extends AbstractPlugin 63 implements Plugin83 implements InteractivePlugin 64 84 { 65 85 … … 70 90 new AboutImpl 71 91 ( 72 "Intensity calculator", 73 "This plugin is used to calculate intensities from raw data creating an initial raw bioassay.", 74 "1.0", 92 "Formula intensity calculator", 93 "This plugin is used to calculate intensities from raw data creating an initial root bioassay set. "+ 94 "The intensities are calculated using Formula objects registered for the experiment's raw data type. " + 95 "Thus, the functionality of this plugin can be extended by adding more formula objects to the database.", 96 "2.0", 75 97 "2006, Department of Theoretical Physics, Lund University", 76 98 null, … … 79 101 ); 80 102 81 103 private static final Set<GuiContext> guiContexts = 104 Collections.singleton(new GuiContext(Item.BIOASSAYSET, GuiContext.Type.LIST)); 105 106 private static final RequestInformation configurePlugin = new RequestInformation 107 ( 108 Request.COMMAND_CONFIGURE_PLUGIN, 109 "Configure intensity calculator", 110 "This plugin has no configuration options.", 111 null 112 ); 113 114 private static final StringParameterType nameType = 115 new StringParameterType(BioAssaySet.MAX_NAME_LENGTH, "New bioassayset", true); 116 private static final PluginParameter<String> nameParameter = new PluginParameter<String>( 117 "name", "Bioassay set name", "The name of the root bioassayset", nameType); 118 119 private ItemParameterType<Experiment> experimentType; 120 private PluginParameter<Experiment> experimentParameter; 121 122 private ItemParameterType<RawBioAssay> rawBioAssaysType; 123 private PluginParameter<RawBioAssay> rawBioAssaysParameter; 124 125 private ItemParameterType<Formula> formulaType; 126 private PluginParameter<Formula> formulaParameter; 127 128 private RequestInformation configureJob; 129 82 130 /** 83 131 Constructor should be empty. … … 86 134 {} 87 135 88 89 /* 90 Plugin interface implementation 91 ------------------------------- 136 /* 137 From the Plugin interface 138 ------------------------------------------- 92 139 */ 93 140 public About getAbout() … … 95 142 return about; 96 143 } 97 98 99 144 /** 100 145 Returns the main plugin type this plugin belongs to. … … 106 151 } 107 152 108 109 /**110 @param request111 @param response112 @param progress113 */114 153 @SuppressWarnings("unchecked") 115 154 public void run(Request request, Response response, ProgressReporter progress) … … 118 157 try 119 158 { 120 / * name parameter */159 // name parameter 121 160 String name = (String)job.getValue("name"); 122 161 123 /* experiment parameter*/ 124 125 Integer experimentId = (Integer)job.getValue("experiment_id"); 126 if(experimentId != null) 127 { 128 Experiment experiment = Experiment.getById(dc, experimentId.intValue()); 129 130 /* rawBioAssays parameter*/ 131 List<RawBioAssay> sources = (List<RawBioAssay>)job.getValues("rawBioAssays"); 132 for (RawBioAssay rba : sources) 133 { 134 dc.reattachItem(rba); 135 } 136 137 /* formula parameter */ 138 String formula = (String)job.getValue("formula"); 139 140 /* intensity calculation */ 141 RawDataType rdt = experiment.getRawDataType(); 142 IntensityFormula intensityFormula = rdt.getIntensityFormula( formula ); 143 IntensityCalculator iCalc = IntensityCalculatorUtil.createJepIntensityCalculator(dc, rdt, intensityFormula.getExpressions()); 144 int jobId = job.getId(); 145 Job thisJob = Job.getById(dc, jobId); 146 BioAssaySet rootBas = IntensityCalculatorUtil.createRootBioAssaySet(dc, experiment, sources, thisJob, iCalc, progress); 147 rootBas.setName(name); 148 Transformation t = rootBas.getTransformation(); 149 t.setName(intensityFormula.getTitle()); 150 dc.commit(); 151 response.setDone("Done"); 162 // experiment parameter 163 Experiment experiment = (Experiment)job.getValue("experiment"); 164 165 // To avoid disconnection/reconnection issues 166 experiment = Experiment.getById(dc, experiment.getId()); 167 168 // rawBioAssays parameter 169 List<RawBioAssay> sources = (List<RawBioAssay>)job.getValues("rawBioAssays"); 170 for (RawBioAssay rba : sources) 171 { 172 dc.reattachItem(rba); 152 173 } 153 else 154 { 155 response.setError("Experiment id is null", null); 174 175 // Formula parameter 176 Formula formula = (Formula)job.getValue("formula"); 177 formula = Formula.getById(dc, formula.getId()); 178 179 // intensity calculation 180 RawDataType rdt = experiment.getRawDataType(); 181 182 // IntensityFormula intensityFormula = rdt.getIntensityFormula( formula ); 183 IntensityCalculator iCalc = 184 IntensityCalculatorUtil.createJepIntensityCalculator(dc, rdt, 185 formula.getFormulas().toArray(new String[formula.getNumFormulas()])); 186 int jobId = job.getId(); 187 Job thisJob = Job.getById(dc, jobId); 188 189 BioAssaySet rootBas = IntensityCalculatorUtil.createRootBioAssaySet(dc, experiment, sources, thisJob, iCalc, progress); 190 rootBas.setName(name); 191 Transformation t = rootBas.getTransformation(); 192 t.setName(formula.getName()); 193 dc.commit(); 194 response.setDone("Done"); 195 } 196 finally 197 { 198 if (dc != null) dc.close(); 199 } 200 } 201 // ------------------------------------------- 202 203 /* 204 From the InteractivePlugin interface 205 ------------------------------------------- 206 */ 207 public Set<GuiContext> getGuiContexts() 208 { 209 return guiContexts; 210 } 211 /** 212 Always false, since plugin doesn't operate on individual items. 213 */ 214 public boolean isInContext(GuiContext context, Object item) 215 { 216 return false; 217 } 218 /** 219 The {@link Request#COMMAND_CONFIGURE_PLUGIN} command will not ask for 220 any parameters. 221 The {@link Request#COMMAND_CONFIGURE_JOB} command will ask for 222 the parameters mentioned in the class documentation. 223 */ 224 public RequestInformation getRequestInformation(GuiContext context, String command) 225 throws BaseException 226 { 227 RequestInformation requestInformation = null; 228 if (command.equals(Request.COMMAND_CONFIGURE_PLUGIN)) 229 { 230 requestInformation = configurePlugin; 231 } 232 else if (command.equals(Request.COMMAND_CONFIGURE_JOB)) 233 { 234 requestInformation = getConfigureJobParameters(); 235 } 236 return requestInformation; 237 } 238 /** 239 Store configuration settings for {@link Request#COMMAND_CONFIGURE_PLUGIN}, 240 and {@link Request#COMMAND_CONFIGURE_JOB}. 241 */ 242 @SuppressWarnings("unchecked") 243 public void configure(GuiContext context, Request request, Response response) 244 { 245 String command = request.getCommand(); 246 247 try 248 { 249 if (command.equals(Request.COMMAND_CONFIGURE_PLUGIN)) 250 { 251 response.setDone("No configuration needed."); 156 252 } 157 } 158 finally 159 { 160 if (dc != null) dc.close(); 161 } 162 } 253 else if (command.equals(Request.COMMAND_CONFIGURE_JOB)) 254 { 255 List<Throwable> errors = validateRequestParameters(configureJob.getParameters(), request); 256 if (errors != null) 257 { 258 response.setError(errors.size()+" invalid parameter(s) were found in the request", errors); 259 return; 260 } 261 262 Experiment experiment = (Experiment)request.getParameterValue("experiment"); 263 DbControl dc = sc.newDbControl(); 264 int numSpots = 0; 265 try 266 { 267 experiment = Experiment.getById(dc, experiment.getId()); 268 List<RawBioAssay> rawBioAssays = (List<RawBioAssay>)request.getParameterValues("rawBioAssays"); 269 for (RawBioAssay rba : rawBioAssays) 270 { 271 if (!experiment.isUsing(rba)) 272 { 273 throw new InvalidDataException("Raw bioassay '" + rba.getName() + 274 "' is not part of the experiment '" + experiment.getName()+"'"); 275 } 276 numSpots += rba.getSpots(); 277 } 278 } 279 finally 280 { 281 if (dc != null) dc.close(); 282 } 283 284 Formula formula = (Formula)request.getParameterValue("formula"); 285 if (formula.getFormulaType() != Formula.Type.INTENSITY_EXPRESSION) 286 { 287 throw new InvalidDataException("The selected formula is not an intensity expression formula: " + 288 formula.getName()); 289 } 290 if (formula.getRawDataType() != experiment.getRawDataType()) 291 { 292 throw new InvalidDataException("The selected formula '"+formula.getName()+ 293 "' uses a different raw data type than the experiment '" + experiment.getName()+"'"); 294 } 295 296 storeValue(job, request, nameParameter); 297 storeValue(job, request, experimentParameter); 298 storeValues(job, request, rawBioAssaysParameter); 299 storeValue(job, request, formulaParameter); 300 301 Job.ExecutionTime execTime = Job.ExecutionTime.SHORT; 302 // TODO - this should be configurable in some way 303 if (numSpots > 1000000 && numSpots < 10000000) 304 { 305 execTime = Job.ExecutionTime.MEDIUM; 306 } 307 else 308 { 309 execTime = Job.ExecutionTime.LONG; 310 } 311 312 response.setDone("Job configuration complete", execTime); 313 } 314 } 315 catch (Throwable ex) 316 { 317 response.setError(ex.getMessage(), Arrays.asList(ex)); 318 ex.printStackTrace(); 319 } 320 } 321 322 323 private RequestInformation getConfigureJobParameters() 324 { 325 if (configureJob == null) 326 { 327 List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(); 328 329 experimentType = new ItemParameterType<Experiment>(Experiment.class, null, true, 1, null); 330 experimentParameter = new PluginParameter<Experiment>( 331 "experiment", "Experiment", "The experiment we are working with", experimentType); 332 333 parameters.add(experimentParameter); 334 parameters.add(nameParameter); 335 336 DbControl dc = sc.newDbControl(); 337 try 338 { 339 int experimentId = sc.getCurrentContext(Item.EXPERIMENT).getId(); 340 Experiment experiment = Experiment.getById(dc, experimentId); 341 342 ItemQuery<RawBioAssay> rawBioAssayQuery = experiment.getRawBioAssays(); 343 rawBioAssayQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT); 344 rawBioAssayQuery.order(Orders.asc(Hql.property("name"))); 345 List<RawBioAssay> rawBioAssays = new ArrayList<RawBioAssay>(rawBioAssayQuery.list(dc)); 346 rawBioAssaysType = new ItemParameterType<RawBioAssay>(RawBioAssay.class, null, true, 0, rawBioAssays); 347 rawBioAssaysParameter = new PluginParameter<RawBioAssay>( 348 "rawBioAssays", "Raw bioassays", "Select the raw bioassays to use when creating the root bioassay set", 349 rawBioAssaysType); 350 351 parameters.add(rawBioAssaysParameter); 352 353 ItemQuery<Formula> formulaQuery = Formula.getQuery(Formula.Type.INTENSITY_EXPRESSION, 354 experiment.getRawDataType()); 355 formulaQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT); 356 formulaQuery.order(Orders.asc(Hql.property("name"))); 357 List<Formula> formulas = new ArrayList<Formula>(formulaQuery.list(dc)); 358 formulaType = new ItemParameterType<Formula>(Formula.class, null, true, 1, formulas); 359 formulaParameter = new PluginParameter<Formula>( 360 "formula", "Formula", "Select the expression to use for calculating the intensities", 361 formulaType); 362 parameters.add(formulaParameter); 363 } 364 finally 365 { 366 if (dc != null) dc.close(); 367 } 368 configureJob = new RequestInformation 369 ( 370 Request.COMMAND_CONFIGURE_JOB, 371 "Intensity calculation options", 372 "Select which raw bioassays to use and a formula for the calculations", 373 parameters 374 ); 375 } 376 return configureJob; 377 } 378 163 379 } -
branches/rf1/src/core/net/sf/basedb/plugins/MedianRatioNormalization.java
r2036 r2128 48 48 import net.sf.basedb.core.SpotBatcher; 49 49 import net.sf.basedb.core.Transformation; 50 import net.sf.basedb.core.Type; 50 51 import net.sf.basedb.core.VirtualColumn; 51 52 import net.sf.basedb.core.plugin.About; … … 58 59 import net.sf.basedb.core.plugin.Request; 59 60 import net.sf.basedb.core.plugin.Response; 61 import net.sf.basedb.core.query.Aggregations; 60 62 import net.sf.basedb.core.query.Dynamic; 61 63 import net.sf.basedb.core.query.Expressions; … … 102 104 "highExclude", 103 105 "Exclude top", 104 " Exclude top %",106 "A percentage of the highest values that are ignored when calculating the median.", 105 107 new FloatParameterType(0F, 100F, 5F, true) 106 108 ); … … 110 112 "lowExclude", 111 113 "Exclude low", 112 " Exclude low %",114 "A percentage of the lowest values that are ignored when calculating the median.", 113 115 new FloatParameterType(0F, 100F, 5F, true) 114 116 ); … … 185 187 try 186 188 { 189 int blockGroupSize = (Integer) job.getValue(blockGroupParameter.getName()); 187 190 BioAssaySet bioAssaySet = (BioAssaySet) job.getValue(bioAssaySetParameter.getName()); 188 191 bioAssaySet = BioAssaySet.getById(dc, bioAssaySet.getId()); … … 193 196 child.setName(bioAssaySet.getName()); 194 197 dc.saveItem(child); 195 196 198 batcher = child.getSpotBatcher(); 197 199 … … 201 203 202 204 Select ratio = Selects.expression(Expressions.divide(Dynamic.column(VirtualColumn.channel(1)), Dynamic.column(VirtualColumn.channel(2))), "ratio"); 203 205 Restriction intensityRestriction = Restrictions.and 206 ( 207 Restrictions.gt(Dynamic.column(VirtualColumn.channel(1)), Expressions.aFloat((Float) job.getValue(minIntensityParameter.getName()))), 208 Restrictions.gt(Dynamic.column(VirtualColumn.channel(2)), Expressions.aFloat((Float) job.getValue(minIntensityParameter.getName()))) 209 ); 210 float lowExclude = (Float) job.getValue(lowExcludeParameter.getName()); 211 float highExclude = (Float) job.getValue(highExcludeParameter.getName()); 212 213 DynamicSpotQuery query; 214 DynamicResultIterator resultIter; 204 215 List<BioAssay> assays = bioAssaySet.getBioAssays().list(dc); 205 216 for (BioAssay assay : assays) 206 217 { 207 218 //TODO use block numbers to create subgroups 208 DynamicSpotQuery query = getQuery(assay.getSpotData());209 query.select(ratio);210 query.order(Orders.asc(Expressions.selected(ratio)));211 212 int count = query.count(dc);213 numSpots -= assay.getNumSpots() - count;214 progress.display((normalizedSpots * 100) / numSpots, (assay.getNumSpots() - count)+ " spots removed from assay " + assay.getName());215 216 // check count > 0217 double median;218 if (count % 2 == 0)219 {220 query.setFirstResult((count/2)-1);221 query.setMaxResults(2);222 DynamicResultIterator iter = query.iterate(dc);223 median = Math.sqrt(iter.next().getFloat(iter.getIndex("ratio"))*iter.next().getFloat(iter.getIndex("ratio")));224 }225 else226 {227 query.setFirstResult((count-1)/2);228 query.setMaxResults(1);229 DynamicResultIterator iter = query.iterate(dc);230 median = iter.next().getFloat(iter.getIndex("ratio"));231 }232 233 float sqrtMedRatio = (float) Math.sqrt(median);234 float invSqrtMedRatio = 1/sqrtMedRatio;235 Select newCh1 = Selects.expression236 (237 Expressions.multiply(Expressions.selected(Dynamic.select(VirtualColumn.channel(1))), Expressions.aFloat(invSqrtMedRatio)),238 "newCh1"239 );240 Select newCh2 = Selects.expression241 (242 Expressions.multiply(Expressions.selected(Dynamic.select(VirtualColumn.channel(2))), Expressions.aFloat(sqrtMedRatio)),243 "newCh2"244 );245 246 query = getQuery(assay.getSpotData());247 query.select(Dynamic.select(VirtualColumn.COLUMN));248 query.select(Dynamic.select(VirtualColumn.POSITION));249 query.select(newCh1);250 query.select(newCh2);251 252 219 dc.saveItem(child.newBioAssay(assay)); 253 220 254 DynamicResultIterator iter = query.iterate(dc); 255 int column = iter.getIndex(VirtualColumn.COLUMN.getName()); 256 int position = iter.getIndex(VirtualColumn.POSITION.getName()); 257 int ch1 = iter.getIndex("newCh1"); 258 int ch2 = iter.getIndex("newCh2"); 259 while (iter.hasNext()) 221 query = assay.getSpotData(); 222 query.restrict(intensityRestriction); 223 query.joinRawData(JoinType.LEFT); 224 query.select(Selects.expression(Aggregations.max(Expressions.selected(Dynamic.selectRawData("block"))), "max")); 225 resultIter = query.iterate(dc); 226 int maxBlock = resultIter.next().getInt(resultIter.getIndex("max")); 227 228 for (int i = 0; i < maxBlock; i += blockGroupSize) 260 229 { 261 SqlResult r = iter.next(); 262 batcher.insert(r.getShort(column), r.getInt(position), r.getFloat(ch1), r.getFloat(ch2)); 263 normalizedSpots++; 264 progress.display((normalizedSpots * 100) / numSpots, normalizedSpots + " spots normalized"); 230 Restriction blockRestriction = Restrictions.between 231 ( 232 Expressions.selected(Dynamic.selectRawData("block")), 233 Expressions.integer(i), 234 Expressions.integer(i+blockGroupSize) 235 ); 236 237 query = assay.getSpotData(); 238 query.joinRawData(JoinType.LEFT); 239 query.select(Dynamic.select(VirtualColumn.channel(1))); 240 query.select(Dynamic.select(VirtualColumn.channel(2))); 241 query.select(Dynamic.selectRawData("block")); 242 query.select(ratio); 243 query.restrict(intensityRestriction); 244 query.restrict(blockRestriction); 245 query.order(Orders.asc(Expressions.selected(ratio))); 246 247 int count = query.count(dc); 248 if (count <= 0) continue; 249 int lowCount = (int) Math.floor(count * lowExclude / 100); 250 int highCount = (int) Math.floor(count * highExclude / 100); 251 numSpots -= assay.getNumSpots() - count; 252 progress.display((normalizedSpots * 100) / numSpots, (assay.getNumSpots() - count) + " spots removed from assay " + assay.getName()); 253 254 // check count > 0 255 int include = count - lowCount - highCount; 256 if (include <= 0) continue; 257 double median; 258 if (include % 2 == 0) 259 { 260 query.setFirstResult((include / 2) - 1 + lowCount); 261 query.setMaxResults(2); 262 DynamicResultIterator iter = query.iterate(dc); 263 median = Math.sqrt(iter.next().getFloat(iter.getIndex("ratio")) * iter.next().getFloat(iter.getIndex("ratio"))); 264 } 265 else 266 { 267 query.setFirstResult(((include - 1) / 2) + lowCount); 268 query.setMaxResults(1); 269 DynamicResultIterator iter = query.iterate(dc); 270 median = iter.next().getFloat(iter.getIndex("ratio")); 271 } 272 273 float sqrtMedRatio = (float) Math.sqrt(median); 274 float invSqrtMedRatio = 1 / sqrtMedRatio; 275 Select newCh1 = Selects.expression(Expressions.multiply(Expressions.selected(Dynamic.select(VirtualColumn.channel(1))), 276 Expressions.aFloat(invSqrtMedRatio)), "newCh1"); 277 Select newCh2 = Selects.expression(Expressions.multiply(Expressions.selected(Dynamic.select(VirtualColumn.channel(2))), 278 Expressions.aFloat(sqrtMedRatio)), "newCh2"); 279 280 query = assay.getSpotData(); 281 query.joinRawData(JoinType.LEFT); 282 query.select(Dynamic.select(VirtualColumn.COLUMN)); 283 query.select(Dynamic.select(VirtualColumn.POSITION)); 284 query.select(newCh1); 285 query.select(newCh2); 286 query.restrict(intensityRestriction); 287 query.restrict(blockRestriction); 288 query.setParameter("low", new Integer(i), Type.INT); 289 query.setParameter("high", new Integer(i + blockGroupSize), Type.INT); 290 291 DynamicResultIterator iter = query.iterate(dc); 292 int column = iter.getIndex(VirtualColumn.COLUMN.getName()); 293 int position = iter.getIndex(VirtualColumn.POSITION.getName()); 294 int ch1 = iter.getIndex("newCh1"); 295 int ch2 = iter.getIndex("newCh2"); 296 while (iter.hasNext()) 297 { 298 SqlResult r = iter.next(); 299 batcher.insert(r.getShort(column), r.getInt(position), r.getFloat(ch1), r.getFloat(ch2)); 300 normalizedSpots++; 301 progress.display((normalizedSpots * 100) / numSpots, normalizedSpots + " spots normalized"); 302 } 265 303 } 266 304 } … … 358 396 } 359 397 // ------------------------------------------- 360 361 private DynamicSpotQuery getQuery(DynamicSpotQuery query)362 {363 Restriction restriction = Restrictions.and364 (365 Restrictions.gt(Dynamic.column(VirtualColumn.channel(1)), Expressions.aFloat((Float) job.getValue(minIntensityParameter.getName()))),366 Restrictions.gt(Dynamic.column(VirtualColumn.channel(2)), Expressions.aFloat((Float) job.getValue(minIntensityParameter.getName())))367 );368 369 query.restrictPermanent(restriction);370 query.joinRawData(JoinType.LEFT);371 query.selectPermanent(Dynamic.select(VirtualColumn.channel(1)));372 query.selectPermanent(Dynamic.select(VirtualColumn.channel(2)));373 query.selectPermanent(Dynamic.selectRawData("block"));374 return query;375 }376 398 } -
branches/rf1/www/admin/clients/view_client.jsp
r2004 r2128 106 106 Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540); 107 107 } 108 function viewHelp() 109 { 110 location.href = 'help/index.jsp?ID=<%=ID%>&cmd=List&client_id=<%=itemId%>'; 111 } 112 function switchTab(tabControlId, tabId) 113 { 114 if (tabId == 'help') 115 { 116 viewHelp(); 117 } 118 else 119 { 120 TabControl.setActiveTab(tabControlId, tabId); 121 } 122 } 108 123 </script> 109 124 </base:head> … … 115 130 </p:path> 116 131 117 <t:tabcontrol id="main" active="properties" >132 <t:tabcontrol id="main" active="properties" switch="switchTab"> 118 133 <t:tab id="properties" title="Properties"> 119 134 … … 207 222 </div> 208 223 </t:tab> 224 225 <t:tab id="help" title="Help" tooltip="View and manage help texts for this client application" /> 209 226 </t:tabcontrol> 210 227 -
branches/rf1/www/common/plugin/configure.jsp
r2073 r2128 129 129 } 130 130 // Finally we use the parameters default value 131 if ( values == null || values.size() == 0)131 if ((values == null || values.size() == 0) && pType.getDefaultValue() != null) 132 132 { 133 133 values = Collections.singletonList(pType.getDefaultValue()); … … 579 579 { 580 580 %> 581 <select name="<%=inputName%>" multiple size="10" 581 <select name="<%=inputName%>" multiple size="10" style="width: 30em;" 582 582 onchange="setEnumValues('<%=inputName%>')"> 583 583 <% … … 587 587 String listValue = ""; 588 588 String listText = ""; 589 String listTitle = ""; 589 590 if (value instanceof Date) 590 591 { … … 596 597 BasicItem item = (BasicItem)value; 597 598 listValue = Integer.toString(item.getId()); 598 listText = HTML.encodeTags(item instanceof Nameable ? ((Nameable)item).getName() : item.toString()); 599 if (item instanceof Nameable) 600 { 601 Nameable nameable = (Nameable)item; 602 listText = HTML.encodeTags(nameable.getName()); 603 listTitle = HTML.encodeTags(nameable.getDescription()); 604 } 605 else 606 { 607 listText = item.toString(); 608 } 599 609 } 600 610 else … … 604 614 } 605 615 %> 606 <option value="<%=listValue%>" ><%=listText%>616 <option value="<%=listValue%>" title="<%=listTitle%>"><%=listText%> 607 617 <% 608 618 } … … 786 796 if (cc.getId() != 0) 787 797 { 798 BasicItem item = parameterItemType.getById(dc, cc.getId()); 799 String display = ""; 800 if (item instanceof Nameable) 801 { 802 Nameable nameable = (Nameable)item; 803 display = nameable.getName(); 804 } 805 else 806 { 807 display = item.toString(); 808 } 788 809 %> 789 <%=parameterItemType.getById(dc, cc.getId()).toString()%> 810 <b><%=HTML.encodeTags(param.getLabel())%></b><br> 811 <input class="text disabled" size="50" type="text" disabled value="<%=HTML.encodeTags(display)%>"> 790 812 <% 791 813 } -
branches/rf1/www/exception/exception.jsp
r1973 r2128 36 36 --%> 37 37 <%@ page 38 import="net.sf.basedb.core.Application" 39 import="net.sf.basedb.core.Config" 38 40 import="net.sf.basedb.core.NotLoggedInException" 39 41 import="net.sf.basedb.core.PermissionDeniedException" … … 111 113 <base:body onload="fixWindow()"> 112 114 <base:note type="error" title="<%=exceptionClassName + " on page "+request.getAttribute("javax.servlet.error.request_uri")%>" style="width:90%;"> 113 <%=HTML.formatLineBreaks(HTML.encodeTags(ex.getMessage(), ""))%> 115 <table border="0" cellpadding="0" cellspacing="0" class="form"> 116 <tr> 117 <td class="prompt">Base version</td> 118 <td><%=Application.getMajorVersion() + "." +Application.getMinorVersion() + " (build #" + Application.getBuild()+")"%></td> 119 </tr> 120 <tr> 121 <td class="prompt">Web server</td> 122 <td><%=application.getServerInfo()%></td> 123 </tr> 124 <tr> 125 <td class="prompt">Database Dialect</td> 126 <td><%=Config.getString("db.dialect")%></td> 127 </tr> 128 <tr> 129 <td class="prompt">JDBC Driver</td> 130 <td><%=Config.getString("db.driver")%></td> 131 </tr> 132 <tr> 133 <td class="prompt">Browser</td> 134 <td><%=HTML.encodeTags(request.getHeader("User-Agent"))%></td> 135 </tr> 136 <tr> 137 <td class="prompt">Error message</td> 138 <td><%=HTML.formatLineBreaks(HTML.encodeTags(ex.getMessage(), ""))%></td> 139 </tr> 140 <tr> 141 <td class="prompt">Stack trace</td> 142 <td></td> 143 </tr> 144 </table> 145 114 146 <% 115 147 StackTraceElement[] st = ex.getStackTrace(); … … 151 183 <base:button id="goback" onclick="<%="history.go(-1)"%>" title="Go back"/> 152 184 <base:button id="close" onclick="<%="window.close()"%>" title="Close"/> 153 <base:button id="reportbug" onclick="<%="window.open('"+reportbuglink+"','Reportbug')"%>" title="Report bug" 185 <base:button id="reportbug" onclick="<%="window.open('"+reportbuglink+"','Reportbug')"%>" 186 title="Report bug…" 154 187 visible="<%=HTML.isValidUrl(reportbuglink)%>"/> 155 188 </base:buttongroup> -
branches/rf1/www/views/experiments/bioassaysets/index.jsp
r2117 r2128 83 83 final String viewPage = "view_bioassayset.jsp?ID="+ID+"&experiment_id="+experimentId; 84 84 final String editPage = "edit_bioassayset.jsp?ID="+ID+"&experiment_id="+experimentId; 85 final String newPage = "create_root_bioassayset.jsp?ID="+ID+"&experiment_id="+experimentId; 85 86 final String newPage = "../../../common/plugin/index.jsp?ID="+ID 87 +"&cmd=SelectPlugin&main_type=INTENSITY&item_type=BIOASSAYSET&context_type=LIST&title=Create+root+bioassay+set"; 88 89 sc.getCurrentContext(Item.EXPERIMENT).setId(experimentId); 86 90 87 91 String forward = null; -
branches/rf1/www/views/experiments/bioassaysets/list_bioassaysets.jsp
r2117 r2128 166 166 function newItem() 167 167 { 168 Main.openPopup('index.jsp?ID=<%=ID%>&cmd=NewItem&experiment_id=<%=experimentId%>', 'NewBioAssaySet', 600, 400);168 Main.openPopup('index.jsp?ID=<%=ID%>&cmd=NewItem&experiment_id=<%=experimentId%>', 'NewBioAssaySet', 740, 540); 169 169 } 170 170 function editItem(itemId) … … 210 210 function runPlugin(cmd) 211 211 { 212 Table.submitToPopup(formId, cmd, 540, 460);212 Table.submitToPopup(formId, cmd, 740, 540); 213 213 } 214 214 function returnSelected() … … 455 455 title="New root bioassay set…" 456 456 tooltip="<%=createPermission ? "Create new event" : "You do not have permission to create events"%>" 457 visible="<%=pluginCount.containsKey(Plugin.MainType.INTENSITY)%>" 457 458 /> 458 459 <tbl:button -
branches/rf1/www/views/formulas/edit_formula.jsp
r2117 r2128 36 36 import="net.sf.basedb.core.RawDataType" 37 37 import="net.sf.basedb.core.RawDataTypes" 38 import="net.sf.basedb.core.RawDataProperty" 38 39 import="net.sf.basedb.core.PermissionDeniedException" 39 40 import="net.sf.basedb.clients.web.Base" … … 158 159 %> 159 160 rawDataTypes['<%=rdt.getId()%>'] = <%=rdt.getChannels()%>; 161 var a = new Array(); 162 <% 163 for (RawDataProperty rp : rdt.getProperties()) 164 { 165 %> 166 a['<%=rp.getName()%>'] = 1; 167 <% 168 } 169 %> 170 rawDataTypes['<%=rdt.getId()%>.properties'] = a; 160 171 <% 161 172 } … … 219 230 } 220 231 232 function validateOnClick() 233 { 234 var frm = document.forms['formula']; 235 if (frm.expression.value != '') 236 { 237 try 238 { 239 var result = eval(frm.expression.value); 240 alert('The expressions seems to be ok.\nNote! This feature is experimental and may not be 100% correct.'); 241 } 242 catch (er) 243 { 244 alert(er + '\nNote! This feature is experimental and may not be 100% correct.'); 245 } 246 } 247 } 248 function raw(property) 249 { 250 var frm = document.forms['formula']; 251 var rdt = frm.rawdatatype[frm.rawdatatype.selectedIndex].value; 252 if (!property) throw 'Property must be specified for function raw()'; 253 if (rdt == '') throw 'Cannot use function raw(). No raw data type selected'; 254 if (!rawDataTypes[rdt+'.properties'][property]) throw 'Property '+property+' not found for raw data type ' + rdt; 255 return Math.random() * 100; 256 } 257 function mean(property) 258 { 259 var frm = document.forms['formula']; 260 var rdt = frm.rawdatatype[frm.rawdatatype.selectedIndex].value; 261 if (!property) throw 'Property must be specified for function mean()'; 262 if (rdt == '') throw 'Cannot use function mean(). No raw data type selected'; 263 if (!rawDataTypes[rdt+'.properties'][property]) throw 'Property '+property+' not found for raw data type ' + rdt; 264 return Math.random() * 100; 265 } 266 function ch(channel) 267 { 268 var frm = document.forms['formula']; 269 var type = frm.type[frm.type.selectedIndex].value; 270 if (type == '<%=Formula.Type.INTENSITY_EXPRESSION.name()%>' || type == '<%=Formula.Type.INTENSITY_TRANSFORMATION.name()%>') 271 { 272 // Channel function not available 273 throw 'Function ch() is not available for ' + frm.type[frm.type.selectedIndex].text; 274 } 275 276 var channels = parseInt(frm.channels.value); 277 if (!channel || channel <= 0 || channel > channels) throw 'Invalid channel: ' + channel + '; must be between 1 and '+ channels; 278 return channel; 279 } 280 function log(value) 281 { 282 return Math.log(value); 283 } 284 function log2(value) 285 { 286 return Math.log(value); 287 } 288 function ln(value) 289 { 290 return Math.log(value); 291 } 292 function sqrt(value) 293 { 294 return Math.sqrt(value); 295 } 221 296 </script> 222 297 </base:head> … … 324 399 <base:button onclick="addOnClick()" title="Add" /> 325 400 </td> 401 <td> 402 <base:button onclick="validateOnClick()" title="Validate…" 403 tooltip="Validate the selected expression. EXPERIMENTAL!!" /> 404 </td> 326 405 </table> 327 406 </td>
Note: See TracChangeset
for help on using the changeset viewer.