Search in sources :

Example 41 with SequenceFilePair

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair 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 42 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 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)

Example 43 with SequenceFilePair

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

the class DatabaseSetupGalaxyITService method setupSampleSequenceFileInDatabase.

/**
 * Attaches the given sequence file paths as pairs (using parallel lists) to
 * a particular sample id.
 *
 * @param sampleId
 *            The id of the sample to attach a sequence file to.
 * @param sequenceFiles1
 *            A list of the first part of each pairs to setup.
 * @param sequenceFiles2
 *            A list of the second part of each pairs to setup.
 * @return A {@link List} of {@link SequenceFilePair} objects with the given
 *         sequence file paths attached and saved in the database.
 */
public List<SequenceFilePair> setupSampleSequenceFileInDatabase(long sampleId, List<Path> sequenceFiles1, List<Path> sequenceFiles2) {
    checkArgument(sequenceFiles1.size() == sequenceFiles2.size(), "sequenceFiles lists are unequal");
    Sample sample = sampleService.read(sampleId);
    List<SequenceFilePair> returnedSequenceFilePairs = new ArrayList<>();
    for (int i = 0; i < sequenceFiles1.size(); i++) {
        SequenceFile sf1 = new SequenceFile(sequenceFiles1.get(i));
        SequenceFile sf2 = new SequenceFile(sequenceFiles2.get(i));
        SequenceFilePair pair = new SequenceFilePair(sf1, sf2);
        sequencingObjectService.createSequencingObjectInSample(pair, sample);
        waitForFilesToSettle(pair);
        returnedSequenceFilePairs.add((SequenceFilePair) sequencingObjectService.read(pair.getId()));
    }
    return returnedSequenceFilePairs;
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) ArrayList(java.util.ArrayList)

Example 44 with SequenceFilePair

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

the class ProjectSynchronizationServiceTest method testSyncFilesError.

@Test(expected = ProjectSynchronizationException.class)
public void testSyncFilesError() {
    Sample sample = new Sample();
    SequenceFilePair pair = new SequenceFilePair();
    RemoteStatus pairStatus = new RemoteStatus("http://pair", api);
    pair.setRemoteStatus(pairStatus);
    pair.setId(1L);
    when(pairRemoteService.mirrorSequencingObject(pair)).thenReturn(pair);
    when(objectService.createSequencingObjectInSample(pair, sample)).thenThrow(new NullPointerException("Bad file"));
    syncService.syncSequenceFilePair(pair, sample);
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) RemoteStatus(ca.corefacility.bioinformatics.irida.model.remote.RemoteStatus) Test(org.junit.Test)

Example 45 with SequenceFilePair

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

the class SequencingObjectServiceImplIT method testAddSequenceFilePairAsSequencer.

@Test
@WithMockUser(username = "fbristow", roles = "SEQUENCER")
public void testAddSequenceFilePairAsSequencer() throws IOException {
    SequenceFile file1 = createSequenceFile("file1");
    SequenceFile file2 = createSequenceFile("file2");
    SequenceFilePair sequenceFilePair = new SequenceFilePair(file1, file2);
    SequencingObject createSequenceFilePair = objectService.create(sequenceFilePair);
    assertTrue(createSequenceFilePair.getFiles().contains(file1));
    assertTrue(createSequenceFilePair.getFiles().contains(file2));
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

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