Changeset 4628


Ignore:
Timestamp:
Nov 5, 2008, 4:43:03 PM (15 years ago)
Author:
Martin Svensson
Message:

References #1151 Refactored to better use the existing code in the roles test. There is a risk the changes can effect the existing test program, this is not yet checked.

Location:
trunk/src/test/net/sf/basedb/test/roles
Files:
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/test/net/sf/basedb/test/roles/PowerUserTest.java

    r4548 r4628  
    9797    Run the tests in this class.
    9898  */
    99   public static boolean run()
     99  public static boolean run(boolean useBatchImporters)
    100100  {
    101101    DbControl dc = null;
     
    162162      Util.setAnnotation(rawDataImporterDyeSwap, dyeSwap, true, null);
    163163     
     164      PluginDefinition arrayDesignImporter = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.batchimport.ArrayDesignImporter");
     165      PluginDefinition arrayBatchImporter = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.batchimport.ArrayBatchImporter");
     166      PluginDefinition arraySlideImporter = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.batchimport.ArraySlideImporter");
     167           
    164168      dc.commit();
    165169     
     
    169173      File printMap = FileUtil.uploadFile(dc, "/mouse", "printmap.mouse.v4.37k.tam", FileType.PRINT_MAP);
    170174      File cdfFile = FileUtil.uploadFile(dc, "/affymetrix/cdf", "MG_U74Av2.cdf.tar.bz2", FileType.REPORTER_MAP);
     175      File batchImportFile_ArrayBatch = null;
     176      File batchImportFile_ArrayDesign = null;
     177      File batchImportFile_ArraySlide = null;
     178      if (useBatchImporters)
     179      {
     180        batchImportFile_ArrayBatch = FileUtil.uploadFile(dc, "/batchimport", "arraybatch_out.txt", null);
     181        batchImportFile_ArrayDesign = FileUtil.uploadFile(dc, "/batchimport", "arraydesign_out.txt", null);
     182        batchImportFile_ArraySlide = FileUtil.uploadFile(dc, "/batchimport", "arrayslide_out.txt", null);
     183      }
    171184      dc.commit();
    172185     
    173186      importPlates(platesImporter, plates, "Plate A", plateType);
    174187     
     188      ArrayDesign design = null;
     189      ArrayDesign affyDesign = null;
    175190      dc = TestUtil.getDbControl();
    176191      Platform genericPlatform = Platform.getByExternalId(dc, Platform.GENERIC);
    177192      Platform affymetrixPlatform = Platform.getByExternalId(dc, Platform.AFFYMETRIX);
    178       ArrayDesign design = createArrayDesign(dc, genericPlatform, "Array design A");
    179       FileUtil.addDataFile(dc, design, DataFileType.GENERIC_PRINT_MAP, printMap, true, true);
    180       ArrayDesign affyDesign = createArrayDesign(dc, affymetrixPlatform, "Affymetrix A");
    181       FileUtil.addDataFile(dc, affyDesign, DataFileType.AFFYMETRIX_CDF, cdfFile, true, true);
    182       dc.commit();
    183 
     193      if (!useBatchImporters)
     194      {
     195        design = createArrayDesign(dc, genericPlatform, "Array design A");
     196        FileUtil.addDataFile(dc, design, DataFileType.GENERIC_PRINT_MAP, printMap, true, true);
     197        affyDesign = createArrayDesign(dc, affymetrixPlatform, "Affymetrix A");
     198        FileUtil.addDataFile(dc, affyDesign, DataFileType.AFFYMETRIX_CDF, cdfFile, true, true);
     199      }
     200      else
     201      {
     202        importArrayDesigns(arrayDesignImporter, batchImportFile_ArrayDesign);
     203        design = Util.findArrayDesign(dc, "Array design A");
     204        assert design != null : "Could not find expected Array design: 'Array design A'";
     205        design.setPlateList(Util.findPlates(dc));               
     206      }
     207      dc.commit();
     208     
    184209      importFeatures(printMapImporter, printMap, design);
    185210     
     
    201226      p.setDefaultItem(dc, feature, Project.Default.FEATURE_EXTRACTION_PROTOCOL);
    202227      p.setDefaultItem(dc, printing, Project.Default.PRINTING_PROTOCOL); 
    203      
    204       ArrayBatch batch = createArrayBatch(dc, "Array batch A", design, robot, printing);
    205       ArraySlide slide1 = createArraySlide(dc, "Array slide A.1", batch, 1);
    206       ArraySlide slide2 = createArraySlide(dc, "Array slide A.2", batch, 2);
    207       ArraySlide slide3 = createArraySlide(dc, "Array slide A.3", batch, 3);
    208       ArraySlide slide4 = createArraySlide(dc, "Array slide A.4", batch, 4);
    209      
    210       // Affymetrix
    211       ArrayBatch affyBatch = createArrayBatch(dc, "Affymetrix batch A", affyDesign, null, null);
    212       ArraySlide affySlide1 = createArraySlide(dc, "Affymetrix slide A.1", affyBatch, 1);
    213       ArraySlide affySlide2 = createArraySlide(dc, "Affymetrix slide A.2", affyBatch, 2);
    214       ArraySlide affySlide3 = createArraySlide(dc, "Affymetrix slide A.3", affyBatch, 3);
    215       dc.commit();
    216 
     228      dc.commit();
     229      if (!useBatchImporters)
     230      {
     231        dc = TestUtil.getDbControl();
     232        ArrayBatch batch = createArrayBatch(dc, "Array batch A", design, robot, printing);
     233        ArraySlide slide1 = createArraySlide(dc, "Array slide A.1", batch, 1);
     234        ArraySlide slide2 = createArraySlide(dc, "Array slide A.2", batch, 2);
     235        ArraySlide slide3 = createArraySlide(dc, "Array slide A.3", batch, 3);
     236        ArraySlide slide4 = createArraySlide(dc, "Array slide A.4", batch, 4);
     237       
     238        // Affymetrix
     239        ArrayBatch affyBatch = createArrayBatch(dc, "Affymetrix batch A", affyDesign, null, null);
     240        ArraySlide affySlide1 = createArraySlide(dc, "Affymetrix slide A.1", affyBatch, 1);
     241        ArraySlide affySlide2 = createArraySlide(dc, "Affymetrix slide A.2", affyBatch, 2);
     242        ArraySlide affySlide3 = createArraySlide(dc, "Affymetrix slide A.3", affyBatch, 3);
     243        dc.commit();
     244      }
     245      else
     246      {
     247        importArrayBatches(arrayBatchImporter, batchImportFile_ArrayBatch);
     248        importArraySlides(arraySlideImporter, batchImportFile_ArraySlide);
     249      }
    217250      TestUtil.logout();
    218251    }
     
    426459  }
    427460 
     461  public static void importArrayBatches(PluginDefinition batchImporter, File file)
     462  {
     463    TestUtil.write("--Importing array batches from file: " + file + "\n");
     464    DbControl dc = null;
     465    try
     466    {
     467      dc = TestUtil.getDbControl();
     468      PluginDefinition plugin = PluginDefinition.getById(dc, batchImporter.getId());
     469      Job job = Job.getNew(dc, plugin, null, null);
     470      job.setName("Batch import of Array batches to Project A");
     471      job.setParameterValue("file", new FileParameterType(), file);
     472      job.setParameterValue("dataSplitterRegexp", new StringParameterType(), "\\t");
     473      job.setParameterValue("dataHeaderRegexp", new StringParameterType(), "Name\\tArray design\\tDescription\\tProtocol\\tPrint robot");
     474     
     475      job.setParameterValue("nameColumnMapping", new StringParameterType(), "\\Name\\");
     476      job.setParameterValue("descriptionColumnMapping", new StringParameterType(), "\\Description\\");
     477      job.setParameterValue("hardwareColumnMapping", new StringParameterType(), "\\Print robot\\");
     478      job.setParameterValue("arrayDesignColumnMapping", new StringParameterType(), "\\Array design\\");
     479      job.setParameterValue("protocolColumnMapping", new StringParameterType(), "\\Protocol\\");
     480     
     481      dc.saveItem(job);
     482      dc.commit();
     483      PluginUtil.executeJob(job);
     484    }
     485    finally
     486    {
     487      if (dc != null) dc.close();
     488    }
     489   
     490  }
     491
     492  public static void importArrayDesigns(PluginDefinition batchImporter, File file)
     493  {
     494    TestUtil.write("--Importing array designs from file: " + file.getName() + "\n");
     495    DbControl dc = null;
     496    try
     497    {
     498      dc = TestUtil.getDbControl();
     499      PluginDefinition plugin = PluginDefinition.getById(dc, batchImporter.getId());
     500      Job job = Job.getNew(dc, plugin, null, null);
     501      job.setName("Batch import of Array designs to Project A");
     502      job.setParameterValue("file", new FileParameterType(), file);
     503      job.setParameterValue("dataSplitterRegexp", new StringParameterType(), "\\t");
     504      job.setParameterValue("dataHeaderRegexp", new StringParameterType(), "Name\\tDescription\\tArrays/slide\\tPlatform\\tFile type\\tFile");
     505     
     506      // Item properties
     507      job.setParameterValue("nameColumnMapping", new StringParameterType(), "\\Name\\");
     508      job.setParameterValue("descriptionColumnMapping", new StringParameterType(), "\\Description\\");
     509      job.setParameterValue("numArraysColumnMapping", new StringParameterType(), "\\Arrays/slide\\");
     510      job.setParameterValue("platformColumnMapping", new StringParameterType(), "\\Platform\\");
     511      job.setParameterValue("fileTypeColumnMapping", new StringParameterType(), "\\File type\\");
     512      job.setParameterValue("fileColumnMapping", new StringParameterType(), "\\File\\");
     513     
     514      dc.saveItem(job);
     515      dc.commit();
     516      PluginUtil.executeJob(job);
     517    }
     518    finally
     519    {
     520      if (dc != null) dc.close();
     521    }
     522  }
     523 
     524  public static void importArraySlides(PluginDefinition batchImporter, File file)
     525  {
     526    TestUtil.write("--Importing array slides from file: " + file.getName() + "\n");
     527    DbControl dc = null;
     528    try
     529    {
     530      dc = TestUtil.getDbControl();
     531      PluginDefinition plugin = PluginDefinition.getById(dc, batchImporter.getId());
     532      Job job = Job.getNew(dc, plugin, null, null);
     533      job.setName("Batch import of Array slides to Project A");
     534      job.setParameterValue("file", new FileParameterType(), file);
     535      job.setParameterValue("dataSplitterRegexp", new StringParameterType(), "\\t");
     536      job.setParameterValue("dataHeaderRegexp", new StringParameterType(), "Name\\tHybridization\\tDescription\\tBarcode\\tDestroyed\\tArray batch\\tIndex");
     537     
     538      // Item properties
     539      job.setParameterValue("nameColumnMapping", new StringParameterType(), "\\Name\\");
     540      job.setParameterValue("arrayBatchColumnMapping", new StringParameterType(), "\\Array batch\\");
     541      job.setParameterValue("hybridizationColumnMapping", new StringParameterType(), "\\Hybridization\\");
     542      job.setParameterValue("descriptionColumnMapping", new StringParameterType(), "\\Description\\");
     543      job.setParameterValue("barcodeColumnMapping", new StringParameterType(), "\\Barcode\\");
     544      job.setParameterValue("destroyedColumnMapping", new StringParameterType(), "\\Destroyed\\");
     545      job.setParameterValue("indexColumnMapping", new StringParameterType(), "\\Index\\");
     546     
     547      dc.saveItem(job);
     548      dc.commit();
     549      PluginUtil.executeJob(job);
     550    }
     551    finally
     552    {
     553      if (dc != null) dc.close();
     554    }
     555  }
    428556}
  • trunk/src/test/net/sf/basedb/test/roles/Run.java

    r4625 r4628  
    6262    {
    6363      TestUtil.begin(logMemoryUsage, true);
    64       ok = useBatchImporters ? PowerUserBatchImporterTest.run() : PowerUserTest.run();
     64      ok = PowerUserTest.run(useBatchImporters);
    6565      tests++;
    6666    }
     
    6868    {
    6969      TestUtil.begin(logMemoryUsage, true);
    70       ok = useBatchImporters ? UserBatchImporterTest.run() : UserTest.run();
     70      ok = UserTest.run(useBatchImporters);
    7171      tests++;
    7272    }
  • trunk/src/test/net/sf/basedb/test/roles/UserTest.java

    r4548 r4628  
    4444import net.sf.basedb.core.Platform;
    4545import net.sf.basedb.core.PluginConfiguration;
     46import net.sf.basedb.core.PluginDefinition;
    4647import net.sf.basedb.core.Project;
    4748import net.sf.basedb.core.Quantity;
     
    7576    Run the tests in this class.
    7677  */
    77   public static boolean run()
     78  public static boolean run(boolean useBatchImporters)
    7879  {
    7980    DbControl dc = null;
     
    8283    {
    8384      TestUtil.login("user", "user", false);
     85      PluginDefinition bioSourceBatchImporter = null;
     86      PluginDefinition sampleBatchImporter = null;
     87      PluginDefinition extractBatchImporter = null;
     88      PluginDefinition labeledExtractBatchImporter = null;
     89      PluginDefinition hybridizationBatchImporter = null;
     90      PluginDefinition scanBatchImporter = null;
     91      PluginDefinition rawBioAssayBatchImporter = null;
     92     
     93      File batchImportFile_BioSource = null;
     94      File batchImportFile_Sample = null;
     95      File batchImportFile_Extract = null;
     96      File batchImportFile_LabeledExtract = null;
     97      File batchImportFile_Hybridization = null;
     98      File batchImportFile_Scan = null;
     99      File batchImportFile_RawBioAssay = null;
     100     
    84101
    85102      // Activate project
     
    88105      dc.close();
    89106      TestUtil.getSessionControl().setActiveProject(p);
     107     
     108      if (useBatchImporters)
     109      {
     110        // Preparation; uploading files and find plugins
     111        dc = TestUtil.getDbControl();
     112        bioSourceBatchImporter = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.batchimport.BioSourceImporter");
     113        sampleBatchImporter = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.batchimport.SampleImporter");
     114        extractBatchImporter = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.batchimport.ExtractImporter");
     115        labeledExtractBatchImporter = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.batchimport.LabeledExtractImporter");
     116        hybridizationBatchImporter = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.batchimport.HybridizationImporter");
     117        scanBatchImporter = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.batchimport.ScanImporter");
     118        rawBioAssayBatchImporter = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.batchimport.RawBioAssayImporter");
     119       
     120        batchImportFile_BioSource = FileUtil.uploadFile(dc, "/batchimport", "biosource_out.txt", null);
     121        batchImportFile_Sample = FileUtil.uploadFile(dc, "/batchimport", "sample_out.txt", null);
     122        batchImportFile_Extract = FileUtil.uploadFile(dc, "/batchimport", "extract_out.txt", null);
     123        batchImportFile_LabeledExtract = FileUtil.uploadFile(dc, "/batchimport", "labeledextract_out.txt", null);
     124        batchImportFile_Hybridization = FileUtil.uploadFile(dc, "/batchimport", "hybridization_out.txt", null);
     125        batchImportFile_Scan = FileUtil.uploadFile(dc, "/batchimport", "scan_out.txt", null);
     126        batchImportFile_RawBioAssay = FileUtil.uploadFile(dc, "/batchimport", "rawbioassay_out.txt", null);
     127        dc.commit();
     128      }
    90129
    91130      // Create biomaterials
     
    93132      Quantity time = Quantity.getById(dc, SystemItems.getId(Quantity.TIME));
    94133      Unit hoursUnit = time.getUnit("hour");
    95       BioSource bioSource =  createBioSource(dc, "Biosource A", "medium");
    96       Sample s1 = createSample(dc, "Sample A.00h", bioSource, 0, hoursUnit);
    97       Sample s2 = createSample(dc, "Sample A.24h", bioSource, 24, hoursUnit);
    98       Sample sRef = createSample(dc, "Sample A.ref", null, null, null);
    99      
    100       Extract e1 = createExtract(dc, "Extract A.00h", s1);
    101       Extract e2 = createExtract(dc, "Extract A.24h", s2);
    102       Extract eRef = createExtract(dc, "Extract A.ref", sRef);
    103      
    104       Label cy3 = Util.findLabel(dc, "cy3");     
    105       Label cy5 = Util.findLabel(dc, "cy5");     
    106       LabeledExtract le1 = createLabeledExtract(dc, "Labeled extract A.00h", e1, cy3);
    107       LabeledExtract le2 = createLabeledExtract(dc, "Labeled extract A.24h", e2, cy3);
    108       LabeledExtract leRef = createLabeledExtract(dc, "Labeled extract A.ref", eRef, cy5);
    109       LabeledExtract le1DyeSwap = createLabeledExtract(dc, "Labeled extract A.00h (dye-swap)", e1, cy5);
    110       LabeledExtract le2DyeSwap = createLabeledExtract(dc, "Labeled extract A.24h (dye-swap)", e2, cy5);
    111       LabeledExtract leRefDyeSwap = createLabeledExtract(dc, "Labeled extract A.ref (dye-swap)", eRef, cy3);
    112       dc.commit();
    113      
    114       // Hybridizations, etc.
    115       dc = TestUtil.getDbControl();
    116       Hybridization h1 = createHybridization(dc, "Hybridization A.00h", "Array slide A.1", le1, leRef);
    117       Hybridization h2 = createHybridization(dc, "Hybridization A.24h", "Array slide A.2", le2, leRef);
    118       Hybridization h1DyeSwap = createHybridization(dc, "Hybridization A.00h (dye-swap)", "Array slide A.3", le1DyeSwap, leRefDyeSwap);
    119       Hybridization h2DyeSwap = createHybridization(dc, "Hybridization A.24h (dye-swap)", "Array slide A.4", le2DyeSwap, leRefDyeSwap);
    120 
    121       // Affymetrix
    122       Hybridization affyHyb1 = createHybridization(dc, "Affymetrix hyb A.1", "Affymetrix slide A.1", le1);
    123       Hybridization affyHyb2 = createHybridization(dc, "Affymetrix hyb A.2", "Affymetrix slide A.2", le2);
    124       Hybridization affyHyb3 = createHybridization(dc, "Affymetrix hyb A.3", "Affymetrix slide A.3", leRef);
    125      
    126       Scan sc1 = createScan(dc, "Scan A.00h", h1);
    127       Scan sc2 = createScan(dc, "Scan A.24h", h2);
    128       Scan sc1DyeSwap = createScan(dc, "Scan A.00h (dye-swap)", h1DyeSwap);
    129       Scan sc2DyeSwap = createScan(dc, "Scan A.24h (dye-swap)", h2DyeSwap);
    130 
    131       // Affymetrix
    132       Scan affyScan1 = createScan(dc, "Affymetrix scan A.1", affyHyb1);
    133       Scan affyScan2 = createScan(dc, "Affymetrix scan A.2", affyHyb2);
    134       Scan affyScan3 = createScan(dc, "Affymetrix scan A.3", affyHyb3);
    135       dc.commit();
    136      
    137       // Images
    138       // TODO - when we have the image files
    139 
     134      Platform genericPlatform = Platform.getByExternalId(dc, Platform.GENERIC);
     135      Platform affymetrixPlatform = Platform.getByExternalId(dc, Platform.AFFYMETRIX);
     136     
     137     
    140138      // Upload raw data files
    141       dc = TestUtil.getDbControl();
    142139      File rawData1 = FileUtil.uploadFile(dc, "/mouse", "genepix.mouse.v4.37k.00h.gpr", FileType.RAW_DATA);
    143140      File rawData2 = FileUtil.uploadFile(dc, "/mouse", "genepix.mouse.v4.37k.24h.gpr", FileType.RAW_DATA);
     
    150147      dc.commit();
    151148     
    152       // Raw bioassays
    153       dc = TestUtil.getDbControl();
    154       Platform genericPlatform = Platform.getByExternalId(dc, Platform.GENERIC);
    155       Platform affymetrixPlatform = Platform.getByExternalId(dc, Platform.AFFYMETRIX);
    156       ArrayDesign genericDesign = Util.findArrayDesign(dc, "Array design A");
    157       ArrayDesign affymetrixDesign = Util.findArrayDesign(dc, "Affymetrix A");
    158       RawDataType genepix = RawDataTypes.getSafeRawDataType("genepix");
    159       RawBioAssay rba1 = createRawBioAssay(dc, genericPlatform, genepix, "Raw bioassay A.00h", sc1, genericDesign);
    160       RawBioAssay rba2 = createRawBioAssay(dc, genericPlatform, genepix, "Raw bioassay A.24h", sc2, genericDesign);
    161       RawBioAssay rba1DyeSwap = createRawBioAssay(dc, genericPlatform, genepix, "Raw bioassay A.00h (dye-swap)", sc1DyeSwap, genericDesign);
    162       RawBioAssay rba2DyeSwap = createRawBioAssay(dc, genericPlatform, genepix, "Raw bioassay A.24h (dye-swap)", sc2DyeSwap, genericDesign);
    163      
    164       // Affymetrix raw bioassays
    165       RawBioAssay affyRaw1 = createRawBioAssay(dc, affymetrixPlatform, null, "Affymetrix raw A.1", affyScan1, affymetrixDesign);
    166       RawBioAssay affyRaw2 = createRawBioAssay(dc, affymetrixPlatform, null, "Affymetrix raw A.2", affyScan2, affymetrixDesign);
    167       RawBioAssay affyRaw3 = createRawBioAssay(dc, affymetrixPlatform, null, "Affymetrix raw A.3", affyScan3, affymetrixDesign);
    168 
    169       // Assign Affymetrix CEL files
    170       FileUtil.addDataFile(dc, affyRaw1, DataFileType.AFFYMETRIX_CEL, affy1, true, true);
    171       FileUtil.addDataFile(dc, affyRaw2, DataFileType.AFFYMETRIX_CEL, affy2, true, true);
    172       FileUtil.addDataFile(dc, affyRaw3, DataFileType.AFFYMETRIX_CEL, affy3, true, true);
    173      
     149      BioSource bioSource = null;
     150      Sample s1 = null;
     151      Sample s2 = null;
     152      Sample sRef = null;
     153     
     154      RawBioAssay rba1 = null;
     155      RawBioAssay rba2 = null;
     156      RawBioAssay rba1DyeSwap = null;
     157      RawBioAssay rba2DyeSwap = null;
     158      RawBioAssay affyRaw1 = null;
     159      RawBioAssay affyRaw2 = null;
     160      RawBioAssay affyRaw3 = null;
     161      if (!useBatchImporters)
     162      {
     163        dc = TestUtil.getDbControl();
     164        bioSource =  createBioSource(dc, "Biosource A", "medium");
     165        s1 = createSample(dc, "Sample A.00h", bioSource, 0, hoursUnit);
     166        s2 = createSample(dc, "Sample A.24h", bioSource, 24, hoursUnit);
     167        sRef = createSample(dc, "Sample A.ref", null, null, null);
     168       
     169        Extract e1 = createExtract(dc, "Extract A.00h", s1);
     170        Extract e2 = createExtract(dc, "Extract A.24h", s2);
     171        Extract eRef = createExtract(dc, "Extract A.ref", sRef);
     172       
     173        Label cy3 = Util.findLabel(dc, "cy3");     
     174        Label cy5 = Util.findLabel(dc, "cy5");     
     175        LabeledExtract le1 = createLabeledExtract(dc, "Labeled extract A.00h", e1, cy3);
     176        LabeledExtract le2 = createLabeledExtract(dc, "Labeled extract A.24h", e2, cy3);
     177        LabeledExtract leRef = createLabeledExtract(dc, "Labeled extract A.ref", eRef, cy5);
     178        LabeledExtract le1DyeSwap = createLabeledExtract(dc, "Labeled extract A.00h (dye-swap)", e1, cy5);
     179        LabeledExtract le2DyeSwap = createLabeledExtract(dc, "Labeled extract A.24h (dye-swap)", e2, cy5);
     180        LabeledExtract leRefDyeSwap = createLabeledExtract(dc, "Labeled extract A.ref (dye-swap)", eRef, cy3);
     181//        dc.commit();
     182       
     183        // Hybridizations, etc.
     184//        dc = TestUtil.getDbControl();
     185        Hybridization h1 = createHybridization(dc, "Hybridization A.00h", "Array slide A.1", le1, leRef);
     186        Hybridization h2 = createHybridization(dc, "Hybridization A.24h", "Array slide A.2", le2, leRef);
     187        Hybridization h1DyeSwap = createHybridization(dc, "Hybridization A.00h (dye-swap)", "Array slide A.3", le1DyeSwap, leRefDyeSwap);
     188        Hybridization h2DyeSwap = createHybridization(dc, "Hybridization A.24h (dye-swap)", "Array slide A.4", le2DyeSwap, leRefDyeSwap);
     189 
     190        // Affymetrix
     191        Hybridization affyHyb1 = createHybridization(dc, "Affymetrix hyb A.1", "Affymetrix slide A.1", le1);
     192        Hybridization affyHyb2 = createHybridization(dc, "Affymetrix hyb A.2", "Affymetrix slide A.2", le2);
     193        Hybridization affyHyb3 = createHybridization(dc, "Affymetrix hyb A.3", "Affymetrix slide A.3", leRef);
     194       
     195        Scan sc1 = createScan(dc, "Scan A.00h", h1);
     196        Scan sc2 = createScan(dc, "Scan A.24h", h2);
     197        Scan sc1DyeSwap = createScan(dc, "Scan A.00h (dye-swap)", h1DyeSwap);
     198        Scan sc2DyeSwap = createScan(dc, "Scan A.24h (dye-swap)", h2DyeSwap);
     199 
     200        // Affymetrix
     201        Scan affyScan1 = createScan(dc, "Affymetrix scan A.1", affyHyb1);
     202        Scan affyScan2 = createScan(dc, "Affymetrix scan A.2", affyHyb2);
     203        Scan affyScan3 = createScan(dc, "Affymetrix scan A.3", affyHyb3);
     204     
     205        // Images
     206        // TODO - when we have the image files
     207       
     208        // Raw bioassays
     209        ArrayDesign genericDesign = Util.findArrayDesign(dc, "Array design A");
     210        ArrayDesign affymetrixDesign = Util.findArrayDesign(dc, "Affymetrix A");
     211        RawDataType genepix = RawDataTypes.getSafeRawDataType("genepix");
     212        rba1 = createRawBioAssay(dc, genericPlatform, genepix, "Raw bioassay A.00h", sc1, genericDesign);
     213        rba2 = createRawBioAssay(dc, genericPlatform, genepix, "Raw bioassay A.24h", sc2, genericDesign);
     214        rba1DyeSwap = createRawBioAssay(dc, genericPlatform, genepix, "Raw bioassay A.00h (dye-swap)", sc1DyeSwap, genericDesign);
     215        rba2DyeSwap = createRawBioAssay(dc, genericPlatform, genepix, "Raw bioassay A.24h (dye-swap)", sc2DyeSwap, genericDesign);
     216       
     217        // Affymetrix raw bioassays
     218        affyRaw1 = createRawBioAssay(dc, affymetrixPlatform, null, "Affymetrix raw A.1", affyScan1, affymetrixDesign);
     219        affyRaw2 = createRawBioAssay(dc, affymetrixPlatform, null, "Affymetrix raw A.2", affyScan2, affymetrixDesign);
     220        affyRaw3 = createRawBioAssay(dc, affymetrixPlatform, null, "Affymetrix raw A.3", affyScan3, affymetrixDesign);
     221 
     222        // Assign Affymetrix CEL files
     223        FileUtil.addDataFile(dc, affyRaw1, DataFileType.AFFYMETRIX_CEL, affy1, true, true);
     224        FileUtil.addDataFile(dc, affyRaw2, DataFileType.AFFYMETRIX_CEL, affy2, true, true);
     225        FileUtil.addDataFile(dc, affyRaw3, DataFileType.AFFYMETRIX_CEL, affy3, true, true);
     226        dc.commit();
     227      }
     228      else
     229      {
     230        // Import biomaterials
     231        importBioSources(bioSourceBatchImporter, batchImportFile_BioSource);
     232        importSamples(sampleBatchImporter, batchImportFile_Sample);
     233        importExtracts(extractBatchImporter, batchImportFile_Extract);
     234        importLabelExtracts(labeledExtractBatchImporter, batchImportFile_LabeledExtract);
     235       
     236        // Hybridizations, etc.
     237        importHybridizations(hybridizationBatchImporter, batchImportFile_Hybridization);     
     238        importScans(scanBatchImporter, batchImportFile_Scan);
     239        importRawBioAssays(rawBioAssayBatchImporter, batchImportFile_RawBioAssay);
     240        dc = TestUtil.getDbControl();
     241        bioSource = Util.findBioSource(dc, "Biosource A");
     242        s1 = Util.findSample(dc, "Sample A.00h");
     243        s2 = Util.findSample(dc, "Sample A.24h");
     244        sRef = Util.findSample(dc, "Sample A.ref");
     245        rba1 = Util.findRawBioAssay(dc, "Raw bioassay A.00h");
     246        rba2 = Util.findRawBioAssay(dc, "Raw bioassay A.24h");
     247        rba1DyeSwap = Util.findRawBioAssay(dc, "Raw bioassay A.24h");
     248        rba2DyeSwap = Util.findRawBioAssay(dc, "Raw bioassay A.24h (dye-swap)");
     249        affyRaw1 = Util.findRawBioAssay(dc, "Affymetrix raw A.1");
     250        affyRaw2 = Util.findRawBioAssay(dc, "Affymetrix raw A.2");
     251        affyRaw3 = Util.findRawBioAssay(dc, "Affymetrix raw A.3");
     252        dc.close();
     253      }
     254     
     255      dc = TestUtil.getDbControl();
    174256      inheritAnnotations(dc, rba1, s1, bioSource);
    175257      inheritAnnotations(dc, rba2, s2, bioSource);
     
    416498  }
    417499
    418  
     500  public static void importRawBioAssays(PluginDefinition batchImporter, File file)
     501  {
     502    TestUtil.write("--Importing raw bioassays from file: " + file + "\n");
     503    DbControl dc = null;
     504    try
     505    {
     506      dc = TestUtil.getDbControl();
     507      PluginDefinition plugin = PluginDefinition.getById(dc, batchImporter.getId());
     508      Job job = Job.getNew(dc, plugin, null, null);
     509     
     510      job.setName("Batch import of raw bioassays to Project A");
     511      job.setParameterValue("file", new FileParameterType(), file);
     512      job.setParameterValue("dataSplitterRegexp", new StringParameterType(), "\\t");
     513      job.setParameterValue("dataHeaderRegexp", new StringParameterType(),
     514          "Name\\tPlatform\\tVariant\\tRaw data type\\tArray index\\tScan\\tSoftware\\tProtocol\\tArray design\\tDescription\\tFile type\\tFile");
     515     
     516      job.setParameterValue("nameColumnMapping", new StringParameterType(), "\\Name\\");
     517      job.setParameterValue("descriptionColumnMapping", new StringParameterType(), "\\Description\\");
     518      job.setParameterValue("rawDataTypeColumnMapping", new StringParameterType(), "\\Raw data type\\");
     519      job.setParameterValue("platformColumnMapping", new StringParameterType(), "\\Platform\\");
     520      job.setParameterValue("variantColumnMapping", new StringParameterType(), "\\Variant\\");
     521      job.setParameterValue("arrayIndexColumnMapping", new StringParameterType(), "\\Array index\\");
     522      job.setParameterValue("scanColumnMapping", new StringParameterType(), "\\Scan\\");
     523      job.setParameterValue("softwareColumnMapping", new StringParameterType(), "\\Software\\");
     524      job.setParameterValue("protocolColumnMapping", new StringParameterType(), "\\Protocol\\");
     525      job.setParameterValue("arrayDesignColumnMapping", new StringParameterType(), "\\Array design\\");
     526      job.setParameterValue("fileTypeColumnMapping", new StringParameterType(), "\\File type\\");
     527      job.setParameterValue("fileColumnMapping", new StringParameterType(), "\\File\\");
     528     
     529      dc.saveItem(job);
     530      dc.commit();
     531      PluginUtil.executeJob(job);
     532    }
     533    finally
     534    {
     535      if (dc != null) dc.close();
     536    }
     537  }
     538 
     539  public static void importScans(PluginDefinition batchImporter, File file)
     540  {
     541    TestUtil.write("--Importing scans from file: " + file + "\n");
     542    DbControl dc = null;
     543    try
     544    {
     545      dc = TestUtil.getDbControl();
     546      PluginDefinition plugin = PluginDefinition.getById(dc, batchImporter.getId());
     547      Job job = Job.getNew(dc, plugin, null, null);
     548     
     549      job.setName("Batch import of scans to Project A");
     550      job.setParameterValue("file", new FileParameterType(), file);
     551      job.setParameterValue("dataSplitterRegexp", new StringParameterType(), "\\t");
     552      job.setParameterValue("dataHeaderRegexp", new StringParameterType(),
     553          "Name\\tHybridization\\tDescription\\tProtocol\\tScanner");
     554     
     555      job.setParameterValue("nameColumnMapping", new StringParameterType(), "\\Name\\");
     556      job.setParameterValue("descriptionColumnMapping", new StringParameterType(), "\\Description\\");
     557      job.setParameterValue("hybridizationColumnMapping", new StringParameterType(), "\\Hybridization\\");
     558      job.setParameterValue("hardwareColumnMapping", new StringParameterType(), "\\Scanner\\");     
     559      job.setParameterValue("protocolColumnMapping", new StringParameterType(), "\\Protocol\\");
     560     
     561     
     562      dc.saveItem(job);
     563      dc.commit();
     564      PluginUtil.executeJob(job);
     565    }
     566    finally
     567    {
     568      if (dc != null) dc.close();
     569    }
     570  }
     571 
     572  public static void importHybridizations(PluginDefinition batchImporter, File file)
     573  {
     574    TestUtil.write("--Importing hybridizations from file: " + file + "\n");
     575    DbControl dc = null;
     576    try
     577    {
     578      dc = TestUtil.getDbControl();
     579      PluginDefinition plugin = PluginDefinition.getById(dc, batchImporter.getId());
     580      Job job = Job.getNew(dc, plugin, null, null);
     581     
     582      job.setName("Batch import of hybridizations to Project A");
     583      job.setParameterValue("file", new FileParameterType(), file);
     584      job.setParameterValue("dataSplitterRegexp", new StringParameterType(), "\\t");
     585      job.setParameterValue("dataHeaderRegexp", new StringParameterType(),
     586          "Name\\tArray slide\\tDescription\\tHardware\\tArrays/slide\\tProtocol\\tParent\\tParent used quantity");
     587     
     588      job.setParameterValue("nameColumnMapping", new StringParameterType(), "\\Name\\");
     589      job.setParameterValue("descriptionColumnMapping", new StringParameterType(), "\\Description\\");
     590      job.setParameterValue("hardwareColumnMapping", new StringParameterType(), "\\Hardware\\");
     591      job.setParameterValue("parentColumnMapping", new StringParameterType(), "\\Parent\\");
     592      job.setParameterValue("usedQuantityColumnMapping", new StringParameterType(), "\\Parent used quantity\\");
     593      job.setParameterValue("protocolColumnMapping", new StringParameterType(), "\\Protocol\\");
     594      job.setParameterValue("arraySlideColumnMapping", new StringParameterType(), "\\Array slide\\");
     595      job.setParameterValue("numArraysColumnMapping", new StringParameterType(), "\\Arrays/slide\\");
     596     
     597      dc.saveItem(job);
     598      dc.commit();
     599      PluginUtil.executeJob(job);
     600    }
     601    finally
     602    {
     603      if (dc != null) dc.close();
     604    }
     605  }
     606
     607  public static void importLabelExtracts(PluginDefinition batchImporter, File file)
     608  {
     609    TestUtil.write("--Importing labeled extracts from file: " + file + "\n");
     610    DbControl dc = null;
     611    try
     612    {
     613      dc = TestUtil.getDbControl();
     614      PluginDefinition plugin = PluginDefinition.getById(dc, batchImporter.getId());
     615      Job job = Job.getNew(dc, plugin, null, null);
     616     
     617      job.setName("Batch import of labeled extracts to Project A");
     618      job.setParameterValue("file", new FileParameterType(), file);
     619      job.setParameterValue("dataSplitterRegexp", new StringParameterType(), "\\t");
     620      job.setParameterValue("dataHeaderRegexp", new StringParameterType(),
     621          "Name\\tLabel\\tOriginal quantity\\tDescription\\tExternal id\\tProtocol\\tCreated\\tPooled\\tParent\\tParent used quantity");
     622     
     623      job.setParameterValue("nameColumnMapping", new StringParameterType(), "\\Name\\");
     624      job.setParameterValue("descriptionColumnMapping", new StringParameterType(), "\\Description\\");
     625      job.setParameterValue("externalIdColumnMapping", new StringParameterType(), "\\External id\\");
     626      job.setParameterValue("originalQuantityColumnMapping", new StringParameterType(), "\\Original quantity\\");
     627      job.setParameterValue("createdColumnMapping", new StringParameterType(), "\\Created\\");
     628      job.setParameterValue("pooledColumnMapping", new StringParameterType(), "\\Pooled\\");
     629      job.setParameterValue("parentColumnMapping", new StringParameterType(), "\\Parent\\");
     630      job.setParameterValue("usedQuantityColumnMapping", new StringParameterType(), "\\Parent used quantity\\");
     631      job.setParameterValue("protocolColumnMapping", new StringParameterType(), "\\Protocol\\");
     632      job.setParameterValue("labelColumnMapping", new StringParameterType(), "\\Label\\");
     633     
     634      dc.saveItem(job);
     635      dc.commit();
     636      PluginUtil.executeJob(job);
     637    }
     638    finally
     639    {
     640      if (dc != null) dc.close();
     641    }   
     642  }
     643
     644  public  static void importExtracts(PluginDefinition batchImporter,  File file)
     645  {
     646    TestUtil.write("--Importing extracts from file: " + file + "\n");
     647    DbControl dc = null;
     648    try
     649    {
     650      dc = TestUtil.getDbControl();
     651      PluginDefinition plugin = PluginDefinition.getById(dc, batchImporter.getId());
     652      Job job = Job.getNew(dc, plugin, null, null);
     653     
     654      job.setName("Batch import of extracts to Project A");
     655      job.setParameterValue("file", new FileParameterType(), file);
     656      job.setParameterValue("dataSplitterRegexp", new StringParameterType(), "\\t");
     657      job.setParameterValue("dataHeaderRegexp", new StringParameterType(),
     658          "Name\\tOriginal quantity\\tDescription\\tExternal id\\tProtocol\\tCreated\\tPooled\\tParent\\tParent used quantity");
     659     
     660      job.setParameterValue("nameColumnMapping", new StringParameterType(), "\\Name\\");
     661      job.setParameterValue("descriptionColumnMapping", new StringParameterType(), "\\Description\\");
     662      job.setParameterValue("externalIdColumnMapping", new StringParameterType(), "\\External id\\");
     663      job.setParameterValue("originalQuantityColumnMapping", new StringParameterType(), "\\Original quantity\\");
     664      job.setParameterValue("createdColumnMapping", new StringParameterType(), "\\Created\\");
     665      job.setParameterValue("pooledColumnMapping", new StringParameterType(), "\\Pooled\\");
     666      job.setParameterValue("parentColumnMapping", new StringParameterType(), "\\Parent\\");
     667      job.setParameterValue("usedQuantityColumnMapping", new StringParameterType(), "\\Parent used quantity\\");
     668      job.setParameterValue("protocolColumnMapping", new StringParameterType(), "\\Protocol\\");
     669     
     670      dc.saveItem(job);
     671      dc.commit();
     672      PluginUtil.executeJob(job);
     673    }
     674    finally
     675    {
     676      if (dc != null) dc.close();
     677    }
     678  }
     679
     680  public static void importSamples(PluginDefinition batchImporter, File file)
     681  {
     682    TestUtil.write("--Importing samples from file: " + file + "\n");
     683    DbControl dc = null;
     684    try
     685    {
     686      dc = TestUtil.getDbControl();
     687      PluginDefinition plugin = PluginDefinition.getById(dc, batchImporter.getId());
     688      Job job = Job.getNew(dc, plugin, null, null);
     689     
     690      job.setName("Batch import of samples to Project A");
     691      job.setParameterValue("file", new FileParameterType(), file);
     692      job.setParameterValue("dataSplitterRegexp", new StringParameterType(), "\\t");
     693      job.setParameterValue("dataHeaderRegexp", new StringParameterType(),
     694          "Name\\tOriginal quantity\\tDescription\\tExternal id\\tCreated\\tPooled\\tBiosource\\tProtocol");
     695     
     696      job.setParameterValue("nameColumnMapping", new StringParameterType(), "\\Name\\");
     697      job.setParameterValue("descriptionColumnMapping", new StringParameterType(), "\\Description\\");
     698      job.setParameterValue("externalIdColumnMapping", new StringParameterType(), "\\External id\\");
     699      job.setParameterValue("originalQuantityColumnMapping", new StringParameterType(), "\\Original quantity\\");
     700      job.setParameterValue("createdColumnMapping", new StringParameterType(), "\\Created\\");
     701      job.setParameterValue("pooledColumnMapping", new StringParameterType(), "\\Pooled\\");
     702      job.setParameterValue("parentColumnMapping", new StringParameterType(), "\\Biosource\\");
     703      job.setParameterValue("protocolColumnMapping", new StringParameterType(), "\\Protocol\\");
     704     
     705      dc.saveItem(job);
     706      dc.commit();
     707      PluginUtil.executeJob(job);
     708    }
     709    finally
     710    {
     711      if(dc != null) dc.close();
     712    }   
     713  }
     714
     715  public static void importBioSources(PluginDefinition batchImporter, File file)
     716  {
     717    TestUtil.write("--Importing biosources from file: " + file + "\n");
     718    DbControl dc = null;
     719    try
     720    {
     721      dc = TestUtil.getDbControl();
     722      PluginDefinition plugin = PluginDefinition.getById(dc, batchImporter.getId());
     723      Job job = Job.getNew(dc, plugin, null, null);
     724     
     725      job.setName("Batch import of bio-sources to Project A");
     726      job.setParameterValue("file", new FileParameterType(), file);
     727      job.setParameterValue("dataSplitterRegexp", new StringParameterType(), "\\t");
     728      job.setParameterValue("dataHeaderRegexp", new StringParameterType(), "Name\\tDescription\\tExternal id");
     729     
     730      job.setParameterValue("nameColumnMapping", new StringParameterType(), "\\Name\\");
     731      job.setParameterValue("descriptionColumnMapping", new StringParameterType(), "\\Description\\");
     732      job.setParameterValue("externalIdColumnMapping", new StringParameterType(), "\\External id\\");
     733     
     734      dc.saveItem(job);
     735      dc.commit();
     736      PluginUtil.executeJob(job);
     737    }
     738    finally
     739    {
     740      if(dc != null) dc.close();
     741    }   
     742  }
    419743}
Note: See TracChangeset for help on using the changeset viewer.