Changeset 4097
- Timestamp:
- Jan 23, 2008, 2:43:49 PM (15 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/FeatureBatcher.java
r4083 r4097 171 171 if (featureIds.contains(featureId)) 172 172 { 173 throw new I nvalidDataException("Another feature with the same identifier already exists: " +173 throw new ItemAlreadyExistsException("Another feature with the same identifier already exists: " + 174 174 fiMethod.toString() + "=" + featureId); 175 175 } -
trunk/src/core/net/sf/basedb/core/RawDataBatcher.java
r4083 r4097 33 33 34 34 import java.util.HashMap; 35 import java.util.HashSet; 35 36 import java.util.List; 36 37 import java.util.Map; 38 import java.util.Set; 37 39 import java.sql.Statement; 38 40 import java.sql.SQLException; … … 162 164 163 165 /** 166 Keep track of the used features to make sure that no more than raw data spot 167 references the same feature. 168 */ 169 private Set<Object> usedFeatures; 170 171 /** 164 172 If we should use the null reporter if a reporter isn't found. 165 173 */ … … 180 188 } 181 189 182 // Use the feature identification method set by the array design if none was given183 190 this.fiMethod = fim; 184 if (arrayDesign != null && arrayDesign.getHasFeatures()) 185 { 186 if (fiMethod == null) 187 { 191 if (fiMethod == null || fiMethod == FeatureIdentificationMethod.NONE) 192 { 193 if (arrayDesign != null && arrayDesign.getHasFeatures()) 194 { 195 // Use the feature identification method set by the array design if none was given 188 196 fiMethod = FeatureIdentificationMethod.fromValue(arrayDesign.getFeatureIdentificationMethod()); 189 197 } 190 // As a last resort fallback to the coordinates method191 if (fiMethod == null || fiMethod == FeatureIdentificationMethod.NONE)192 {198 else 199 { 200 // Otherwise fallback to the coordinates method 193 201 fiMethod = FeatureIdentificationMethod.COORDINATES; 194 202 } 195 }196 else197 {198 fiMethod = FeatureIdentificationMethod.NONE;199 203 } 200 204 201 205 // Preload features 202 if ( fiMethod != FeatureIdentificationMethod.NONE&& rawBioAssay.getNumDbSpots() == 0)206 if (arrayDesign != null && arrayDesign.getHasFeatures() && rawBioAssay.getNumDbSpots() == 0) 203 207 { 204 208 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(dc.getStatelessSession(), "COUNT_FEATURES_FOR_ARRAYDESIGN"); … … 238 242 this.preloaded = null; 239 243 } 244 this.usedFeatures = new HashSet<Object>(preloaded == null ? 100 : preloaded.size()); 240 245 setDbControl(dc); 241 246 } … … 414 419 { 415 420 if (data.getPosition() == 0) data.setPosition(++currentPosition); 421 Object featureId = fiMethod.getIdentifier(data, externalFeatureId); 422 if (!usedFeatures.add(featureId)) 423 { 424 throw new ItemAlreadyExistsException("Feature[" + fiMethod.toString() + "=" + featureId + 425 "] has already been used by another spot."); 426 } 416 427 // If no reporter has been set on the RawData object we try to find the external id 417 428 if (externalReporterId != null && data.getReporter() == null) … … 434 445 { 435 446 Object featureId = fiMethod.getIdentifier(data, externalFeatureId); 447 if (!usedFeatures.add(featureId)) 448 { 449 throw new ItemAlreadyExistsException("Feature[" + fiMethod.toString() + "=" + featureId + 450 "] has already been used by another spot."); 451 } 436 452 FeatureData f = preloaded.get(featureId); 437 453 if (f == null) 438 454 { 439 throw new ItemNotFoundException("Feature["+ fiMethod.toString() + "=" + featureId + "] ");455 throw new ItemNotFoundException("Feature["+ fiMethod.toString() + "=" + featureId + "] doesn't exist on array design"); 440 456 } 441 457 ReporterData r = f.getReporter(); -
trunk/src/plugins/core/net/sf/basedb/plugins/RawDataFlatFileImporter.java
r4083 r4097 37 37 import net.sf.basedb.core.FileType; 38 38 import net.sf.basedb.core.Item; 39 import net.sf.basedb.core.ItemAlreadyExistsException; 39 40 import net.sf.basedb.core.ItemContext; 40 41 import net.sf.basedb.core.ItemNotFoundException; … … 240 241 Arrays.asList( new String[] { "skip", "fail"} )) 241 242 ); 243 244 protected static final PluginParameter<String> duplicateFeatureErrorParameter = new PluginParameter<String>( 245 "duplicateFeatureError", 246 "Duplicate feature", 247 "How to handle errors that are caused by more than data spot matching the same " + 248 "feature on the array design. This can for example be caused by invalid block and/or " + 249 "spot coordinates or using an incorrect feature or reporter ID column. " + 250 "If not specified the default error handling is used.\n\n"+ 251 "skip = Skip the current data line and continue\n"+ 252 "fail = Stop with an error message", 253 new StringParameterType(255, null, false, 1, 0, 0, 254 Arrays.asList( new String[] { "skip", "fail"} )) 255 ); 256 242 257 243 258 public static final String COMMAND_CONFIGURE_PARSER = "config_parser"; … … 475 490 storeValue(job, request, missingReporterErrorParameter); 476 491 storeValue(job, request, featureMismatchErrorParameter); 492 storeValue(job, request, duplicateFeatureErrorParameter); 477 493 storeValue(job, request, stringTooLongErrorParameter); 478 494 storeValue(job, request, invalidUseOfNullErrorParameter); … … 567 583 } 568 584 } 585 // Error handling for "duplicate feature" 586 String method = (String)job.getValue("duplicateFeatureError"); 587 if (method != null) 588 { 589 addErrorHandler(ItemAlreadyExistsException.class, new SimpleErrorHandler("skip".equals(method))); 590 } 591 569 592 } 570 593 … … 843 866 parameters.add(featureMismatchErrorParameter); 844 867 } 868 parameters.add(duplicateFeatureErrorParameter); 845 869 parameters.add(stringTooLongErrorParameter); 846 870 parameters.add(invalidUseOfNullErrorParameter); -
trunk/src/plugins/core/net/sf/basedb/plugins/ReporterMapFlatFileImporter.java
r4083 r4097 41 41 import net.sf.basedb.core.InvalidDataException; 42 42 import net.sf.basedb.core.InvalidUseOfNullException; 43 import net.sf.basedb.core.ItemAlreadyExistsException; 43 44 import net.sf.basedb.core.ItemContext; 44 45 import net.sf.basedb.core.ItemNotFoundException; … … 218 219 new StringParameterType(255, null, false, 1, 0, 0, 219 220 Arrays.asList( new String[] { "null", "skip", "fail"} )) 221 ); 222 223 protected static final PluginParameter<String> duplicateFeatureErrorParameter = new PluginParameter<String>( 224 "duplicateFeatureError", 225 "Duplicate feature", 226 "How to handle errors that are caused by more than one feature having the same " + 227 "identifier. If not specified the default error handling is used.\n\n" + 228 "skip = Skip the current data line and continue\n"+ 229 "fail = Stop with an error message", 230 new StringParameterType(255, null, false, 1, 0, 0, 231 Arrays.asList( new String[] {"skip", "fail"} )) 220 232 ); 221 233 … … 464 476 storeValue(job, request, defaultErrorParameter); 465 477 storeValue(job, request, missingReporterErrorParameter); 478 storeValue(job, request, duplicateFeatureErrorParameter); 466 479 storeValue(job, request, invalidUseOfNullErrorParameter); 467 480 storeValue(job, request, numberFormatErrorParameter); … … 509 522 reporterBatcher = ReporterBatcher.getNew(dc); 510 523 this.ffp = ffp; 524 // Error handling for "missing reporter" 511 525 String method = (String)job.getValue("missingReporterError"); 512 526 errorIfNotFound = !"null".equals(method); … … 514 528 { 515 529 addErrorHandler(ItemNotFoundException.class, new SimpleErrorHandler("skip".equals(method))); 530 } 531 // Error handling for "duplicate feature" 532 method = (String)job.getValue("duplicateFeatureError"); 533 if (method != null) 534 { 535 addErrorHandler(ItemAlreadyExistsException.class, new SimpleErrorHandler("skip".equals(method))); 516 536 } 517 537 if (job.getValue("file") != null) … … 692 712 parameters.add(defaultErrorParameter); 693 713 parameters.add(missingReporterErrorParameter); 714 parameters.add(duplicateFeatureErrorParameter); 694 715 parameters.add(invalidUseOfNullErrorParameter); 695 716 parameters.add(numberFormatErrorParameter); -
trunk/src/test/TestArrayDesign.java
r4093 r4097 36 36 import net.sf.basedb.core.DataFileType; 37 37 import net.sf.basedb.core.Item; 38 import net.sf.basedb.core.ItemAlreadyExistsException; 38 39 import net.sf.basedb.core.Permission; 39 40 import net.sf.basedb.core.ItemQuery; … … 583 584 featureData.setColumn(Integer.valueOf(parsedData.get(colCol))); 584 585 585 featureBatcher.insert(featureData); 586 i++; 586 try 587 { 588 featureBatcher.insert(featureData); 589 i++; 590 } 591 catch (ItemAlreadyExistsException ex) 592 { 593 // Ignore duplicate features 594 } 587 595 } 588 596 dc.commit(); -
trunk/src/test/TestRawBioAssay.java
r4093 r4097 509 509 extraData.put("ch2PercSat", Integer.valueOf(parsedData.get(25))); 510 510 511 rawDataBatcher.insert(rawData); 512 i++; 511 try 512 { 513 rawDataBatcher.insert(rawData); 514 i++; 515 } 516 catch (ItemAlreadyExistsException ex) 517 { 518 // Ignore duplicate features 519 } 513 520 } 514 521 dc.commit(); -
trunk/src/test/TestRawDataFlatFileImporter.java
r3820 r4097 190 190 request.setParameterValue("numberFormatError", "null"); 191 191 request.setParameterValue("decimalSeparator", "dot"); 192 request.setParameterValue("duplicateFeatureError", "skip"); 192 193 193 194 PluginResponse response = request.invoke(); -
trunk/src/test/data/test.rawdata.import.txt
r2959 r4097 607 607 1 23 24 "EST" "1629538" 6085 6020 130 452 453 57 331 335 23 95 91 0 503 503 74 306 311 18 99 97 0 1.628 1.615 1.660 1.710 1.899 1.615 0.701 540 2091 318 319 0.703 121 197 122 197 244644 271708 5.130 10.667 0 0 608 608 1 24 24 "2580289" "B-actin_1/4" 6255 6025 135 1011 1161 391 334 373 434 92 32 0 1506 1743 707 312 383 660 94 42 0 1.764 1.730 1.725 1.707 1.210 1.762 0.962 540 2289 1871 2258 0.819 677 1194 827 1431 627065 941279 1.816 2.061 0 0 609 1 1 1 "2580289" "B-actin_1/4" 2040 1730 135 887 1003 360 320 324 23 100 100 0 1138 1376 592 302 305 11 100 100 0 1.474 1.572 1.568 1.562 1.239 1.614 0.955 540 2328 1403 1757 0.560 567 836 683 1074 541800 743047 29.522 97.364 0 0
Note: See TracChangeset
for help on using the changeset viewer.