use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.
the class AnalysisExecutionServiceGalaxyTest method setup.
/**
* Setup variables for tests.
*
* @throws IridaWorkflowNotFoundException
* @throws IOException
* @throws ExecutionManagerException
* @throws NoSuchValueException
* @throws IridaWorkflowAnalysisTypeException
*/
@Before
public void setup() throws IridaWorkflowNotFoundException, IOException, ExecutionManagerException, NoSuchValueException, IridaWorkflowAnalysisTypeException, AnalysisAlreadySetException {
MockitoAnnotations.initMocks(this);
String submissionName = "name";
Set<SequencingObject> submissionInputFiles = Sets.newHashSet(new SingleEndSequenceFile(new SequenceFile()));
analysisSubmission = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "intial").inputFiles(submissionInputFiles).build();
analysisPreparing = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "preparing").inputFiles(submissionInputFiles).build();
analysisPrepared = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "prepared").inputFiles(submissionInputFiles).build();
analysisSubmitting = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "submitting").inputFiles(submissionInputFiles).build();
analysisRunning = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "running").inputFiles(submissionInputFiles).build();
analysisFinishedRunning = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "finishedrunning").inputFiles(submissionInputFiles).build();
analysisCompleting = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "completing").inputFiles(submissionInputFiles).build();
analysisCompleted = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "completed").inputFiles(submissionInputFiles).build();
analysisCompletedCleaning = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "cleaning").inputFiles(submissionInputFiles).build();
analysisCompletedCleaned = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "cleaned").inputFiles(submissionInputFiles).build();
analysisError = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "error").inputFiles(submissionInputFiles).build();
analysisErrorCleaning = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "errorcleaning").inputFiles(submissionInputFiles).build();
analysisErrorCleaned = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "errorcleaned").inputFiles(submissionInputFiles).build();
AnalysisExecutionServiceGalaxyAsync workflowManagementAsync = new AnalysisExecutionServiceGalaxyAsync(analysisSubmissionService, analysisService, galaxyWorkflowService, analysisWorkspaceService, iridaWorkflowsService, analysisSubmissionSampleProcessor);
AnalysisExecutionServiceGalaxyCleanupAsync analysisExecutionServiceGalaxyCleanupAsync = new AnalysisExecutionServiceGalaxyCleanupAsync(analysisSubmissionService, galaxyWorkflowService, galaxyHistoriesService, galaxyLibrariesService);
workflowManagement = new AnalysisExecutionServiceGalaxy(analysisSubmissionService, galaxyHistoriesService, workflowManagementAsync, analysisExecutionServiceGalaxyCleanupAsync);
when(iridaWorkflowsService.getIridaWorkflow(WORKFLOW_ID)).thenReturn(iridaWorkflow);
when(iridaWorkflow.getWorkflowStructure()).thenReturn(iridaWorkflowStructure);
when(iridaWorkflowStructure.getWorkflowFile()).thenReturn(workflowFile);
when(analysisSubmissionService.create(analysisSubmission)).thenReturn(analysisSubmission);
when(analysisSubmissionService.read(INTERNAL_ANALYSIS_ID)).thenReturn(analysisSubmission);
analysisSubmission.setId(INTERNAL_ANALYSIS_ID);
analysisPreparing.setId(INTERNAL_ANALYSIS_ID);
analysisPreparing.setAnalysisState(AnalysisState.PREPARING);
when(analysisWorkspaceService.prepareAnalysisWorkspace(analysisPreparing)).thenReturn(ANALYSIS_ID);
analysisPrepared.setId(INTERNAL_ANALYSIS_ID);
analysisPrepared.setAnalysisState(AnalysisState.PREPARED);
analysisPrepared.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
analysisPrepared.setRemoteAnalysisId(ANALYSIS_ID);
analysisSubmitting.setId(INTERNAL_ANALYSIS_ID);
analysisSubmitting.setAnalysisState(AnalysisState.SUBMITTING);
analysisSubmitting.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
analysisSubmitting.setRemoteAnalysisId(ANALYSIS_ID);
analysisRunning.setId(INTERNAL_ANALYSIS_ID);
analysisRunning.setAnalysisState(AnalysisState.RUNNING);
analysisRunning.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
analysisRunning.setRemoteAnalysisId(ANALYSIS_ID);
analysisRunning.setRemoteInputDataId(LIBRARY_ID);
analysisFinishedRunning.setId(INTERNAL_ANALYSIS_ID);
analysisFinishedRunning.setAnalysisState(AnalysisState.FINISHED_RUNNING);
analysisFinishedRunning.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
analysisFinishedRunning.setRemoteAnalysisId(ANALYSIS_ID);
analysisFinishedRunning.setRemoteInputDataId(LIBRARY_ID);
analysisCompleting.setId(INTERNAL_ANALYSIS_ID);
analysisCompleting.setAnalysisState(AnalysisState.COMPLETING);
analysisCompleting.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
analysisCompleting.setRemoteAnalysisId(ANALYSIS_ID);
analysisCompleting.setRemoteInputDataId(LIBRARY_ID);
when(analysisWorkspaceService.getAnalysisResults(analysisCompleting)).thenReturn(analysisResults);
when(analysisService.create(analysisResults)).thenReturn(analysisResults);
analysisCompleted.setId(INTERNAL_ANALYSIS_ID);
analysisCompleted.setAnalysisState(AnalysisState.COMPLETED);
analysisCompleted.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
analysisCompleted.setRemoteAnalysisId(ANALYSIS_ID);
analysisCompleted.setAnalysisCleanedState(AnalysisCleanedState.NOT_CLEANED);
analysisCompleted.setAnalysis(analysisResults);
analysisCompleted.setRemoteInputDataId(LIBRARY_ID);
analysisCompleted.setUpdateSamples(true);
analysisCompletedCleaning.setId(INTERNAL_ANALYSIS_ID);
analysisCompletedCleaning.setAnalysisState(AnalysisState.COMPLETED);
analysisCompletedCleaning.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
analysisCompletedCleaning.setRemoteAnalysisId(ANALYSIS_ID);
analysisCompletedCleaning.setAnalysisCleanedState(AnalysisCleanedState.CLEANING);
analysisCompletedCleaning.setAnalysis(analysisResults);
analysisCompletedCleaning.setRemoteInputDataId(LIBRARY_ID);
analysisCompletedCleaned.setId(INTERNAL_ANALYSIS_ID);
analysisCompletedCleaned.setAnalysisState(AnalysisState.COMPLETED);
analysisCompletedCleaned.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
analysisCompletedCleaned.setRemoteAnalysisId(ANALYSIS_ID);
analysisCompletedCleaned.setAnalysisCleanedState(AnalysisCleanedState.CLEANED);
analysisCompletedCleaned.setAnalysis(analysisResults);
analysisCompletedCleaned.setRemoteInputDataId(LIBRARY_ID);
analysisError.setId(INTERNAL_ANALYSIS_ID);
analysisError.setAnalysisState(AnalysisState.ERROR);
analysisError.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
analysisError.setAnalysisCleanedState(AnalysisCleanedState.NOT_CLEANED);
analysisErrorCleaning.setId(INTERNAL_ANALYSIS_ID);
analysisErrorCleaning.setAnalysisState(AnalysisState.ERROR);
analysisErrorCleaning.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
analysisErrorCleaning.setAnalysisCleanedState(AnalysisCleanedState.CLEANING);
analysisErrorCleaned.setId(INTERNAL_ANALYSIS_ID);
analysisErrorCleaned.setAnalysisState(AnalysisState.ERROR);
analysisErrorCleaned.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
analysisErrorCleaned.setAnalysisCleanedState(AnalysisCleanedState.CLEANED);
analysisPrepared.setRemoteAnalysisId(ANALYSIS_ID);
preparedWorkflow = new PreparedWorkflowGalaxy(ANALYSIS_ID, LIBRARY_ID, workflowInputsGalaxy);
when(galaxyWorkflowService.uploadGalaxyWorkflow(workflowFile)).thenReturn(REMOTE_WORKFLOW_ID);
when(galaxyHistoriesService.deleteHistory(ANALYSIS_ID)).thenReturn(new HistoryDeleteResponse());
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyIT method testGetAnalysisResultsTestAnalysisPairedSingleSampleSuccess.
/**
* Tests out successfully getting results for an analysis (TestAnalysis)
* consisting only of paired sequence reads.
*
* @throws InterruptedException
* @throws ExecutionManagerException
* @throws IridaWorkflowNotFoundException
* @throws IOException
* @throws IridaWorkflowAnalysisTypeException
* @throws TimeoutException
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetAnalysisResultsTestAnalysisPairedSingleSampleSuccess() throws InterruptedException, ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException, TimeoutException {
History history = new History();
history.setName("testGetAnalysisResultsTestAnalysisPairedSingleSampleSuccess");
HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
ToolsClient toolsClient = localGalaxy.getGalaxyInstanceAdmin().getToolsClient();
History createdHistory = historiesClient.create(history);
// upload test outputs
uploadFileToHistory(sequenceFilePathA, OUTPUT1_NAME, createdHistory.getId(), toolsClient);
uploadFileToHistory(sequenceFilePathA, OUTPUT2_NAME, createdHistory.getId(), toolsClient);
// wait for history
Util.waitUntilHistoryComplete(createdHistory.getId(), galaxyHistoriesService, 60);
IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(validWorkflowIdPairedSingleSample);
Path workflowPath = iridaWorkflow.getWorkflowStructure().getWorkflowFile();
String workflowString = new String(Files.readAllBytes(workflowPath), StandardCharsets.UTF_8);
Workflow galaxyWorkflow = workflowsClient.importWorkflow(workflowString);
List<Path> paths1 = new ArrayList<>();
paths1.add(sequenceFilePathA);
List<Path> paths2 = new ArrayList<>();
paths2.add(sequenceFilePath2A);
AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupPairSubmissionInDatabase(1L, paths1, paths2, referenceFilePath, validWorkflowIdPairedSingleSample, false);
Set<SingleEndSequenceFile> submittedSingleFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SingleEndSequenceFile.class);
Set<SequenceFilePair> pairedFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SequenceFilePair.class);
assertEquals("the created submission should have no single input files", 0, submittedSingleFiles.size());
assertEquals("the created submission has an invalid number of paired input files", 1, pairedFiles.size());
SequenceFilePair submittedSp = pairedFiles.iterator().next();
Set<SequenceFile> submittedSf = submittedSp.getFiles();
assertEquals("the paired input should have 2 files", 2, submittedSf.size());
analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
analysisSubmission.setAnalysisState(AnalysisState.COMPLETING);
analysisSubmissionRepository.save(analysisSubmission);
Analysis analysis = analysisWorkspaceService.getAnalysisResults(analysisSubmission);
assertNotNull("the analysis results were not properly created", analysis);
assertEquals("the Analysis results class is invalid", Analysis.class, analysis.getClass());
assertEquals("the analysis results has an invalid number of output files", 2, analysis.getAnalysisOutputFiles().size());
assertEquals("the analysis results output file has an invalid name", Paths.get(OUTPUT1_NAME), analysis.getAnalysisOutputFile(OUTPUT1_KEY).getFile().getFileName());
assertEquals("the analysis results output file has an invalid label", SAMPLE1_NAME + "-" + OUTPUT1_NAME, analysis.getAnalysisOutputFile(OUTPUT1_KEY).getLabel());
assertEquals("the analysis results output file has an invalid name", Paths.get(OUTPUT2_NAME), analysis.getAnalysisOutputFile(OUTPUT2_KEY).getFile().getFileName());
assertEquals("the analysis results output file has an invalid label", SAMPLE1_NAME + "-" + OUTPUT2_NAME, analysis.getAnalysisOutputFile(OUTPUT2_KEY).getLabel());
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyIT method testGetAnalysisResultsTestAnalysisPairedSuccess.
/**
* Tests out successfully getting results for an analysis (TestAnalysis)
* consisting only of paired sequence reads.
*
* @throws InterruptedException
* @throws ExecutionManagerException
* @throws IridaWorkflowNotFoundException
* @throws IOException
* @throws IridaWorkflowAnalysisTypeException
* @throws TimeoutException
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetAnalysisResultsTestAnalysisPairedSuccess() throws InterruptedException, ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException, TimeoutException {
History history = new History();
history.setName("testGetAnalysisResultsTestAnalysisPairedSuccess");
HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
ToolsClient toolsClient = localGalaxy.getGalaxyInstanceAdmin().getToolsClient();
History createdHistory = historiesClient.create(history);
// upload test outputs
uploadFileToHistory(sequenceFilePathA, OUTPUT1_NAME, createdHistory.getId(), toolsClient);
uploadFileToHistory(sequenceFilePathA, OUTPUT2_NAME, createdHistory.getId(), toolsClient);
// wait for history
Util.waitUntilHistoryComplete(createdHistory.getId(), galaxyHistoriesService, 60);
IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(validWorkflowIdPaired);
Path workflowPath = iridaWorkflow.getWorkflowStructure().getWorkflowFile();
String workflowString = new String(Files.readAllBytes(workflowPath), StandardCharsets.UTF_8);
Workflow galaxyWorkflow = workflowsClient.importWorkflow(workflowString);
List<Path> paths1 = new ArrayList<>();
paths1.add(sequenceFilePathA);
List<Path> paths2 = new ArrayList<>();
paths2.add(sequenceFilePath2A);
AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupPairSubmissionInDatabase(1L, paths1, paths2, referenceFilePath, validWorkflowIdPaired, false);
Set<SingleEndSequenceFile> submittedSingleFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SingleEndSequenceFile.class);
Set<SequenceFilePair> pairedFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SequenceFilePair.class);
assertEquals("the created submission should have no single input files", 0, submittedSingleFiles.size());
assertEquals("the created submission has an invalid number of paired input files", 1, pairedFiles.size());
SequenceFilePair submittedSp = pairedFiles.iterator().next();
Set<SequenceFile> submittedSf = submittedSp.getFiles();
assertEquals("the paired input should have 2 files", 2, submittedSf.size());
analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
analysisSubmission.setAnalysisState(AnalysisState.COMPLETING);
analysisSubmissionRepository.save(analysisSubmission);
Analysis analysis = analysisWorkspaceService.getAnalysisResults(analysisSubmission);
assertNotNull("the analysis results were not properly created", analysis);
assertEquals("the Analysis results class is invalid", Analysis.class, analysis.getClass());
assertEquals("the analysis results has an invalid number of output files", 2, analysis.getAnalysisOutputFiles().size());
assertEquals("the analysis results output file has an invalid name", Paths.get(OUTPUT1_NAME), analysis.getAnalysisOutputFile(OUTPUT1_KEY).getFile().getFileName());
assertEquals("the analysis results output file has an invalid label", OUTPUT1_NAME, analysis.getAnalysisOutputFile(OUTPUT1_KEY).getLabel());
assertEquals("the analysis results output file has an invalid name", Paths.get(OUTPUT2_NAME), analysis.getAnalysisOutputFile(OUTPUT2_KEY).getFile().getFileName());
assertEquals("the analysis results output file has an invalid label", OUTPUT2_NAME, analysis.getAnalysisOutputFile(OUTPUT2_KEY).getLabel());
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyTest method setup.
/**
* Sets up variables for testing.
*
* @throws IOException
* @throws GalaxyDatasetException
* @throws UploadException
*/
@Before
public void setup() throws IOException, UploadException, GalaxyDatasetException {
MockitoAnnotations.initMocks(this);
sFileA = new SequenceFile(createTempFile("fileA", "fastq"));
sFileB = new SequenceFile(createTempFile("fileB", "fastq"));
sFileC = new SequenceFile(createTempFile("fileC", "fastq"));
sObjA = new SingleEndSequenceFile(sFileA);
sObjB = new SingleEndSequenceFile(sFileB);
sObjC = new SingleEndSequenceFile(sFileC);
sequenceFilePair = new SequenceFilePair(sFileB, sFileC);
singleEndSequenceFile = sObjA;
Sample sampleA = new Sample();
sampleA.setSampleName("SampleA");
Sample sampleB = new Sample();
sampleB.setSampleName("SampleB");
Sample sampleC = new Sample();
sampleC.setSampleName("SampleC");
sampleSingleSequenceFileMap = ImmutableMap.of(sampleA, singleEndSequenceFile);
sampleSequenceFilePairMap = ImmutableMap.of(sampleB, sequenceFilePair);
sampleSequenceFilePairMapSampleA = ImmutableMap.of(sampleA, sequenceFilePair);
refFile = createTempFile("reference", "fasta");
referenceFile = new ReferenceFile(refFile);
inputFiles = new HashSet<>();
inputFiles.addAll(Arrays.asList(sObjA, sObjB, sObjC));
submission = AnalysisSubmission.builder(workflowId).name("my analysis").inputFiles(inputFiles).referenceFile(referenceFile).build();
workflowHistory = new History();
workflowHistory.setId(HISTORY_ID);
workflowLibrary = new Library();
workflowLibrary.setId(LIBRARY_ID);
workflowDetails = new WorkflowDetails();
workflowDetails.setId(WORKFLOW_ID);
workflowPreparation = new AnalysisWorkspaceServiceGalaxy(galaxyHistoriesService, galaxyWorkflowService, galaxyLibrariesService, iridaWorkflowsService, analysisCollectionServiceGalaxy, analysisProvenanceServiceGalaxy, analysisParameterServiceGalaxy, sequencingObjectService);
output1Dataset = new Dataset();
output1Dataset.setId("1");
output1Dataset.setName("output1.txt");
output2Dataset = new Dataset();
output2Dataset.setId("2");
output2Dataset.setName("output2.txt");
collectionResponseSingle = new CollectionResponse();
collectionResponseSingle.setId(COLLECTION_SINGLE_ID);
collectionResponsePaired = new CollectionResponse();
collectionResponsePaired.setId(COLLECTION_PAIRED_ID);
singleInputFiles = Sets.newHashSet(singleEndSequenceFile);
pairedInputFiles = Sets.newHashSet(sequenceFilePair);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.
the class SequencingObjectServiceImplIT method testGetSequenceFilePairForSample.
@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testGetSequenceFilePairForSample() {
Sample s = sampleService.read(2L);
Set<Long> fileIds = Sets.newHashSet(3L, 4L);
Collection<SampleSequencingObjectJoin> sequenceFilePairsForSample = objectService.getSequencesForSampleOfType(s, SequenceFilePair.class);
assertEquals(1, sequenceFilePairsForSample.size());
SequencingObject pair = sequenceFilePairsForSample.iterator().next().getObject();
for (SequenceFile file : pair.getFiles()) {
assertTrue("file id should be in set", fileIds.contains(file.getId()));
fileIds.remove(file.getId());
}
assertTrue("all file ids should have been found", fileIds.isEmpty());
}
Aggregations