use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile 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.SequenceFile 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.SequenceFile in project irida by phac-nml.
the class SampleServiceImpl method getTotalBasesForSample.
/**
* {@inheritDoc}
*/
@Override
@Transactional(readOnly = true)
@PreAuthorize("hasRole('ROLE_ADMIN') or hasPermission(#sample, 'canReadSample')")
public Long getTotalBasesForSample(Sample sample) throws SequenceFileAnalysisException {
checkNotNull(sample, "sample is null");
long totalBases = 0;
List<SampleSequencingObjectJoin> sequencesForSample = ssoRepository.getSequencesForSample(sample);
for (SampleSequencingObjectJoin join : sequencesForSample) {
for (SequenceFile sequenceFile : join.getObject().getFiles()) {
final AnalysisFastQC sequenceFileFastQC = analysisRepository.findFastqcAnalysisForSequenceFile(sequenceFile);
if (sequenceFileFastQC == null || sequenceFileFastQC.getTotalBases() == null) {
throw new SequenceFileAnalysisException("Missing FastQC analysis for SequenceFile [" + sequenceFile.getId() + "]");
}
totalBases += sequenceFileFastQC.getTotalBases();
}
}
return totalBases;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.
the class SequencingObjectRemoteServiceImpl method mirrorSequencingObject.
@Override
public Type mirrorSequencingObject(Type seqObject) {
Set<SequenceFile> files = seqObject.getFiles();
for (SequenceFile file : files) {
String fileHref = file.getSelfHref();
RemoteAPI api = getRemoteApiForURI(fileHref);
Path downloadRemoteSequenceFile = sequenceFileRemoteRepository.downloadRemoteSequenceFile(fileHref, api);
file.setFile(downloadRemoteSequenceFile);
}
return seqObject;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.
the class DefaultFileProcessingChain method getSettledSequencingObject.
/**
* Checks the {@link SequenceFile}s for the given {@link SequencingObject}
* to see if it's files are in the place they should be. Since there's lots
* of saves going on during the {@link FileProcessingChain} the transaction
* might not be complete in the time the file is first read.
*
* @param sequencingObjectId
* the id of the {@link SequencingObject} to check
* @return the settled {@link SequencingObject}
* @throws FileProcessorTimeoutException
* if the files don't settle in the configured timeout
*/
private SequencingObject getSettledSequencingObject(Long sequencingObjectId) throws FileProcessorTimeoutException {
boolean filesNotSettled = true;
Integer waiting = 0;
SequencingObject sequencingObject;
do {
if (waiting > timeout) {
throw new FileProcessorTimeoutException("Waiting for longer than " + sleepDuration * timeout + "ms, bailing out. File id " + sequencingObjectId);
}
waiting++;
try {
Thread.sleep(sleepDuration);
} catch (InterruptedException e) {
}
sequencingObject = sequencingObjectRepository.findOne(sequencingObjectId);
Set<SequenceFile> files = sequencingObject.getFiles();
filesNotSettled = files.stream().anyMatch(f -> {
return !Files.exists(f.getFile());
});
} while (filesNotSettled);
return sequencingObject;
}
Aggregations