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

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

public class FileLocatorServiceImpl
extends java.lang.Object
implements FileLocatorService

Author:
Original: kr2, $Author: kr2 $

Field Summary
protected static org.apache.commons.logging.Log log
           
 
Constructor Summary
FileLocatorServiceImpl()
          Creates a new instance of FileLocatorServiceImpl
 
Method Summary
 java.lang.String csvExists()
          Gets the location of the results.csv if it exists.
protected static void findFiles(java.util.Map amplimerFileMap, java.io.File fileOrDirToCheck)
          Self recursing method for finding files in a directory structure.
 java.util.Map findOutput()
          Collates information required to construct an index page.
 TraceGroupBean getAmplimerGroup(java.util.List files, AmplimerBean amplimer)
          Constructs a TraceGroupBean for the specified amplimer.
 java.util.Map getTraceFiles()
          Gets a list of possible trace filenames.
protected static void processPossibleFile(java.io.File possibleReadFile, java.util.Map amplimerFileMap)
          Validates input against standard criteria for sequencing files.
 
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

FileLocatorServiceImpl

public FileLocatorServiceImpl()
Creates a new instance of FileLocatorServiceImpl

Method Detail

getTraceFiles

public java.util.Map getTraceFiles()
Description copied from interface: FileLocatorService
Gets a list of possible trace filenames. This method is expected to behave as follows:

- parse directory structures starting from the input location specified in the standaloneCsa.properties file
- build a list of files where the extension and file name parse correctly based on the standaloneCsa.properties file

Specified by:
getTraceFiles in interface FileLocatorService
Returns:
a set of Files grouped by amplimer name

processPossibleFile

protected static void processPossibleFile(java.io.File possibleReadFile,
                                          java.util.Map amplimerFileMap)
Validates input against standard criteria for sequencing files. Expects that all files with the extension specified in standaloneCsa.properties (scf, ab1) will parse as required by ExperimentBean.

Parameters:
possibleReadFile - a file (not directory) to try to validate
amplimerFileMap - an object to add files into where amplimer name is the key and a List of Files the value

findFiles

protected static void findFiles(java.util.Map amplimerFileMap,
                                java.io.File fileOrDirToCheck)
Self recursing method for finding files in a directory structure. Follows all possible routes in a directory tree storing any files that meet the criteria required in processPossibleFile(File readFile, Map amplimerFileMap).

Parameters:
amplimerFileMap - map to add any valid input files (key is amplimer name)
fileOrDirToCheck - the next file or directory to test

getAmplimerGroup

public TraceGroupBean getAmplimerGroup(java.util.List files,
                                       AmplimerBean amplimer)
Description copied from interface: FileLocatorService
Constructs a TraceGroupBean for the specified amplimer. This method is expected to behave as follows:

- construct an ExperimentBean for each input file with its chromatogram already loaded - add the ExperimentBean to the relevant list within the group (wildtype/variant) - pair the ExperimentBeans in each list (ExperimentBean.setComplimentExp(ExperimentBean complimentExp))

Specified by:
getAmplimerGroup in interface FileLocatorService
Parameters:
files - a list of files that should be incorporated into this group
amplimer - the AmplimerBean for this amplimer
Returns:
a TraceGroupBean populated with ExperimentBeans constructed from the list of files

findOutput

public java.util.Map findOutput()
Description copied from interface: FileLocatorService
Collates information required to construct an index page. This method is expected to behave as follows:

- Search the view output location (specified in standaloneCsa.properties) for *-amp.html files - For each *-amp.html file recurse the amplimer directory counting the number of variants - Construct a Map with amplimerName as the key and the number of variants as the value

Specified by:
findOutput in interface FileLocatorService
Returns:
a Map of amplimerName and number of variants

csvExists

public java.lang.String csvExists()
Description copied from interface: FileLocatorService
Gets the location of the results.csv if it exists. This method is expected to behave as follows:

- Check for the presence of the 'results.csv' file in the location specified in standaloneCsa.properties - When present return the location as a string - When not present return an empty string (not able to use null as this is passed to VelocityTemplate engine)

Specified by:
csvExists in interface FileLocatorService
Returns:
the location of the results.csv file (empty string if not present)