2.17.2: 2011-06-17

net.sf.basedb.core
Class ArrayDesign

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<D>
      extended by net.sf.basedb.core.OwnedItem<D>
          extended by net.sf.basedb.core.SharedItem<D>
              extended by net.sf.basedb.core.CommonItem<D>
                  extended by net.sf.basedb.core.AnnotatedItem<ArrayDesignData>
                      extended by net.sf.basedb.core.ArrayDesign
All Implemented Interfaces:
AccessControlled, Annotatable, FileStoreEnabled, Identifiable, Nameable, Ownable, Registered, Removable, Shareable, ToTransferable<ArrayDesignInfo>

public class ArrayDesign
extends AnnotatedItem<ArrayDesignData>
implements FileStoreEnabled, ToTransferable<ArrayDesignInfo>, Registered

An array design is a description of the design of a microarray slide. An array design item is first created without any Feature information. A feature maps a coordinate on the array to a Reporter. Features can be added with links directly to reporters, or to Wells if the array design is associated with a set of Plates.

Once features has been added to the array design, they cannot be removed or modified.

Version:
2.0
Author:
Nicklas, Enell
See Also:
ArrayBatch, ArraySlide, Plate, Feature, ArrayDesignBlock

Field Summary
private  Map<BlockInfo,Integer> blocks
           
private  FeatureBatcher featureBatcher
           
static Item TYPE
          The type of item represented by this class.
 
Fields inherited from interface net.sf.basedb.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
 
Constructor Summary
ArrayDesign(ArrayDesignData arrayDesignData)
           
 
Method Summary
 ArrayDesignBlock addArrayDesignBlock(BlockInfo bi)
          Adds an ArrayDesignBlock to the array design.
 void addPlate(Plate plate)
          Adds a single plate to the plate list.
 Set<Annotatable> getAnnotatableParents()
          Get the plates, if any.
 ItemQuery<ArrayBatch> getArrayBatches()
          Get a query that returns the batches for this design.
 ItemQuery<ArrayDesignBlock> getArrayDesignBlocks()
          Get a query that returns the block of this array design.
 ItemQuery<ArrayDesignPlate> getArrayDesignPlates()
          Get plate connections for this array design.
static ArrayDesign getById(DbControl dc, int id)
          Get an ArrayDesign item when you know the ID.
 Date getEntryDate()
          Get the date that the item was registered in the database.
 FeatureBatcher getFeatureBatcher()
          Deprecated. Use getFeatureBatcher(FeatureIdentificationMethod, Job) instead
 FeatureBatcher getFeatureBatcher(FeatureIdentificationMethod fiMethod, Job job)
          Get a feature batcher which can be used to add regular features to the array design.
 FeatureData getFeatureById(int id)
          Get a feature when you know the id.
 FeatureData getFeatureById(int id, boolean forceInitialization)
          Get a feature when you know the id.
 FeatureIdentificationMethod getFeatureIdentificationMethod()
          Get the method used to identify features on this array design.
 DataQuery<FeatureData> getFeatures()
          Get a query that returns the regular features of this array design.
 FileSet getFileSet()
          Get the file set that collects all files that holds data for this item.
 Job getJob()
          Get the job that imported features to this array design.
static ArrayDesign getNew(DbControl dc, boolean affyChip)
          Deprecated. Use getNew(DbControl, Platform) instead
static ArrayDesign getNew(DbControl dc, Platform platform)
          Create a new ArrayDesign item for a given platform.
static ArrayDesign getNew(DbControl dc, PlatformVariant variant)
          Create a new ArrayDesign item for a given platform variant.
 int getNumArrays()
          Get the number of arrays on a single slide.
 int getNumDbFeatures()
          Get the number of features on this array design that are stored in the database.
 long getNumFeatures(DbControl dc)
          Deprecated. Use getNumDbFeatures() and/or getNumFileFeatures() instead
 int getNumFileFeatures()
          Get the number of features on this array design that are stored inside files.
 int getNumPlates()
          The number of plates connected to this array design.
 Collection<FileSet> getParentFileSets()
          There are no parent file sets.
 Plate getPlate(int position)
          Get a Plate from a given position.
 int getPlatePosition(Plate plate)
          Get the position of a Plate in this array design.
 ItemQuery<Plate> getPlates()
          Get a query that returns the plates that are used by this arraydesign.
 Platform getPlatform()
          Get the platform the item is related to.
static ItemQuery<ArrayDesign> getQuery()
          Get a ItemQuery object configured to retrieve array designs.
 DataQuery<ReporterData> getReporters()
          Get a query that returns the reporters on this array design.
 Item getType()
          Get the type of item represented by the object.
 Set<ItemProxy> getUsingItems()
          Get all: ArrayBatch:s of this design RawBioAssay:s of this design
 PlatformVariant getVariant()
          Get the platform variant the item is related to.
 boolean hasFeatures()
          Check if this array design has information about features, either in the database or in files.
 boolean hasFileSet()
          Check if this item has a file set.
 boolean isAffyChip()
          Deprecated. Use isPlatform(String) instead with Platform.AFFYMETRIX as the parameter
 boolean isFileOnlyPlatform()
          Check if this array design uses a file-only platform or variant.
 boolean isPlatform(String externalId)
          Check if the platform/variant of this array design has the given external ID.
 boolean isUsed()
          Check if this item is used by some other item.
 ArrayBatch newArrayBatch()
          Create a new ArrayBatch with this design.
 void setNumArrays(int numArrays)
          Set the number of arrays on a single slide.
 void setNumFileFeatures(int numFeatures)
          Set the number of features that are stored in files.
 void setPlateList(List<Plate> plates)
          Set the list of plates to be used by this array design.
 void setPlatform(Platform platform)
          Set the platform of the array design.
 void setVariant(PlatformVariant variant)
          Set the platform and variant of the array design.
 ArrayDesignInfo toTransferable(ArrayDesignInfo info)
          Transfer the internal state to a transferable object.
 FeatureBatcher xgetFeatureBatcher(FeatureIdentificationMethod fiMethod)
          Deprecated. Use getFeatureBatcher(FeatureIdentificationMethod, Job) instead
 
Methods inherited from class net.sf.basedb.core.AnnotatedItem
getAnnotationSet, getProtocol, isAnnotated, removeAnnotations, toTransferable
 
Methods inherited from class net.sf.basedb.core.CommonItem
getDescription, getName, isRemoved, setDescription, setName, setRemoved, toTransferable
 
Methods inherited from class net.sf.basedb.core.SharedItem
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey, toTransferable
 
Methods inherited from class net.sf.basedb.core.OwnedItem
getOwner, isOwner, setOwner, takeOwnership, toTransferable
 
Methods inherited from class net.sf.basedb.core.BasicItem
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.basedb.core.Identifiable
getId, getVersion
 
Methods inherited from interface net.sf.basedb.core.AccessControlled
checkPermission, getPermissions, hasPermission
 
Methods inherited from interface net.sf.basedb.core.Ownable
getOwner, isOwner, setOwner, takeOwnership
 

Field Detail

TYPE

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

See Also:
Item.ARRAYDESIGN, getType()

featureBatcher

private FeatureBatcher featureBatcher

blocks

private Map<BlockInfo,Integer> blocks
Constructor Detail

ArrayDesign

ArrayDesign(ArrayDesignData arrayDesignData)
Method Detail

getNew

public static ArrayDesign getNew(DbControl dc,
                                 boolean affyChip)
                          throws BaseException
Deprecated. Use getNew(DbControl, Platform) instead

Create a new ArrayDesign item.

Parameters:
dc - The DbControl which will be used for permission checking and database access
affyChip - true if the new design is an Affymetrix chip, false otherwise
Returns:
The new ArrayDesign item
Throws:
BaseException - If there is an error

getNew

public static ArrayDesign getNew(DbControl dc,
                                 Platform platform)
Create a new ArrayDesign item for a given platform.

Parameters:
dc - The DbControl which will be used for permission checking and database access
platform - The platform of the array design
Returns:
The new ArrayDesign item
Throws:
BaseException - If there is an error
Since:
2.5

getNew

public static ArrayDesign getNew(DbControl dc,
                                 PlatformVariant variant)
Create a new ArrayDesign item for a given platform variant.

Parameters:
dc - The DbControl which will be used for permission checking and database access
variant - The platform variant of the array design
Returns:
The new ArrayDesign item
Throws:
BaseException - If there is an error
Since:
2.5

getById

public static ArrayDesign getById(DbControl dc,
                                  int id)
                           throws ItemNotFoundException,
                                  PermissionDeniedException,
                                  BaseException
Get an ArrayDesign 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 ArrayDesign 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

getQuery

public static ItemQuery<ArrayDesign> getQuery()
Get a ItemQuery object configured to retrieve array designs.

Returns:
An ItemQuery object

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.

Specified by:
getType in interface Identifiable
Returns:
A value indicating the type of item

getAnnotatableParents

public Set<Annotatable> getAnnotatableParents()
                                       throws BaseException
Get the plates, if any.

Specified by:
getAnnotatableParents in interface Annotatable
Returns:
A set containing annotatable items, or null
Throws:
BaseException - If there is an error

getFileSet

public FileSet getFileSet()
Description copied from interface: FileStoreEnabled
Get the file set that collects all files that holds data for this item. If no file set exists a new one is created and automatically saved to the database when DbControl.commit() is called. To check if an item has files without creating a new file set use the FileStoreEnabled.hasFileSet() method.

Specified by:
getFileSet in interface FileStoreEnabled
Returns:
A file set
Since:
2.5

hasFileSet

public boolean hasFileSet()
Description copied from interface: FileStoreEnabled
Check if this item has a file set. Always call this method before FileStoreEnabled.getFileSet() to avoid creating a new file set when there is no need for it.

Specified by:
hasFileSet in interface FileStoreEnabled
Returns:
TRUE if a file set exists, FALSE if not
Since:
2.5

getPlatform

public Platform getPlatform()
Description copied from interface: FileStoreEnabled
Get the platform the item is related to. The platform is used to limit the DataFileType:s that can be added to the file set.

Specified by:
getPlatform in interface FileStoreEnabled
Returns:
A platform or null if the items is not related to any platform.
Since:
2.5

getVariant

public PlatformVariant getVariant()
Description copied from interface: FileStoreEnabled
Get the platform variant the item is related to. The platform is used to limit the DataFileType:s that can be added to the file set.

Specified by:
getVariant in interface FileStoreEnabled
Returns:
A platform or null if the items is not related to any variant.
Since:
2.5

getParentFileSets

public Collection<FileSet> getParentFileSets()
There are no parent file sets.

Specified by:
getParentFileSets in interface FileStoreEnabled
Returns:
Always null
Since:
2.5

getEntryDate

public Date getEntryDate()
Description copied from interface: Registered
Get the date that the item was registered in the database.

Specified by:
getEntryDate in interface Registered
Returns:
A date or null if this is not known

isUsed

public boolean isUsed()
               throws BaseException
Description copied from class: BasicItem
Check if this item is used by some other item. With used we mean that another item is linking to this item in way that prevents this item from beeing deleted. Ie. if we tried to delete an item that is used, we would get a foreign key violation error from the database. If the subclass overrides this method it should propagate the call to the superclass, ie. super.isUsed(), unless it has decided that the item is used by some other means.

Overrides:
isUsed in class BasicItem<ArrayDesignData>
Returns:
TRUE if this item is used, FALSE otherwise
Throws:
BaseException - If not able to tell if item is used or not.
See Also:
BasicItem.getUsingItems()

getUsingItems

public Set<ItemProxy> getUsingItems()
Get all:

setPlatform

public void setPlatform(Platform platform)
Set the platform of the array design. This method will set the variant to null. Use setVariant(PlatformVariant) if you want to set a specific variant.

Parameters:
platform - The new platform
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If platform is null
Since:
2.5

setVariant

public void setVariant(PlatformVariant variant)
Set the platform and variant of the array design. This method will automatically set the platform to PlatformVariant.getPlatform().

Parameters:
variant - The new platform variant, or null to remove the variant and keep the platform as it is
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
Since:
2.5

isPlatform

public boolean isPlatform(String externalId)
Check if the platform/variant of this array design has the given external ID.

Parameters:
externalId - The external ID to match
Returns:
TRUE if either the variant of platform matches the external ID
Since:
2.5

isFileOnlyPlatform

public boolean isFileOnlyPlatform()
Check if this array design uses a file-only platform or variant. If the array design has a platform variant, the setting from the variant is returned, otherwise the setting from the platform.

Returns:
TRUE if this array design use a file-only variant / platform
Since:
2.5

isAffyChip

public boolean isAffyChip()
Deprecated. Use isPlatform(String) instead with Platform.AFFYMETRIX as the parameter

Returns:
TRUE if this is an Affymetrix chip, FALSE otherwise.

getJob

public Job getJob()
           throws PermissionDeniedException,
                  BaseException
Get the job that imported features to this array design.

Returns:
A Job object, ot null if this information is not available
Throws:
PermissionDeniedException - If the logged in user doesn't have read permission to the job
BaseException - If there is another error
Since:
2.7

getNumArrays

public int getNumArrays()
Get the number of arrays on a single slide. The default value is 1.

Since:
2.6

setNumArrays

public void setNumArrays(int numArrays)
Set the number of arrays on a single slide.

Parameters:
numArrays - A value > 0
Throws:
NumberOutOfRangeException - If the value is <=0
Since:
2.6

hasFeatures

public boolean hasFeatures()
Check if this array design has information about features, either in the database or in files.

Returns:
TRUE if this object has features, FALSE otherwise

getFeatureIdentificationMethod

public FeatureIdentificationMethod getFeatureIdentificationMethod()
Get the method used to identify features on this array design.

Returns:
A FeatureIdentificationMethod
Since:
2.6

getPlates

public ItemQuery<Plate> getPlates()
                           throws BaseException
Get a query that returns the plates that are used by this arraydesign.

Returns:
An ItemQuery object
Throws:
BaseException - If something fails when getting the query.

getArrayDesignPlates

public ItemQuery<ArrayDesignPlate> getArrayDesignPlates()
Get plate connections for this array design. This method has better performance than using the getPlates() and getPlatePosition(Plate) and/or getPlate(int) methods since it only requires a single query to the database.

Returns:
An ItemQuery object

getPlatePosition

public int getPlatePosition(Plate plate)
Get the position of a Plate in this array design.

Parameters:
plate - The plate.
Returns:
The position of the plate. -1 if the array design doesn't contain this plate.

getPlate

public Plate getPlate(int position)
Get a Plate from a given position.

Parameters:
position - The position of the plate, starting at 0
Returns:
The plate or null if the position couldn't be found

getNumPlates

public int getNumPlates()
The number of plates connected to this array design.

Returns:
The number of plates.

setPlateList

public void setPlateList(List<Plate> plates)
                  throws PermissionDeniedException
Set the list of plates to be used by this array design. If the logged in user lacks Permission.USE to any plate in the list no plates will be added.

Parameters:
plates - A list of plates to replace the old list with. It may not contain nulls, but if the list is null or empty all plates will be removed.
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.WRITE permission to this ArrayDesign item or Permission.USE permission to any plate item in the list or tries to add a plate to an arraydesign that has features.

addPlate

public void addPlate(Plate plate)
              throws PermissionDeniedException
Adds a single plate to the plate list.

Parameters:
plate - the Plate item to be added to the list. It may be null.
Throws:
PermissionDeniedException - If the logged in user doesn't have Permission.WRITE permission to this ArrayDesign item , Permission.USE permission to the plate item or tries to add a plate to an arraydesign that has features.

newArrayBatch

public ArrayBatch newArrayBatch()
                         throws PermissionDeniedException,
                                BaseException
Create a new ArrayBatch with this design.

Returns:
The new ArrayBatch item
Throws:
PermissionDeniedException - If the logged in user doesn't have use permission for this design
BaseException - If there is another error

getArrayBatches

public ItemQuery<ArrayBatch> getArrayBatches()
Get a query that returns the batches for this design.

Returns:
An ItemQuery object

addArrayDesignBlock

public ArrayDesignBlock addArrayDesignBlock(BlockInfo bi)
                                     throws PermissionDeniedException,
                                            BaseException
Adds an ArrayDesignBlock to the array design. If the block already exists it is returned instead. Unlike other items, the block is automatically saved to the database. The reason is that otherwise we wouldn't be able to add features to the block since the FeatureBatcher object requires that the block has an id.

Use the getFeatureBatcher() method to get an batcher object that can add features to the new block.

It is not possible to add blocks to an array design which uses a file-only platform. The must store feature information in files instead. See Platform and DataFileType.

Parameters:
bi - The information for the new block
Returns:
The new ArrayDesignBlock
Throws:
PermissionDeniedException - if the logged in user doesn't have write permission on the array design
BaseException - If there is another error

getFeatureBatcher

public FeatureBatcher getFeatureBatcher()
                                 throws PermissionDeniedException,
                                        BaseException
Deprecated. Use getFeatureBatcher(FeatureIdentificationMethod, Job) instead

Get a feature batcher that uses the COORDINATES feature identification method.

Throws:
PermissionDeniedException
BaseException

xgetFeatureBatcher

public FeatureBatcher xgetFeatureBatcher(FeatureIdentificationMethod fiMethod)
                                  throws PermissionDeniedException,
                                         BaseException
Deprecated. Use getFeatureBatcher(FeatureIdentificationMethod, Job) instead

Throws:
PermissionDeniedException
BaseException
Since:
2.6

getFeatureBatcher

public FeatureBatcher getFeatureBatcher(FeatureIdentificationMethod fiMethod,
                                        Job job)
                                 throws PermissionDeniedException,
                                        BaseException
Get a feature batcher which can be used to add regular features to the array design.

It is not possible to add blocks to an array design which uses a file-only platform. The must store feature information in files instead. See Platform and DataFileType.

Parameters:
fiMethod - The method to use for identifying features
job - The job that is currently running, or null if the feature import is not running as a job
Returns:
The feature batcher of the array design. If this method is called multiple times the fiMethod and job parameter is ignored and the same batcher as before is returned.
Throws:
PermissionDeniedException - If raw data has already been added or the logged in user doesn't have write permission
BaseException - If there is another error
Since:
2.7

getFeatures

public DataQuery<FeatureData> getFeatures()
Get a query that returns the regular features of this array design.

Returns:
A DataQuery object

getReporters

public DataQuery<ReporterData> getReporters()
Get a query that returns the reporters on this array design. The query is rooted at the features, which means that:

Returns:
A DataQuery object
Since:
2.8

getFeatureById

public FeatureData getFeatureById(int id)
                           throws ItemNotFoundException,
                                  BaseException
Get a feature when you know the id. NOTE! This method may return an uninitialized proxy. If an initialized object is required use getFeatureById(int, boolean) instead.

Parameters:
id - The id of the feature
Throws:
ItemNotFoundException - If the feature could not be found.
BaseException - If something else fails when getting the feature.

getFeatureById

public FeatureData getFeatureById(int id,
                                  boolean forceInitialization)
Get a feature when you know the id.

Parameters:
id - The id of the feature
forceInitialization - If TRUE the feature and associated reporter are sure to be initialized
Throws:
ItemNotFoundException - If the feature could not be found.
BaseException - If something else fails when getting the feature
Since:
2.15

getArrayDesignBlocks

public ItemQuery<ArrayDesignBlock> getArrayDesignBlocks()
Get a query that returns the block of this array design.

Returns:
An ItemQuery object
See Also:
ArrayDesignBlock.getQuery(ArrayDesign)

getNumFeatures

public long getNumFeatures(DbControl dc)
Deprecated. Use getNumDbFeatures() and/or getNumFileFeatures() instead

Get the number of features added to this array design. If the array design has features in the database the value from getNumDbFeatures() is returned, otherwise the value from getNumFileFeatures()

Returns:
The number of features or probesets
Since:
2.4

getNumDbFeatures

public int getNumDbFeatures()
Get the number of features on this array design that are stored in the database.

Returns:
The number of features or probesets
Since:
2.5

getNumFileFeatures

public int getNumFileFeatures()
Get the number of features on this array design that are stored inside files.

Returns:
The number of features or probesets
Since:
2.5

setNumFileFeatures

public void setNumFileFeatures(int numFeatures)
Set the number of features that are stored in files.

Parameters:
numFeatures - The number of features
Since:
2.5

toTransferable

public ArrayDesignInfo toTransferable(ArrayDesignInfo info)
Description copied from interface: ToTransferable
Transfer the internal state to a transferable object. The method should return the same object that is passed in as an argument.

Specified by:
toTransferable in interface ToTransferable<ArrayDesignInfo>
Parameters:
info - The transferable object to use
Returns:
The transferable object with values set.
Since:
2.5

2.17.2: 2011-06-17