Changeset 2938
- Timestamp:
- Nov 20, 2006, 11:24:12 AM (16 years ago)
- Location:
- trunk/src/test/net/sf/basedb/test
- Files:
-
- 7 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/test/net/sf/basedb/test/TestUtil.java
r2568 r2938 194 194 System.out.print(msg); 195 195 } 196 private static final long MB = 1024 * 1024; 197 public static void gc() 198 { 199 Runtime rt = Runtime.getRuntime(); 200 long freeBefore = rt.freeMemory() / MB; 201 System.gc(); 202 long freeAfter = rt.freeMemory() / MB; 203 write("Free memory: before=" + freeBefore + "MB; after=" + freeAfter + "MB\n"); 204 } 196 205 197 206 } -
trunk/src/test/net/sf/basedb/test/merge/MergeTest.java
r2815 r2938 68 68 import net.sf.basedb.core.query.Selects; 69 69 import net.sf.basedb.core.query.SqlResult; 70 import net.sf.basedb.test.PluginUtil; 70 71 import net.sf.basedb.test.TestUtil; 71 72 import net.sf.basedb.test.roles.Util; … … 304 305 dc.saveItem(job); 305 306 dc.commit(); 306 Util.executeJob(job);307 PluginUtil.executeJob(job); 307 308 308 309 dc = TestUtil.getDbControl(); -
trunk/src/test/net/sf/basedb/test/roles/AnalysisTest.java
r2751 r2938 36 36 import net.sf.basedb.core.RawDataTypes; 37 37 import net.sf.basedb.core.StringParameterType; 38 import net.sf.basedb.test.PluginUtil; 38 39 import net.sf.basedb.test.TestUtil; 39 40 … … 112 113 dc.saveItem(job); 113 114 dc.commit(); 114 Util.executeJob(job);115 PluginUtil.executeJob(job); 115 116 116 117 dc = TestUtil.getDbControl(); … … 144 145 dc.saveItem(job); 145 146 dc.commit(); 146 Util.executeJob(job);147 PluginUtil.executeJob(job); 147 148 148 149 dc = TestUtil.getDbControl(); … … 180 181 dc.saveItem(job); 181 182 dc.commit(); 182 Util.executeJob(job);183 PluginUtil.executeJob(job); 183 184 184 185 dc = TestUtil.getDbControl(); -
trunk/src/test/net/sf/basedb/test/roles/PowerUserTest.java
r2751 r2938 25 25 26 26 import java.util.Arrays; 27 import java.util.Collections;28 27 import java.util.EnumSet; 29 import java.util.HashMap;30 28 import java.util.List; 31 import java.util.Map;32 29 33 30 import net.sf.basedb.core.AnnotationType; … … 35 32 import net.sf.basedb.core.ArrayDesign; 36 33 import net.sf.basedb.core.ArraySlide; 37 import net.sf.basedb.core.BaseException;38 import net.sf.basedb.core.BooleanParameterType;39 34 import net.sf.basedb.core.DbControl; 40 35 import net.sf.basedb.core.File; … … 48 43 import net.sf.basedb.core.ItemParameterType; 49 44 import net.sf.basedb.core.Job; 50 import net.sf.basedb.core.ParameterType;51 45 import net.sf.basedb.core.Permission; 52 46 import net.sf.basedb.core.Plate; … … 63 57 import net.sf.basedb.core.SystemItems; 64 58 import net.sf.basedb.core.Type; 59 import net.sf.basedb.test.FileUtil; 60 import net.sf.basedb.test.MouseData; 61 import net.sf.basedb.test.PluginUtil; 65 62 import net.sf.basedb.test.TestUtil; 66 63 … … 133 130 PlateType plateType = createPlateType(dc, "Plate type A", 16, 24); 134 131 135 PluginConfiguration platesImporter = createPluginConfiguration(dc, "Plates for project A",136 "net.sf.basedb.plugins.PlateFlatFileImporter", getPlateParameters());137 138 PluginConfiguration reporterImporter = createPluginConfiguration(dc, "Reporters for project A",139 "net.sf.basedb.plugins.ReporterFlatFileImporter", getReporterParameters());140 141 PluginConfiguration genePixReporterImporter = createPluginConfiguration(dc, "Reporters from GenePix file",142 "net.sf.basedb.plugins.ReporterFlatFileImporter", getGenePixReporterParameters());143 144 PluginConfiguration genePixFeatureImporter = createPluginConfiguration(dc, "Features from GenePix file",145 "net.sf.basedb.plugins.ReporterMapFlatFileImporter", getGenePixReporterMapParameters());132 PluginConfiguration platesImporter = PluginUtil.createPluginConfiguration(dc, "Plates for project A", 133 "net.sf.basedb.plugins.PlateFlatFileImporter", MouseData.getPlateParameters()); 134 135 PluginConfiguration reporterImporter = PluginUtil.createPluginConfiguration(dc, "Reporters for project A", 136 "net.sf.basedb.plugins.ReporterFlatFileImporter", MouseData.getReporterParameters()); 137 138 PluginConfiguration genePixReporterImporter = PluginUtil.createPluginConfiguration(dc, "Reporters from GenePix file", 139 "net.sf.basedb.plugins.ReporterFlatFileImporter", MouseData.getGenePixReporterParameters()); 140 141 PluginConfiguration genePixFeatureImporter = PluginUtil.createPluginConfiguration(dc, "Features from GenePix file", 142 "net.sf.basedb.plugins.ReporterMapFlatFileImporter", MouseData.getGenePixReporterMapParameters()); 146 143 147 144 PluginDefinition printMapImporter = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.PrintMapFlatFileImporter"); 148 145 149 PluginConfiguration rawDataImporter = createPluginConfiguration(dc, "Raw data for project A",150 "net.sf.basedb.plugins.RawDataFlatFileImporter", getGenePixRawDataParameters(false));151 152 PluginConfiguration rawDataImporterDyeSwap = createPluginConfiguration(dc, "Raw data for project A (dye-swap)",153 "net.sf.basedb.plugins.RawDataFlatFileImporter", getGenePixRawDataParameters(true));154 155 dc.commit(); 156 157 dc = TestUtil.getDbControl(); 158 159 File plates = Util.uploadFile(dc, "plates_and_reporters.mouse.v4.37k.txt", FileType.PLATE);146 PluginConfiguration rawDataImporter = PluginUtil.createPluginConfiguration(dc, "Raw data for project A", 147 "net.sf.basedb.plugins.RawDataFlatFileImporter", MouseData.getGenePixRawDataParameters(false)); 148 149 PluginConfiguration rawDataImporterDyeSwap = PluginUtil.createPluginConfiguration(dc, "Raw data for project A (dye-swap)", 150 "net.sf.basedb.plugins.RawDataFlatFileImporter", MouseData.getGenePixRawDataParameters(true)); 151 152 dc.commit(); 153 154 dc = TestUtil.getDbControl(); 155 156 File plates = FileUtil.uploadFile(dc, "plates_and_reporters.mouse.v4.37k.txt", FileType.PLATE); 160 157 File reporters = plates; // Reporter info is found in the plate file 161 File printMap = Util.uploadFile(dc, "printmap.mouse.v4.37k.tam", FileType.PRINT_MAP);162 163 dc.commit(); 164 165 importReporters(reporterImporter, reporters);158 File printMap = FileUtil.uploadFile(dc, "printmap.mouse.v4.37k.tam", FileType.PRINT_MAP); 159 160 dc.commit(); 161 162 PluginUtil.importReporters(reporterImporter, reporters); 166 163 importPlates(platesImporter, plates, "Plate A", plateType); 167 164 … … 334 331 } 335 332 336 public static PluginConfiguration createPluginConfiguration(DbControl dc, String name, String className, Map<String, Object> parameters)337 {338 TestUtil.write("--Creating plugin configuration: " + name + "\n");339 340 PluginDefinition definition = PluginDefinition.getByClassName(dc, className);341 PluginConfiguration config = PluginConfiguration.getNew(dc, definition);342 config.setName(name);343 if (parameters != null)344 {345 ParameterType stringType = new StringParameterType();346 ParameterType intType = new IntegerParameterType();347 for (Map.Entry<String, Object> param : parameters.entrySet())348 {349 Object value = param.getValue();350 List<?> values = Collections.singletonList(value);351 if (value instanceof String)352 {353 config.setParameterValues(param.getKey(), stringType, values);354 }355 else if (value instanceof Integer)356 {357 config.setParameterValues(param.getKey(), intType, values);358 }359 else360 {361 throw new BaseException("Invalid paramater type: " + value);362 }363 }364 }365 366 dc.saveItem(config);367 return config;368 }369 370 /**371 Import reporters.372 */373 public static void importReporters(PluginConfiguration config, File file)374 throws Exception375 {376 TestUtil.write("--Importing reporters from file: " + file.getName() + "\n");377 378 DbControl dc = TestUtil.getDbControl();379 try380 {381 config = PluginConfiguration.getById(dc, config.getId());382 Job job = Job.getNew(dc, config.getPluginDefinition(), config);383 job.setName("Importing reporters for project A");384 job.setParameterValue("file", new FileParameterType(), file);385 job.setParameterValue("updateExisting", new BooleanParameterType(), true);386 job.setParameterValue("invalidUseOfNullError", new StringParameterType(), "skip");387 dc.saveItem(job);388 dc.commit();389 Util.executeJob(job);390 }391 finally392 {393 if (dc != null) dc.close();394 }395 }396 397 333 public static void importPlates(PluginConfiguration config, File file, String plateNamePrefix, PlateType plateType) 398 334 { … … 411 347 dc.saveItem(job); 412 348 dc.commit(); 413 Util.executeJob(job);349 PluginUtil.executeJob(job); 414 350 } 415 351 finally … … 439 375 dc.saveItem(job); 440 376 dc.commit(); 441 Util.executeJob(job);377 PluginUtil.executeJob(job); 442 378 } 443 379 finally … … 446 382 } 447 383 } 448 449 450 /**451 Get configuration parameters required for the raw data importer.452 */453 public static Map<String, Object> getGenePixRawDataParameters(boolean dyeSwap)454 {455 Map<String, Object> parameters = new HashMap<String, Object>();456 parameters.put("rawDataType", "genepix");457 parameters.put("headerRegexp", "\"(.+)=(.*)\"");458 parameters.put("dataSplitterRegexp", "\\t");459 //parameters.put("ignoreRegexp", ".*(NoOligoInfo|no clone).*");460 if (dyeSwap)461 {462 parameters.put("dataHeaderRegexp", "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*\"Ratio of Medians \\(635\\/532\\)\".*");463 }464 else465 {466 parameters.put("dataHeaderRegexp", "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*\"Ratio of Medians \\(532\\/635\\)\".*");467 }468 parameters.put("minDataColumns", 48);469 parameters.put("maxDataColumns", 48);470 471 parameters.put("blockColumnMapping", "\\Block\\");472 parameters.put("columnColumnMapping", "\\Column\\");473 parameters.put("rowColumnMapping", "\\Row\\");474 parameters.put("reporterIdColumnMapping", "\\ID\\");475 parameters.put("xColumnMapping", "\\X\\");476 parameters.put("yColumnMapping", "\\Y\\");477 parameters.put("propertyMapping.diameter", "\\Dia.\\");478 int chF635 = dyeSwap ? 2 : 1;479 int chF532 = dyeSwap ? 1 : 2;480 parameters.put("propertyMapping.ch"+chF635+"FgMedian", "\\F635 Median\\");481 parameters.put("propertyMapping.ch"+chF635+"FgMean", "\\F635 Mean\\");482 parameters.put("propertyMapping.ch"+chF635+"FgSd", "\\F635 SD\\");483 parameters.put("propertyMapping.ch"+chF635+"BgMedian", "\\B635 Median\\");484 parameters.put("propertyMapping.ch"+chF635+"BgMean", "\\B635 Mean\\");485 parameters.put("propertyMapping.ch"+chF635+"BgSd", "\\B635 SD\\");486 parameters.put("propertyMapping.ch"+chF635+"PercSd1", "\\% > B635+1SD\\");487 parameters.put("propertyMapping.ch"+chF635+"PercSd2", "\\% > B635+2SD\\");488 parameters.put("propertyMapping.ch"+chF635+"PercSat", "\\F635 % Sat.\\");489 490 parameters.put("propertyMapping.ch"+chF532+"FgMedian", "\\F532 Median\\");491 parameters.put("propertyMapping.ch"+chF532+"FgMean", "\\F532 Mean\\");492 parameters.put("propertyMapping.ch"+chF532+"FgSd", "\\F532 SD\\");493 parameters.put("propertyMapping.ch"+chF532+"BgMedian", "\\B532 Median\\");494 parameters.put("propertyMapping.ch"+chF532+"BgMean", "\\B532 Mean\\");495 parameters.put("propertyMapping.ch"+chF532+"BgSd", "\\B532 SD\\");496 parameters.put("propertyMapping.ch"+chF532+"PercSd1", "\\% > B532+1SD\\");497 parameters.put("propertyMapping.ch"+chF532+"PercSd2", "\\% > B532+2SD\\");498 parameters.put("propertyMapping.ch"+chF532+"PercSat", "\\F532 % Sat.\\");499 500 parameters.put("propertyMapping.fgPixels", "\\F Pixels\\");501 parameters.put("propertyMapping.bgPixels", "\\B Pixels\\");502 parameters.put("propertyMapping.flags", "\\Flags\\");503 504 return parameters;505 }506 507 /**508 Get configuration parameters required for the reporter importer.509 */510 public static Map<String, Object> getReporterParameters()511 {512 Map<String, Object> parameters = new HashMap<String, Object>();513 parameters.put("dataSplitterRegexp", "\\t");514 parameters.put("dataHeaderRegexp", "384_number\\t384_column\\t384_row\\t384_position\\toligo_id.*");515 parameters.put("minDataColumns", 5);516 517 parameters.put("reporterIdColumnMapping", "\\oligo_id\\");518 parameters.put("nameColumnMapping", "\\oligo_id\\");519 parameters.put("symbolColumnMapping", "\\gene_symbol_Ensembl*\\");520 parameters.put("descriptionColumnMapping", "\\description_Ensembl*\\");521 522 parameters.put("extendedColumnMapping.sequence", "\\oligo_sequence\\");523 return parameters;524 }525 526 /**527 Get configuration parameters required for importing reporters from a GenePix raw data file.528 */529 public static Map<String, Object> getGenePixReporterParameters()530 {531 Map<String, Object> parameters = new HashMap<String, Object>();532 parameters.put("dataSplitterRegexp", "\\t");533 parameters.put("dataHeaderRegexp", "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*");534 parameters.put("minDataColumns", 48);535 parameters.put("maxDataColumns", 48);536 537 parameters.put("reporterIdColumnMapping", "\\ID\\");538 parameters.put("nameColumnMapping", "\\Name\\");539 540 // No extended properties are available in the file541 return parameters;542 }543 544 /**545 Get configuration parameters required for importing features from a GenePix raw data file.546 */547 public static Map<String, Object> getGenePixReporterMapParameters()548 {549 Map<String, Object> parameters = new HashMap<String, Object>();550 parameters.put("dataSplitterRegexp", "\\t");551 parameters.put("dataHeaderRegexp", "\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*");552 parameters.put("minDataColumns", 48);553 parameters.put("maxDataColumns", 48);554 555 parameters.put("reporterIdColumnMapping", "\\ID\\");556 parameters.put("blockColumnMapping", "\\Block\\");557 parameters.put("columnColumnMapping", "\\Column\\");558 parameters.put("rowColumnMapping", "\\Row\\");559 560 return parameters;561 }562 563 /**564 Get configuration parameters required for the plate importer.565 */566 public static Map<String, Object> getPlateParameters()567 {568 Map<String, Object> parameters = new HashMap<String, Object>();569 parameters.put("dataSplitterRegexp", "\\t");570 parameters.put("dataHeaderRegexp", "384_number\\t384_column\\t384_row\\t384_position\\toligo_id.*");571 parameters.put("minDataColumns", 5);572 573 parameters.put("reporterColumnMapping", "\\oligo_id\\");574 parameters.put("nameColumnMapping", "\\384_number\\");575 parameters.put("rowColumnMapping", "\\384_row\\");576 parameters.put("columnColumnMapping", "\\384_column\\");577 578 return parameters;579 }580 384 581 385 } -
trunk/src/test/net/sf/basedb/test/roles/UserTest.java
r2751 r2938 49 49 import net.sf.basedb.core.Scan; 50 50 import net.sf.basedb.core.StringParameterType; 51 import net.sf.basedb.test.FileUtil; 52 import net.sf.basedb.test.PluginUtil; 51 53 import net.sf.basedb.test.TestUtil; 52 54 … … 131 133 // Upload raw data files 132 134 dc = TestUtil.getDbControl(); 133 File rawData1 = Util.uploadFile(dc, "genepix.mouse.v4.37k.00h.gpr", FileType.RAW_DATA);134 File rawData2 = Util.uploadFile(dc, "genepix.mouse.v4.37k.24h.gpr", FileType.RAW_DATA);135 File rawData1DyeSwap = Util.uploadFile(dc, "genepix.mouse.v4.37k.00h.dyeswap.gpr", FileType.RAW_DATA);136 File rawData2DyeSwap = Util.uploadFile(dc, "genepix.mouse.v4.37k.24h.dyeswap.gpr", FileType.RAW_DATA);135 File rawData1 = FileUtil.uploadFile(dc, "genepix.mouse.v4.37k.00h.gpr", FileType.RAW_DATA); 136 File rawData2 = FileUtil.uploadFile(dc, "genepix.mouse.v4.37k.24h.gpr", FileType.RAW_DATA); 137 File rawData1DyeSwap = FileUtil.uploadFile(dc, "genepix.mouse.v4.37k.00h.dyeswap.gpr", FileType.RAW_DATA); 138 File rawData2DyeSwap = FileUtil.uploadFile(dc, "genepix.mouse.v4.37k.24h.dyeswap.gpr", FileType.RAW_DATA); 137 139 PluginConfiguration rawDataImporter = Util.findPluginConfiguration(dc, "Raw data for project A"); 138 140 PluginConfiguration rawDataImporterDyeSwap = Util.findPluginConfiguration(dc, "Raw data for project A (dye-swap)"); … … 325 327 dc.saveItem(job); 326 328 dc.commit(); 327 Util.executeJob(job);329 PluginUtil.executeJob(job); 328 330 } 329 331 finally -
trunk/src/test/net/sf/basedb/test/roles/Util.java
r2582 r2938 33 33 import net.sf.basedb.core.ArrayDesign; 34 34 import net.sf.basedb.core.ArraySlide; 35 import net.sf.basedb.core.BaseException;36 35 import net.sf.basedb.core.BioAssaySet; 37 36 import net.sf.basedb.core.DbControl; 38 import net.sf.basedb.core.Directory;39 37 import net.sf.basedb.core.Experiment; 40 import net.sf.basedb.core.File;41 import net.sf.basedb.core.FileType;42 38 import net.sf.basedb.core.Formula; 43 39 import net.sf.basedb.core.Group; … … 46 42 import net.sf.basedb.core.Item; 47 43 import net.sf.basedb.core.ItemQuery; 48 import net.sf.basedb.core.Job;49 44 import net.sf.basedb.core.Label; 50 45 import net.sf.basedb.core.Plate; 51 46 import net.sf.basedb.core.PlateGeometry; 52 47 import net.sf.basedb.core.PluginConfiguration; 53 import net.sf.basedb.core.PluginExecutionRequest;54 import net.sf.basedb.core.PluginResponse;55 48 import net.sf.basedb.core.Project; 56 49 import net.sf.basedb.core.Protocol; … … 59 52 import net.sf.basedb.core.Role; 60 53 import net.sf.basedb.core.Software; 61 import net.sf.basedb.core.SystemItems;62 54 import net.sf.basedb.core.User; 63 import net.sf.basedb.core.plugin.Response;64 55 import net.sf.basedb.core.query.Expressions; 65 56 import net.sf.basedb.core.query.Hql; 66 57 import net.sf.basedb.core.query.Orders; 67 58 import net.sf.basedb.core.query.Restrictions; 68 import net.sf.basedb.test.TestUtil;69 import net.sf.basedb.util.ConsoleProgressReporter;70 59 71 60 /** … … 282 271 return query.list(dc).get(0); 283 272 } 284 285 /**286 Upload a file to the logged in user's home directory.287 */288 public static File uploadFile(DbControl dc, String filename, String fileTypeId)289 throws Exception290 {291 String path = "/mouse/" + filename;292 TestUtil.write("--Uploading file: " + path + "\n");293 294 Directory home = User.getById(dc, dc.getSessionControl().getLoggedInUserId()).getHomeDirectory();295 File file = File.getFile(dc, home, filename, true);296 if (fileTypeId != null)297 {298 file.setFileType(FileType.getById(dc, SystemItems.getId(fileTypeId)));299 }300 if (!file.isInDatabase()) dc.saveItem(file);301 302 file.upload(TestUtil.class.getResourceAsStream(path), false);303 return file;304 }305 306 /**307 Execute a job.308 @param job309 */310 public static void executeJob(Job job)311 {312 TestUtil.write("--Executing job: " + job.getName() + "\n");313 DbControl dc = TestUtil.getDbControl();314 job = Job.getById(dc, job.getId());315 PluginExecutionRequest request =316 job.execute(new ConsoleProgressReporter(false), TestUtil.getLocalIp());317 dc.commit();318 319 PluginResponse response = request.invoke();320 if (response.getStatus() == Response.Status.ERROR)321 {322 throw new BaseException(response.getMessage(), response.getErrorList().get(0));323 }324 TestUtil.write("--Job ended successfully: " + response.getMessage() + "\n");325 }326 273 327 274 }
Note: See TracChangeset
for help on using the changeset viewer.