use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SampleSequenceFilesControllerTest method testRemoveSequenceFileFromSample.
@Test
public void testRemoveSequenceFileFromSample() throws IOException {
Sample s = TestDataFactory.constructSample();
SingleEndSequenceFile so = TestDataFactory.constructSingleEndSequenceFile();
when(sampleService.read(s.getId())).thenReturn(s);
when(sequencingObjectService.readSequencingObjectForSample(s, so.getId())).thenReturn(so);
ModelMap modelMap = controller.removeSequenceFileFromSample(s.getId(), "unpaired", so.getId());
verify(sampleService, times(1)).read(s.getId());
verify(sequencingObjectService).readSequencingObjectForSample(s, so.getId());
verify(sampleService, times(1)).removeSequencingObjectFromSample(s, so);
Object o = modelMap.get(RESTGenericController.RESOURCE_NAME);
assertNotNull(o);
assertTrue(o instanceof RootResource);
RootResource resource = (RootResource) o;
Link sample = resource.getLink(RESTSampleSequenceFilesController.REL_SAMPLE);
Link sequenceFiles = resource.getLink(RESTSampleSequenceFilesController.REL_SAMPLE_SEQUENCE_FILES);
String sampleLocation = "http://localhost/api/samples/" + s.getId();
assertNotNull(sample);
assertEquals(sampleLocation, sample.getHref());
assertNotNull(sequenceFiles);
assertEquals(sampleLocation + "/sequenceFiles", sequenceFiles.getHref());
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SampleSequenceFilesControllerTest method testGetQcForFile.
@Test
public void testGetQcForFile() throws IOException {
Sample s = TestDataFactory.constructSample();
SingleEndSequenceFile so = TestDataFactory.constructSingleEndSequenceFile();
AnalysisFastQC analysisFastQC = new AnalysisFastQC(AnalysisFastQC.builder());
when(sampleService.read(s.getId())).thenReturn(s);
when(sequencingObjectService.readSequencingObjectForSample(s, so.getId())).thenReturn(so);
when(analysisService.getFastQCAnalysisForSequenceFile(so, so.getSequenceFile().getId())).thenReturn(analysisFastQC);
ModelMap readQCForSequenceFile = controller.readQCForSequenceFile(s.getId(), RESTSampleSequenceFilesController.objectLabels.get(so.getClass()), so.getId(), so.getSequenceFile().getId());
verify(sampleService).read(s.getId());
verify(sequencingObjectService).readSequencingObjectForSample(s, so.getId());
verify(analysisService).getFastQCAnalysisForSequenceFile(so, so.getSequenceFile().getId());
assertTrue(readQCForSequenceFile.containsKey(RESTGenericController.RESOURCE_NAME));
Object object = readQCForSequenceFile.get(RESTGenericController.RESOURCE_NAME);
assertTrue(object instanceof AnalysisFastQC);
AnalysisFastQC qc = (AnalysisFastQC) object;
assertNotNull(qc.getLink(RESTSampleSequenceFilesController.REL_QC_SEQFILE));
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SampleServiceImplTest method testGetTotalBasesForSampleFailNoFastQC.
/**
* Tests out failing to get the total bases from a sample with one sequence
* file due to missing FastQC
*
* @throws SequenceFileAnalysisException
*/
@Test(expected = SequenceFileAnalysisException.class)
public void testGetTotalBasesForSampleFailNoFastQC() throws SequenceFileAnalysisException {
Sample s1 = new Sample();
s1.setId(1L);
SequenceFile sf1 = new SequenceFile();
sf1.setId(2222L);
SampleSequencingObjectJoin join = new SampleSequencingObjectJoin(s1, new SingleEndSequenceFile(sf1));
when(ssoRepository.getSequencesForSample(s1)).thenReturn(Arrays.asList(join));
sampleService.getTotalBasesForSample(s1);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SampleServiceImplTest method so.
private SequencingObject so(Long id) {
SequencingObject so = new SingleEndSequenceFile(sf(id));
so.setId(id);
return so;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxy method prepareAnalysisFiles.
/**
* {@inheritDoc}
*/
@Override
public PreparedWorkflowGalaxy prepareAnalysisFiles(AnalysisSubmission analysisSubmission) throws ExecutionManagerException, IridaWorkflowException {
checkNotNull(analysisSubmission, "analysisSubmission is null");
checkNotNull(analysisSubmission.getRemoteAnalysisId(), "analysisId is null");
checkNotNull(analysisSubmission.getWorkflowId(), "workflowId is null");
checkNotNull(analysisSubmission.getRemoteWorkflowId(), "remoteWorkflowId is null");
IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(analysisSubmission.getWorkflowId());
IridaWorkflowInput workflowInput = iridaWorkflow.getWorkflowDescription().getInputs();
Set<SingleEndSequenceFile> singleEndFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SingleEndSequenceFile.class);
Set<SequenceFilePair> pairedEndFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SequenceFilePair.class);
if (iridaWorkflow.getWorkflowDescription().requiresReference()) {
checkArgument(analysisSubmission.getReferenceFile().isPresent(), "workflow requires reference but none defined in submission");
} else {
checkArgument(!analysisSubmission.getReferenceFile().isPresent(), "workflow does not require a reference and a reference file is set in the submission");
}
if (!iridaWorkflow.getWorkflowDescription().acceptsSingleSequenceFiles()) {
checkArgument(singleEndFiles.isEmpty(), "workflow does not accept single sequence files, but single sequence files are passed as input to " + analysisSubmission);
}
if (!iridaWorkflow.getWorkflowDescription().acceptsPairedSequenceFiles()) {
checkArgument(pairedEndFiles.isEmpty(), "workflow does not accept paired sequence files, but paired sequence files are passed as input to " + analysisSubmission);
}
String temporaryLibraryName = AnalysisSubmission.class.getSimpleName() + "-" + UUID.randomUUID().toString();
History workflowHistory = galaxyHistoriesService.findById(analysisSubmission.getRemoteAnalysisId());
Library workflowLibrary = galaxyLibrariesService.buildEmptyLibrary(new GalaxyProjectName(temporaryLibraryName));
// get unique files for pairs and single files
Map<Sample, SingleEndSequenceFile> singleFiles = sequencingObjectService.getUniqueSamplesForSequencingObjects(singleEndFiles);
Map<Sample, SequenceFilePair> pairedFiles = sequencingObjectService.getUniqueSamplesForSequencingObjects(pairedEndFiles);
// check that there aren't common sample names between single and paired
if (samplesInCommon(singleFiles, pairedFiles)) {
throw new SampleAnalysisDuplicateException("Single and paired input files share a common sample for submission " + analysisSubmission);
}
String workflowId = analysisSubmission.getRemoteWorkflowId();
WorkflowDetails workflowDetails = galaxyWorkflowService.getWorkflowDetails(workflowId);
WorkflowInputsGalaxy workflowInputsGalaxy = analysisParameterServiceGalaxy.prepareAnalysisParameters(analysisSubmission.getInputParameters(), iridaWorkflow);
WorkflowInputs inputs = workflowInputsGalaxy.getInputsObject();
inputs.setDestination(new WorkflowInputs.ExistingHistory(workflowHistory.getId()));
inputs.setWorkflowId(workflowDetails.getId());
if (!singleFiles.isEmpty()) {
String sequenceFilesLabelSingle = workflowInput.getSequenceReadsSingle().get();
String workflowSequenceFileSingleInputId = galaxyWorkflowService.getWorkflowInputId(workflowDetails, sequenceFilesLabelSingle);
CollectionResponse collectionResponseSingle = analysisCollectionServiceGalaxy.uploadSequenceFilesSingleEnd(singleFiles, workflowHistory, workflowLibrary);
inputs.setInput(workflowSequenceFileSingleInputId, new WorkflowInputs.WorkflowInput(collectionResponseSingle.getId(), WorkflowInputs.InputSourceType.HDCA));
}
if (!pairedFiles.isEmpty()) {
String sequenceFilesLabelPaired = workflowInput.getSequenceReadsPaired().get();
String workflowSequenceFilePairedInputId = galaxyWorkflowService.getWorkflowInputId(workflowDetails, sequenceFilesLabelPaired);
CollectionResponse collectionResponsePaired = analysisCollectionServiceGalaxy.uploadSequenceFilesPaired(pairedFiles, workflowHistory, workflowLibrary);
inputs.setInput(workflowSequenceFilePairedInputId, new WorkflowInputs.WorkflowInput(collectionResponsePaired.getId(), WorkflowInputs.InputSourceType.HDCA));
}
String analysisId = workflowHistory.getId();
if (iridaWorkflow.getWorkflowDescription().requiresReference()) {
String referenceFileLabel = workflowInput.getReference().get();
prepareReferenceFile(analysisSubmission.getReferenceFile().get(), workflowHistory, referenceFileLabel, workflowDetails, inputs);
}
return new PreparedWorkflowGalaxy(analysisId, workflowLibrary.getId(), new WorkflowInputsGalaxy(inputs));
}
Aggregations