Changeset 873


Ignore:
Timestamp:
Dec 4, 2008, 11:53:05 AM (13 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #151: Use two queries instead of one in DetectionPValue.run() method

File:
1 edited

Legend:

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

    • Property svn:eol-style set to native
    • Property svn:keywords set to Date Id
    r833 r873  
    22  $Id$
    33
    4   Copyright (C) 2008 Jari Häkkinen
     4  Copyright (C) 2008 Jari Hakkinen
    55
    66  This file is part of BASE - BioArray Software Environment.
     
    394394      dc.saveItem(child);
    395395
     396      // Create restriction: column = :bioAssayColumn
     397      Restriction bioAssayRestriction = Restrictions.eq(
     398        Dynamic.column(VirtualColumn.COLUMN),
     399        Expressions.parameter("bioAssayColumn")
     400        );
     401      // Channel one contains the data
     402      Expression ch1=Dynamic.rawData("mean");
     403
     404      // Prepare query to retrieve spot data. We use a parameter to
     405      // restrict the query to return data for one bioassay at a time
     406      DynamicSpotQuery mainQuery = source.getSpotData();
     407      mainQuery.joinRawData(JoinType.INNER);
     408      mainQuery.selectPermanent(Dynamic.select(VirtualColumn.COLUMN));
     409      mainQuery.selectPermanent(Dynamic.select(VirtualColumn.POSITION));
     410      mainQuery.selectPermanent(Selects.expression(ch1,"ch1"));
     411      mainQuery.restrictPermanent(bioAssayRestriction);
     412
     413      // Prepare a second query to retrieve control data
    396414      // Create restriction: negative control beads only (background spots)
    397415      Expression control = Dynamic.reporter("controlGroupName");
     
    399417        Restrictions.eq(control, Expressions.string("negative"))
    400418        );
    401 
    402       // Create restriction: column = :bioAssayColumn
    403       Restriction bioAssayRestriction = Restrictions.eq(
    404         Dynamic.column(VirtualColumn.COLUMN),
    405         Expressions.parameter("bioAssayColumn")
    406         );
    407 
    408       // Prepare query to retrieve spot data. We use a parameter to
    409       // restrict the query to return data for one bioassay at a time
    410       DynamicSpotQuery query = source.getSpotData();
    411       query.joinRawData(JoinType.INNER);
    412       query.selectPermanent(Dynamic.select(VirtualColumn.COLUMN));
    413       query.selectPermanent(Dynamic.select(VirtualColumn.POSITION));
    414       Expression ch1=Dynamic.rawData("mean");
    415       query.selectPermanent(Selects.expression(ch1,"ch1"));
    416       query.restrictPermanent(bioAssayRestriction);
    417       query.setReturnTotalCount(true);
    418 
     419      DynamicSpotQuery controlQuery = source.getSpotData();
     420      controlQuery.joinRawData(JoinType.INNER);
     421      controlQuery.selectPermanent(Selects.expression(ch1,"ch1"));
     422      controlQuery.restrictPermanent(bioAssayRestriction);
     423      controlQuery.restrict(controlRestriction);
     424      controlQuery.order(Orders.asc(ch1));
     425      controlQuery.setReturnTotalCount(true);
     426     
    419427      try
    420428      {
     
    440448          // extract negative control intensities for this bioassay
    441449          short bioassayColumn = assay.getDataCubeColumnNo();
    442           query.setParameter("bioAssayColumn", (int)bioassayColumn, Type.INT);
    443           query.restrict(controlRestriction);
    444           query.order(Orders.asc(ch1));
    445           DynamicResultIterator dri = query.iterate(dc);
     450          controlQuery.setParameter("bioAssayColumn", (int)bioassayColumn, Type.INT);
     451          DynamicResultIterator dri = controlQuery.iterate(dc);
    446452          int ch1Index = dri.getIndex(VirtualColumn.channel(1).getName());
    447453          float[] sortedControlIntensity=new float[(int)dri.getTotalCount()];
     
    459465
    460466          // calculate detection P-value for all beadsets
    461           query.reset();  // remove controlRestriction and ordering
    462           query.setParameter("bioAssayColumn", (int)bioassayColumn, Type.INT);
    463           dri = query.iterate(dc);
     467          mainQuery.setParameter("bioAssayColumn", (int)bioassayColumn, Type.INT);
     468          dri = mainQuery.iterate(dc);
    464469          int positionIndex = dri.getIndex(VirtualColumn.POSITION.getName());
    465470          int columnIndex = dri.getIndex(VirtualColumn.COLUMN.getName());
Note: See TracChangeset for help on using the changeset viewer.