Search in sources :

Example 61 with SingleEndSequenceFile

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

the class SequenceFileControllerTest method setUp.

@Before
public void setUp() {
    sequencingRunService = mock(SequencingRunService.class);
    analysisService = mock(AnalysisService.class);
    objectService = mock(SequencingObjectService.class);
    controller = new SequenceFileController(objectService, sequencingRunService, analysisService);
    Path path = Paths.get(FILE_PATH);
    SequenceFile file = new SequenceFile(path);
    file.setId(FILE_ID);
    SingleEndSequenceFile seqObject = new SingleEndSequenceFile(file);
    when(objectService.read(anyLong())).thenReturn(seqObject);
}
Also used : Path(java.nio.file.Path) SequencingObjectService(ca.corefacility.bioinformatics.irida.service.SequencingObjectService) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SequencingRunService(ca.corefacility.bioinformatics.irida.service.SequencingRunService) AnalysisService(ca.corefacility.bioinformatics.irida.service.AnalysisService) SequenceFileController(ca.corefacility.bioinformatics.irida.ria.web.files.SequenceFileController) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Before(org.junit.Before)

Example 62 with SingleEndSequenceFile

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

the class ReadAnalysisSubmissionPermissionTest method setUp.

/**
 * Setup for tests
 */
@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    readAnalysisSubmissionPermission = new ReadAnalysisSubmissionPermission(analysisSubmissionRepository, userRepository, sequencingObjectRepository, seqObjectPermission, pasRepository, readProjectPermission);
    inputSingleFiles = Sets.newHashSet(new SingleEndSequenceFile(new SequenceFile()));
}
Also used : ReadAnalysisSubmissionPermission(ca.corefacility.bioinformatics.irida.security.permissions.analysis.ReadAnalysisSubmissionPermission) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Before(org.junit.Before)

Example 63 with SingleEndSequenceFile

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

the class ReadSequencingObjectPermissionTest method testRejectPermission.

@Test
public void testRejectPermission() {
    Project p = new Project();
    Sample s = new Sample();
    List<Join<Project, Sample>> projectSampleList = new ArrayList<>();
    projectSampleList.add(new ProjectSampleJoin(p, s, true));
    SingleEndSequenceFile sf = new SingleEndSequenceFile(null);
    SampleSequencingObjectJoin join = new SampleSequencingObjectJoin(s, sf);
    when(psjRepository.getProjectForSample(s)).thenReturn(projectSampleList);
    when(sequencingObjectRepository.findOne(1L)).thenReturn(sf);
    when(ssoRepository.getSampleForSequencingObject(sf)).thenReturn(join);
    when(readProjectPermission.isAllowed(any(), eq(p))).thenReturn(false);
    Authentication auth = new UsernamePasswordAuthenticationToken("fbristow", "password1");
    assertFalse("permission was granted.", permission.isAllowed(auth, 1L));
    verify(sequencingObjectRepository).findOne(1L);
    verify(psjRepository).getProjectForSample(s);
    verify(ssoRepository).getSampleForSequencingObject(sf);
    verify(readProjectPermission).isAllowed(any(), eq(p));
}
Also used : ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) Authentication(org.springframework.security.core.Authentication) ArrayList(java.util.ArrayList) Join(ca.corefacility.bioinformatics.irida.model.joins.Join) ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) Test(org.junit.Test)

Example 64 with SingleEndSequenceFile

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

the class ReadSequencingObjectPermissionTest method testGrantPermission.

@Test
public void testGrantPermission() {
    Project p = new Project();
    Sample s = new Sample();
    List<Join<Project, Sample>> projectSampleList = new ArrayList<>();
    projectSampleList.add(new ProjectSampleJoin(p, s, true));
    SingleEndSequenceFile sf = new SingleEndSequenceFile(null);
    SampleSequencingObjectJoin join = new SampleSequencingObjectJoin(s, sf);
    when(psjRepository.getProjectForSample(s)).thenReturn(projectSampleList);
    when(sequencingObjectRepository.findOne(1L)).thenReturn(sf);
    when(ssoRepository.getSampleForSequencingObject(sf)).thenReturn(join);
    when(readProjectPermission.isAllowed(any(), eq(p))).thenReturn(true);
    Authentication auth = new UsernamePasswordAuthenticationToken("fbristow", "password1");
    assertTrue("permission was not granted.", permission.isAllowed(auth, 1L));
    verify(sequencingObjectRepository).findOne(1L);
    verify(psjRepository).getProjectForSample(s);
    verify(ssoRepository).getSampleForSequencingObject(sf);
    verify(readProjectPermission).isAllowed(any(), eq(p));
}
Also used : ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) Authentication(org.springframework.security.core.Authentication) ArrayList(java.util.ArrayList) Join(ca.corefacility.bioinformatics.irida.model.joins.Join) ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) Test(org.junit.Test)

Example 65 with SingleEndSequenceFile

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

Aggregations

SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)99 Test (org.junit.Test)72 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)61 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)44 Path (java.nio.file.Path)33 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)24 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)22 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)20 WithMockUser (org.springframework.security.test.context.support.WithMockUser)18 Project (ca.corefacility.bioinformatics.irida.model.project.Project)17 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)17 AnalysisFastQC (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC)12 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)11 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)10 ArrayList (java.util.ArrayList)10 SequencingRun (ca.corefacility.bioinformatics.irida.model.run.SequencingRun)8 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)8 History (com.github.jmchilton.blend4j.galaxy.beans.History)8 GZIPOutputStream (java.util.zip.GZIPOutputStream)8 ModelMap (org.springframework.ui.ModelMap)8