Contents
This document describes the process of filtering an existing bioassayset.See also
Transformation
item.
BioAssaySet
using the same DataCubeLayer
as the
source bioassayset.
BioAssay
item for each bioassay in the source bioassayset.
DataCubeColumn
as the source.
FilterBatcher
DynamicQuery
that reads data from the source bioassayset.
FilterBatcher.insert(AbstractSqlQuery)
method.
FilterBatcher.insert(column, position)
method to
insert the spots that passed the filter.
Note! Most of the above steps are implemented by the
net.sf.basedb.util.XXXXX
class. Most plugins should be able to use the methods in that class.
TODO - add example and implement similar functionality for filters that
the IntensityCalculatorUtil class provides for intensity calculators.
/** Filter a BioAssaySet using a restriction. */ public BioAssaySet filterBioAssaySet(BioAssaySet source, Expression restriction) { DbControl dc = source.getDbControl(); // Create Transformation Transformation t = source.newTransformation(null); dc.saveItem(t); // Create a new BioAssaySet using the same data cube and layer BioAssaySet filtered = t.newProduct(null, null, true); filtered.setName("Filtered bioassayset"); dc.saveItem(filtered); // Get all column and position coordinate for all spots that pass the filter DynamicQuery query = source.getSpotData(); query.select(Dynamic.select(VirtualColumn.COLUMN)); query.select(Dynamic.select(VirtualColumn.POSITION)); query.restrict(restriction); // Create a FilterBatcher FilterBatcher filterBatcher = filtered.getFilterBatcher(); // TODO - when implemented by the core this should be possible: // filterBatcher.insert(query); // Load the spot data and insert coordinates with batcher DynamicResultIterator spots = query.iterate(dc); int column = spots.getIndex(VirtualColumn.COLUMN.getName()); int position = spots.getIndex(VirtualColumn.POSITION.getName()); while (spots.hasNext()) { SqlResult r = spots.next(); filterBatcher.insert(r.getShort(column), r.getInt(position)); } // Close, commit and return filterBatcher.close(); dc.commit(); return filtered; }