Search in sources :

Example 1 with BasicStats

use of uk.ac.babraham.FastQC.Modules.BasicStats in project irida by phac-nml.

the class FastqcFileProcessor method processSingleFile.

/**
 * Process a single {@link SequenceFile}
 *
 * @param sequenceFile
 *            file to process
 * @throws FileProcessorException
 *             if an error occurs while processing
 */
private void processSingleFile(SequenceFile sequenceFile) throws FileProcessorException {
    Path fileToProcess = sequenceFile.getFile();
    AnalysisFastQC.AnalysisFastQCBuilder analysis = AnalysisFastQC.builder().executionManagerAnalysisId(EXECUTION_MANAGER_ANALYSIS_ID).description(messageSource.getMessage("fastqc.file.processor.analysis.description", null, LocaleContextHolder.getLocale()));
    try {
        uk.ac.babraham.FastQC.Sequence.SequenceFile fastQCSequenceFile = SequenceFactory.getSequenceFile(fileToProcess.toFile());
        BasicStats basicStats = new BasicStats();
        PerBaseQualityScores pbqs = new PerBaseQualityScores();
        PerSequenceQualityScores psqs = new PerSequenceQualityScores();
        OverRepresentedSeqs overRep = new OverRepresentedSeqs();
        QCModule[] moduleList = new QCModule[] { basicStats, pbqs, psqs, overRep };
        logger.debug("Launching FastQC analysis modules on all sequences.");
        while (fastQCSequenceFile.hasNext()) {
            Sequence sequence = fastQCSequenceFile.next();
            for (QCModule module : moduleList) {
                module.processSequence(sequence);
            }
        }
        logger.debug("Finished FastQC analysis modules.");
        handleBasicStats(basicStats, analysis);
        handlePerBaseQualityScores(pbqs, analysis);
        handlePerSequenceQualityScores(psqs, analysis);
        handleDuplicationLevel(overRep.duplicationLevelModule(), analysis);
        Set<OverrepresentedSequence> overrepresentedSequences = handleOverRepresentedSequences(overRep);
        logger.trace("Saving FastQC analysis.");
        analysis.overrepresentedSequences(overrepresentedSequences);
        sequenceFile.setFastQCAnalysis(analysis.build());
        sequenceFileRepository.saveMetadata(sequenceFile);
    } catch (Exception e) {
        logger.error("FastQC failed to process the sequence file. Stack trace follows.", e);
        throw new FileProcessorException("FastQC failed to parse the sequence file.", e);
    }
}
Also used : Path(java.nio.file.Path) Sequence(uk.ac.babraham.FastQC.Sequence.Sequence) OverrepresentedSequence(ca.corefacility.bioinformatics.irida.model.sequenceFile.OverrepresentedSequence) AnalysisFastQC(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC) FileProcessorException(ca.corefacility.bioinformatics.irida.processing.FileProcessorException) IOException(java.io.IOException) QCModule(uk.ac.babraham.FastQC.Modules.QCModule) PerBaseQualityScores(uk.ac.babraham.FastQC.Modules.PerBaseQualityScores) FileProcessorException(ca.corefacility.bioinformatics.irida.processing.FileProcessorException) OverRepresentedSeqs(uk.ac.babraham.FastQC.Modules.OverRepresentedSeqs) AnalysisFastQCBuilder(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC.AnalysisFastQCBuilder) PerSequenceQualityScores(uk.ac.babraham.FastQC.Modules.PerSequenceQualityScores) BasicStats(uk.ac.babraham.FastQC.Modules.BasicStats) OverrepresentedSequence(ca.corefacility.bioinformatics.irida.model.sequenceFile.OverrepresentedSequence)

Aggregations

OverrepresentedSequence (ca.corefacility.bioinformatics.irida.model.sequenceFile.OverrepresentedSequence)1 AnalysisFastQC (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC)1 AnalysisFastQCBuilder (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC.AnalysisFastQCBuilder)1 FileProcessorException (ca.corefacility.bioinformatics.irida.processing.FileProcessorException)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 BasicStats (uk.ac.babraham.FastQC.Modules.BasicStats)1 OverRepresentedSeqs (uk.ac.babraham.FastQC.Modules.OverRepresentedSeqs)1 PerBaseQualityScores (uk.ac.babraham.FastQC.Modules.PerBaseQualityScores)1 PerSequenceQualityScores (uk.ac.babraham.FastQC.Modules.PerSequenceQualityScores)1 QCModule (uk.ac.babraham.FastQC.Modules.QCModule)1 Sequence (uk.ac.babraham.FastQC.Sequence.Sequence)1