Changeset 4083
- Timestamp:
- Jan 17, 2008, 11:08:21 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/src/docbook/appendix/incompatible.xml
r4080 r4083 52 52 <para> 53 53 Array design features can now be identified by three different methods: 54 COORDINATES, POSITION and EXTERNAL_ID. The coordinates method was the54 COORDINATES, POSITION and FEATURE_ID. The coordinates method was the 55 55 only one supported earlier. 56 56 </para> … … 64 64 <classname docapi="net.sf.basedb.core">FeatureBatcher</classname> or 65 65 <classname docapi="net.sf.basedb.core">RawDataBatcher</classname> are 66 probably affected by this. For example, includes raw data importerswhich67 doesn't know how to set the position or the feature ID when those identification68 methods are used.66 probably affected by this. For example, a raw data importer which 67 doesn't know how to set the position or the feature ID can't import data to 68 an array design that is using one of the new identification methods. 69 69 </para> 70 70 </listitem> -
trunk/doc/src/docbook/userdoc/rawbioassays.xml
r3940 r4083 138 138 The array design can be changed after raw data has been 139 139 imported, but this triggers a new validation. If the raw data 140 is stored in the database, the position, coordinates and reporter of all features 141 on the new array design must exactly match the position, 142 coordinates and reporter of the raw data. For Affymetrix data, the 140 is stored in the database, the features on the new array design must 141 match the the raw data. The verification can use three different methods: 142 </para> 143 144 <itemizedlist> 145 <listitem> 146 <para> 147 Coordinates: Verify block, meta-grid, row and column coordinates. 148 </para> 149 </listitem> 150 <listitem> 151 <para>Position: Verify the position number.</para> 152 </listitem> 153 <listitem> 154 <para> 155 Feature ID: Verify the feature ID. This option can only be used 156 if the raw bioassay is currently connected to an array design that 157 has feature ID values already. 158 </para> 159 </listitem> 160 </itemizedlist> 161 <para> 162 In all three cases it is also verified that the reporter of the raw 163 data matches the reporter of the features. 164 </para> 165 166 <para> 167 For Affymetrix data, the 143 168 CEL file is validated against the CDF file of the new array design. 144 169 If the validation fails, the array design is not changed. -
trunk/src/clients/migrate/net/sf/basedb/clients/migrate/RawBioAssayDataTransfer.java
r3941 r4083 168 168 */ 169 169 cleanUpMemory(); 170 RawDataBatcher batcher = rawBioAssay.getRawDataBatcher( );170 RawDataBatcher batcher = rawBioAssay.getRawDataBatcher(null); 171 171 batcher.setBatchSize(getBatchSize()); 172 172 runRawBioAssay(rawBioAssay, batcher, hasArrayDesign, rawBioAssayId); -
trunk/src/core/net/sf/basedb/core/FeatureBatcher.java
r4080 r4083 54 54 <li>COORDINATES: {@link FeatureData#setRow(int)} and {@link FeatureData#setColumn(int)} 55 55 <li>POSITION: {@link FeatureData#setPosition(int)} 56 <li> EXTERNAL_ID: {@link FeatureData#setExternalId(String)}56 <li>FEATURE_ID: {@link FeatureData#setExternalId(String)} 57 57 </ul> 58 58 59 59 For all methods, each feature that is inserted must have a unqiue value. For example, 60 there can't be two features with the same external ID if the EXTERNAL_ID method is60 there can't be two features with the same external ID if the FEATURE_ID method is 61 61 used. Values for the methods that are not used can still be set and saved to the 62 62 database, but the uniqueness is not checked. The position number will be auto-generated … … 79 79 add features to 80 80 @throws BaseException If there is an error 81 @see ArrayDesign#getFeatureBatcher( )81 @see ArrayDesign#getFeatureBatcher(FeatureIdentificationMethod) 82 82 */ 83 83 static FeatureBatcher getNew(DbControl dc, ArrayDesign arrayDesign) -
trunk/src/core/net/sf/basedb/core/FeatureIdentificationMethod.java
r4080 r4083 111 111 Use the external feature ID. 112 112 */ 113 EXTERNAL_ID(3, true, "ExternalID")113 FEATURE_ID(3, true, "Feature ID") 114 114 { 115 115 /** -
trunk/src/core/net/sf/basedb/core/RawBioAssay.java
r4020 r4083 58 58 <p> 59 59 Raw data is added by a {@link RawDataBatcher} object. You can get a 60 batcher for this raw bioassay by calling the {@link #getRawDataBatcher()}61 method.60 batcher for this raw bioassay by calling the {@link 61 #getRawDataBatcher(FeatureIdentificationMethod)} method. 62 62 63 63 @author Nicklas … … 418 418 if (getRawDataType().isStoredInDb() && getSpots() > 0) 419 419 { 420 RawDataBatcher rdb = RawDataBatcher.getNew(getDbControl(), this );420 RawDataBatcher rdb = RawDataBatcher.getNew(getDbControl(), this, null); 421 421 rdb.deleteAll(); 422 422 } … … 731 731 getData().setArrayDesign(arrayDesign == null ? null : arrayDesign.getData()); 732 732 } 733 733 734 /** 735 @deprecated Use {@link #updateArrayDesign(ArrayDesign, FeatureIdentificationMethod, ProgressReporter)} 736 instead 737 */ 738 public void updateArrayDesign(ArrayDesign arrayDesign, ProgressReporter progress) 739 throws PermissionDeniedException, InvalidDataException 740 { 741 updateArrayDesign(arrayDesign, null, progress); 742 } 743 734 744 /** 735 745 Set the {@link ArrayDesign} this raw data uses. If data has already been … … 739 749 740 750 @param arrayDesign The <code>ArrayDesign</code> item or null if not known 751 @param fiMethod The method to use for identifying features on the 752 new array design. Use null to use the method choosen by the new array design. 753 The {@link FeatureIdentificationMethod#FEATURE_ID} will not work unless the 754 raw bioassay is already connected to an array design which has features with 755 external ID:s 741 756 @param progress An optional progress reporter 742 757 @throws PermissionDeniedException If the logged in user doesn't have … … 745 760 match the raw data 746 761 @throws BaseException If there is another error 747 @since 2. 4748 */ 749 public void updateArrayDesign(ArrayDesign arrayDesign, ProgressReporter progress)762 @since 2.6 763 */ 764 public void updateArrayDesign(ArrayDesign arrayDesign, FeatureIdentificationMethod fiMethod, ProgressReporter progress) 750 765 throws PermissionDeniedException, InvalidDataException 751 766 { … … 760 775 if (getData().getSpots() > 0 && arrayDesign != null) 761 776 { 762 validateFeatures(getDbControl(), arrayDesign, true, progress);777 validateFeatures(getDbControl(), arrayDesign, fiMethod, true, progress); 763 778 } 764 779 getData().setArrayDesign(arrayDesign == null ? null : arrayDesign.getData()); … … 956 971 return query; 957 972 } 973 974 /** 975 @deprecated Use {@link #getRawDataBatcher(FeatureIdentificationMethod)} instead 976 */ 977 public RawDataBatcher getRawDataBatcher() 978 throws PermissionDeniedException, BaseException 979 { 980 return getRawDataBatcher(null); 981 } 958 982 959 983 /** 960 984 Get a raw data batcher object which can be used to add raw data to 961 the raw bioassay. 985 the raw bioassay. 986 @param fiMethod The method to use for identifying features, or null to 987 use the method choosen by the array design. This parameter has no meaning 988 if the raw bioassay is not connected to an array design or if the array 989 design has no features. 990 @return A <code>RawDataBatcher</code> object. If this method is called multiple 991 times the fiMethod parameter is ignored and the same batcher as before 992 is returned 962 993 @throws PermissionDeniedException If raw data has already been added 963 994 or the logged in user doesn't have write permission 964 995 @throws BaseException If there is another error 965 */ 966 public RawDataBatcher getRawDataBatcher() 996 @since 2.6 997 */ 998 public RawDataBatcher getRawDataBatcher(FeatureIdentificationMethod fiMethod) 967 999 throws PermissionDeniedException, BaseException 968 1000 { 969 1001 checkPermission(Permission.WRITE); 970 if ( hasData())1002 if (getNumDbSpots() > 0) 971 1003 { 972 1004 throw new PermissionDeniedException("Raw data has already been added to "+this); … … 974 1006 if (rawDataBatcher == null) 975 1007 { 976 rawDataBatcher = RawDataBatcher.getNew(getDbControl(), this );1008 rawDataBatcher = RawDataBatcher.getNew(getDbControl(), this, fiMethod); 977 1009 } 978 1010 return rawDataBatcher; … … 1004 1036 if (getNumDbSpots() > 0) 1005 1037 { 1006 RawDataBatcher rdb = RawDataBatcher.getNew(getDbControl(), this );1038 RawDataBatcher rdb = RawDataBatcher.getNew(getDbControl(), this, null); 1007 1039 rdb.deleteAll(); 1008 1040 } … … 1073 1105 features/reporter on the array design. 1074 1106 @param dc The DbControl to use for database access 1075 @param design The array design to validate agains 1107 @param design The array design to validate against 1108 @param fiMethod The method to use for identifying features, or null 1109 to use the method choosen by the array design 1076 1110 @param update If the raw data should be linked to the new feature or not 1077 1111 @param progress An optional progress reporter 1078 @since 2.4 1079 */ 1080 private void validateFeatures(DbControl dc, ArrayDesign design, boolean update, ProgressReporter progress) 1112 @since 2.6 1113 */ 1114 private void validateFeatures(DbControl dc, ArrayDesign design, FeatureIdentificationMethod fiMethod, 1115 boolean update, ProgressReporter progress) 1081 1116 { 1082 1117 if (design.hasFeatures()) 1083 1118 { 1119 if (fiMethod == null) fiMethod = design.getFeatureIdentificationMethod(); 1120 if (fiMethod == FeatureIdentificationMethod.NONE) fiMethod = FeatureIdentificationMethod.COORDINATES; 1121 1084 1122 if (progress != null) progress.display(5, "Loading features from array design..."); 1085 1123 … … 1089 1127 String entityName = getRawDataType().getEntityName(); 1090 1128 1091 // Preload features from array design 1092 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(), 1093 "COUNT_FEATURES_FOR_ARRAYDESIGN"); 1094 /* 1095 SELECT count(*) 1096 FROM FeatureData f 1097 WHERE f.arrayDesignBlock.arrayDesign = :arrayDesign 1098 */ 1099 query.setInteger("arrayDesign", design.getId()); 1100 int numFeatures = HibernateUtil.loadData(Long.class, query).intValue(); 1101 Map<Integer, FeatureData> features = new HashMap<Integer, FeatureData>(numFeatures); 1102 query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(), "PRELOAD_FEATURES"); 1129 int numFeatures = design.getNumDbFeatures(); 1130 Map<Object, FeatureData> features = new HashMap<Object, FeatureData>(numFeatures); 1131 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(), "PRELOAD_FEATURES"); 1103 1132 /* 1104 1133 SELECT f … … 1114 1143 { 1115 1144 FeatureData f = si.next(); 1116 features.put(f.getPosition(), f); 1145 Object featureId = fiMethod.getIdentifier(f); 1146 if (features.put(featureId, f) != null) 1147 { 1148 throw new InvalidDataException("Can't identify features with " + fiMethod + 1149 ". Found duplicate feature: " + featureId); 1150 } 1117 1151 } 1118 1152 si.close(); … … 1121 1155 if (progress != null) progress.display(10, "Loading raw data from raw bioassay..."); 1122 1156 DataQuery<RawData> rawQuery = getRawData(); 1157 // NOTE!! Due to an issue in Hibernate we must join all three 1158 // tables or we will get an AssertionFailure: possible non-threadsafe access to the session 1159 // The query also works if don't join at all, but that will generate a lot 1160 // of extra queries for each iteration 1161 rawQuery.join(Hql.leftJoin(null, "reporter", "rep", null, true)); 1162 rawQuery.join(Hql.leftJoin(null, "feature", "feat", null, true)); 1163 rawQuery.join(Hql.leftJoin("feat", "arrayDesignBlock", "bl", null, true)); 1164 1123 1165 DataResultIterator<RawData> result = rawQuery.iterate(dc); 1124 1166 int numValidated = 0; … … 1127 1169 { 1128 1170 RawData raw = result.next(); 1129 int position = raw.getPosition(); 1130 FeatureData feature = features.get(position); 1131 if (feature == null) 1171 1172 // Get the feature identifier for the current raw data 1173 FeatureData oldFeature = raw.getFeature(); 1174 String externalFeatureId = oldFeature == null ? null : oldFeature.getExternalId();; 1175 Object rawFeatureId = fiMethod.getIdentifier(raw, externalFeatureId); 1176 1177 // Find the new feature with the same identifier 1178 FeatureData newFeature = features.get(rawFeatureId); 1179 if (newFeature == null) 1132 1180 { 1133 1181 throw new InvalidDataException("Array design '" + design.getName() + 1134 "' is missing a feature at position " + raw.getPosition());1182 "' is missing a feature for " + fiMethod + "=" + rawFeatureId); 1135 1183 } 1136 1184 1137 1185 // Check that reporters are the same 1138 1186 ReporterData rawReporter = raw.getReporter(); 1139 ReporterData featureReporter = feature.getReporter();1187 ReporterData featureReporter = newFeature.getReporter(); 1140 1188 if (rawReporter == null) 1141 1189 { 1142 1190 if (featureReporter != null) 1143 1191 { 1144 throw new InvalidDataException("Reporter mismatch at position " + position +1192 throw new InvalidDataException("Reporter mismatch at " + fiMethod + "=" + rawFeatureId + 1145 1193 "; raw reporter=none, feature reporter=" + featureReporter.getExternalId()); 1146 1194 } … … 1150 1198 if (featureReporter == null) 1151 1199 { 1152 throw new InvalidDataException("Reporter mismatch at position " + position+1200 throw new InvalidDataException("Reporter mismatch at " + fiMethod + "=" + rawFeatureId + 1153 1201 "; raw reporter=" + rawReporter.getExternalId() + ", feature reporter=none"); 1154 1202 } 1155 1203 else if (rawReporter.getId() != featureReporter.getId()) 1156 1204 { 1157 throw new InvalidDataException("Reporter mismatch at position " + position+1205 throw new InvalidDataException("Reporter mismatch at " + fiMethod + "=" + rawFeatureId + 1158 1206 "; raw reporter=" + rawReporter.getExternalId() + 1159 1207 ", feature reporter=" + featureReporter.getExternalId()); 1160 1208 } 1161 1209 } 1162 1163 // Check that coordinates are the same 1164 FeatureCoordinate featureCoordinate = Feature.getFeatureCoordinate(feature); 1165 FeatureCoordinate rawCoordinate = new FeatureCoordinate(raw.getBlock(), 1166 raw.getMetaGridX(), raw.getMetaGridY(), raw.getRow(), raw.getColumn()); 1167 1168 if (!featureCoordinate.equals(rawCoordinate)) 1169 { 1170 throw new InvalidDataException("Coordinate mismatch at position " + position + 1171 "; raw=" + rawCoordinate +", feature=" + featureCoordinate); 1172 } 1173 1210 1174 1211 // All is ok, re-assign raw data to the new feature 1175 1212 if (update) 1176 1213 { 1177 metaData.setPropertyValue(raw, "feature", feature, EntityMode.POJO); 1214 metaData.setPropertyValue(raw, "feature", newFeature, EntityMode.POJO); 1215 raw.setPosition(newFeature.getPosition()); 1178 1216 session.update(entityName, raw); 1179 1217 } -
trunk/src/core/net/sf/basedb/core/RawDataBatcher.java
r4080 r4083 92 92 @param rawBioAssay The raw bioassay this batcher should 93 93 add raw data to 94 @param fiMethod The method to use for identifying features, use null 95 to use the method specified by the array design 94 96 @throws BaseException If there is an error 95 @see RawBioAssay#getRawDataBatcher( )96 */ 97 static RawDataBatcher getNew(DbControl dc, RawBioAssay rawBioAssay )98 throws BaseException 99 { 100 RawDataBatcher rdb = new RawDataBatcher(dc, rawBioAssay );97 @see RawBioAssay#getRawDataBatcher(FeatureIdentificationMethod) 98 */ 99 static RawDataBatcher getNew(DbControl dc, RawBioAssay rawBioAssay, FeatureIdentificationMethod fiMethod) 100 throws BaseException 101 { 102 RawDataBatcher rdb = new RawDataBatcher(dc, rawBioAssay, fiMethod); 101 103 rdb.initPermissions(0, 0); 102 104 return rdb; … … 164 166 private boolean useNullIfReporterNotFound = true; 165 167 166 RawDataBatcher(DbControl dc, RawBioAssay rawBioAssay )168 RawDataBatcher(DbControl dc, RawBioAssay rawBioAssay, FeatureIdentificationMethod fim) 167 169 throws BaseException 168 170 { … … 178 180 } 179 181 180 this.fiMethod = arrayDesign != null && arrayDesign.getHasFeatures() ? 181 FeatureIdentificationMethod.fromValue(arrayDesign.getFeatureIdentificationMethod()) : 182 FeatureIdentificationMethod.NONE; 183 184 if (fiMethod != FeatureIdentificationMethod.NONE) 182 // Use the feature identification method set by the array design if none was given 183 this.fiMethod = fim; 184 if (arrayDesign != null && arrayDesign.getHasFeatures()) 185 { 186 if (fiMethod == null) 187 { 188 fiMethod = FeatureIdentificationMethod.fromValue(arrayDesign.getFeatureIdentificationMethod()); 189 } 190 // As a last resort fallback to the coordinates method 191 if (fiMethod == null || fiMethod == FeatureIdentificationMethod.NONE) 192 { 193 fiMethod = FeatureIdentificationMethod.COORDINATES; 194 } 195 } 196 else 197 { 198 fiMethod = FeatureIdentificationMethod.NONE; 199 } 200 201 // Preload features 202 if (fiMethod != FeatureIdentificationMethod.NONE && rawBioAssay.getNumDbSpots() == 0) 185 203 { 186 204 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(), "COUNT_FEATURES_FOR_ARRAYDESIGN"); … … 208 226 FeatureData feature = si.next(); 209 227 Object featureId = fiMethod.getIdentifier(feature); 210 preloaded.put(featureId, feature); 228 if (preloaded.put(featureId, feature) != null) 229 { 230 throw new InvalidDataException("Can't identify features with " + fiMethod + 231 ". Found duplicate feature: " + featureId); 232 } 211 233 } 212 234 si.close(); … … 309 331 { 310 332 granted |= Permission.grant(Permission.WRITE, Permission.DELETE, Permission.CREATE); 333 if (rawBioAssay.getNumDbSpots() > 0) 334 { 335 denied |= Permission.deny(Permission.CREATE); 336 } 311 337 } 312 338 super.initPermissions(granted, denied); -
trunk/src/core/net/sf/basedb/core/data/ArrayDesignData.java
r4080 r4083 159 159 /** 160 160 The method to use for identiying features. 161 1 = COORDINATES, 2 = POSITION, 3 = EXTERNAL_ID161 1 = COORDINATES, 2 = POSITION, 3 = FEATURE_ID 162 162 @hibernate.property column="`identification_method`" type="int" not-null="true" 163 163 @since 2.6 -
trunk/src/plugins/core/net/sf/basedb/plugins/IlluminaRawDataImporter.java
r4080 r4083 38 38 39 39 40 import net.sf.basedb.core.ArrayDesign; 40 41 import net.sf.basedb.core.BaseException; 41 42 import net.sf.basedb.core.BasicItem; … … 109 110 110 111 <li> 111 If the array design uses the {@link FeatureIdentificationMethod# EXTERNAL_ID}112 If the array design uses the {@link FeatureIdentificationMethod#FEATURE_ID} 112 113 method for identifying features. The plug-in assumes that the feature ID is the 113 114 same as the reporter ID. … … 151 152 )); 152 153 154 private static final PluginParameter<String> featureIdentificationParameter = 155 new PluginParameter<String>( 156 "featureIdentification", 157 "Identify features by", 158 "Choose which method to use for identifying features. If no value " + 159 "is selected the identification method used on the array design is used: \n\n" + 160 "* COORDINATES: Use auto-generated coordinates (block = 1, column = 1, row = line number in file)\n" + 161 "* POSITION: Use auto-generated position = line number in file\n" + 162 "* FEATURE_ID: Use TargetID (requires that each Target ID only appears once in the file)\n\n" + 163 "NOTE! This parameter has no meaning unless an array design is selected", 164 new StringParameterType(255, null, false, 1, 0, 0, 165 Arrays.asList(new String[] {"COORDINATE", "POSITION", "FEATURE_ID" } )) 166 ); 167 168 153 169 private static final PluginParameter<String> invalidColumnsErrorParameter = new PluginParameter<String>( 154 170 "invalidColumnsError", … … 277 293 // Associations 278 294 storeValue(job, request, ri.getParameter("experiment")); 295 storeValue(job, request, ri.getParameter("arrayDesign")); 296 storeValue(job, request, featureIdentificationParameter); 279 297 storeValue(job, request, ri.getParameter("scan")); 280 298 storeValue(job, request, ri.getParameter("protocol")); … … 306 324 private DbControl dc; 307 325 private Experiment experiment; 326 private ArrayDesign design; 308 327 private Scan scan; 309 328 private Software software; 310 329 private Protocol protocol; 330 private FeatureIdentificationMethod fiMethod; 311 331 private List<RawBioAssay> rawBioAssays; 312 332 private List<BatchAndMapHolder> holders; … … 369 389 this.headerLines = new LinkedList<Line>(); 370 390 this.experiment = (Experiment)job.getValue("experiment"); 391 this.design = (ArrayDesign)job.getValue("arrayDesign"); 371 392 this.scan = (Scan)job.getValue("scan"); 372 393 this.protocol = (Protocol)job.getValue("protocol"); 373 394 this.software = (Software)job.getValue("software"); 374 395 396 // Feature identification 397 try 398 { 399 String fiTemp = (String)job.getValue("featureIdentification"); 400 fiMethod = FeatureIdentificationMethod.valueOf(fiTemp); 401 } 402 catch (Exception ex) 403 { 404 fiMethod = null; 405 } 375 406 // Setup error handling 376 407 this.nullIfException = "null".equals(getErrorOption("numberFormatError")); … … 429 460 // Need to reload raw bioassay with current DbControl 430 461 rba = RawBioAssay.getById(dc, rba.getId()); 431 RawDataBatcher batcher = rba.getRawDataBatcher( );462 RawDataBatcher batcher = rba.getRawDataBatcher(fiMethod); 432 463 batcher.useNullIfReporterNotFound(nullIfMissingReporter); 433 464 holders.add(new BatchAndMapHolder(batcher, illumina, ffp)); … … 566 597 RawBioAssay rba = RawBioAssay.getNew(dc, generic, illumina); 567 598 rba.setName(arrayName); 599 if (design != null) rba.setArrayDesign(design); 568 600 if (scan != null) rba.setScan(scan); 569 601 if (protocol != null) rba.setProtocol(protocol); … … 618 650 parameters.add(getCharsetParameter(null, null, null)); 619 651 620 // parameters for scan, protocol and software652 // parameters for scan, protocol, software and array design 621 653 dc = sc.newDbControl(); 622 654 List<Scan> scans = getItems(dc, Scan.getQuery()); … … 633 665 ) 634 666 ); 667 List<ArrayDesign> designs = getItems(dc, ArrayDesign.getQuery(), 668 Restrictions.gt( 669 Hql.property("numDbFeatures"), 670 Expressions.integer(0) 671 ) 672 ); 635 673 636 674 boolean hasAssociations = 637 675 context.getItem() == Item.EXPERIMENT || scans.size() > 0 || 638 protocols.size() > 0 || software.size() > 0 ;676 protocols.size() > 0 || software.size() > 0 || designs.size() > 0; 639 677 640 678 if (hasAssociations) … … 650 688 new ItemParameterType<Experiment>(Experiment.class, null, true, 1, null) 651 689 )); 690 } 691 if (!designs.isEmpty()) 692 { 693 parameters.add(new PluginParameter<ArrayDesign>( 694 "arrayDesign", 695 "Array design", 696 "The imported raw bioassays will be linked to the selected array design.", 697 new ItemParameterType<ArrayDesign>(ArrayDesign.class, null, false, 1, designs) 698 )); 699 parameters.add(featureIdentificationParameter); 652 700 } 653 701 if (!scans.isEmpty()) -
trunk/src/plugins/core/net/sf/basedb/plugins/RawDataFlatFileImporter.java
r4080 r4083 26 26 27 27 import net.sf.basedb.core.AnnotationType; 28 import net.sf.basedb.core.ArrayDesign; 28 29 import net.sf.basedb.core.BaseException; 29 30 import net.sf.basedb.core.DataFileType; 30 31 import net.sf.basedb.core.DbControl; 32 import net.sf.basedb.core.FeatureIdentificationMethod; 31 33 import net.sf.basedb.core.File; 32 34 import net.sf.basedb.core.FileParameterType; … … 208 210 "Mapping that picks the spot's feature ID from the data columns. " + 209 211 "This column is only used when the raw data is connected to an array design " + 210 "which uses the EXTERNAL_ID method for identifying features. The value is not saved " +212 "which uses the FEATURE_ID method for identifying features. The value is not saved " + 211 213 "to the database." + 212 214 "For example: \\Feature ID\\", … … 530 532 } 531 533 532 batcher = rawBioAssay.getRawDataBatcher(); 534 FeatureIdentificationMethod fiMethod = null; 535 if (job.getValue("featureIdentification") != null) 536 { 537 try 538 { 539 fiMethod = FeatureIdentificationMethod.valueOf((String)job.getValue("featureIdentification")); 540 } 541 catch (Exception ex) 542 {} 543 } 544 545 batcher = rawBioAssay.getRawDataBatcher(fiMethod); 533 546 numInserted = 0; 534 547 this.ffp = ffp; … … 678 691 { 679 692 allColumnMappings = new ArrayList<PluginParameter<String>>(); 693 allColumnMappings.add(reporterIdColumnMapping); 694 allColumnMappings.add(featureIdColumnMapping); 680 695 allColumnMappings.add(positionColumnMapping); 681 696 allColumnMappings.add(blockColumnMapping); … … 686 701 allColumnMappings.add(xColumnMapping); 687 702 allColumnMappings.add(yColumnMapping); 688 allColumnMappings.add(reporterIdColumnMapping);689 allColumnMappings.add(featureIdColumnMapping);690 703 for(RawDataProperty rdp : rdt.getProperties()) 691 704 { … … 726 739 dc = sc.newDbControl(); 727 740 boolean configIsAnnotated = false; 741 ArrayDesign design = null; 728 742 try 729 743 { … … 731 745 rawDataFiles = FileStoreUtil.getGenericDataFiles(dc, rba, FileType.RAW_DATA); 732 746 configIsAnnotated = getCurrentConfiguration(dc).isAnnotated(); 747 design = rba.getArrayDesign(); 733 748 } 734 749 catch (Throwable t) … … 748 763 null : rawDataFiles.get(0), true, 1) 749 764 ); 750 parameters.add(fileParameter); 765 parameters.add(fileParameter); 766 767 if (design != null && design.getNumDbFeatures() > 0) 768 { 769 // Parameter for asking which feature identification method to use 770 // Only used if the connected array design has features 771 772 FeatureIdentificationMethod fiMethod = design.getFeatureIdentificationMethod(); 773 List<String> methods = new ArrayList<String>(); 774 String description = "Choose which method to use for identifying features: \n"; 775 if (configuration.getValue("rowColumnMapping") != null && configuration.getValue("columnColumnMapping") != null) 776 { 777 methods.add("COORDINATES"); 778 description += "COORDINATES: Use block, meta-grid, row and column coordinates\n"; 779 } 780 if (configuration.getValue("positionColumnMapping") != null) 781 { 782 methods.add("POSITION"); 783 description += "POSITION: Use a position number only\n"; 784 } 785 if (configuration.getValue("featureIdColumnMapping") != null) 786 { 787 methods.add("FEATURE_ID"); 788 description += "FEATURE_ID: Use the feature ID value (string)\n"; 789 } 790 791 if (methods.size() > 0) 792 { 793 PluginParameter<String> featureIdentificationParameter = 794 new PluginParameter<String>( 795 "featureIdentification", 796 "Identify features by", 797 description, 798 new StringParameterType(255, methods.contains(fiMethod.name()) ? fiMethod.name() : null, 799 true, 1, 0, 0, methods) 800 ); 801 parameters.add(featureIdentificationParameter); 802 } 803 } 804 751 805 parameters.add(getCharsetParameter(null, null, (String)configuration.getValue(CHARSET))); 752 806 parameters.add(getDecimalSeparatorParameter(null, null, (String)configuration.getValue(DECIMAL_SEPARATOR))); -
trunk/src/plugins/core/net/sf/basedb/plugins/ReporterMapFlatFileImporter.java
r4080 r4083 118 118 "COORDINATES: Use block, meta-grid, row and column coordinates\n" + 119 119 "POSITION: Use a position number only\n" + 120 " EXTERNAL_ID: Use the feature ID value (string)\n" +120 "FEATURE_ID: Use the feature ID value (string)\n" + 121 121 "In all cases, the identifier value must be unique.", 122 122 new StringParameterType(255, "COORDINATES", true, 1, 0, 0, 123 Arrays.asList(new String[] {"COORDINATES", "POSITION", " EXTERNAL_ID"}))123 Arrays.asList(new String[] {"COORDINATES", "POSITION", "FEATURE_ID"})) 124 124 ); 125 125 … … 136 136 "Feature ID", 137 137 "Mapping that picks the feature's ID from the data columns. This column is " + 138 "only used when the array design uses the EXTERNAL_ID method for " +138 "only used when the array design uses the FEATURE_ID method for " + 139 139 "identifying features. In the other cases, the value is just stored as it is." + 140 140 "For example: \\Feature ID\\", … … 407 407 if (positionMapping == null) mapErrors.add(new InvalidUseOfNullException("Position")); 408 408 } 409 else if (fiMethod == FeatureIdentificationMethod. EXTERNAL_ID)409 else if (fiMethod == FeatureIdentificationMethod.FEATURE_ID) 410 410 { 411 411 String positionMapping = (String)request.getParameterValue("featureIdColumnMapping"); … … 421 421 response.setError("Missing column mapping for feature identification method: " 422 422 + fiMethod, mapErrors); 423 return; 423 424 } 424 425 … … 571 572 572 573 FeatureData feature = batcher.newFeature(adb, reporter); 574 feature.setExternalId(featureId); 573 575 Integer position = positionMapper.getInt(data); 574 576 Integer row = rowMapper.getInt(data); -
trunk/src/test/TestAnalyzePluginUtil.java
r3820 r4083 72 72 rba.setName("TestAnalyzePluginUtil"+i); 73 73 rba.setDescription("RawBioAssay created by TestAnalyzePluginUtil. Number of spots should be "+spots); 74 RawDataBatcher rawDataBatcher = rba.getRawDataBatcher( );74 RawDataBatcher rawDataBatcher = rba.getRawDataBatcher(null); 75 75 for (int j = 0; parser.hasMoreData() && j < spots; j++) 76 76 { -
trunk/src/test/TestArrayDesign.java
r4080 r4083 75 75 int id3 = test_create(Platform.AFFYMETRIX, true); 76 76 int id4 = test_create(Platform.AFFYMETRIX, false); 77 int id6 = test_create(Platform.GENERIC, false); 77 78 test_load(id); 78 79 test_list(-1); … … 82 83 test_import_from_file(id2, "data/test.reportermap.import.txt", 83 84 "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"ID\"\\t\"Name\".*", 0, 2, 1, 3); 84 test_add_features(id, 10); 85 test_add_features(id, FeatureIdentificationMethod.COORDINATES, 10); 86 test_add_features(id6, FeatureIdentificationMethod.FEATURE_ID, 10); 85 87 86 88 write_feature_header(); … … 115 117 test_delete(id4); 116 118 test_delete(id5); 119 test_delete(id6); 117 120 118 121 TestPlate.test_delete_all(); … … 310 313 } 311 314 312 static void test_add_features(int arrayDesignId, int numFeatures)315 static void test_add_features(int arrayDesignId, FeatureIdentificationMethod fiMethod, int numFeatures) 313 316 { 314 317 if (arrayDesignId == 0) return; … … 329 332 } 330 333 331 FeatureBatcher batcher = ad.getFeatureBatcher( FeatureIdentificationMethod.COORDINATES);334 FeatureBatcher batcher = ad.getFeatureBatcher(fiMethod); 332 335 int block = 1; 333 336 int row = 1; 334 337 int column = 1; 338 int position = 1; 335 339 ArrayDesignBlock adBlock = ad.addArrayDesignBlock(new BlockInfo(block, (int)Math.ceil(block/4F), ((block-1)%4)+1)); 336 340 time = System.currentTimeMillis(); … … 345 349 data.setRow(row); 346 350 data.setColumn(column); 351 data.setPosition(position); 352 data.setExternalId(reporter.getExternalId() + "." + position); 347 353 348 354 batcher.insert(data); 349 355 row++; 356 position++; 350 357 if (row == 11) 351 358 { -
trunk/src/test/TestBioAsssaySetExporter.java
r3820 r4083 171 171 ReporterData r2 = Reporter.getById(dc, r2Id); 172 172 ReporterData r3 = Reporter.getById(dc, r3Id); 173 RawDataBatcher rdb = rba.getRawDataBatcher( );173 RawDataBatcher rdb = rba.getRawDataBatcher(null); 174 174 for (int i=0; i < 4; ++i) 175 175 { -
trunk/src/test/TestRawBioAssay.java
r3820 r4083 315 315 RawDataType rdt = rba.getRawDataType(); 316 316 List<RawDataProperty> extraProperties = rdt.getProperties(); 317 RawDataBatcher rdb = rba.getRawDataBatcher( );317 RawDataBatcher rdb = rba.getRawDataBatcher(null); 318 318 int block = 1; 319 319 int row = 1; … … 459 459 dc = TestUtil.getDbControl(); 460 460 RawBioAssay rba = RawBioAssay.getById(dc, rawBioAssayId); 461 RawDataBatcher rawDataBatcher = rba.getRawDataBatcher( );461 RawDataBatcher rawDataBatcher = rba.getRawDataBatcher(null); 462 462 ReporterBatcher reporterBatcher = ReporterBatcher.getNew(dc); 463 463 -
trunk/src/test/net/sf/basedb/test/merge/MergeTest.java
r4080 r4083 238 238 TestUtil.write("--Creating data for raw bioassay: " + rba.getName() + "\n"); 239 239 dc.reattachItem(rba); 240 RawDataBatcher batcher = rba.getRawDataBatcher( );240 RawDataBatcher batcher = rba.getRawDataBatcher(null); 241 241 for (int block = 1; block <= 10; block++) 242 242 { -
trunk/www/lims/arraydesigns/features/index.jsp
r3775 r4083 46 46 <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> 47 47 <%! 48 private static final ItemContext defaultContext = Base.createDefaultContext("position", "position,block,row,column,reporter.name,reporter.externalId"); 48 private static final ItemContext defaultContext = Base.createDefaultContext("position", 49 "position,externalId,block,row,column,reporter.name,reporter.externalId"); 49 50 private static final Item itemType = Item.FEATURE; 50 51 %> -
trunk/www/lims/arraydesigns/features/list_features.jsp
r3679 r4083 36 36 import="net.sf.basedb.core.ArrayDesignBlock" 37 37 import="net.sf.basedb.core.Feature" 38 import="net.sf.basedb.core.FeatureIdentificationMethod" 38 39 import="net.sf.basedb.core.ReporterType" 39 40 import="net.sf.basedb.core.Reporter" … … 88 89 final ArrayDesign design = ArrayDesign.getById(dc, arrayDesignId); 89 90 final boolean isAffy = design.isAffyChip(); 91 final FeatureIdentificationMethod fiMethod = design.getFeatureIdentificationMethod(); 90 92 Formatter<Date> dateFormatter = FormatterFactory.getDateTimeFormatter(sc); 91 93 … … 112 114 int numListed = 0; 113 115 %> 114 116 <base:page title="<%=title%>"> 115 117 <base:head scripts="table.js,tabcontrol.js" styles="table.css,headertabcontrol.css,path.css"> 116 118 <script language="JavaScript"> … … 210 212 filterable="true" 211 213 exportable="true" 212 show="always" 214 show="<%=fiMethod == FeatureIdentificationMethod.EXTERNAL_ID ? "auto" : "always"%>" 215 /> 216 <tbl:columndef 217 id="externalId" 218 property="externalId" 219 datatype="string" 220 title="Feature ID" 221 sortable="true" 222 filterable="true" 223 exportable="true" 224 show="<%=fiMethod == FeatureIdentificationMethod.EXTERNAL_ID ? "always" : "auto"%>" 213 225 /> 214 226 <tbl:columndef … … 540 552 <tbl:cell column="position"><div class="link" onclick="itemOnClick(event, <%=itemId%>)" 541 553 title="<%=tooltip%>"><%=item.getPosition()%></div></tbl:cell> 554 <tbl:cell column="externalId"><div class="link" onclick="itemOnClick(event, <%=itemId%>)" 555 title="<%=tooltip%>"><%=HTML.encodeTags(item.getExternalId())%></div></tbl:cell> 542 556 <tbl:cell column="block"><%=block.getBlockNumber()%></tbl:cell> 543 557 <tbl:cell column="row"><%=item.getRow()%></tbl:cell> -
trunk/www/lims/arraydesigns/features/view_feature.jsp
r3679 r4083 79 79 80 80 final ArrayDesign design = ArrayDesign.getById(dc, arrayDesignId); 81 81 82 final boolean isAffy = design.isAffyChip(); 82 83 FeatureData feature = design.getFeatureById(itemId); … … 107 108 </tr> 108 109 <tr> 109 <td class="prompt">Affy chip</td> 110 <td><%=isAffy ? " yes" : "no"%></td> 110 <td class="prompt">Platform / Variant</td> 111 <td><base:propertyvalue item="<%=design%>" property="platform" /> / <base:propertyvalue item="<%=design%>" property="variant" /></td> 112 </tr> 113 <tr> 114 <td class="prompt">Feature identification method</td> 115 <td><%=design.getFeatureIdentificationMethod()%></td> 111 116 </tr> 112 117 </table> … … 114 119 <h4>Feature / block</h4> 115 120 <table class="form" cellspacing=0> 121 <tr> 122 <td class="prompt">Feature ID</td> 123 <td colspan="7"><%=HTML.encodeTags(feature.getExternalId())%></td> 124 </tr> 116 125 <tr> 117 126 <td class="prompt">Position</td> -
trunk/www/lims/arraydesigns/list_designs.jsp
r4003 r4083 48 48 import="net.sf.basedb.core.PermissionDeniedException" 49 49 import="net.sf.basedb.core.PluginDefinition" 50 import="net.sf.basedb.core.FeatureIdentificationMethod" 50 51 import="net.sf.basedb.core.query.Hql" 51 52 import="net.sf.basedb.core.query.Restrictions" … … 72 73 private static final Item itemType = Item.ARRAYDESIGN; 73 74 private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST); 75 private static final Enumeration<String, String> fiMethods = new Enumeration<String, String>(); 76 static 77 { 78 for (FeatureIdentificationMethod fim : FeatureIdentificationMethod.values()) 79 { 80 fiMethods.add(Integer.toString(fim.getValue()), fim.toString()); 81 } 82 fiMethods.lock(); 83 } 74 84 %> 75 85 <% … … 305 315 filterable="true" 306 316 exportable="true" 317 /> 318 <tbl:columndef 319 id="featureIdentificationMethod" 320 property="featureIdentificationMethod" 321 datatype="int" 322 title="Feature ID meth." 323 tooltip="Feature identification method" 324 sortable="true" 325 filterable="true" 326 exportable="true" 327 enumeration="<%=fiMethods%>" 307 328 /> 308 329 <tbl:columndef … … 547 568 <tbl:cell column="numDbFeatures"><%=item.getNumDbFeatures()%></tbl:cell> 548 569 <tbl:cell column="numFileFeatures"><%=item.getNumFileFeatures()%></tbl:cell> 570 <tbl:cell column="featureIdentificationMethod"><%=item.getFeatureIdentificationMethod()%></tbl:cell> 549 571 <tbl:cell column="batches"> 550 572 <% -
trunk/www/lims/arraydesigns/view_design.jsp
r4003 r4083 303 303 <td class="prompt">Features</td> 304 304 <td><%=design.hasFeatures() ? "yes (db: " + design.getNumDbFeatures() + "; file: " + design.getNumFileFeatures() + ")" : "no"%></td> 305 </tr> 306 <tr> 307 <td class="prompt">Feature identification method</td> 308 <td><%=design.getFeatureIdentificationMethod()%></td> 305 309 </tr> 306 310 <tr> -
trunk/www/views/rawbioassays/edit_rawbioassay.jsp
r4029 r4083 509 509 { 510 510 parentsChanged = true; 511 <% 512 if (rawBioAssay != null && rawBioAssay.getNumDbSpots() > 0) 513 { 514 %> 515 var frm = document.forms['rawbioassay']; 516 var selectedId = frm.arraydesign_id[frm.arraydesign_id.selectedIndex].value; 517 var showFiMethod = (selectedId > 0 && selectedId != <%=currentArrayDesign == null ? 0 : currentArrayDesign.getId()%>); 518 if (showFiMethod) 519 { 520 Main.show('fiMethod'); 521 } 522 else 523 { 524 Main.hide('fiMethod'); 525 } 526 <% 527 } 528 %> 511 529 } 512 530 function selectArrayDesignOnClick() … … 535 553 list.selectedIndex = 1; 536 554 parentsChanged = true; 555 arrayDesignOnChange(); 537 556 } 538 557 … … 653 672 </td> 654 673 </tr> 655 674 <tr id="fiMethod" style="display: none;"> 675 <td></td> 676 <td> 677 <select name="fiMethod"> 678 <option value="">-auto- (array design decides) 679 <option value="COORDINATES">Coordinates 680 <option value="POSITION">Position 681 <option value="FEATURE_ID">Feature ID (*) 682 </select> 683 <br> 684 Select a method for feature identification. <br> 685 (*) The Feature ID method only works if the raw data is currently 686 connected to an array design which has Feature ID values. 687 </td> 688 </tr> 656 689 <tr> 657 690 <td class="prompt">Protocol</td> -
trunk/www/views/rawbioassays/index.jsp
r3909 r4083 1 <%@page import="net.sf.basedb.core.FeatureIdentificationMethod"%> 1 2 <%-- $Id$ 2 3 ------------------------------------------------------------------ … … 90 91 private final int arrayDesignId; 91 92 private final SessionControl sc; 92 93 private UpdateArrayDesign(Job job, RawBioAssay rba, ArrayDesign design) 93 private final FeatureIdentificationMethod fiMethod; 94 95 private UpdateArrayDesign(Job job, RawBioAssay rba, ArrayDesign design, FeatureIdentificationMethod fiMethod) 94 96 { 95 97 this.jobId = job.getId(); … … 97 99 this.arrayDesignId = design.getId(); 98 100 this.sc = job.getSessionControl(); 101 this.fiMethod = fiMethod; 99 102 } 100 103 … … 113 116 try 114 117 { 115 rba.updateArrayDesign(design, progress);118 rba.updateArrayDesign(design, fiMethod, progress); 116 119 progress.display(99, "Committing changes to database..."); 117 120 dc.commit(); … … 124 127 catch (Throwable t) 125 128 { 129 if (dc != null) dc.close(); 126 130 dc = sc.newDbControl(); 127 131 j = Job.getById(dc, jobId); … … 284 288 Job job = null; 285 289 ArrayDesign ad = null; 290 FeatureIdentificationMethod fiMethod = null; 286 291 int arrayDesignId = Values.getInt(request.getParameter("arraydesign_id"), -1); 287 292 if (arrayDesignId >= 0) // < 0 = denied or unchanged … … 290 295 if (rba.hasData()) 291 296 { 297 try 298 { 299 fiMethod = FeatureIdentificationMethod.valueOf(request.getParameter("fiMethod")); 300 } 301 catch (Exception ex) 302 {} 292 303 if (rba.getRawDataType().isStoredInDb() && ad != null && ad.hasFeatures()) 293 304 { … … 301 312 else 302 313 { 303 rba.updateArrayDesign(ad, null);314 rba.updateArrayDesign(ad, fiMethod, null); 304 315 } 305 316 } … … 323 334 { 324 335 redirect = "../jobs/index.jsp?ID="+ID+"&cmd=ViewItem&item_id="+job.getId(); 325 Thread updateThread = new Thread(new UpdateArrayDesign(job, rba, ad ));336 Thread updateThread = new Thread(new UpdateArrayDesign(job, rba, ad, fiMethod)); 326 337 updateThread.setPriority(Thread.currentThread().getPriority() - 1); 327 338 updateThread.start(); -
trunk/www/views/rawbioassays/rawdata/list_rawdata.jsp
r3679 r4083 95 95 96 96 final DataQuery<RawData> query = rawBioAssay.getRawData(); 97 query.join(Hql.leftJoin(null, "reporter", "r", null, true)); 98 query.join(Hql.leftJoin(null, "feature", "f", null, true)); 99 query.join(Hql.leftJoin("f", "arrayDesignBlock", "b", null, true)); 97 100 cc.configureQuery(query, true); 98 101 if (!"row".equals(cc.getSortProperty())) query.order(Orders.asc(Hql.property("row"))); … … 397 400 datatype="int" 398 401 title="[Feat] Position" 402 sortable="true" 403 filterable="true" 404 exportable="true" 405 /> 406 <tbl:columndef 407 id="feature.externalId" 408 property="feature.externalId" 409 datatype="string" 410 title="[Feat] Feature ID" 399 411 sortable="true" 400 412 filterable="true" … … 704 716 %> 705 717 <tbl:cell column="feature.position"><i>- none -</i></tbl:cell> 718 <tbl:cell column="feature.externalId"><i>- none -</i></tbl:cell> 706 719 <tbl:cell column="feature.row"><i>- none -</i></tbl:cell> 707 720 <tbl:cell column="feature.column"><i>- none -</i></tbl:cell> … … 721 734 %> 722 735 <tbl:cell column="feature.position"><%=feature.getPosition()%></tbl:cell> 736 <tbl:cell column="feature.externalId"><%=HTML.encodeTags(feature.getExternalId())%></tbl:cell> 723 737 <tbl:cell column="feature.row"><%=feature.getRow()%></tbl:cell> 724 738 <tbl:cell column="feature.column"><%=feature.getColumn()%></tbl:cell>
Note: See TracChangeset
for help on using the changeset viewer.