Class Transformation

All Implemented Interfaces:
AccessControlled, Identifiable, Nameable, Removable

public class Transformation extends ChildItem implements Nameable, Removable
A transformation represents an analysis step for an Experiment. There are two types of transformations. A root transformation is used to calculate the initial set of intensities from a set of RawBioAssay:s. The result of a transformation is usually one or more BioAssaySet:s. The other type of transformation takes a bioassayset as the source and recalculates the intensities, applies a filter or does something else.

A transformation is created by either the Experiment.newTransformation(Job, Collection) method or the BioAssaySet.newTransformation(Job) method.

Version:
2.0
Author:
Nicklas
See Also:
Last modified
$Date: 2015-11-18 09:08:17 +0100 (on, 18 nov 2015) $
  • Field Details

    • TYPE

      public static final Item TYPE
      The type of item represented by this class.
      See Also:
    • job

      private Job job
    • namedCubes

      private Map<String,DataCube> namedCubes
      Internal cache of named cubes used by the newProduct method.
    • namedLayers

      private Map<String,DataCubeLayer> namedLayers
      Internal cache of named layers used by the newProduct method.
  • Constructor Details

    • Transformation

      Transformation(TransformationData data)
      Creates a new experiment item from the given data.
      Parameters:
      data - the data
  • Method Details

    • getNew

      static Transformation getNew(DbControl dc, Experiment experiment, Job job) throws BaseException
      Create a new Transformation item. No source has been specified. A caller should use either: setSource(BioAssaySet) or setRawSources(Collection).
      Parameters:
      dc - The DbControl which will be used for permission checking and database access.
      experiment - The experiment
      job - The job that executed the transformation
      Returns:
      The new Transformation item
      Throws:
      BaseException - If there is another error
      See Also:
    • getById

      Get a Transformation 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 Transformation 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<Transformation> getQuery(Experiment experiment) throws InvalidDataException
      Get a query configured to retrieve transformations for a given experiment.
      Parameters:
      experiment - The experiment to retreive transformations for, null is not allowed
      Returns:
      An ItemQuery object
      Throws:
      InvalidDataException - If required parameter is null.
    • getQuery

      public static ItemQuery<Transformation> getQuery(BioAssaySet bioAssaySet) throws InvalidDataException
      Get a query configured to retrieve transformations using the given bioassayset as source.
      Parameters:
      bioAssaySet - The source bioassayset to retreive transformations for, null is not allowed
      Returns:
      An ItemQuery object
      Throws:
      InvalidDataException - If required parameter is null.
    • getData

      Description copied from class: BasicItem
      Get the BasicData object that holds all data for this item.
      Specified by:
      getData in class BasicItem
    • 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
    • getName

      public String getName()
      Description copied from interface: Nameable
      Get the name of the item.
      Specified by:
      getName in interface Nameable
      Returns:
      A String with the name of the item
    • setName

      public void setName(String name) throws PermissionDeniedException, InvalidDataException
      Description copied from interface: Nameable
      Set the name of the item. The name cannot be null and mustn't be longer than the value specified by the Nameable.MAX_NAME_LENGTH constant.
      Specified by:
      setName in interface Nameable
      Parameters:
      name - The new name for the item
      Throws:
      PermissionDeniedException - If the logged in user doesn't have write permission
      InvalidDataException - If the name is null or longer than specified by the Nameable.MAX_NAME_LENGTH constant
    • getDescription

      public String getDescription()
      Description copied from interface: Nameable
      Get the description for the item.
      Specified by:
      getDescription in interface Nameable
      Returns:
      A String with a description of the item
    • setDescription

      public void setDescription(String description) throws PermissionDeniedException, InvalidDataException
      Description copied from interface: Nameable
      Set the description for the item. The description can be null but mustn't be longer than the value specified by the Nameable.MAX_DESCRIPTION_LENGTH constant.
      Specified by:
      setDescription in interface Nameable
      Parameters:
      description - The new description for the item
      Throws:
      PermissionDeniedException - If the logged in user doesn't have write permission
      InvalidDataException - If the description longer than specified by the Nameable.MAX_DESCRIPTION_LENGTH constant
    • isRemoved

      public boolean isRemoved()
      Description copied from interface: Removable
      Check if the removed flag is set for this item.
      Specified by:
      isRemoved in interface Removable
      Returns:
      TRUE if the item is flagged as removed, FALSE otherwise
    • setRemoved

      public void setRemoved(boolean removed) throws PermissionDeniedException
      Description copied from interface: Removable
      Set the removed flag for this item.
      Specified by:
      setRemoved in interface Removable
      Parameters:
      removed - TRUE if the item should be flagged as removed, FALSE otherwise
      Throws:
      PermissionDeniedException - If the logged in user doesn't have Permission.DELETE permission for setting the flag to TRUE or Permission.WRITE permission for setting the flag to FALSE
    • getRemovedBy

      public User getRemovedBy() throws PermissionDeniedException, ItemNotFoundException
      Description copied from interface: Removable
      Get the user that flagged this item for removal.
      Specified by:
      getRemovedBy in interface Removable
      Returns:
      A User object, or null if this item has not been flagged
      Throws:
      PermissionDeniedException - If the logged in user doesn't have Permission.READ permission for the user
      ItemNotFoundException - If the user that removed this item can't be found
    • onBeforeCommit

      void onBeforeCommit(Transactional.Action action) throws BaseException
      Delete the product bioassaysets when deleting this transction. Set the experiment for the job when creating this transction.
      Overrides:
      onBeforeCommit in class BasicItem
      Throws:
      BaseException - If there is an error
      See Also:
    • getSharedParent

      SharedData getSharedParent()
      Get the experiment.
      Specified by:
      getSharedParent in class ChildItem
      Returns:
      The parent item
    • getPermissionForWriteDeleteAndCreate

      Permission getPermissionForWriteDeleteAndCreate()
      USE permission is enough to be able to manage transformations.
      Overrides:
      getPermissionForWriteDeleteAndCreate in class ChildItem
    • getExperiment

      public Experiment getExperiment() throws PermissionDeniedException, BaseException
      Get the experiment this transformation 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
    • setExperiment

      private void setExperiment(Experiment experiment)
      Set the experiment. This cannot be changed after the transformation has been created.
    • getSource

      Get the source bioassayset used by this transformation.
      Returns:
      A BioAssaySet item, or null if this is a root transformation
      Throws:
      PermissionDeniedException - If the logged in user doesn't have read permission to the experiment
      BaseException - If there is another error
      See Also:
    • setSource

      void setSource(BioAssaySet bioAssaySet)
      Set the source bioassayset. This cannot be changed after the transformation has been created.
      See Also:
    • getRawSources

      public ItemQuery<RawBioAssay> getRawSources()
      Get a query that returns the raw bioassay sources used by this transformation. It is only a root transformation that has raw bioassays as sources, other transformations has a source BioAssaySet.
      Returns:
      An ItemQuery object
      See Also:
    • setRawSources

      void setRawSources(Collection<RawBioAssay> rawBioAssays) throws InvalidDataException
      Set the raw bioassay sources used in this transformation. Can only be specified for a root transformation. All raw bioassays must be members of the experiment.
      Throws:
      InvalidDataException - If any of the raw bioassays are not part of the experiment
      See Also:
    • getJob

      public Job getJob() throws PermissionDeniedException, BaseException
      Get the job that executed this transformation.
      Returns:
      A Job object, ot null if this transformation wasn't executed by a job
      Throws:
      PermissionDeniedException - If the logged in user doesn't have read permission to the experiment
      BaseException - If there is another error
    • setJob

      private void setJob(Job job)
      Set the job that executed this transformation. Once set it can't be changed.
    • newProduct

      public BioAssaySet newProduct(String namedCube, String namedLayer, boolean createChildBioAssays) throws PermissionDeniedException, InvalidDataException, BaseException
      Create a new product bioassayset from this transformation. The transformation mustn't have been committed to the database. The bioassayset can use either the same data cube/layer as the source bioassayset is using, a new data cube/layer or a data cube/layer that has previously been created by this method. The names specified here are only valid for the current session and are only needed if the transformation must create more than one bioassayset in a different data cube than it's source bioassayset.
      Transformation t = ...
      
      // Use same data cube, but a new layer. Automatically create child bioassays
      BioAssaySet bas = t.newProduct(null, "new", true);
      
      // Use same data cube and layer. Automatically create child bioassays
      BioAssaySet filtered = t.newProduct(null, null, true);
      
      // Use new data cube and layer. Automatic creation of 
      // child bioassays is not supported
      BioAsssySet merged = t.newProduct("new", "new", false);
      
      // Create four new bioassaysets using two datacubes, one
      // with two layers and one with one layer
      BioAssaySet bas1 = t.newProduct("cube1", "layer1", false);
      BioAssaySet bas2 = t.newProduct("cube1", "layer2", false);
      BioAssaySet bas3 = t.newProduct("cube2", "layer3", false);
      BioAssaySet bas4 = t.newProduct("cube2", "layer3", false);
      
      Note that the name of the layer is checked first, so we can't have the layers with the same name in two different cubes. For example the following call won't work:
      // Don't! We bas3 is now using the same cube and layer as bas1
      BioAssaySet bas3 = t.newProduct("cube2", "layer1", false);
      
      Parameters:
      namedCube - The name of the data cube where the new bioassayset should store/find it's data. If no data cube with the specified name exists a new data cube is created. Specify 'null' to use the same data cube as the source bioassayset.
      namedLayer - The name of the data cube layer where the new bioassayset should store/find it's data. If no layer with the specified name exists a new layer is created. Specify 'null' to use the same layer as the source bioassayset.
      createChildBioAssays - TRUE to create one child bioassay for each bioassay in the source bioassay set. This requires that the product is created in the same data cube as the source bioassay set, ie. namedCube should be null
      Returns:
      The new bioassayset
      Throws:
      PermissionDeniedException - If the logged in user doesn't have write permission for the experiment this transformation belongs to or if this transformation has already been committed to the database
      InvalidDataException - If the layer is null or not part of the same experiment as this transformation
      BaseException - If there is another error
    • getProducts

      public ItemQuery<BioAssaySet> getProducts()
      Get a query that return all bioassaysets created by this transformation.
      Returns:
      An ItemQuery object
      See Also:
    • deleteProducts

      private void deleteProducts()
      Delete all product bioassaysets. Called by onBeforeCommit when the transformation is deleted.