uk.ac.sanger.cgp.standalonecsa.services
Class ChromatogramServiceImpl

java.lang.Object
  extended by uk.ac.sanger.cgp.standalonecsa.services.ChromatogramServiceImpl
All Implemented Interfaces:
ChromatogramService

public class ChromatogramServiceImpl
extends java.lang.Object
implements ChromatogramService

This class handles rendering of chromatogram graphics.

Author:
Original: kr2, $Author: kr2 $

Field Summary
protected static org.apache.commons.logging.Log log
           
 
Constructor Summary
ChromatogramServiceImpl()
          Creates a new instance of ChromatogramServiceImpl
 
Method Summary
 java.awt.image.BufferedImage generateComplexVariantView(java.lang.String pathRoot, ExperimentBean expBean, ExperimentBean wtExp, boolean drawBaseChar, boolean writeToFile)
          Generates images required for the complex variant view.
 java.awt.image.BufferedImage generateFullChrom(java.lang.String pathStub, ExperimentBean expBean, boolean writeImage, boolean drawBaseChar)
          Generates a full chromatogram image.
 java.awt.image.BufferedImage[] generateVariantViewSet(java.lang.String pathRoot, ExperimentBean expBean, ExperimentBean wtExp, boolean drawBaseChar, boolean writeToFile)
          Generates images required for the simple variant view.
 java.awt.image.BufferedImage generateVariantViewSingle(java.lang.String pathRoot, ExperimentBean expBean, boolean writeToFile, boolean drawBaseChar)
          Generates an image as used in the simple variant view.
 void resetPreviousRendered()
          Resets the set of files that have been previously rendered and written to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
Constructor Detail

ChromatogramServiceImpl

public ChromatogramServiceImpl()
Creates a new instance of ChromatogramServiceImpl

Method Detail

generateVariantViewSingle

public java.awt.image.BufferedImage generateVariantViewSingle(java.lang.String pathRoot,
                                                              ExperimentBean expBean,
                                                              boolean writeToFile,
                                                              boolean drawBaseChar)
Description copied from interface: ChromatogramService
Generates an image as used in the simple variant view. Method should behave as follows:

- ExperimentBean.getVariantToRender() must not be null
- calculate where image should start and finish based on the length of the variant
- render and write to file (if indicated) the segment

If writeToFile is false pathRoot can be null

Specified by:
generateVariantViewSingle in interface ChromatogramService
Parameters:
pathRoot - directory to write image to
expBean - the experiment to use when rendering this variant
writeToFile - indicates if writing to a file should be attempted
drawBaseChar - true when base character should be rendered over the change
Returns:
to be used if further processing of image is required, or streaming

generateVariantViewSet

public java.awt.image.BufferedImage[] generateVariantViewSet(java.lang.String pathRoot,
                                                             ExperimentBean expBean,
                                                             ExperimentBean wtExp,
                                                             boolean drawBaseChar,
                                                             boolean writeToFile)
Description copied from interface: ChromatogramService
Generates images required for the simple variant view. Method should behave as follows:

- variant ExperimentBean.getVariantToRender() must not be null
- calculate where image should start and finish based on the length of the variant
- render and write to file (if indicated) the variant and wildtype segment
- if a compliment comparison was performed render these segments too

Specified by:
generateVariantViewSet in interface ChromatogramService
Parameters:
pathRoot - directory to write image to
expBean - the variant experiment to use when rendering this variant
wtExp - the wildtype experiment to use when rendering this variant
drawBaseChar - true when base character should be rendered over the change
writeToFile - indicates if writing to a file should be attempted
Returns:
array of BufferedImages, ordered {sample, reference, compliment sample, compliment reference}.

generateComplexVariantView

public java.awt.image.BufferedImage generateComplexVariantView(java.lang.String pathRoot,
                                                               ExperimentBean expBean,
                                                               ExperimentBean wtExp,
                                                               boolean drawBaseChar,
                                                               boolean writeToFile)
Description copied from interface: ChromatogramService
Generates images required for the complex variant view. Method should behave as follows:

- variant ExperimentBean.getVariantToRender() must not be null
- render full trace for both variant and wildtype traces, but not write to file
- calculate which image should be shifted to right to align variant location
- calculate the x offset for the shift
- create a new image with the wildtype displayed at the top and the variant trace on the bottom
- write this new image to file

Specified by:
generateComplexVariantView in interface ChromatogramService
Parameters:
pathRoot - directory to write image to
expBean - the variant experiment to use when rendering this variant
wtExp - the wildtype experiment to use when rendering this variant
drawBaseChar - true when base character should be rendered over the change
writeToFile - indicates if writing to a file should be attempted
Returns:
to be used if further processing of image is required, or streaming

generateFullChrom

public java.awt.image.BufferedImage generateFullChrom(java.lang.String pathStub,
                                                      ExperimentBean expBean,
                                                      boolean writeImage,
                                                      boolean drawBaseChar)
Description copied from interface: ChromatogramService
Generates a full chromatogram image. This method is expected to generate a full chromatogram image.

Specified by:
generateFullChrom in interface ChromatogramService
Parameters:
pathStub - directory to write image to
expBean - the experiment containing the chromatogram to be rendered
writeImage - true if the image should be written to file
drawBaseChar - true if the character of the DNA change should be rendered when a variant is provided
Returns:
to be used if further processing of image is required, or streaming

resetPreviousRendered

public void resetPreviousRendered()
Description copied from interface: ChromatogramService
Resets the set of files that have been previously rendered and written to a file. A list is kept to prevent images generated for a variant in one direction being regenerated when the same variant is called on the opposite comparison.

Use this method to empty this list at the end of each amplimer set to reduce memory footprint.

NOT NEEDED IF NOT WRITING TO FILE

Specified by:
resetPreviousRendered in interface ChromatogramService