2.17.2: 2011-06-17

net.sf.basedb.core
Class DataCube

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<D>
      extended by net.sf.basedb.core.ChildItem<DataCubeData>
          extended by net.sf.basedb.core.DataCube
All Implemented Interfaces:
AccessControlled, Identifiable

public class DataCube
extends ChildItem<DataCubeData>

A data cube is the main unit for an experiment to store analysed data. A location in the cube can be described by three coordinates: position, column and layer.

The position coordinate The position is similar to the position of raw data in a raw bioassay. The position coordinate can be linked to a single reporter. This means that all analysed data with that position coordinate is related to the specified reporter. Normally, this means that all raw data spots should have the same reporter, but this is not checked by the data cube. There may be exceptions, since a merge operation may merge raw data spots which have different, but still related, reporters (for example different reporters for the same gene). The position coordinate can then be linked to a a generic reporter for that gene.

The column coordinate The column corresponds to a single bioassay which can have links to any number of raw bioassays. The combination of position and column coordinate may be linked to any number of raw data spots. This means that all analysed data with that column/position coordinate has been calculated from the specified raw data spots. It is not checked that the specified raw data spots actually are members of the raw bioassays that the bioassay is linked to.

The layer coordinate The layer corresponds more or less to a bioassayset. All analysed data with a given layer is part of the same bioassayset. However, it is possible that more than one bioassayset use the same layer. For example, a filtering bioassayset that doesn't change the data uses the same layer as it's parent bioassayset.

Version:
2.0
Author:
Nicklas
See Also:
Dynamic API overview
Last modified
$Date: 2010-04-20 10:02:16 +0200 (Tue, 20 Apr 2010) $

Nested Class Summary
private static class DataCube.RawMappingQuery
          Select data from Dynamic#RawParents table.
 
Field Summary
private  long addedBytes
           
private  MappingBatcher mappingBatcher
           
private  PositionBatcher positionBatcher
           
static Item TYPE
          The type of item represented by this class.
 
Constructor Summary
DataCube(DataCubeData data)
          Creates a new data cube item from the given data.
 
Method Summary
(package private)  void addBytes(long bytes)
           
(package private)  int countSpotMappings()
          Count the number of raw data mappings for the spot with the most mappings.
static DataCube getById(DbControl dc, int id)
          Get a VirtualDb item when you know the id.
 long getBytes()
          Gets the number of bytes the analysed data in this cube occupies on disk.
 short getCubeNo()
          Get the number of this data cube.
 Experiment getExperiment()
          Get the experiment this data cube belongs to.
(package private)  MappingBatcher getMappingBatcher()
           
 int getMaxRawMappingsForSpot()
          Get the number of mappings to raw data spots for the spot with the most number of mappings.
(package private) static DataCube getNew(DbControl dc, VirtualDb virtualDb)
          Create a new DataCube item.
(package private)  short getNextColumnNo()
          Generate the next available column number.
(package private)  short getNextExtraValueNo()
          Generate the next available extra value number.
(package private)  short getNextFilterNo()
          Generate the next available filter number.
(package private)  short getNextLayerNo()
          Generate the next available layer number.
 short getNumColumns()
          Get the number of columns created in this data cube.
 short getNumExtraValues()
          Get the number of extra values created for this data cube.
 short getNumFilters()
          Get the number of filters created for this data cube.
 short getNumLayers()
          Get the number of layers created in this data cube.
 int getNumPositions()
          Get the number of positions created in this data cube.
(package private)  Permission getPermissionForWriteDeleteAndCreate()
          USE permission is enough to be able to manage data cubes.
(package private)  PositionBatcher getPositionBatcher()
           
 RawDataType getRawDataType()
          Get the raw data type this experiment uses for the raw data.
(package private)  SharedData getSharedParent()
          Get the experiment.
 Item getType()
          Get the type of item represented by the object.
(package private)  VirtualDb getVirtualDb()
          Get the virtual database this cube is a part of.
(package private)  DataCubeColumn newColumn()
          Create a new column in this database.
(package private)  DataCubeExtraValue newExtraValue(Type valueType, ExtraValue.CoordinateType coordinateType)
          Create a new extra vlaue in this data cube.
(package private)  DataCubeFilter newFilter()
          Create a new filter in this datacube.
(package private)  DataCubeLayer newLayer()
          Create a new layer in this datacube.
(package private)  void onBeforeCommit(Transactional.Action action)
          Delete data and update disk usage information on the experiment if action == Action.DELETE
private  void setCubeNo(short cubeNo)
           
(package private)  void setNumPositions(int positions)
          Set by the AbstractBatcher.close() method.
private  void setVirtualDb(VirtualDb virtualDb)
          Set the experiment.
 
Methods inherited from class net.sf.basedb.core.ChildItem
getPluginPermissions, initPermissions
 
Methods inherited from class net.sf.basedb.core.BasicItem
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE

public static final Item TYPE
The type of item represented by this class.

See Also:
Item.DATACUBE, getType()

addedBytes

private long addedBytes

positionBatcher

private PositionBatcher positionBatcher

mappingBatcher

private MappingBatcher mappingBatcher
Constructor Detail

DataCube

DataCube(DataCubeData data)
Creates a new data cube item from the given data.

Parameters:
data - the data
Method Detail

getNew

static DataCube getNew(DbControl dc,
                       VirtualDb virtualDb)
                throws BaseException
Create a new DataCube item.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
virtualDb - The virtual database the cube is located in
Returns:
The new DataCube item
Throws:
BaseException - If there is an error

getById

public static DataCube getById(DbControl dc,
                               int id)
                        throws ItemNotFoundException,
                               PermissionDeniedException,
                               BaseException
Get a VirtualDb item when you know the id.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
id - The id of the item to load
Returns:
The VirtualDb item
Throws:
ItemNotFoundException - If an item with the specified id is not found
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission to the item
BaseException - If there is another error

getType

public Item getType()
Description copied from interface: Identifiable
Get the type of item represented by the object. The returned value is one of the values defined in the Item enumeration.

Returns:
A value indicating the type of item

onBeforeCommit

void onBeforeCommit(Transactional.Action action)
              throws BaseException
Delete data and update disk usage information on the experiment if action == Action.DELETE

Overrides:
onBeforeCommit in class BasicItem<DataCubeData>
Throws:
BaseException - If there is an error
See Also:
Transactional, Core API overview - Transaction handling, Coding rules and guidelines for item classes

getSharedParent

SharedData getSharedParent()
Get the experiment.

Specified by:
getSharedParent in class ChildItem<DataCubeData>
Returns:
The parent item

getPermissionForWriteDeleteAndCreate

Permission getPermissionForWriteDeleteAndCreate()
USE permission is enough to be able to manage data cubes.

Overrides:
getPermissionForWriteDeleteAndCreate in class ChildItem<DataCubeData>

getRawDataType

public RawDataType getRawDataType()
Get the raw data type this experiment uses for the raw data.

Returns:
A RawDataType object

getExperiment

public Experiment getExperiment()
                         throws PermissionDeniedException,
                                BaseException
Get the experiment this data cube belongs to.

Returns:
An Experiment object
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission to the experiment
BaseException - If there is another error

getVirtualDb

VirtualDb getVirtualDb()
                 throws PermissionDeniedException,
                        BaseException
Get the virtual database this cube is a part of.

Returns:
A VirtualDb object
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission to the item
BaseException - If there is another error

setVirtualDb

private void setVirtualDb(VirtualDb virtualDb)
                   throws PermissionDeniedException,
                          InvalidDataException
Set the experiment. This cannot be changed after the dynamic tables has been created.

Throws:
PermissionDeniedException
InvalidDataException

getCubeNo

public short getCubeNo()
Get the number of this data cube.


setCubeNo

private void setCubeNo(short cubeNo)

getNumFilters

public short getNumFilters()
Get the number of filters created for this data cube.


getNextFilterNo

short getNextFilterNo()
                throws BaseException
Generate the next available filter number. This method will open a second transaction and update the DataCubeData.getNumFilters() property by one, unless this item hasn't been saved to the database yet.

Returns:
The next filter number
Throws:
BaseException

getNumExtraValues

public short getNumExtraValues()
Get the number of extra values created for this data cube.


getNextExtraValueNo

short getNextExtraValueNo()
                    throws BaseException
Generate the next available extra value number. This method will open a second transaction and update the DataCubeData.getNumExtraValues() property by one, unless this item hasn't been saved to the database yet.

Returns:
The next extra value number
Throws:
BaseException

getNumLayers

public short getNumLayers()
Get the number of layers created in this data cube.


getNextLayerNo

short getNextLayerNo()
               throws BaseException
Generate the next available layer number. This method will open a second transaction and update the DataCubeData.getNumLayers() property by one, unless this item hasn't been saved to the database yet.

Returns:
The next layer number
Throws:
BaseException

getNumColumns

public short getNumColumns()
Get the number of columns created in this data cube.


getNextColumnNo

short getNextColumnNo()
                throws BaseException
Generate the next available column number. This method will open a second transaction and update the DataCubeData.getNumColumns() property by one, unless this item hasn't been saved to the database yet.

Returns:
The next column number
Throws:
BaseException

getNumPositions

public int getNumPositions()
Get the number of positions created in this data cube.


setNumPositions

void setNumPositions(int positions)
Set by the AbstractBatcher.close() method. Cannot be updated after that.


getMaxRawMappingsForSpot

public int getMaxRawMappingsForSpot()
Get the number of mappings to raw data spots for the spot with the most number of mappings. For most data cubes this value is probably 1. After a merge, the count can be higher which may require some plugins to behave differently when using values from the raw data table.

Since:
2.2

getBytes

public long getBytes()
Gets the number of bytes the analysed data in this cube occupies on disk.


addBytes

void addBytes(long bytes)

newLayer

DataCubeLayer newLayer()
Create a new layer in this datacube.


newColumn

DataCubeColumn newColumn()
Create a new column in this database.


newFilter

DataCubeFilter newFilter()
Create a new filter in this datacube.


newExtraValue

DataCubeExtraValue newExtraValue(Type valueType,
                                 ExtraValue.CoordinateType coordinateType)
Create a new extra vlaue in this data cube.


getPositionBatcher

PositionBatcher getPositionBatcher()
                             throws BaseException
Throws:
BaseException

getMappingBatcher

MappingBatcher getMappingBatcher()
                           throws BaseException
Throws:
BaseException

countSpotMappings

int countSpotMappings()
Count the number of raw data mappings for the spot with the most mappings.

Since:
2.2

2.17.2: 2011-06-17