Interface UniParcBlastService
- All Superinterfaces:
BlastService<UniParcHit>,Service
Blast service geared specifically towards the UniParc blast databases. Queries to other databases will not work
with this service.
Submission of a blast request to the service will create an asynchronous job, which will run independently from the
main thread. You can run other code whilst waiting for the job to complete. To access the job results directly use
CompletableFuture.get(), or add a task to the Future so as to further process the results CompletableFuture.thenApply(Function)
Note: The blast service needs to be explicitly initialized and destroyed using the Service.start() and Service.stop() methods respectively.
// Create UniParc blast service
ServiceFactory serviceFactoryInstance = Client.getServiceFactoryInstance();
UniParcBlastService uniParcBlastService = serviceFactoryInstance.getUniParcBlastService();
uniParcBlastService.start();
// Create a blast input with a Database and sequence
BlastInput input = new BlastInput.Builder(DatabaseOption.UNIPARC, querySequence).build();
// Submitting the input to the service will return a completable future
CompletableFuture<BlastResult<UniParcHit>> resultFuture = uniParcBlastService.runBlast(input);
// Either block and wait for the task, or do some other work
... // doing some work
try {
BlastResult blastResult = resultFuture.get();
// The blast data contains the job information and the hits with entries
logger.info("Number of blast hits: " + blastResult.getNumberOfHits());
for (UniParcHit hit : blastResult.hits()) {
System.out.println(hit.getSummary().getEntryId() + "\t" +
hit.getEntry().getUniParcId().getValue());
}
} catch (ExecutionException e) {
// Catch any potential execution exceptions from the blast job
logger.error(e.getCause().getMessage());
} catch (InterruptedException e) {
// Will only be thrown if the job is interrupted
logger.error(e.getMessage());
} finally {
uniParcBlastService.stop();
}
-
Method Summary
Modifier and TypeMethodDescriptionrunBlast(BlastInput input) Returns the jobId for a job that has been submitted.
-
Method Details
-
runBlast
Returns the jobId for a job that has been submitted.- Specified by:
runBlastin interfaceBlastService<UniParcHit>- Parameters:
input- an object containing a set of parameters necessary to runBlast a job- Returns:
- a CompletableFuture with the blast results
-