use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class ReadSequencingObjectPermissionTest method testPermitAdmin.
@Test
public void testPermitAdmin() {
Collection<GrantedAuthority> roles = new ArrayList<>();
roles.add(Role.ROLE_ADMIN);
Authentication auth = new UsernamePasswordAuthenticationToken("fbristow", "password1", roles);
when(sequencingObjectRepository.findOne(1L)).thenReturn(new SingleEndSequenceFile(null));
assertTrue("permission was not granted to admin.", permission.isAllowed(auth, 1L));
// we should fast pass through to permission granted for administrators.
verifyZeroInteractions(userRepository);
verifyZeroInteractions(psjRepository);
verifyZeroInteractions(userRepository);
verifyZeroInteractions(ssoRepository);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class DatabaseSetupGalaxyITService method setupSequencingObjectInDatabase.
/**
* Attaches the given sequence file paths to a particular sample id.
*
* @param sampleId
* The id of the sample to attach a sequence file to.
* @param sequenceFilePaths
* A path of the sequence file to attach.
* @return A List of {@link SequencingObject}s the given sequence file path
* attached and saved in the database.
*/
public List<SingleEndSequenceFile> setupSequencingObjectInDatabase(Long sampleId, Path... sequenceFilePaths) {
Sample sample = sampleService.read(sampleId);
List<SingleEndSequenceFile> returnedSequenceFiles = new ArrayList<>();
for (Path sequenceFilePath : sequenceFilePaths) {
SingleEndSequenceFile singleEndSequenceFile = new SingleEndSequenceFile(new SequenceFile(sequenceFilePath));
sequencingObjectService.createSequencingObjectInSample(singleEndSequenceFile, sample);
waitForFilesToSettle(singleEndSequenceFile);
returnedSequenceFiles.add((SingleEndSequenceFile) sequencingObjectService.read(singleEndSequenceFile.getId()));
}
return returnedSequenceFiles;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SequencingRunSequenceFilesControllerTest method addSequenceFileToMiseqRunTest.
@Test
public void addSequenceFileToMiseqRunTest() throws IOException {
Long seqId = 1L;
Long sequencingrunId = 2L;
MockHttpServletResponse response = new MockHttpServletResponse();
SingleEndSequenceFile singleEndSequenceFile = TestDataFactory.constructSingleEndSequenceFile();
MiseqRun run = new MiseqRun(LayoutType.SINGLE_END, "workflow");
Map<String, String> representation = new HashMap<String, String>();
representation.put(RESTSequencingRunSequenceFilesController.SEQUENCEFILE_ID_KEY, "" + seqId);
when(objectService.read(seqId)).thenReturn(singleEndSequenceFile);
when(miseqRunService.read(sequencingrunId)).thenReturn(run);
ModelMap modelMap = controller.addSequenceFileToMiseqRun(sequencingrunId, representation, response);
verify(objectService).read(seqId);
verify(miseqRunService).read(sequencingrunId);
Object o = modelMap.get(RESTGenericController.RESOURCE_NAME);
assertNotNull("Object should not be null", o);
assertTrue("Object should be an instance of MiseqRunResource", o instanceof MiseqRun);
MiseqRun res = (MiseqRun) o;
String seqFileLocation = linkTo(RESTSequencingRunController.class).slash(sequencingrunId).slash("sequenceFiles").slash(seqId).withSelfRel().getHref();
assertEquals("Sequence file location should be correct", seqFileLocation, res.getLink(Link.REL_SELF).getHref());
assertEquals("Sequence file location should be correct", seqFileLocation, response.getHeader(HttpHeaders.LOCATION));
assertEquals("HTTP status must be CREATED", HttpStatus.CREATED.value(), response.getStatus());
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SequencingObjectServiceImpl method create.
/**
* {@inheritDoc}
*/
@Override
@Transactional
@PreAuthorize("hasAnyRole('ROLE_SEQUENCER', 'ROLE_USER')")
public SequencingObject create(SequencingObject object) throws ConstraintViolationException, EntityExistsException {
SequencingRun sequencingRun = object.getSequencingRun();
if (sequencingRun != null) {
if (object instanceof SingleEndSequenceFile && sequencingRun.getLayoutType() != LayoutType.SINGLE_END) {
throw new IllegalArgumentException("Attempting to add a single end file to a non single end run");
} else if (object instanceof SequenceFilePair && sequencingRun.getLayoutType() != LayoutType.PAIRED_END) {
throw new IllegalArgumentException("Attempting to add a paired end file to a non paired end run");
}
}
for (SequenceFile file : object.getFiles()) {
file = sequenceFileRepository.save(file);
}
SequencingObject so = super.create(object);
fileProcessingChainExecutor.execute(new SequenceFileProcessorLauncher(fileProcessingChain, so.getId(), SecurityContextHolder.getContext()));
return so;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class AnalysisSubmissionServiceImpl method createSingleSampleSubmission.
/**
* {@inheritDoc}
*/
@Override
@Transactional
@PreAuthorize("hasRole('ROLE_USER')")
public Collection<AnalysisSubmission> createSingleSampleSubmission(IridaWorkflow workflow, Long ref, List<SingleEndSequenceFile> sequenceFiles, List<SequenceFilePair> sequenceFilePairs, Map<String, String> params, IridaWorkflowNamedParameters namedParameters, String name, String analysisDescription, List<Project> projectsToShare, boolean writeResultsToSamples) {
final Collection<AnalysisSubmission> createdSubmissions = new HashSet<AnalysisSubmission>();
// Single end reads
IridaWorkflowDescription description = workflow.getWorkflowDescription();
if (description.acceptsSingleSequenceFiles()) {
final Map<Sample, SingleEndSequenceFile> samplesMap = sequencingObjectService.getUniqueSamplesForSequencingObjects(Sets.newHashSet(sequenceFiles));
for (final Map.Entry<Sample, SingleEndSequenceFile> entry : samplesMap.entrySet()) {
Sample s = entry.getKey();
SingleEndSequenceFile file = entry.getValue();
// Build the analysis submission
AnalysisSubmission.Builder builder = AnalysisSubmission.builder(workflow.getWorkflowIdentifier());
builder.name(name + "_" + s.getSampleName());
builder.inputFiles(ImmutableSet.of(file));
builder.updateSamples(writeResultsToSamples);
builder.priority(AnalysisSubmission.Priority.MEDIUM);
// Add reference file
if (ref != null && description.requiresReference()) {
// Note: This cannot be empty if through the UI if the
// pipeline required a reference file.
ReferenceFile referenceFile = referenceFileRepository.findOne(ref);
builder.referenceFile(referenceFile);
}
if (description.acceptsParameters()) {
if (namedParameters != null) {
builder.withNamedParameters(namedParameters);
} else {
if (!params.isEmpty()) {
// Note: This cannot be empty if through the UI if
// the pipeline required params.
builder.inputParameters(params);
}
}
}
// Create the submission
createdSubmissions.add(create(builder.build()));
}
}
// Paired end reads
if (description.acceptsPairedSequenceFiles()) {
final Map<Sample, SequenceFilePair> samplesMap = sequencingObjectService.getUniqueSamplesForSequencingObjects(Sets.newHashSet(sequenceFilePairs));
for (final Map.Entry<Sample, SequenceFilePair> entry : samplesMap.entrySet()) {
Sample s = entry.getKey();
SequenceFilePair filePair = entry.getValue();
// Build the analysis submission
AnalysisSubmission.Builder builder = AnalysisSubmission.builder(workflow.getWorkflowIdentifier());
builder.name(name + "_" + s.getSampleName());
builder.inputFiles(ImmutableSet.of(filePair));
builder.updateSamples(writeResultsToSamples);
// Add reference file
if (ref != null && description.requiresReference()) {
ReferenceFile referenceFile = referenceFileRepository.findOne(ref);
builder.referenceFile(referenceFile);
}
if (description.acceptsParameters()) {
if (namedParameters != null) {
builder.withNamedParameters(namedParameters);
} else {
if (!params.isEmpty()) {
// Note: This cannot be empty if through the UI if
// the pipeline required params.
builder.inputParameters(params);
}
}
}
// Add description to submission, can be null
builder.analysisDescription(analysisDescription);
// Create the submission
createdSubmissions.add(create(builder.build()));
}
}
// Share with the required projects
for (AnalysisSubmission submission : createdSubmissions) {
for (Project project : projectsToShare) {
pasRepository.save(new ProjectAnalysisSubmissionJoin(project, submission));
}
}
return createdSubmissions;
}
Aggregations