Changeset 1205


Ignore:
Timestamp:
Mar 12, 2010, 12:07:34 PM (12 years ago)
Author:
Jari Häkkinen
Message:

Addresses #248 and #252. Optionally creating and attaching background info file to transformation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/base2/net.sf.basedb.illumina/trunk/src/net/sf/basedb/illumina/plugins/BackgroundCorrection.java

    r1203 r1205  
    22  $Id$
    33
    4   Copyright (C) 2008, 2009 Jari Häkkinen
     4  Copyright (C) 2008, 2009, 2010 Jari Häkkinen
    55
    66  This file is part of Illumina plug-in package for BASE.
     
    2424package net.sf.basedb.illumina.plugins;
    2525
     26import net.sf.basedb.core.AnyToAny;
    2627import net.sf.basedb.core.BaseException;
    2728import net.sf.basedb.core.BioAssay;
    2829import net.sf.basedb.core.BioAssaySet;
     30import net.sf.basedb.core.BooleanParameterType;
    2931import net.sf.basedb.core.DbControl;
     32import net.sf.basedb.core.Directory;
    3033import net.sf.basedb.core.DynamicResultIterator;
    3134import net.sf.basedb.core.DynamicSpotQuery;
    3235import net.sf.basedb.core.Experiment;
     36import net.sf.basedb.core.File;
    3337import net.sf.basedb.core.InvalidDataException;
    3438import net.sf.basedb.core.Item;
    3539import net.sf.basedb.core.Job;
     40import net.sf.basedb.core.Location;
    3641import net.sf.basedb.core.Permission;
    3742import net.sf.basedb.core.PluginParameter;
     
    5459import net.sf.basedb.core.query.Expression;
    5560import net.sf.basedb.core.query.Expressions;
     61import net.sf.basedb.core.query.JoinType;
    5662import net.sf.basedb.core.query.Orders;
    5763import net.sf.basedb.core.query.Restriction;
     
    6672import net.sf.basedb.util.Values;
    6773
     74import java.io.PrintWriter;
    6875import java.sql.SQLException;
    6976import java.util.ArrayList;
     
    145152      );
    146153
     154  private static final
     155  PluginParameter<Boolean> saveBgParameter = new PluginParameter<Boolean>
     156    ( "saveBackgroud",
     157      "Save background information",
     158      "Setting this to true instructs the plug-in to generate a file " +
     159      "containing information about the background probes used in the " +
     160      "calculation. The file is self-explanatory and the file format may " +
     161      "change at any time.",
     162      new BooleanParameterType(false, true)
     163      );
     164
    147165  /**
    148166    Make it possible to abort the job.
     
    179197        // Plug-in options
    180198        storeValue(job, request, methodParameter);
     199        storeValue(job, request, saveBgParameter);
    181200
    182201        // Estimate execution time
     
    234253        // background correction method
    235254        parameters.add(methodParameter);
     255
     256        // whether to save background probe information
     257        parameters.add(saveBgParameter);
    236258 
    237259        configureJob = new RequestInformation(
     
    385407      BioAssaySet child = t.newProduct(null, "new", true);
    386408      dc.saveItem(child);
     409
     410      PrintWriter bgWriter = null;
     411      Boolean saveBG = (Boolean)job.getValue(saveBgParameter.getName());
     412      if (saveBG)
     413      {
     414        Directory expDir=source.getExperiment().getDirectory();
     415        File bgData=File.getFile(dc, expDir,
     416                                 about.getName() + "_backgroundProbes_" +
     417                                 thisJob.getId() + ".txt", true);
     418        bgData.setLocation(Location.PRIMARY);
     419        bgData.setMimeType("text/plain");
     420        dc.saveItem(bgData);
     421
     422        // Associate files in a directory with transformation
     423        String root = expDir.getPath().toString();
     424        AnyToAny ata = AnyToAny.getNew(dc, t, bgData,
     425                                       bgData.getPath().toString(), false);
     426        dc.saveItem(ata);
     427
     428        bgWriter = new PrintWriter(bgData.getUploadStream(false,true));
     429      }
    387430
    388431      // Create restriction: negative control beads only (background
     
    431474            ( method.equals("Illumina BeadStudio median") ?
    432475              median(dri,ch1Index) : mean(dri,ch1Index) );
     476
     477          if (saveBG) bgWriter.println(assay.getName() + ": " + backgroundCh1[assayNo]);
     478
    433479          ++assayNo;
    434480        }
    435481        query.reset();
     482        if (saveBG) bgWriter.close();
     483
    436484        int nofAssays=assayNo;
    437485
Note: See TracChangeset for help on using the changeset viewer.