Search in sources :

Example 16 with ReferenceFile

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

the class ReferenceFileControllerTest method setUp.

@Before
public void setUp() {
    projectService = mock(ProjectService.class);
    referenceFileService = mock(ReferenceFileService.class);
    messageSource = mock(MessageSource.class);
    // Set up the reference file
    Path path = Paths.get(FILE_PATH);
    ReferenceFile file = new ReferenceFile(path);
    when(referenceFileService.read(FILE_ID)).thenReturn(file);
    controller = new ReferenceFileController(projectService, referenceFileService, messageSource);
}
Also used : Path(java.nio.file.Path) ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) ReferenceFileController(ca.corefacility.bioinformatics.irida.ria.web.files.ReferenceFileController) ProjectService(ca.corefacility.bioinformatics.irida.service.ProjectService) MessageSource(org.springframework.context.MessageSource) ReferenceFileService(ca.corefacility.bioinformatics.irida.service.ReferenceFileService) Before(org.junit.Before)

Example 17 with ReferenceFile

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

the class ReferenceFileControllerTest method testCreateNewReferenceFile.

@Test
public void testCreateNewReferenceFile() throws IOException {
    Path path = Paths.get(FILE_PATH);
    byte[] origBytes = Files.readAllBytes(path);
    List<MultipartFile> mockMultipartFiles = ImmutableList.of(new MockMultipartFile(FILE_NAME, FILE_NAME, "octet-stream", origBytes));
    // TODO: (14-08-14 - Josh) look at Franklin's TestDataFactory
    Project project = new Project("foo");
    ReferenceFile referenceFile = new TestReferenceFile(path, 2L);
    when(projectService.read(PROJECT_ID)).thenReturn(project);
    when(projectService.addReferenceFileToProject(eq(project), any(ReferenceFile.class))).thenReturn(new ProjectReferenceFileJoin(project, referenceFile));
    MockHttpServletResponse response = new MockHttpServletResponse();
    controller.addReferenceFileToProject(PROJECT_ID, mockMultipartFiles, response, null);
    verify(projectService).read(PROJECT_ID);
    verify(projectService).addReferenceFileToProject(eq(project), any(ReferenceFile.class));
}
Also used : Path(java.nio.file.Path) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) Project(ca.corefacility.bioinformatics.irida.model.project.Project) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) MultipartFile(org.springframework.web.multipart.MultipartFile) ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) ProjectReferenceFileJoin(ca.corefacility.bioinformatics.irida.model.project.ProjectReferenceFileJoin) Test(org.junit.Test)

Example 18 with ReferenceFile

use of ca.corefacility.bioinformatics.irida.model.project.ReferenceFile 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 referenceFilePath
 *            The path to an input reference file for this test.
 * @param parameters
 *            The input parameters.
 * @param iridaWorkflowId
 *            The id of an irida workflow.
 * @param state
 *            {@link AnalysisState} of the submission
 * @return An {@link AnalysisSubmission} which has been saved to the
 *         database.
 */
public AnalysisSubmission setupPairSubmissionInDatabase(long sampleId, List<Path> sequenceFilePaths1, List<Path> sequenceFilePaths2, Path referenceFilePath, Map<String, String> parameters, UUID iridaWorkflowId, AnalysisState state) {
    List<SequenceFilePair> sequenceFilePairs = setupSampleSequenceFileInDatabase(sampleId, sequenceFilePaths1, sequenceFilePaths2);
    ReferenceFile referenceFile = referenceFileRepository.save(new ReferenceFile(referenceFilePath));
    AnalysisSubmission submission = AnalysisSubmission.builder(iridaWorkflowId).name("paired analysis").inputFiles(Sets.newHashSet(sequenceFilePairs)).referenceFile(referenceFile).inputParameters(parameters).build();
    submission.setAnalysisState(state);
    analysisSubmissionService.create(submission);
    return analysisSubmissionRepository.findOne(submission.getId());
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)

Example 19 with ReferenceFile

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

the class DatabaseSetupGalaxyITService method setupSinglePairSubmissionInDatabaseDifferentSample.

/**
 * Sets up an {@link AnalysisSubmission} with a list of paired sequence
 * files and a single sequence file under a different sample and saves all
 * dependencies in database.
 *
 * @param sampleIdPaired
 *            The id of the sample to associate with the paired sequence
 *            files.
 * @param sampleIdSingle
 *            The id of the sample to associate with the single 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 singleSequenceFile
 *            A single sequence file to add.
 * @param referenceFilePath
 *            The path to an input reference 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 setupSinglePairSubmissionInDatabaseDifferentSample(long sampleIdPaired, long sampleIdSingle, List<Path> sequenceFilePaths1, List<Path> sequenceFilePaths2, Path singleSequenceFile, Path referenceFilePath, UUID iridaWorkflowId) {
    SingleEndSequenceFile singleEndFile = (SingleEndSequenceFile) setupSequencingObjectInDatabase(sampleIdSingle, singleSequenceFile).get(0);
    List<SequenceFilePair> sequenceFilePairs = setupSampleSequenceFileInDatabase(sampleIdPaired, sequenceFilePaths1, sequenceFilePaths2);
    Set<SequencingObject> inputs = Sets.newHashSet(sequenceFilePairs);
    inputs.add(singleEndFile);
    ReferenceFile referenceFile = referenceFileRepository.save(new ReferenceFile(referenceFilePath));
    AnalysisSubmission submission = AnalysisSubmission.builder(iridaWorkflowId).name("paired analysis").inputFiles(inputs).referenceFile(referenceFile).build();
    analysisSubmissionService.create(submission);
    return analysisSubmissionRepository.findOne(submission.getId());
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)

Example 20 with ReferenceFile

use of ca.corefacility.bioinformatics.irida.model.project.ReferenceFile 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 iridaWorkflowId    The id of an irida workflow.
 * @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 referenceFilePath  The path to an input reference file for this test.
 * @param updateSamples      whether to run the sampleUpdater for this analysis
 * @return An {@link AnalysisSubmission} which has been saved to the
 * database.
 */
public AnalysisSubmission setupPairSubmissionInDatabase(long sampleId, List<Path> sequenceFilePaths1, List<Path> sequenceFilePaths2, Path referenceFilePath, UUID iridaWorkflowId, boolean updateSamples) {
    List<SequenceFilePair> sequenceFilePairs = setupSampleSequenceFileInDatabase(sampleId, sequenceFilePaths1, sequenceFilePaths2);
    List<SequenceFilePair> settledFiles = new ArrayList<>();
    for (final SequenceFilePair f : sequenceFilePairs) {
        waitForFilesToSettle(f);
        settledFiles.add((SequenceFilePair) sequencingObjectService.read(f.getId()));
    }
    ReferenceFile referenceFile = referenceFileRepository.save(new ReferenceFile(referenceFilePath));
    AnalysisSubmission submission = AnalysisSubmission.builder(iridaWorkflowId).name("paired analysis").inputFiles(Sets.newHashSet(settledFiles)).referenceFile(referenceFile).updateSamples(updateSamples).build();
    analysisSubmissionService.create(submission);
    return analysisSubmissionRepository.findOne(submission.getId());
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) ArrayList(java.util.ArrayList)

Aggregations

ReferenceFile (ca.corefacility.bioinformatics.irida.model.project.ReferenceFile)30 Project (ca.corefacility.bioinformatics.irida.model.project.Project)15 Test (org.junit.Test)12 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)10 Path (java.nio.file.Path)10 WithMockUser (org.springframework.security.test.context.support.WithMockUser)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 Join (ca.corefacility.bioinformatics.irida.model.joins.Join)5 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)5 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)4 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)4 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)3 IridaWorkflowDescription (ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription)3 ProjectAnalysisSubmissionJoin (ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 UnsupportedReferenceFileContentError (ca.corefacility.bioinformatics.irida.exceptions.UnsupportedReferenceFileContentError)2