use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.
the class AnalysisCollectionServiceGalaxyIT method testUploadSequenceFilesPairedFailForward.
/**
* Tests failing to upload a paired-end sequence file to Galaxy and
* constructing a collection due to no found forward file.
*
* @throws ExecutionManagerException
*/
@Test(expected = NoSuchElementException.class)
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testUploadSequenceFilesPairedFailForward() throws ExecutionManagerException {
History history = new History();
history.setName("testUploadSequenceFilesPairedFailForward");
HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
LibrariesClient librariesClient = localGalaxy.getGalaxyInstanceAdmin().getLibrariesClient();
History createdHistory = historiesClient.create(history);
Library library = new Library();
library.setName("testUploadSequenceFilesPairedFailForward");
Library createdLibrary = librariesClient.createLibrary(library);
Set<SequenceFilePair> sequenceFiles = Sets.newHashSet(databaseSetupGalaxyITService.setupSampleSequenceFileInDatabase(1L, pairSequenceFiles1AInvalidName, pairSequenceFiles2A));
Map<Sample, IridaSequenceFilePair> sampleSequenceFilePairs = new HashMap<>(sequencingObjectService.getUniqueSamplesForSequencingObjects(sequenceFiles));
analysisCollectionServiceGalaxy.uploadSequenceFilesPaired(sampleSequenceFilePairs, createdHistory, createdLibrary);
}
use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.
the class AnalysisCollectionServiceGalaxyIT method testGetSequenceFileSingleSamplesSuccess.
/**
* Tests successfully getting a map of samples and sequence files (single).
*
* @throws DuplicateSampleException
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetSequenceFileSingleSamplesSuccess() throws DuplicateSampleException {
Set<SequencingObject> sequenceFiles = Sets.newHashSet(databaseSetupGalaxyITService.setupSequencingObjectInDatabase(1L, sequenceFilePathA));
Sample sample = sampleRepository.findOne(1L);
SequencingObject sequenceFile = sequenceFiles.iterator().next();
Map<Sample, SequencingObject> sampleSequenceFiles = sequencingObjectService.getUniqueSamplesForSequencingObjects(sequenceFiles);
assertEquals("sampleSequenceFiles map has size != 1", 1, sampleSequenceFiles.size());
assertEquals("sampleSequenceFiles map does not have sequenceFile " + sequenceFile + " corresponding to sample " + sample, sequenceFile, sampleSequenceFiles.get(sample));
}
use of ca.corefacility.bioinformatics.irida.model.sample.Sample 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.sample.Sample in project irida by phac-nml.
the class ProjectServiceImplIT method testShareSamplesWithOwner.
@Test
@WithMockUser(username = "user1", roles = "USER")
public void testShareSamplesWithOwner() {
Project source = projectService.read(2L);
Project destination = projectService.read(10L);
Sample sample1 = sampleService.read(1L);
Set<Sample> samples = Sets.newHashSet(sample1);
List<ProjectSampleJoin> copiedSamples = projectService.shareSamples(source, destination, samples, true);
assertEquals(samples.size(), copiedSamples.size());
copiedSamples.forEach(j -> {
assertTrue("Project should be owner for sample", j.isOwner());
});
assertNotNull("Samples should still exist in source project", projectSampleJoinRepository.readSampleForProject(source, sample1));
assertNotNull("Sample should exist in destination project", projectSampleJoinRepository.readSampleForProject(destination, sample1));
}
use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.
the class ProjectServiceImplIT method testMoveLockedSamplesWithOwnerFail.
@Test(expected = AccessDeniedException.class)
@WithMockUser(username = "user1", roles = "USER")
public void testMoveLockedSamplesWithOwnerFail() {
Project source = projectService.read(2L);
Project destination = projectService.read(10L);
List<Join<Project, Sample>> samplesForProject = sampleService.getSamplesForProject(source);
Set<Sample> samples = samplesForProject.stream().map(j -> j.getObject()).collect(Collectors.toSet());
projectService.moveSamples(source, destination, samples, true);
}
Aggregations