Changeset 2938


Ignore:
Timestamp:
Nov 20, 2006, 11:24:12 AM (16 years ago)
Author:
Nicklas Nordborg
Message:

Added performance test program

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  
    194194    System.out.print(msg);
    195195  }
     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  }
    196205
    197206}
  • trunk/src/test/net/sf/basedb/test/merge/MergeTest.java

    r2815 r2938  
    6868import net.sf.basedb.core.query.Selects;
    6969import net.sf.basedb.core.query.SqlResult;
     70import net.sf.basedb.test.PluginUtil;
    7071import net.sf.basedb.test.TestUtil;
    7172import net.sf.basedb.test.roles.Util;
     
    304305      dc.saveItem(job);
    305306      dc.commit();
    306       Util.executeJob(job);
     307      PluginUtil.executeJob(job);
    307308     
    308309      dc = TestUtil.getDbControl();
  • trunk/src/test/net/sf/basedb/test/roles/AnalysisTest.java

    r2751 r2938  
    3636import net.sf.basedb.core.RawDataTypes;
    3737import net.sf.basedb.core.StringParameterType;
     38import net.sf.basedb.test.PluginUtil;
    3839import net.sf.basedb.test.TestUtil;
    3940
     
    112113      dc.saveItem(job);
    113114      dc.commit();
    114       Util.executeJob(job);
     115      PluginUtil.executeJob(job);
    115116     
    116117      dc = TestUtil.getDbControl();
     
    144145      dc.saveItem(job);
    145146      dc.commit();
    146       Util.executeJob(job);
     147      PluginUtil.executeJob(job);
    147148     
    148149      dc = TestUtil.getDbControl();
     
    180181      dc.saveItem(job);
    181182      dc.commit();
    182       Util.executeJob(job);
     183      PluginUtil.executeJob(job);
    183184     
    184185      dc = TestUtil.getDbControl();
  • trunk/src/test/net/sf/basedb/test/roles/PowerUserTest.java

    r2751 r2938  
    2525
    2626import java.util.Arrays;
    27 import java.util.Collections;
    2827import java.util.EnumSet;
    29 import java.util.HashMap;
    3028import java.util.List;
    31 import java.util.Map;
    3229
    3330import net.sf.basedb.core.AnnotationType;
     
    3532import net.sf.basedb.core.ArrayDesign;
    3633import net.sf.basedb.core.ArraySlide;
    37 import net.sf.basedb.core.BaseException;
    38 import net.sf.basedb.core.BooleanParameterType;
    3934import net.sf.basedb.core.DbControl;
    4035import net.sf.basedb.core.File;
     
    4843import net.sf.basedb.core.ItemParameterType;
    4944import net.sf.basedb.core.Job;
    50 import net.sf.basedb.core.ParameterType;
    5145import net.sf.basedb.core.Permission;
    5246import net.sf.basedb.core.Plate;
     
    6357import net.sf.basedb.core.SystemItems;
    6458import net.sf.basedb.core.Type;
     59import net.sf.basedb.test.FileUtil;
     60import net.sf.basedb.test.MouseData;
     61import net.sf.basedb.test.PluginUtil;
    6562import net.sf.basedb.test.TestUtil;
    6663
     
    133130      PlateType plateType = createPlateType(dc, "Plate type A", 16, 24);
    134131     
    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());
    146143     
    147144      PluginDefinition printMapImporter = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.PrintMapFlatFileImporter");
    148145
    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);
    160157      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);
    166163      importPlates(platesImporter, plates, "Plate A", plateType);
    167164     
     
    334331  }
    335332 
    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         else
    360         {
    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 Exception
    375   {
    376     TestUtil.write("--Importing reporters from file: " + file.getName() + "\n");
    377    
    378     DbControl dc = TestUtil.getDbControl();
    379     try
    380     {
    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     finally
    392     {
    393       if (dc != null) dc.close();
    394     }
    395   }
    396 
    397333  public static void importPlates(PluginConfiguration config, File file, String plateNamePrefix, PlateType plateType)
    398334  {
     
    411347      dc.saveItem(job);
    412348      dc.commit();
    413       Util.executeJob(job);
     349      PluginUtil.executeJob(job);
    414350    }
    415351    finally
     
    439375      dc.saveItem(job);
    440376      dc.commit();
    441       Util.executeJob(job);
     377      PluginUtil.executeJob(job);
    442378    }
    443379    finally
     
    446382    }
    447383  }
    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     else
    465     {
    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 file
    541     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   }
    580384 
    581385}
  • trunk/src/test/net/sf/basedb/test/roles/UserTest.java

    r2751 r2938  
    4949import net.sf.basedb.core.Scan;
    5050import net.sf.basedb.core.StringParameterType;
     51import net.sf.basedb.test.FileUtil;
     52import net.sf.basedb.test.PluginUtil;
    5153import net.sf.basedb.test.TestUtil;
    5254
     
    131133      // Upload raw data files
    132134      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);
    137139      PluginConfiguration rawDataImporter = Util.findPluginConfiguration(dc, "Raw data for project A");
    138140      PluginConfiguration rawDataImporterDyeSwap = Util.findPluginConfiguration(dc, "Raw data for project A (dye-swap)");
     
    325327      dc.saveItem(job);
    326328      dc.commit();
    327       Util.executeJob(job);
     329      PluginUtil.executeJob(job);
    328330    }
    329331    finally
  • trunk/src/test/net/sf/basedb/test/roles/Util.java

    r2582 r2938  
    3333import net.sf.basedb.core.ArrayDesign;
    3434import net.sf.basedb.core.ArraySlide;
    35 import net.sf.basedb.core.BaseException;
    3635import net.sf.basedb.core.BioAssaySet;
    3736import net.sf.basedb.core.DbControl;
    38 import net.sf.basedb.core.Directory;
    3937import net.sf.basedb.core.Experiment;
    40 import net.sf.basedb.core.File;
    41 import net.sf.basedb.core.FileType;
    4238import net.sf.basedb.core.Formula;
    4339import net.sf.basedb.core.Group;
     
    4642import net.sf.basedb.core.Item;
    4743import net.sf.basedb.core.ItemQuery;
    48 import net.sf.basedb.core.Job;
    4944import net.sf.basedb.core.Label;
    5045import net.sf.basedb.core.Plate;
    5146import net.sf.basedb.core.PlateGeometry;
    5247import net.sf.basedb.core.PluginConfiguration;
    53 import net.sf.basedb.core.PluginExecutionRequest;
    54 import net.sf.basedb.core.PluginResponse;
    5548import net.sf.basedb.core.Project;
    5649import net.sf.basedb.core.Protocol;
     
    5952import net.sf.basedb.core.Role;
    6053import net.sf.basedb.core.Software;
    61 import net.sf.basedb.core.SystemItems;
    6254import net.sf.basedb.core.User;
    63 import net.sf.basedb.core.plugin.Response;
    6455import net.sf.basedb.core.query.Expressions;
    6556import net.sf.basedb.core.query.Hql;
    6657import net.sf.basedb.core.query.Orders;
    6758import net.sf.basedb.core.query.Restrictions;
    68 import net.sf.basedb.test.TestUtil;
    69 import net.sf.basedb.util.ConsoleProgressReporter;
    7059
    7160/**
     
    282271    return query.list(dc).get(0);
    283272  }
    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 Exception
    290   {
    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 job
    309   */
    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   }
    326273 
    327274}
Note: See TracChangeset for help on using the changeset viewer.