use of ca.corefacility.bioinformatics.irida.processing.FileProcessorException in project irida by phac-nml.
the class AssemblyFileProcessor method process.
/**
* {@inheritDoc}
*/
@Override
@Transactional
public void process(SequencingObject sequencingObject) {
logger.debug("Setting up automated assembly for sequence " + sequencingObject.getId());
// assembly run by admin
User admin = userRepository.loadUserByUsername("admin");
// assembled
if (sequencingObject instanceof SequenceFilePair) {
IridaWorkflow defaultWorkflowByType;
// get the workflow
try {
defaultWorkflowByType = workflowsService.getDefaultWorkflowByType(AnalysisType.ASSEMBLY_ANNOTATION);
} catch (IridaWorkflowNotFoundException e) {
throw new FileProcessorException("Cannot find assembly workflow", e);
}
UUID pipelineUUID = defaultWorkflowByType.getWorkflowIdentifier();
// build an AnalysisSubmission
Builder builder = new AnalysisSubmission.Builder(pipelineUUID);
AnalysisSubmission submission = builder.inputFiles(Sets.newHashSet((SequenceFilePair) sequencingObject)).priority(AnalysisSubmission.Priority.LOW).name("Automated Assembly " + sequencingObject.toString()).updateSamples(true).build();
submission.setSubmitter(admin);
submission = submissionRepository.save(submission);
// Associate the submission with the seqobject
sequencingObject.setAutomatedAssembly(submission);
objectRepository.save(sequencingObject);
logger.debug("Automated assembly submission created for sequencing object " + sequencingObject.getId());
} else {
logger.warn("Could not assemble sequencing object " + sequencingObject.getId() + " because it's not paired end");
}
}
use of ca.corefacility.bioinformatics.irida.processing.FileProcessorException in project irida by phac-nml.
the class SistrTypingFileProcessor method process.
/**
* {@inheritDoc}
*/
@Override
public void process(SequencingObject sequencingObject) {
logger.debug("Setting up SISTR typing for sequence " + sequencingObject.getId());
User admin = userRepository.loadUserByUsername("admin");
Project.AutomatedSISTRSetting automatedSISTRSetting = shouldTypeWithSISTR(sequencingObject);
// assembled/typed.
if (sequencingObject instanceof SequenceFilePair) {
IridaWorkflow defaultWorkflowByType;
// get the workflow
try {
defaultWorkflowByType = workflowsService.getDefaultWorkflowByType(AnalysisType.SISTR_TYPING);
} catch (IridaWorkflowNotFoundException e) {
throw new FileProcessorException("Cannot find assembly workflow", e);
}
UUID pipelineUUID = defaultWorkflowByType.getWorkflowIdentifier();
// build an AnalysisSubmission
Builder builder = new AnalysisSubmission.Builder(pipelineUUID);
if (automatedSISTRSetting.equals(Project.AutomatedSISTRSetting.AUTO_METADATA)) {
builder.updateSamples(true);
} else if (automatedSISTRSetting.equals(Project.AutomatedSISTRSetting.AUTO)) {
builder.updateSamples(false);
}
AnalysisSubmission submission = builder.inputFiles(Sets.newHashSet((SequenceFilePair) sequencingObject)).priority(AnalysisSubmission.Priority.LOW).name("Automated SISTR Typing " + sequencingObject.toString()).build();
submission.setSubmitter(admin);
submission = submissionRepository.save(submission);
// Associate the submission with the seqobject
sequencingObject.setSistrTyping(submission);
objectRepository.save(sequencingObject);
logger.debug("Automated SISTR typing submission created for sequencing object " + sequencingObject.getId());
} else {
logger.warn("Could not run SISTR typing for sequencing object " + sequencingObject.getId() + " because it's not paired end");
}
}
use of ca.corefacility.bioinformatics.irida.processing.FileProcessorException in project irida by phac-nml.
the class ChecksumFileProcessor method process.
/**
* Create an sha256sum for the files in a {@link SequencingObject} and save
* it with the file.
*
* @param sequencingObject
* the {@link SequencingObject} to modify
* @throws FileProcessorException
* a {@link FileProcessorException} if the file could not be
* processed
*/
@Override
public void process(SequencingObject sequencingObject) {
Set<SequenceFile> files = sequencingObject.getFiles();
for (SequenceFile file : files) {
try (InputStream is = Files.newInputStream(file.getFile())) {
String shaDigest = DigestUtils.sha256Hex(is);
logger.trace("Checksum generated for file " + file.getId() + ": " + shaDigest);
file.setUploadSha256(shaDigest);
fileRepository.saveMetadata(file);
} catch (IOException e) {
throw new FileProcessorException("could not calculate checksum", e);
}
}
}
use of ca.corefacility.bioinformatics.irida.processing.FileProcessorException in project irida by phac-nml.
the class DefaultFileProcessingChain method launchChain.
/**
* {@inheritDoc}
*/
@Override
public List<Exception> launchChain(Long sequencingObjectId) throws FileProcessorTimeoutException {
List<Exception> ignoredExceptions = new ArrayList<>();
Integer waiting = 0;
// file has been persisted in the database.
while (!sequencingObjectRepository.exists(sequencingObjectId)) {
if (waiting > timeout) {
throw new FileProcessorTimeoutException("Waiting for longer than " + sleepDuration * timeout + "ms, bailing out.");
}
waiting++;
try {
Thread.sleep(sleepDuration);
} catch (InterruptedException e) {
}
}
for (FileProcessor fileProcessor : fileProcessors) {
try {
if (fileProcessor.shouldProcessFile(sequencingObjectId)) {
SequencingObject settledSequencingObject = getSettledSequencingObject(sequencingObjectId);
fileProcessor.process(settledSequencingObject);
}
} catch (FileProcessorException e) {
SequencingObject sequencingObject = sequencingObjectRepository.findOne(sequencingObjectId);
qcRepository.save(new FileProcessorErrorQCEntry(sequencingObject));
// execution (show the error, but proceed).
if (fileProcessor.modifiesFile() || fastFail) {
throw e;
} else {
ignoredExceptions.add(e);
logger.error("File processor [" + fileProcessor.getClass() + "] failed to process [" + sequencingObjectId + "], but proceeding with the remaining processors because the " + "file would not be modified by the processor. Stack trace follows.", e);
}
}
}
return ignoredExceptions;
}
use of ca.corefacility.bioinformatics.irida.processing.FileProcessorException 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);
}
}
Aggregations