Changeset 730


Ignore:
Timestamp:
Jul 23, 2008, 1:56:20 PM (14 years ago)
Author:
Martin Svensson
Message:

References #117 Average normalization plug-in is almost done. The plug-in cannot handle two-channel data, the implementation needs to be verified and tested.

Location:
plugins/base2/net.sf.basedb.normalizations/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • plugins/base2/net.sf.basedb.normalizations/trunk

    • Property svn:ignore
      •  

        old new  
        11.classpath
        22.project
         3dist
  • plugins/base2/net.sf.basedb.normalizations/trunk/META-INF/base-plugins.xml

    r727 r730  
    33<!-- $Id -->
    44<plugins jarname="%%plugins.jar%%">
    5   <!-- <pluginclass classname="net.sf.basedb.plugins.average.AverageNormalization">
     5  <pluginclass classname="net.sf.basedb.plugins.AverageNormalization">
    66    <minbaseversion>2.7</minbaseversion>
    77    <hasconfigurations/>
    8   </pluginclass> -->
     8  </pluginclass>
    99</plugins>
  • plugins/base2/net.sf.basedb.normalizations/trunk/build.xml

    r727 r730  
    77   
    88    <!-- variables used --> 
    9     <property name="plugin.name" value="normalization-plugins" /> 
     9    <property name="name" value="normalization-plugins" /> 
    1010    <property name="src" value="src" /> 
    11     <property name="bin" value="bin" /> 
    12    
     11    <property name="build" value="build" /> 
     12  <property name="dist" value="dist" />
     13  <property name="jar" value="${name}.jar" />
     14 
    1315    <!-- set up classpath for compiling --> 
    1416    <path id="classpath"> 
     
    2729          encoding="ISO-8859-1" 
    2830            srcdir="${src}" 
    29             destdir="${bin}" 
     31            destdir="${build}" 
    3032            classpathref="classpath"
    3133        /> 
    32    
     34      <copy todir="${build}">
     35      <fileset dir="." includes="META-INF/*" />
     36    </copy>
     37      <replace token="%%plugins.jar%%" value="${jar}" file="${build}/META-INF/base-plugins.xml" /> 
    3338        <jar   
    34             jarfile="${plugin.name}.jar"   
    35             basedir="bin
     39            jarfile="${dist}/${jar}"   
     40            basedir="build
    3641            manifest="META-INF/MANIFEST.MF" 
    3742    > 
    3843          <!--Include this to add required files for auto registration wizard--> 
    3944          <metainf file="META-INF/base-plugins.xml"></metainf> 
    40           <metainf file="META-INF/base-configurations.xml"></metainf>         
     45          <!-- <metainf file="META-INF/base-configurations.xml"></metainf> -->
    4146        </jar>   
    4247     </target> 
  • plugins/base2/net.sf.basedb.normalizations/trunk/src/net/sf/basedb/plugins/AbstractNormalizationPlugin.java

    r729 r730  
    2828import net.sf.basedb.core.BioAssay;
    2929import net.sf.basedb.core.DbControl;
     30import net.sf.basedb.core.InvalidUseOfNullException;
    3031import net.sf.basedb.core.Item;
    3132import net.sf.basedb.core.ItemParameterType;
     
    7980      @return PluginParameter for a BioAssay
    8081   */
    81   protected PluginParameter<BioAssay> getReferenceGroupParameter(String label, String description)
     82  protected PluginParameter<BioAssay> getReferenceGroupParameter(List<BioAssay> assays, String label, String description)
    8283  {
    8384    if (referenceGroupParameter == null)
    8485    {
     86      if (assays == null || assays.size() == 0) throw new InvalidUseOfNullException("assays");
    8587      if (label == null) label = "Reference group";
    8688      if (description == null)
     
    9294      (
    9395        REFERENCE_GROUP, label, description,
    94         new ItemParameterType<BioAssay>(BioAssay.class, null, true, 0, null)
     96        new ItemParameterType<BioAssay>(BioAssay.class, null, true, 0, assays)
    9597       
    9698      );
  • plugins/base2/net.sf.basedb.normalizations/trunk/src/net/sf/basedb/plugins/AverageNormalization.java

    r729 r730  
    3030import net.sf.basedb.core.BioAssaySet;
    3131import net.sf.basedb.core.DbControl;
    32 import net.sf.basedb.core.DynamicQuery;
    3332import net.sf.basedb.core.DynamicResultIterator;
    3433import net.sf.basedb.core.DynamicSpotQuery;
     34import net.sf.basedb.core.ItemQuery;
    3535import net.sf.basedb.core.Job;
    3636import net.sf.basedb.core.PluginParameter;
     
    5151import net.sf.basedb.core.query.Expression;
    5252import net.sf.basedb.core.query.Expressions;
    53 import net.sf.basedb.core.query.Orders;
    5453import net.sf.basedb.core.query.Restriction;
    5554import net.sf.basedb.core.query.Restrictions;
     
    9897    Create restriction: column = :bioAssayColumn
    9998  */
    100   Restriction bioAssayRestriction = Restrictions.eq(
     99  private Restriction bioAssayRestriction = Restrictions.eq(
    101100      Dynamic.column(VirtualColumn.COLUMN),
    102101      Expressions.parameter("bioAssayColumn")
     
    132131  /*
    133132    From InteractivePlugin interface
    134    */
     133  */
    135134  @Override
    136135  public void configure(GuiContext context, Request request, Response response)
     
    171170  }
    172171
    173 
    174172  @Override
    175173  public RequestInformation getRequestInformation(GuiContext context, String command)
     
    218216       
    219217        //Normalize the data
    220         BioAssaySet child = normalize(dc, source, thisJob, refGroup, progress);
    221        
    222         //Finish up
    223         child.setName(childName);
    224         child.setDescription(childDescription);
    225         dc.commit();
    226         int normalizedSpots = child.getNumSpots();
    227         if (progress != null) progress.display(100, normalizedSpots + " spots normalized\n");
    228         response.setDone(normalizedSpots + " spots normalized, " + (source.getNumSpots() - normalizedSpots) + " spots removed");
     218        int noChannels = source.getRawDataType().getChannels();
     219        BioAssaySet child = null;
     220        switch (noChannels)
     221        {
     222          case 1:
     223            child = normalize(dc, source, thisJob, refGroup, progress);
     224            break;
     225
     226        }
     227       
     228        if (child != null)
     229        {
     230          //Finish up
     231          child.setName(childName);
     232          child.setDescription(childDescription);
     233          dc.commit();
     234          int normalizedSpots = child.getNumSpots();
     235          if (progress != null) progress.display(100, normalizedSpots + " spots normalized\n");
     236          response.setDone(normalizedSpots + " spots normalized, " + (source.getNumSpots() - normalizedSpots) + " spots removed");
     237        }
    229238      }
    230239      catch (Throwable ex)
     
    242251  */
    243252 
     253  /**
     254    Normalizes the data in a bio-assay set, using the average algorithm.
     255    Average algorithm uses a scale factor to calculate the normalized intensities.
     256    By dividing the average intensity of a virtual array(reference group) with
     257    the average intensity of all arrays in the data set.
     258    @param dc The DbControl, used for permission- and access control to the database
     259    @param source The bio-assay set with data to normalize.
     260    @param job Job that is running this plug-in.
     261    @param refGroup A list with one or several arrays, which should be used as a virtual array/reference group
     262    @param progress Progress reporter used to send back progress information back to the user.
     263   */
    244264  public BioAssaySet normalize(DbControl dc, BioAssaySet source, Job job, List<BioAssay> refGroup, ProgressReporter progress)
    245265  {
     266    //FIXME The normalization has no support for two-channel data.
     267    //FIXME Confirm normalization
    246268    if (progress != null) progress.display(0, "Preparing normalization...");
    247269   
     
    269291   
    270292    if (progress != null)
    271       progress.display((int)(normalizedSpots / totalNumSpots * 100),
     293      progress.display((int)((normalizedSpots* 100L) / totalNumSpots),
    272294                       normalizedSpots + " spots normalized");
    273295   
     
    319341        dc = sc.newDbControl();
    320342        BioAssaySet bas = getCurrentBioAssaySet(dc);
     343        ItemQuery<BioAssay> query = bas.getBioAssays();
    321344        List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(3);
    322345       
     
    327350
    328351        //Reference group
    329         parameters.add(getReferenceGroupParameter(null, null));
     352        parameters.add(getReferenceGroupParameter(query.list(dc)  ,null, null));
    330353        //TODO More normalization specific parameters???
     354       
     355        configureJob = new RequestInformation
     356        (
     357          Request.COMMAND_CONFIGURE_JOB,
     358          "Configure a new job",
     359          "Set reference group",
     360          parameters
     361        );
    331362      }
    332363    }
     
    343374    float averageVirtualArray;
    344375    float averageWholeGroup;
     376    float totSum = 0;
     377    long numOfSpots = 0;
    345378   
    346379    DynamicSpotQuery query = source.getSpotData();
     
    348381    query.restrictPermanent(bioAssayRestriction);
    349382   
    350     //Get average intensity for the bio assays in reference group.   
    351     float totSum = 0;
    352     long numOfSpots = 0;
     383    //Get average intensity for the bio assays in reference group.     
    353384    try
    354385    {
     
    363394        totSum = totSum + result.getFloat(sumCh1Index);
    364395        it.close();
    365       }     
     396      }
    366397    }
    367398    catch (SQLException e)
    368399    {
    369400      throw new BaseException(e);
    370     }   
     401    }
     402    if (numOfSpots == 0) throw new BaseException("No spots in reference group");
     403   
    371404    averageVirtualArray = totSum / numOfSpots;
     405    if (averageVirtualArray == 0) throw new BaseException("The average intensity is '0' for  the reference group");
    372406    query.reset();
    373407   
     
    394428      throw new BaseException(e);
    395429    }
    396     averageWholeGroup = totSum / numOfSpots;
    397    
     430    if (numOfSpots == 0) throw new BaseException("No spots in selected bio assay set");
     431    averageWholeGroup = totSum / numOfSpots;   
     432    if (averageWholeGroup == 0) throw new BaseException("The average intensity is '0' for the whole group");
    398433   
    399434    float scaleFactor = averageVirtualArray / averageWholeGroup;
Note: See TracChangeset for help on using the changeset viewer.