Changeset 2993
- Timestamp:
- Dec 1, 2006, 3:34:35 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/DynamicUtil.java
r2942 r2993 172 172 } 173 173 174 public static void addFormulaColumns(List<TableColumn> columns, DbControl dc, RawDataType rawDataType, Formula.Type type, String idPrefix, String titlePrefix) 174 public static void addFormulaColumns(List<TableColumn> columns, DbControl dc, 175 RawDataType rawDataType, Formula.Type type, String idPrefix, String titlePrefix, boolean allowRawFunction) 175 176 { 176 177 ItemQuery<Formula> query = Formula.getQuery(type, rawDataType); … … 184 185 Formula f = result.next(); 185 186 String jepExpression = f.getFormula(0); 186 TableColumn tc = new TableColumn(idPrefix+f.getId(), "="+jepExpression, jepExpression, Type.FLOAT, 187 titlePrefix + f.getName(), f.getDescription()); 188 tc.setFormatter(FormatterFactory.getColorFormatter(sc, f.getColoring(), numberFormatter)); 189 columns.add(tc); 187 if (allowRawFunction || !jepExpression.contains("raw(")) 188 { 189 TableColumn tc = new TableColumn(idPrefix+f.getId(), "="+jepExpression, jepExpression, Type.FLOAT, 190 titlePrefix + f.getName(), f.getDescription()); 191 tc.setFormatter(FormatterFactory.getColorFormatter(sc, f.getColoring(), numberFormatter)); 192 columns.add(tc); 193 } 190 194 } 191 195 result.close(); -
trunk/src/clients/web/net/sf/basedb/clients/web/servlet/PlotServlet.java
r2942 r2993 376 376 // Filter 377 377 Restriction filter = filterFormula == null ? 378 null : BioAssaySetUtil.createJepRestriction(dc, bas, filterFormula );378 null : BioAssaySetUtil.createJepRestriction(dc, bas, filterFormula, false); 379 379 380 380 // Convert formulas to Expression:s … … 386 386 for (int i = 0; i < xFormulas.length; ++i) 387 387 { 388 x[i] = BioAssaySetUtil.createJepExpression(dc, bas, xFormulas[i] );388 x[i] = BioAssaySetUtil.createJepExpression(dc, bas, xFormulas[i], false); 389 389 if (xLog) x[i] = Expressions.log2(x[i]); 390 390 } … … 394 394 for (int i = 0; i < yFormulas.length; ++i) 395 395 { 396 y[i] = BioAssaySetUtil.createJepExpression(dc, bas, yFormulas[i] );396 y[i] = BioAssaySetUtil.createJepExpression(dc, bas, yFormulas[i], false); 397 397 if (yLog) y[i] = Expressions.log2(y[i]); 398 398 } -
trunk/src/core/common-queries.xml
r2929 r2993 2485 2485 </query> 2486 2486 2487 <query id="SET_MAX_MAPPING_ON_DATACUBES" type="HQL"> 2488 <sql> 2489 UPDATE DataCubeData dcd 2490 SET dcd.maxRawMappingsForSpot = -1 2491 WHERE dcd.maxRawMappingsForSpot IS NULL 2492 </sql> 2493 <description> 2494 A HQL query that sets the maxRawMappingsForSpot on all data cubes with a 2495 null value to -1. This is required so we can load them by Hibernate. 2496 </description> 2497 </query> 2498 2499 2500 <query id="SET_MAX_MAPPING_ON_DATACUBE" type="HQL"> 2501 <sql> 2502 UPDATE DataCubeData dcd 2503 SET dcd.maxRawMappingsForSpot = :mapCount 2504 WHERE dcd.id = :dataCube 2505 </sql> 2506 <description> 2507 A HQL query that sets the maxRawMappingsForSpot on a data cube. 2508 </description> 2509 </query> 2510 2487 2511 </predefined-queries> -
trunk/src/core/net/sf/basedb/core/BioAssaySet.java
r2981 r2993 414 414 { 415 415 return getData().getNumSpots(); 416 } 417 418 /** 419 Get the number of mappings to raw data spots for the spot with 420 the most number of mappings. For most bioassay sets this value is 421 probably 1. After a merge, the count can be higher which may require some 422 plugins to behave differently when using values from the raw data table. 423 @since 2.2 424 */ 425 public int getMaxRawMappingsForSpot() 426 { 427 return getData().getDataCubeLayer().getDataCube().getMaxRawMappingsForSpot(); 416 428 } 417 429 -
trunk/src/core/net/sf/basedb/core/DataCube.java
r2962 r2993 24 24 package net.sf.basedb.core; 25 25 26 import java.sql.SQLException; 27 26 28 import net.sf.basedb.core.data.DataCubeData; 27 29 import net.sf.basedb.core.data.SharedData; 30 import net.sf.basedb.core.query.Aggregations; 31 import net.sf.basedb.core.query.Dynamic; 32 import net.sf.basedb.core.query.Expression; 33 import net.sf.basedb.core.query.Orders; 34 import net.sf.basedb.core.query.Select; 35 import net.sf.basedb.core.query.Selects; 36 import net.sf.basedb.core.query.SqlResult; 28 37 29 38 /** … … 160 169 { 161 170 getData().setBytes(addedBytes); 171 getData().setMaxRawMappingsForSpot(countSpotMappings()); 162 172 } 163 173 else if (action == Transactional.Action.UPDATE && addedBytes != 0) … … 559 569 560 570 /** 571 Get the number of mappings to raw data spots for the spot with 572 the most number of mappings. For most data cubes this value is 573 probably 1. After a merge, the count can be higher which may require some 574 plugins to behave differently when using values from the raw data table. 575 @since 2.2 576 */ 577 public int getMaxRawMappingsForSpot() 578 { 579 return getData().getMaxRawMappingsForSpot(); 580 } 581 582 /** 561 583 Gets the number of bytes the analysed data in this cube occupies on disk. 562 584 */ … … 627 649 } 628 650 651 /** 652 Count the number of raw data mappings for the spot with the most 653 mappings. 654 @since 2.2 655 */ 656 int countSpotMappings() 657 { 658 DynamicQuery query = new RawMappingQuery(this); 659 Expression count = Aggregations.count(null, false); 660 query.select( 661 Selects.expression(count, "mapCount") 662 ); 663 query.group(Dynamic.column(VirtualColumn.COLUMN)); 664 query.group(Dynamic.column(VirtualColumn.POSITION)); 665 query.order(Orders.desc(count)); 666 query.setMaxResults(1); 667 /* 668 SELECT COUNT(*) AS mapCount 669 FROM Dymamic#RawParents raw 670 WHERE raw.cube = ? 671 GROUP BY raw.column, raw.position 672 ORDER BY COUNT(*) DESC 673 LIMIT 1 674 */ 675 DynamicResultIterator result = query.iterate(getDbControl()); 676 try 677 { 678 int maxCount = 0; 679 if (result.hasNext()) 680 { 681 SqlResult r = result.next(); 682 maxCount = r.getInt(result.getIndex("mapCount")); 683 } 684 return maxCount; 685 } 686 catch (SQLException ex) 687 { 688 throw new BaseException(ex); 689 } 690 finally 691 { 692 result.close(); 693 } 694 } 695 696 /** 697 Select data from Dynamic#RawParents table. Used for counting 698 number of mappings between spots and raw data. 699 700 @version 2.2 701 */ 702 private static final class RawMappingQuery 703 extends DynamicQuery 704 { 705 706 private RawMappingQuery(DataCube dataCube) 707 { 708 super(dataCube, VirtualTable.RAWPARENTS); 709 } 710 711 /* 712 From the AbstractSqlQuery class 713 ------------------------------------------- 714 */ 715 Select[] getDefaultSelects() 716 { 717 return null; 718 } 719 // ------------------------------------------- 720 } 721 629 722 } -
trunk/src/core/net/sf/basedb/core/Install.java
r2941 r2993 102 102 method. 103 103 */ 104 public static final int NEW_SCHEMA_VERSION = 2 7;104 public static final int NEW_SCHEMA_VERSION = 28; 105 105 106 106 public static synchronized void createTables(boolean update, final ProgressReporter progress) -
trunk/src/core/net/sf/basedb/core/ItemContext.java
r2981 r2993 159 159 // For parsing JEP expressions 160 160 private static final JepFunction ch = new ChannelFunction(); 161 private static final JepFunction raw = new RawFunction( );161 private static final JepFunction raw = new RawFunction(true); 162 162 private static final JepFunction rep = new ReporterFunction(); 163 163 -
trunk/src/core/net/sf/basedb/core/Update.java
r2981 r2993 33 33 import org.hibernate.mapping.Table; 34 34 35 import net.sf.basedb.core.data.DataCubeData; 35 36 import net.sf.basedb.core.data.FormulaData; 36 37 import net.sf.basedb.core.data.PlateData; … … 326 327 <li>Added {@link net.sf.basedb.core.data.ProjectData#getProjectDefaults()}. 327 328 </ul> 329 </td> 330 </tr> 331 332 <tr> 333 <td>28</td> 334 <td> 335 <ul> 336 <li>Added {@link net.sf.basedb.core.data.DataCubeData#getMaxRawMappingsForSpot()}. 337 </ul> 338 The update must query the dynamic database and set this value for 339 all existing data cubes. 328 340 </td> 329 341 </tr> … … 442 454 } 443 455 456 // Schemaversion 20-23 only updates the version number 444 457 if (schemaVersion < 23) 445 458 { … … 464 477 if (schemaVersion < 26) 465 478 { 466 if (progress != null) progress.display((int)(25*progress_factor), "--Updating schema version: " + schemaVersion + " -> 26..."); 467 schemaVersion = setSchemaVersionInTransaction(session, 26); 468 } 469 470 if (schemaVersion < 27) 471 { 472 if (progress != null) progress.display((int)(26*progress_factor), "--Updating schema version: " + schemaVersion + " -> 27..."); 479 if (progress != null) progress.display((int)(25*progress_factor), "--Updating schema version: " + schemaVersion + " -> 27..."); 473 480 schemaVersion = setSchemaVersionInTransaction(session, 27); 474 481 } 475 482 483 if (schemaVersion < 28) 484 { 485 if (progress != null) progress.display((int)(27*progress_factor), "--Updating schema version: " + schemaVersion + " -> 28..."); 486 updateToSchemaVersion28(sc); 487 } 488 476 489 /* 477 if (schemaVersion < 2 8)478 { 479 if (progress != null) progress.display((int)(2 7*progress_factor), "--Updating schema version: " + schemaVersion + " -> 28...");480 schemaVersion = setSchemaVersionInTransaction(session, 2 8);490 if (schemaVersion < 29) 491 { 492 if (progress != null) progress.display((int)(28*progress_factor), "--Updating schema version: " + schemaVersion + " -> 29..."); 493 schemaVersion = setSchemaVersionInTransaction(session, 29); 481 494 - or - 482 schemaVersion = updateToSchemaVersion2 8(session);495 schemaVersion = updateToSchemaVersion29(session); 483 496 } 484 497 ... etc... … … 756 769 finally 757 770 { 758 if (dc != null) dc.close(); 771 if (dc != null) dc.close(); 759 772 } 760 773 return schemaVersion; … … 981 994 log.error("updateToSchemaVersion25: FAILED", ex); 982 995 throw ex; 996 } 997 return schemaVersion; 998 } 999 1000 /** 1001 Find the number of raw mappings for the spot with the maximum number 1002 for each data cube 1003 @return The new schema version (=28) 1004 */ 1005 private static int updateToSchemaVersion28(SessionControl sc) 1006 throws BaseException 1007 { 1008 final int schemaVersion = 28; 1009 DbControl dc = null; 1010 try 1011 { 1012 dc = sc.newDbControl(); 1013 org.hibernate.Session session = dc.getHibernateSession(); 1014 1015 // Query for loading all data cubes 1016 org.hibernate.Query query = HibernateUtil.createQuery(session, 1017 "FROM DataCubeData dcd WHERE dcd.maxRawMappingsForSpot = -1"); 1018 org.hibernate.Query updateQuery = HibernateUtil.getPredefinedQuery(session, 1019 "SET_MAX_MAPPING_ON_DATACUBE"); 1020 /* 1021 UPDATE DataCubeData dcd 1022 SET dcd.maxRawMappingsForSpot = :mapCount 1023 WHERE dcd.id = :dataCube 1024 */ 1025 for (DataCubeData cubeData : HibernateUtil.loadList(DataCubeData.class, query)) 1026 { 1027 DataCube cube = dc.getItem(DataCube.class, cubeData); 1028 int mapCount = cube.countSpotMappings(); 1029 updateQuery.setInteger("mapCount", mapCount); 1030 updateQuery.setInteger("dataCube", cube.getId()); 1031 HibernateUtil.executeUpdate(updateQuery); 1032 } 1033 1034 // Update the shcema version number 1035 setSchemaVersion(session, schemaVersion); 1036 1037 // Commit the changes 1038 dc.commit(); 1039 log.info("updateToSchemaVersion28: OK"); 1040 } 1041 catch (BaseException ex) 1042 { 1043 log.error("updateToSchemaVersion28: FAILED", ex); 1044 throw ex; 1045 } 1046 finally 1047 { 1048 if (dc != null) dc.close(); 983 1049 } 984 1050 return schemaVersion; … … 1200 1266 } 1201 1267 1268 if (schemaVersion < 28) 1269 { 1270 // Set maxRawMappingsForSpot to -1 for all data cubes with a null value 1271 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 1272 "SET_MAX_MAPPING_ON_DATACUBES"); 1273 /* 1274 UPDATE DataCubeData dcd 1275 SET dcd.maxRawMappingsForSpot = -1 1276 WHERE dcd.maxRawMappingsForSpot IS NULL 1277 */ 1278 HibernateUtil.executeUpdate(query); 1279 } 1280 1202 1281 // Commit the changes 1203 1282 HibernateUtil.commit(tx); -
trunk/src/core/net/sf/basedb/core/data/DataCubeData.java
r2962 r2993 161 161 this.numPositions = numPositions; 162 162 } 163 164 private int maxRawMappings; 165 /** 166 The maximum number of raw data spots a single spot in this data cube 167 is mapped to. 168 @hibernate.property column="`max_raw_spots`" type="int" not-null="true" update="false" 169 */ 170 public int getMaxRawMappingsForSpot() 171 { 172 return maxRawMappings; 173 } 174 public void setMaxRawMappingsForSpot(int maxRawMappings) 175 { 176 this.maxRawMappings = maxRawMappings; 177 } 163 178 164 179 private Set<DataCubeLayerData> layers; -
trunk/src/core/net/sf/basedb/util/BioAssaySetUtil.java
r2992 r2993 140 140 by JEP (see {@link Jep#getFunctions()}) this method defines the following functions: 141 141 <ul> 142 <li>all functions defined by the {@link #createJepExpression(DbControl, BioAssaySet, String)}143 method142 <li>all functions defined by the {@link #createJepExpression(DbControl, BioAssaySet, 143 String, boolean)} method 144 144 <li>inList(list): Checks if the reporter is included in the specified list 145 145 <li>notInList(list): Checks if the reporter isn't included in the specified list … … 147 147 @see net.sf.basedb.util.jep.Jep 148 148 */ 149 public static Restriction createJepRestriction(DbControl dc, BioAssaySet bioAssaySet, String formula) 149 public static Restriction createJepRestriction(DbControl dc, BioAssaySet bioAssaySet, 150 String formula, boolean allowRawIfMultipleMappings) 150 151 throws InvalidDataException, BaseException 151 152 { 152 153 if (bioAssaySet == null) throw new InvalidUseOfNullException("bioAssaySet"); 153 154 if (formula == null) throw new InvalidUseOfNullException("formula"); 154 RawFunction raw = new RawFunction(); 155 RawFunction raw = new RawFunction(bioAssaySet.getMaxRawMappingsForSpot() == 1 || 156 allowRawIfMultipleMappings); 155 157 ChannelFunction ch = new ChannelFunction(); 156 158 ReporterFunction reporter = new ReporterFunction(); … … 167 169 by JEP (see {@link Jep#getFunctions()}) this method defines the following functions: 168 170 <ul> 169 <li>raw(property): The value of the specified raw data property 171 <li>raw(property): The value of the specified raw data property. The use of this function 172 can be denied if the bioassayset contains spots that are mapped to more than one 173 raw data spot. The <code>allowRawIfMultipleMappings</code> parameter controls 174 this. 170 175 <li>rep(property): The value of the specified reporter property 171 176 <li>pos: The position of a spot. Note that this is not the same as raw(position) … … 178 183 @see net.sf.basedb.util.jep.Jep 179 184 */ 180 public static Expression createJepExpression(DbControl dc, BioAssaySet bioAssaySet, String formula) 185 public static Expression createJepExpression(DbControl dc, BioAssaySet bioAssaySet, 186 String formula, boolean allowRawIfMultipleMappings) 181 187 throws InvalidDataException, BaseException 182 188 { 183 189 if (bioAssaySet == null) throw new InvalidUseOfNullException("bioAssaySet"); 184 190 if (formula == null) throw new InvalidUseOfNullException("formula"); 185 RawFunction raw = new RawFunction(); 191 RawFunction raw = new RawFunction(bioAssaySet.getMaxRawMappingsForSpot() == 1 || 192 allowRawIfMultipleMappings); 186 193 ChannelFunction ch = new ChannelFunction(); 187 194 PositionFunction pos = new PositionFunction(); -
trunk/src/core/net/sf/basedb/util/IntensityCalculatorUtil.java
r2790 r2993 485 485 } 486 486 JEP[] jeps = new JEP[channels]; 487 RawFunction raw = new RawFunction(dc, rawDataType );487 RawFunction raw = new RawFunction(dc, rawDataType, true); 488 488 MeanFunction mean = new MeanFunction(dc); 489 489 for (int i = 0; i < channels; ++i) … … 501 501 { 502 502 Expression[] expressions = new Expression[formulas.length]; 503 RawFunction raw = new RawFunction(dc, rawDataType );503 RawFunction raw = new RawFunction(dc, rawDataType, true); 504 504 MeanFunction mean = new MeanFunction(dc); 505 505 for (int i = 0; i < formulas.length; ++i) -
trunk/src/core/net/sf/basedb/util/jep/ChannelFunction.java
r2981 r2993 70 70 @base.modified $Date$ 71 71 @see Jep 72 @see BioAssaySetUtil#createJepExpression(DbControl, BioAssaySet, String )72 @see BioAssaySetUtil#createJepExpression(DbControl, BioAssaySet, String, boolean) 73 73 */ 74 74 public class ChannelFunction -
trunk/src/core/net/sf/basedb/util/jep/ExtraValueFunction.java
r2981 r2993 55 55 @base.modified $Date$ 56 56 @see Jep 57 @see BioAssaySetUtil#createJepExpression(DbControl, BioAssaySet, String )57 @see BioAssaySetUtil#createJepExpression(DbControl, BioAssaySet, String, boolean) 58 58 */ 59 59 public class ExtraValueFunction -
trunk/src/core/net/sf/basedb/util/jep/InReporterListFunction.java
r2981 r2993 51 51 @base.modified $Date$ 52 52 @see Jep 53 @see BioAssaySetUtil#createJepRestriction(DbControl, BioAssaySet, String )53 @see BioAssaySetUtil#createJepRestriction(DbControl, BioAssaySet, String, boolean) 54 54 */ 55 55 public class InReporterListFunction -
trunk/src/core/net/sf/basedb/util/jep/NotInReporterListFunction.java
r2981 r2993 51 51 @base.modified $Date$ 52 52 @see Jep 53 @see BioAssaySetUtil#createJepRestriction(DbControl, BioAssaySet, String )53 @see BioAssaySetUtil#createJepRestriction(DbControl, BioAssaySet, String, boolean) 54 54 */ 55 55 public class NotInReporterListFunction -
trunk/src/core/net/sf/basedb/util/jep/RawFunction.java
r2981 r2993 26 26 import net.sf.basedb.core.BaseException; 27 27 import net.sf.basedb.core.BioAssaySet; 28 import net.sf.basedb.core.PermissionDeniedException; 28 29 import net.sf.basedb.core.RawDataType; 29 30 import net.sf.basedb.core.DbControl; … … 72 73 @base.modified $Date$ 73 74 @see Jep 74 @see BioAssaySetUtil#createJepExpression(DbControl, BioAssaySet, String )75 @see BioAssaySetUtil#createJepExpression(DbControl, BioAssaySet, String, boolean) 75 76 */ 76 77 public class RawFunction … … 81 82 private final Metadata<RawData> metaData; 82 83 private final DbControl dc; 84 private final boolean allowUse; 83 85 private int numParameters; 84 86 private RawData rawData; … … 90 92 @see Jep#formulaToExpression(String, JepFunction[]) 91 93 */ 92 public RawFunction( )94 public RawFunction(boolean allowUse) 93 95 { 94 96 this.dc = null; 95 97 this.metaData = null; 96 98 this.rawDataType = null; 99 this.allowUse = allowUse; 97 100 } 98 101 … … 102 105 @param rawDataType The type of raw data this function uses 103 106 */ 104 public RawFunction(DbControl dc, RawDataType rawDataType )107 public RawFunction(DbControl dc, RawDataType rawDataType, boolean allowUse) 105 108 { 106 109 this.dc = dc; 107 110 this.rawDataType = rawDataType; 108 111 this.metaData = Metadata.getInstance(RawData.class, rawDataType.getEntityName()); 112 this.allowUse = allowUse; 109 113 } 110 114 … … 131 135 public Expression toExpression(Node node) 132 136 { 137 if (!allowUse) 138 { 139 throw new PermissionDeniedException("Not allowed to use 'raw' function with merged data"); 140 } 133 141 int numChildren = node.jjtGetNumChildren(); 134 142 if (numChildren != 1) -
trunk/src/core/net/sf/basedb/util/jep/ReporterFunction.java
r2981 r2993 71 71 @base.modified $Date$ 72 72 @see Jep 73 @see BioAssaySetUtil#createJepExpression(DbControl, BioAssaySet, String )73 @see BioAssaySetUtil#createJepExpression(DbControl, BioAssaySet, String, boolean) 74 74 */ 75 75 public class ReporterFunction -
trunk/src/core/net/sf/basedb/util/jep/ScoreFunction.java
r2981 r2993 52 52 @base.modified $Date$ 53 53 @see Jep 54 @see BioAssaySetUtil#createJepExpression(DbControl, BioAssaySet, String )54 @see BioAssaySetUtil#createJepExpression(DbControl, BioAssaySet, String, boolean) 55 55 */ 56 56 public class ScoreFunction -
trunk/src/plugins/core/net/sf/basedb/plugins/BioAssaySetExporter.java
r2992 r2993 253 253 { 254 254 ++aliasIndex; 255 query.select(Selects.expression(BioAssaySetUtil.createJepExpression(dc, bas, field ), aliasIndex.toString()));255 query.select(Selects.expression(BioAssaySetUtil.createJepExpression(dc, bas, field, true), aliasIndex.toString())); 256 256 aliases.put(field, aliasIndex.toString()); 257 257 } … … 259 259 { 260 260 ++aliasIndex; 261 query.select(Selects.expression(BioAssaySetUtil.createJepExpression(dc, bas, field ),261 query.select(Selects.expression(BioAssaySetUtil.createJepExpression(dc, bas, field, true), 262 262 aliasIndex.toString())); 263 263 aliases.put(field, aliasIndex.toString()); -
trunk/src/plugins/core/net/sf/basedb/plugins/FormulaFilter.java
r2981 r2993 176 176 177 177 // Parse filter expression 178 Restriction filter = BioAssaySetUtil.createJepRestriction(dc, source, expression );178 Restriction filter = BioAssaySetUtil.createJepRestriction(dc, source, expression, false); 179 179 180 180 if (includeLimit != null || excludeLimit != null) -
trunk/src/plugins/core/net/sf/basedb/plugins/JepExtraValueCalculator.java
r2733 r2993 160 160 query.select(Dynamic.select(VirtualColumn.COLUMN)); 161 161 query.select(Dynamic.select(VirtualColumn.POSITION)); 162 Expression extraExpression = BioAssaySetUtil.createJepExpression(dc, source, expression );162 Expression extraExpression = BioAssaySetUtil.createJepExpression(dc, source, expression, false); 163 163 query.select(Selects.expression(extraExpression, "xtra")); 164 164 -
trunk/src/plugins/core/net/sf/basedb/plugins/JepIntensityTransformer.java
r2722 r2993 171 171 if (expression != null) 172 172 { 173 chExpression = BioAssaySetUtil.createJepExpression(dc, source, expression );173 chExpression = BioAssaySetUtil.createJepExpression(dc, source, expression, false); 174 174 } 175 175 else -
trunk/src/plugins/core/net/sf/basedb/plugins/LowessNormalization.java
r2749 r2993 388 388 message = "Lowess normalization requires 2-channel data, not " + channels + "-channel."; 389 389 } 390 if (bas.getMaxRawMappingsForSpot() != 1) 391 { 392 message = "Lowess normalization can't be done on merged data."; 393 } 390 394 } 391 395 return message; -
trunk/src/plugins/core/net/sf/basedb/plugins/MedianRatioNormalization.java
r2749 r2993 373 373 message = "Normalization requires 2-channel data, not " + channels + "-channel."; 374 374 } 375 if (bas.getMaxRawMappingsForSpot() != 1) 376 { 377 message = "Normalization can't be done on merged data."; 378 } 375 379 } 376 380 return message; -
trunk/src/test/TestExperiment.java
r2959 r2993 570 570 RawDataType rdt = e.getRawDataType(); 571 571 String[] formulas = rdt.getIntensityFormula(intensityFormulaName).getExpressions(); 572 RawFunction raw = new RawFunction(dc, e.getRawDataType() );572 RawFunction raw = new RawFunction(dc, e.getRawDataType(), true); 573 573 Expression ch1 = Jep.formulaToExpression(formulas[0], raw); 574 574 Expression ch2 = Jep.formulaToExpression(formulas[1], raw); -
trunk/src/test/TestJep.java
r2304 r2993 71 71 try 72 72 { 73 Jep.newJep(formula, new RawFunction(null, RawDataTypes.getRawDataType("genepix") ));73 Jep.newJep(formula, new RawFunction(null, RawDataTypes.getRawDataType("genepix"), true)); 74 74 write("--Parse formula: "+formula+" OK"); 75 75 } … … 86 86 try 87 87 { 88 Expression e = Jep.formulaToExpression(formula, new RawFunction(null, RawDataTypes.getRawDataType("genepix") ));88 Expression e = Jep.formulaToExpression(formula, new RawFunction(null, RawDataTypes.getRawDataType("genepix"), true)); 89 89 write(e); 90 90 write("--Jep to Expression: "+formula+" OK"); … … 102 102 try 103 103 { 104 Restriction r = Jep.formulaToRestriction(formula, new RawFunction(null, RawDataTypes.getRawDataType("genepix"))); 104 Restriction r = Jep.formulaToRestriction(formula, 105 new RawFunction(null, RawDataTypes.getRawDataType("genepix"), true)); 105 106 write(r); 106 107 write("--Jep to Restriction: "+formula+" OK"); -
trunk/www/common/expression_builder.jsp
r2978 r2993 68 68 { 69 69 BioAssaySet bas = bioAssaySetId == -1 ? null : BioAssaySet.getById(dc, bioAssaySetId); 70 int maxRawMappings = bas == null ? 1 : bas.getMaxRawMappingsForSpot(); 70 71 71 72 List<TableColumn> spotProperties = new LinkedList<TableColumn>(); … … 74 75 if (rawDataType != null) 75 76 { 76 DynamicUtil.addFormulaColumns(spotProperties, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION, "", "" );77 DynamicUtil.addFormulaColumns(spotProperties, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION, "", "", maxRawMappings == 1); 77 78 if (bas != null) DynamicUtil.addExtraColumns(spotProperties, dc, bas, "", "", "[Xtra] "); 78 DynamicUtil.addRawDataColumns(rawProperties, dc, rawDataType, "", "", "");79 if (maxRawMappings == 1) DynamicUtil.addRawDataColumns(rawProperties, dc, rawDataType, "", "", ""); 79 80 } 80 81 List<TableColumn> reporterProperties = new LinkedList<TableColumn>(); … … 206 207 function raw(property) 207 208 { 209 <% 210 if (maxRawMappings != 1) 211 { 212 %> 213 throw 'Cannot use function raw() for bioassayset that has multiple mappings to raw data'; 214 <% 215 } 216 %> 208 217 var rdt = '<%=rawDataType == null ? "" : rawDataType.getId()%>'; 209 218 if (!property) throw 'Property must be specified for function raw()'; … … 412 421 </td> 413 422 <% 414 if (rawDataType != null && rawDataType.isStoredInDb() )423 if (rawDataType != null && rawDataType.isStoredInDb() && rawProperties.size() > 0) 415 424 { 416 425 %> -
trunk/www/plugins/net/sf/basedb/plugins/jep_extra_value_calculator.jsp
r2978 r2993 75 75 if (source == null) throw new WebException("popup", "No current bioassay set", 76 76 "Could not find any current bioassay set. Please select a bioassay set before trying again"); 77 int maxRawMappings = source.getMaxRawMappingsForSpot(); 77 78 78 79 RawDataType rdt = source.getRawDataType(); … … 91 92 for (Formula f : formulas) 92 93 { 93 addFormulaOption(formulaOptions, f.getFormula(0), f.getName(), f.getDescription()); 94 String formula = f.getFormula(0); 95 if (maxRawMappings == 1 || !formula.contains("raw(")) 96 { 97 addFormulaOption(formulaOptions, formula, f.getName(), f.getDescription()); 98 } 94 99 } 95 100 96 101 // Load recently used items 97 102 List<ExtraValueType> recentExtraValueTypes = (List<ExtraValueType>)cc.getRecent(dc, Item.EXTRAVALUETYPE); 98 99 103 %> 100 104 <base:page type="popup" title="Calculate extra value"> … … 143 147 function openExpressionBuilder() 144 148 { 145 Main.expressionBuilder('<%=ID%>', 'Expression', 'extraValue', 'parameter:expression', 'COLUMN_EXPRESSION', '<%=rdt.getId()%>', <%=rdt.getChannels()%>, false );149 Main.expressionBuilder('<%=ID%>', 'Expression', 'extraValue', 'parameter:expression', 'COLUMN_EXPRESSION', '<%=rdt.getId()%>', <%=rdt.getChannels()%>, false, <%=source.getId()%>); 146 150 } 147 151 function validate() … … 159 163 return false; 160 164 } 165 <% 166 if (maxRawMappings != 1) 167 { 168 %> 169 else if (frm['parameter:expression'].value.search(/raw\(/) != -1) 170 { 171 alert('Can\'t use function raw() for bioassaysets with multiple mappings to raw data'); 172 frm['parameter:expression'].focus(); 173 return false; 174 } 175 <% 176 } 177 %> 161 178 return true; 162 179 } -
trunk/www/plugins/net/sf/basedb/plugins/jep_filter.jsp
r2978 r2993 82 82 RawDataType rdt = source.getRawDataType(); 83 83 long numBioAssays = source.getBioAssays().count(dc); 84 int maxRawMappings = source.getMaxRawMappingsForSpot(); 84 85 85 86 // Find selected bioassays … … 117 118 for (Formula f : formulas) 118 119 { 119 addFormulaOption(formulaOptions, f.getFormula(0), f.getName(), f.getDescription()); 120 String formula = f.getFormula(0); 121 if (maxRawMappings == 1 || !formula.contains("raw(")) 122 { 123 addFormulaOption(formulaOptions, formula, f.getName(), f.getDescription()); 124 } 120 125 } 121 126 %> … … 167 172 return false; 168 173 } 174 <% 175 if (maxRawMappings != 1) 176 { 177 %> 178 else if (frm['parameter:expression'].value.search(/raw\(/) != -1) 179 { 180 alert('Can\'t use function raw() for bioassayset with multiple mappings to raw data'); 181 frm['parameter:expression'].focus(); 182 return false; 183 } 184 <% 185 } 186 %> 169 187 else if (exclude != '' || include != '') 170 188 { -
trunk/www/plugins/net/sf/basedb/plugins/jep_intensity_transformer.jsp
r2978 r2993 70 70 if (source == null) throw new WebException("popup", "No current bioassay set", 71 71 "Could not find any current bioassay set. Please select a bioassay set before trying again"); 72 int maxRawMappings = source.getMaxRawMappingsForSpot(); 72 73 73 74 RawDataType rdt = source.getRawDataType(); … … 110 111 function openExpressionBuilder(title, inputName) 111 112 { 112 Main.expressionBuilder('<%=ID%>', title, 'transformation', inputName, 'INTENSITY_TRANSFORMATION', '<%=rdt.getId()%>', <%=rdt.getChannels()%>, false );113 Main.expressionBuilder('<%=ID%>', title, 'transformation', inputName, 'INTENSITY_TRANSFORMATION', '<%=rdt.getId()%>', <%=rdt.getChannels()%>, false, '<%=source.getId()%>'); 113 114 } 114 115 function validate() … … 124 125 return false; 125 126 } 127 else if (<%=maxRawMappings != 1 ? "true" : "false"%> && frm[inputName].value.search(/raw\(/) != -1) 128 { 129 alert('Can\'t use function raw() for bioassaysets with multiple mappings to raw data'); 130 frm[inputName].focus(); 131 return false; 132 } 126 133 } 127 134 return true; … … 144 151 for (int ch = 1; ch <= rdt.getChannels(); ++ch) 145 152 { 153 String formula = f.getFormula(ch-1); 146 154 %> 147 formulas['<%=f.getId()%>.<%=ch%>'] = '<%=HTML.javaScriptEncode(f .getFormula(ch-1))%>';155 formulas['<%=f.getId()%>.<%=ch%>'] = '<%=HTML.javaScriptEncode(formula)%>'; 148 156 <% 149 157 } … … 234 242 for (Formula f : formulas) 235 243 { 236 %> 237 <option value="<%=f.getId()%>" title="<%=HTML.encodeTags(f.getDescription())%>" 238 ><%=HTML.encodeTags(f.getName())%> 239 <% 244 boolean ok = true; 245 if (maxRawMappings != 1) 246 { 247 for (String formula : f.getFormulas()) 248 { 249 ok &= !formula.contains("raw("); 250 } 251 } 252 if (ok) 253 { 254 %> 255 <option value="<%=f.getId()%>" title="<%=HTML.encodeTags(f.getDescription())%>" 256 ><%=HTML.encodeTags(f.getName())%> 257 <% 258 } 240 259 } 241 260 %> -
trunk/www/views/experiments/bioassaysets/index.jsp
r2978 r2993 69 69 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> 70 70 <%! 71 private static final ItemContext defaultContext = Base.createDefaultContext("name", "name, transformation,spots,reporters,date,tools");71 private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,spots,reporters,date,tools"); 72 72 private static final Item itemType = Item.BIOASSAYSET; 73 73 -
trunk/www/views/experiments/explorer/view/view.jsp
r2978 r2993 104 104 final int channels = rawDataType.getChannels(); 105 105 final boolean hasRatio = channels == 2; 106 final int maxRawMappings = bioAssaySet.getMaxRawMappingsForSpot(); 106 107 107 108 final ExperimentExplorer explorer = ExperimentExplorer.getExplorer(bioAssaySet); … … 111 112 112 113 List<TableColumn> columns = new LinkedList<TableColumn>(); 113 DynamicUtil.addFormulaColumns(columns, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION, "frm.", ""); 114 DynamicUtil.addFormulaColumns(columns, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION, 115 "frm.", "", maxRawMappings == 1); 114 116 DynamicUtil.addExtraColumns(columns, dc, bioAssaySet, "ev", "#", "[Xtra] "); 115 DynamicUtil.addRawDataColumns(columns, dc, rawDataType, "raw.", "$", "[Raw] "); 116 columns.add(new TableColumn("raw.spotimage", "$id", "raw('id')", Type.INT, 117 "[Raw] Spotimage", "", "auto", false, false, false, false, 118 new SpotImageFormatter(dc, rawDataType, root))); 117 if (maxRawMappings == 1) 118 { 119 DynamicUtil.addRawDataColumns(columns, dc, rawDataType, "raw.", "$", "[Raw] "); 120 columns.add(new TableColumn("raw.spotimage", "$id", "raw('id')", Type.INT, 121 "[Raw] Spotimage", "", "auto", false, false, false, false, 122 new SpotImageFormatter(dc, rawDataType, root))); 123 } 119 124 120 125 final int matchingReporters = explorer.getMatchingReporters(dc); -
trunk/www/views/experiments/plotter/index.jsp
r2978 r2993 78 78 RawDataType rdt = bas.getRawDataType(); 79 79 Experiment experiment = bas.getExperiment(); 80 int maxRawMappings = bas.getMaxRawMappingsForSpot(); 80 81 81 82 List<TableColumn> formulas = new LinkedList<TableColumn>(); 82 83 DynamicUtil.addSpotColumns(formulas, dc, rdt.getChannels()); 83 DynamicUtil.addFormulaColumns(formulas, dc, rdt, Formula.Type.COLUMN_EXPRESSION, "", "" );84 DynamicUtil.addFormulaColumns(formulas, dc, rdt, Formula.Type.COLUMN_EXPRESSION, "", "", maxRawMappings == 1); 84 85 DynamicUtil.addExtraColumns(formulas, dc, bas, "ev", "#", "[Xtra] "); 85 DynamicUtil.addRawDataColumns(formulas, dc, rdt, "", "", "[Raw] "); 86 if (maxRawMappings == 1) 87 { 88 DynamicUtil.addRawDataColumns(formulas, dc, rdt, "", "", "[Raw] "); 89 } 86 90 87 91 StringBuilder formulaOptions = new StringBuilder(); … … 90 94 if (tc.getJepExpression() != null && tc.getDatatype().isNumerical()) 91 95 { 92 addFormulaOption(formulaOptions, tc.getJepExpression(), tc.getTitle(), tc.getDescription()); 96 String jepExpression = tc.getJepExpression(); 97 addFormulaOption(formulaOptions, jepExpression, tc.getTitle(), tc.getDescription()); 93 98 } 94 99 } … … 100 105 for (Formula formula : formulaQuery.list(dc)) 101 106 { 102 addFormulaOption(filterOptions, formula.getFormulas().get(0), 103 formula.getName(), formula.getDescription()); 107 String f = formula.getFormulas().get(0); 108 if (maxRawMappings == 1 || !f.contains("raw(")) 109 { 110 addFormulaOption(filterOptions, f, 111 formula.getName(), formula.getDescription()); 112 } 104 113 } 105 114 -
trunk/www/views/experiments/spotdata/list_spotdata.jsp
r2978 r2993 97 97 List<TableColumn> columns = new LinkedList<TableColumn>(); 98 98 DynamicUtil.addSpotColumns(columns, dc, rawDataType.getChannels()); 99 DynamicUtil.addFormulaColumns(columns, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION, "frm.", "" );99 DynamicUtil.addFormulaColumns(columns, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION, "frm.", "", true); 100 100 DynamicUtil.addExtraColumns(columns, dc, bioAssaySet, "ev", "#", "[Xtra] "); 101 101 DynamicUtil.addRawDataColumns(columns, dc, rawDataType, "raw.", "$", "[Raw] ");
Note: See TracChangeset
for help on using the changeset viewer.