Changeset 4359


Ignore:
Timestamp:
Jul 1, 2008, 11:40:28 AM (15 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1076: Backwards incompatible change in MedianRatioNormalization? plugin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.7-stable/src/plugins/core/net/sf/basedb/plugins/MedianRatioNormalization.java

    r4308 r4359  
    237237    if (command.equals(Request.COMMAND_EXECUTE))
    238238    {
    239       if (progress != null) progress.display(0, "Preparing to normalize...");
    240 
    241239      DbControl dc = null;
    242240      try
     
    250248        float highExclude = (Float) job.getValue(highExcludeParameter.getName());
    251249        Job thisJob = getCurrentJob(dc);
    252 
    253         // Create Transformation
    254         Transformation t = source.newTransformation(getCurrentJob(dc));
    255         t.setName(about.getName());
    256         dc.saveItem(t);
    257 
    258         // Create the normalized bioassay set
    259         BioAssaySet child = t.newProduct(null, "new", true);
    260         dc.saveItem(child);
    261 
    262         // Batcher for inserting normalized data
    263         SpotBatcher batcher = child.getSpotBatcher();
    264 
    265         int nofChannels=source.getRawDataType().getChannels();
    266         switch (nofChannels)
     250       
     251        BioAssaySet child = null;
     252        int rawChannels = source.getRawDataType().getChannels();
     253        switch (rawChannels)
    267254        {
    268             case 1:
    269               String method = (String) job.getValue(methodParameter.getName());
    270               normalize1ch(dc, source, batcher, minIntensity, lowExclude,
    271                            highExclude, method.equals("Scale"), progress);
     255          case 1:
     256            String method = (String) job.getValue(methodParameter.getName());
     257            child = normalize1ch(dc, source, thisJob, minIntensity, lowExclude,
     258                    highExclude, method.equals("Scale"), progress);
     259            break;
     260          case 2:
     261            int blockGroupSize =
     262              (Integer) job.getValue(blockGroupParameter.getName());
     263            child = normalize(dc, source, thisJob, minIntensity, lowExclude,
     264                highExclude, blockGroupSize, progress);
    272265              break;
    273             case 2:
    274               int blockGroupSize =
    275                 (Integer) job.getValue(blockGroupParameter.getName());
    276               normalize2ch(dc, source, batcher, minIntensity, lowExclude,
    277                            highExclude, blockGroupSize, progress);
    278               break;
    279             default:
    280               throw new InvalidDataException(nofChannels +
    281                                              "-channel arrays not supported");
    282         }
    283 
    284         batcher.close();
     266          default:
     267              throw new InvalidDataException(rawChannels +
     268                "-channel arrays not supported");
     269        }
     270       
    285271        child.setName(childName);
    286272        child.setDescription(childDescription);
    287273        dc.commit();
    288 
    289274        int normalizedSpots = child.getNumSpots();
    290275        response.setDone(normalizedSpots + " spots normalized, " + (source.getNumSpots() - normalizedSpots) + " spots removed");
     
    416401    @since 2.7
    417402  */
    418   private void
    419   normalize1ch(DbControl dc, BioAssaySet source, SpotBatcher batcher,
     403  private BioAssaySet
     404  normalize1ch(DbControl dc, BioAssaySet source, Job job,
    420405               float minIntensity, float lowExclude, float highExclude,
    421406               boolean scale, ProgressReporter progress)
    422407  {
     408    // Create Transformation
     409    Transformation t = source.newTransformation(job);
     410    t.setName(about.getName());
     411    dc.saveItem(t);
     412
     413    // Create the normalized bioassay set
     414    BioAssaySet child = t.newProduct(null, "new", true);
     415    dc.saveItem(child);
     416
     417    // Batcher for inserting normalized data
     418    SpotBatcher batcher = child.getSpotBatcher();
     419   
    423420    // Expressions used to get data
    424421    Expression ch1 = Dynamic.column(VirtualColumn.channel(1));
     
    504501      throw new BaseException(e);
    505502    }
     503    return child;
    506504  }
    507505
    508506  /**
    509     Normalise the source bioassay set using MEDIAN-RATIO normalization.
     507    Normalise the source bioassay set using MEDIAN-RATIO normalization. NOTE!
     508    This normalization method only works with 2-channel data.
     509   
    510510    @param dc The DbControl to use for database access
    511511    @param source The source bioassay set that is going to be normalized
     512    @param job The job that is doing the normalization, or null
    512513    @param minIntensity All spots which have a lower intensity value in either channel
    513514      will be filtered out
     
    519520    @param progress Progress reporter for the caller to keep track of the plugin's progress. Null is allowed.
    520521    @return The normalized bioassayset
    521     @since 2.5
    522   */
    523   private void
    524   normalize2ch(DbControl dc, BioAssaySet source, SpotBatcher batcher,
    525                float minIntensity, float lowExclude, float highExclude,
    526                int blockGroupSize, ProgressReporter progress)
    527   {
     522    @since 2.5; This method was removed in 2.7.0 by accident, added in 2.7.2 again
     523  */
     524  public BioAssaySet normalize(DbControl dc, BioAssaySet source, Job job,
     525      float minIntensity, float lowExclude, float highExclude,
     526      int blockGroupSize, ProgressReporter progress)
     527  {
     528    if (progress != null) progress.display(0, "Preparing to normalize...");
     529 
     530    // Create Transformation
     531    Transformation t = source.newTransformation(job);
     532    t.setName(about.getName());
     533    dc.saveItem(t);
     534   
     535    // Create the normalized bioassay set
     536    BioAssaySet child = t.newProduct(null, "new", true);
     537    dc.saveItem(child);
     538   
     539    // Batcher for inserting normalized data
     540    SpotBatcher batcher = child.getSpotBatcher();
     541   
    528542    // Expressions used to get data
    529543    Expression block = Dynamic.rawData("block");
     
    560574    query.restrict(bioAssayRestriction);
    561575    query.order(Orders.asc(block));
    562 
     576 
    563577    // Normalize one bioassay at a time
    564578    List<BioAssay> assays = source.getBioAssays().list(dc);
     
    568582      {
    569583        checkInterrupted();
    570 
     584 
    571585        // Prepare list for holding data
    572586        int assaySpots = assay.getNumSpots();
     
    650664          fromBlock = toBlock + 1;
    651665        }
    652         batcher.flush();
    653       }
     666      }
     667      batcher.flush();
    654668      batcher.close();
    655669    }
     
    658672      throw new BaseException(e);
    659673    }
     674    return child;
    660675  }
    661676 
Note: See TracChangeset for help on using the changeset viewer.