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  org.apache.commons.logging.Log log
           
 
Constructor Summary
ChromatogramServiceImpl()
          Creates a new instance of ChromatogramServiceImpl
 
Method Summary
 java.awt.image.BufferedImage generateComplexVariantView(ChromRenderBean varCrb, ChromRenderBean wtCrb, boolean reverseChromObject)
          Generates images required for the complex variant view.
 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.
 java.awt.image.BufferedImage renderChromatogram(ChromRenderBean crb, boolean revCompChromatogram)
          Generates a simple variant or full trace image.
 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 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

generateComplexVariantView

public java.awt.image.BufferedImage generateComplexVariantView(ChromRenderBean varCrb,
                                                               ChromRenderBean wtCrb,
                                                               boolean reverseChromObject)
Description copied from interface: ChromatogramService
Generates images required for the complex variant view. Method should behave as follows:

- a variant call must be defined in varCrb.getFeatures()
- 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

Specified by:
generateComplexVariantView in interface ChromatogramService
Parameters:
varCrb - the crb for the variant chromatogram
wtCrb - the crb for the wildtype chromatogram
reverseChromObject - indicate if the chromatogram object needs to be reversed, also affects the alignment of the variant call
Returns:
a buffered image of the complex view, null on failure

renderChromatogram

public java.awt.image.BufferedImage renderChromatogram(ChromRenderBean crb,
                                                       boolean revCompChromatogram)
                                                throws CsaRenderException
Description copied from interface: ChromatogramService
Generates a simple variant or full trace image. Method should behave as follows:

- a variant can be defined in crb.getFeatures()
- render the segment, or full trace if crb.getStartRenderAtBase() == 0 && crb.getStopRenderAtBase() == 0

Specified by:
renderChromatogram in interface ChromatogramService
Parameters:
crb - object to be rendered
revCompChromatogram - indicate if the chromatogram object needs to be reversed
Returns:
a buffered image of the simple view
Throws:
CsaRenderException - reports a rendering problem, normally due to inputs errors

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