Changeset 1575
- Timestamp:
- Nov 7, 2005, 4:05:24 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/base2.license.txt
r1478 r1575 44 44 * This product includes software developed by the 45 45 The JDOM(TM) Project (http://www.jdom.org) 46 47 * This product includes software developed by 48 Singular Systems (http://www.singularsys.com/) -
trunk/doc/3rd-party-components.txt
r1478 r1575 134 134 commons-collections-2.1.1.jar, commons-logging-1.0.4.jar 135 135 136 137 Java Math Expression Parser 138 --------------------------- 139 Parses and evaluates mathematical expressions in string. Supports 140 most operators and funcations as well as variables. 141 142 More info : http://www.singularsys.com/jep/ 143 Version : 2.3.0 144 License : GPL (gpl.license.txt) 145 Jar files : jep-2.3.0.jar 146 -
trunk/src/core/net/sf/basedb/core/RawDataType.java
r1544 r1575 25 25 package net.sf.basedb.core; 26 26 import java.util.List; 27 import java.util.ArrayList; 27 import java.util.Map; 28 import java.util.HashMap; 28 29 import java.util.Collections; 29 30 … … 51 52 private final String table; 52 53 private final List<RawDataProperty> properties; 54 private final Map<String, RawDataProperty> namedProperties; 55 private final List<IntensityFormula> formulas; 56 private final Map<String, IntensityFormula> namedFormulas; 53 57 54 58 private final RealTable realTable; … … 59 63 */ 60 64 RawDataType(String id, String name, String description, int channels, 61 String table, List<RawDataProperty> properties )65 String table, List<RawDataProperty> properties, List<IntensityFormula> formulas) 62 66 { 63 67 this.id = id; … … 67 71 this.table = table; 68 72 this.properties = Collections.unmodifiableList(properties); 73 this.formulas = formulas; 69 74 this.realTable = new RealTable(table, "raw"); 75 76 this.namedProperties = new HashMap<String, RawDataProperty>(properties.size()); 77 for (RawDataProperty property : properties) 78 { 79 if (namedProperties.put(property.getName(), property) != null) 80 { 81 throw new BaseException("RawDataProperty[name="+property.getName()+"] is already defined for raw data type: "+name); 82 } 83 } 84 this.namedFormulas = new HashMap<String, IntensityFormula>(formulas.size()); 85 for (IntensityFormula formula : formulas) 86 { 87 if (namedFormulas.put(formula.getName(), formula) != null) 88 { 89 throw new BaseException("IntensityFormula[name="+formula.getName()+"] is already defined for raw data type: "+name); 90 } 91 } 92 70 93 } 71 94 … … 157 180 return properties; 158 181 } 182 183 public RawDataProperty getProperty(String name) 184 { 185 return namedProperties.get(name); 186 } 187 188 public List<IntensityFormula> getIntensityFormulas() 189 { 190 return formulas; 191 } 192 193 public IntensityFormula getIntensityFormula(String name) 194 { 195 return namedFormulas.get(name); 196 } 159 197 160 198 } -
trunk/src/core/net/sf/basedb/core/RawDataTypes.java
r1136 r1575 130 130 int channels = XMLUtil.getIntAttribute(el, "channels", 2); 131 131 List<RawDataProperty> properties = loadProperties(el); 132 RawDataType rdt = new RawDataType(id, name, description, channels, table, properties); 132 List<IntensityFormula> formulas = loadIntensityFormulas(el, channels); 133 RawDataType rdt = new RawDataType(id, name, description, channels, table, properties, formulas); 133 134 rawDataTypes.put(id, rdt); 134 135 } … … 159 160 return properties; 160 161 } 162 163 /** 164 Load the intensity formulas for the specified raw data type node and 165 return a list of {@link IntensityFormula} objects. 166 */ 167 @SuppressWarnings({"unchecked"}) 168 private static List<IntensityFormula> loadIntensityFormulas(Element rawDataTypeElement, int channels) 169 { 170 List<IntensityFormula> formulas = new ArrayList<IntensityFormula>(); 171 List<Element> children = rawDataTypeElement.getChildren("intensity-formula"); 172 for (Element formula : children) 173 { 174 String name = formula.getAttributeValue("name"); 175 String title = formula.getAttributeValue("title"); 176 if (title == null) title = name; 177 String description = formula.getAttributeValue("description"); 178 String[] expressions = new String[channels]; 179 for (Element expression : (List<Element>)formula.getChildren("formula")) 180 { 181 int channel = XMLUtil.getIntAttribute(expression, "channel", 0); 182 if (channel <= 0 || channel > channels) 183 { 184 throw new BaseException("Invalid channel number for expression: "+expression); 185 } 186 if (expressions[channel-1] != null) 187 { 188 throw new BaseException("Expression for channel "+channel+" has already been defined: " +expression); 189 } 190 expressions[channel-1] = expression.getAttributeValue("expression"); 191 } 192 formulas.add(new IntensityFormula(name, title, description, expressions)); 193 } 194 return formulas; 195 } 196 161 197 } -
trunk/src/core/net/sf/basedb/core/dtd/raw-data-types.dtd
r1108 r1575 25 25 <!ELEMENT raw-data-types (raw-data-type+) > 26 26 27 <!ELEMENT raw-data-type (property+ ) >27 <!ELEMENT raw-data-type (property+,intensity-formula*) > 28 28 29 29 <!ATTLIST raw-data-type … … 47 47 channel CDATA #IMPLIED 48 48 > 49 50 <!ELEMENT intensity-formula (formula+) > 51 52 <!ATTLIST intensity-formula 53 name CDATA #REQUIRED 54 title CDATA #IMPLIED 55 description CDATA #IMPLIED 56 > 57 58 <!ELEMENT formula EMPTY > 59 60 <!ATTLIST formula 61 channel CDATA #REQUIRED 62 expression CDATA #REQUIRED 63 > -
trunk/src/install/includes
r1478 r1575 70 70 CP=$CP:$WEBINF/lib/jai_core.jar 71 71 CP=$CP:$WEBINF/lib/mlibwrapper_jai.jar 72 73 # Java Math Expression Parser 74 CP=$CP:$WEBINF/lib/jep-2.3.0.jar 75 -
trunk/src/install/initdb.bat
r1478 r1575 71 71 SET CP=%CP%;%WEBINF%/lib/mlibwrapper_jai.jar 72 72 73 REM Java Math Expression Parser 74 SET CP=%CP%;%WEBINF%/lib/jep-2.3.0.jar 75 76 73 77 REM Execute install class 74 78 java -cp %CP% net.sf.basedb.install.InitDB %1 %2 %3 %4 %5 %6 %7 %8 %9 -
trunk/src/raw-data-types.xml
r1108 r1575 243 243 type="float" 244 244 /> 245 245 <intensity-formula 246 name="mean" 247 title="Mean FG - Mean BG" 248 description="Subtract mean background from mean foreground" 249 > 250 <formula 251 channel="1" 252 expression="ch1FgMean - ch1BgMean" 253 /> 254 <formula 255 channel="2" 256 expression="ch2FgMean - ch2BgMean" 257 /> 258 </intensity-formula> 259 <intensity-formula 260 name="median" 261 title="Median FG - Median BG" 262 description="Subtract meadian background from median foreground" 263 > 264 <formula 265 channel="1" 266 expression="ch1FgMedian - ch1BgMedian" 267 /> 268 <formula 269 channel="2" 270 expression="ch2FgMedian - ch2BgMedian" 271 /> 272 </intensity-formula> 246 273 </raw-data-type> 247 274 -
trunk/src/test/TestExperiment.java
r1567 r1575 34 34 import net.sf.basedb.core.query.Selects; 35 35 36 import net.sf.basedb.util.IntensityCalculatorUtil; 37 import net.sf.basedb.util.IntensityCalculator; 38 36 39 import java.util.Date; 37 40 import java.util.Set; … … 82 85 test_list_rawbioassays(id, 2); 83 86 84 int rootBasId = test_create_root_bioassayset(id, rbaId1, rbaId2);87 int rootBasId = test_create_root_bioassayset(id, "mean", rbaId1, rbaId2); 85 88 int filterBasId = test_filter_bioassayset(rootBasId); 86 89 int basId = test_create_bioassayset(filterBasId); … … 413 416 } 414 417 415 static int test_create_root_bioassayset(int experimentId, int... rawBioAssays) 418 419 static int test_create_root_bioassayset(int experimentId, String intensityFormulaName, int... rawBioAssays) 416 420 { 417 421 if (experimentId == 0) return 0; 418 422 int id = 0; 419 423 DbControl dc = null; 424 long time; 420 425 try 421 426 { … … 429 434 } 430 435 431 Transformation t = e.newTransformation(null, rbaCollection); 432 BioAssaySet bas = t.newProduct(null, null); 433 bas.setName("Root bioassayset"); 434 dc.saveItem(t); 435 dc.saveItem(bas); 436 437 boolean first = true; 438 PositionBatcher posBatcher = bas.getPositionBatcher(); 439 SpotBatcher spotBatcher = bas.getSpotBatcher(); 440 MappingBatcher rawBatcher = bas.getMappingBatcher(); 441 int numSpots = 0; 442 for (RawBioAssay rba : rbaCollection) 443 { 444 BioAssay ba = bas.newRootBioAssay(Collections.singleton(rba)); 445 short column = ba.getDataCubeColumnNo(); 446 DataResultIterator<RawData> rawData = rba.getRawData().iterate(dc); 447 while (rawData.hasNext()) 448 { 449 RawData rd = rawData.next(); 450 int position = rd.getPosition(); 451 float[] intensities = new float[2]; 452 intensities[0] = (Float)rd.getExtended("ch1FgMean") - (Float)rd.getExtended("ch1BgMean"); 453 intensities[1] = (Float)rd.getExtended("ch2FgMean") - (Float)rd.getExtended("ch2BgMean"); 454 if (first) 455 { 456 posBatcher.insert(position, rd.getReporter()); 457 } 458 rawBatcher.insert(column, position, rd); 459 spotBatcher.insert(column, position, intensities); 460 numSpots++; 461 } 462 dc.saveItem(ba); 463 first = false; 464 } 465 posBatcher.close(); 466 spotBatcher.close(); 467 rawBatcher.close(); 468 436 RawDataType rdt = e.getRawDataType(); 437 IntensityCalculator iCalc = IntensityCalculatorUtil.createJepIntensityCalculator( 438 rdt, rdt.getIntensityFormula(intensityFormulaName).getExpressions()); 439 440 time = System.currentTimeMillis(); 441 BioAssaySet root = IntensityCalculatorUtil.createRootBioAssaySet( 442 dc, e, rbaCollection, null, iCalc); 469 443 dc.commit(); 470 id = bas.getId(); 471 dc = TestUtil.getDbControl(); 472 dc.reattachItem(bas); 473 write_item(0, bas); 474 write("--Create root bioassayset OK ("+numSpots+" spots inserted)"); 444 445 time = System.currentTimeMillis()-time; 446 int numSpots = root.getNumSpots(); 447 id = root.getId(); 448 dc = TestUtil.getDbControl(); 449 dc.reattachItem(root); 450 write_item(0, root); 451 write("--Create root bioassayset OK ("+numSpots+" spots inserted; "+time+" ms)"); 475 452 } 476 453 catch (Throwable ex) … … 486 463 return id; 487 464 } 488 465 489 466 static int test_create_bioassayset(int bioAssaySetId) 490 467 { -
trunk/src/test/run.bat
r1478 r1575 64 64 SET CP=%CP%;../../lib/compile/mlibwrapper_jai.jar 65 65 66 REM Java Math Expression Parser 67 SET CP=%CP%;../../lib/compile/jep-2.3.0.jar 68 66 69 REM Execute test class 67 70 java -ea -cp %CP% %1 %2 %3 %4 %5 %6 %7 %8 %9 -
trunk/src/test/run.sh
r1478 r1575 63 63 CP=$CP:../../lib/compile/mlibwrapper_jai.jar 64 64 65 # Java Math Expression Parser 66 CP=$CP:../../lib/compile/jep-2.3.0.jar 67 65 68 # Execute test class 66 69 java -ea -cp $CP $*
Note: See TracChangeset
for help on using the changeset viewer.