Search in sources :

Example 16 with SequenceFilePair

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair 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());
}
Also used : Path(java.nio.file.Path) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) ArrayList(java.util.ArrayList) Workflow(com.github.jmchilton.blend4j.galaxy.beans.Workflow) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) History(com.github.jmchilton.blend4j.galaxy.beans.History) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) WorkflowsClient(com.github.jmchilton.blend4j.galaxy.WorkflowsClient) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 17 with SequenceFilePair

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair 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);
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) AnalysisWorkspaceServiceGalaxy(ca.corefacility.bioinformatics.irida.service.analysis.workspace.galaxy.AnalysisWorkspaceServiceGalaxy) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) CollectionResponse(com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Before(org.junit.Before)

Example 18 with SequenceFilePair

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair in project irida by phac-nml.

the class NcbiExportSubmissionServceTest method testCreatePairs.

@Test
public void testCreatePairs() {
    SequenceFile sequenceFile = new SequenceFile();
    NcbiBioSampleFiles ncbiBioSampleFiles = new NcbiBioSampleFiles("sample", Lists.newArrayList(), Lists.newArrayList(new SequenceFilePair(sequenceFile, sequenceFile)), null, "library_name", null, null, null, "library_construction_protocol", "namespace");
    NcbiExportSubmission submission = new NcbiExportSubmission(null, null, "bioProjectId", "organization", "ncbiNamespace", new Date(), Lists.newArrayList(ncbiBioSampleFiles));
    service.create(submission);
    verify(repository).save(submission);
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) NcbiBioSampleFiles(ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles) NcbiExportSubmission(ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Date(java.util.Date) Test(org.junit.Test)

Example 19 with SequenceFilePair

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair in project irida by phac-nml.

the class ReadAnalysisSubmissionPermissionTest method testPermitAutoAssembly.

@Test
public void testPermitAutoAssembly() {
    String username = "aaron";
    User u = new User();
    u.setUsername(username);
    Authentication auth = new UsernamePasswordAuthenticationToken("aaron", "password1");
    Project p = new Project();
    SequenceFilePair pair = new SequenceFilePair();
    AnalysisSubmission analysisSubmission = AnalysisSubmission.builder(workflowId).name("test").inputFiles(ImmutableSet.of(pair)).referenceFile(referenceFile).build();
    analysisSubmission.setSubmitter(new User());
    pair.setAutomatedAssembly(analysisSubmission);
    /*
		 * testing that analysis is shared with a project that user isn't a part
		 * of
		 */
    when(pasRepository.getProjectsForSubmission(analysisSubmission)).thenReturn(ImmutableList.of(new ProjectAnalysisSubmissionJoin(p, analysisSubmission)));
    when(readProjectPermission.customPermissionAllowed(auth, p)).thenReturn(false);
    when(userRepository.loadUserByUsername(username)).thenReturn(u);
    when(analysisSubmissionRepository.findOne(1L)).thenReturn(analysisSubmission);
    when(seqObjectPermission.customPermissionAllowed(auth, pair)).thenReturn(true);
    when(sequencingObjectRepository.findSequencingObjectsForAnalysisSubmission(analysisSubmission)).thenReturn(ImmutableSet.of(pair));
    assertTrue("permission should be granted.", readAnalysisSubmissionPermission.isAllowed(auth, 1L));
    verify(userRepository).loadUserByUsername(username);
    verify(analysisSubmissionRepository).findOne(1L);
    verify(seqObjectPermission).customPermissionAllowed(auth, pair);
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) User(ca.corefacility.bioinformatics.irida.model.user.User) Authentication(org.springframework.security.core.Authentication) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) ProjectAnalysisSubmissionJoin(ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) Test(org.junit.Test)

Example 20 with SequenceFilePair

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair in project irida by phac-nml.

the class DatabaseSetupGalaxyITService method setupPairSubmissionInDatabase.

/**
 * Sets up an {@link AnalysisSubmission} with a list of paired sequence
 * files and saves all dependencies in database.
 *
 * @param sampleId
 *            The id of the sample to associate with the given sequence
 *            file.
 * @param sequenceFilePaths1
 *            A list of paths for the first part of the pair.
 * @param sequenceFilePaths2
 *            A list of paths for the second part of the pair. The path to
 *            an input sequence file for this test.
 * @param iridaWorkflowId
 *            The id of an irida workflow.
 * @return An {@link AnalysisSubmission} which has been saved to the
 *         database.
 */
public AnalysisSubmission setupPairSubmissionInDatabase(long sampleId, List<Path> sequenceFilePaths1, List<Path> sequenceFilePaths2, UUID iridaWorkflowId) {
    List<SequenceFilePair> sequenceFilePairs = setupSampleSequenceFileInDatabase(sampleId, sequenceFilePaths1, sequenceFilePaths2);
    AnalysisSubmission submission = AnalysisSubmission.builder(iridaWorkflowId).name("paired analysis").inputFiles(Sets.newHashSet(sequenceFilePairs)).build();
    analysisSubmissionService.create(submission);
    return analysisSubmissionRepository.findOne(submission.getId());
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)

Aggregations

SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)59 Test (org.junit.Test)33 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)28 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)23 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)22 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)19 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)13 Project (ca.corefacility.bioinformatics.irida.model.project.Project)12 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)12 WithMockUser (org.springframework.security.test.context.support.WithMockUser)12 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)11 Path (java.nio.file.Path)11 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)9 History (com.github.jmchilton.blend4j.galaxy.beans.History)8 User (ca.corefacility.bioinformatics.irida.model.user.User)7 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)7 ArrayList (java.util.ArrayList)7 IridaWorkflowNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNotFoundException)5 ReferenceFile (ca.corefacility.bioinformatics.irida.model.project.ReferenceFile)5 ImmutableMap (com.google.common.collect.ImmutableMap)5