use of org.nextprot.api.commons.utils.ExceptionWithReason in project nextprot-api by calipho-sib.
the class BlastServiceImpl method blastIsoformSequence.
@Override
public BlastProgramOutput blastIsoformSequence(BlastIsoformInput params) {
String isoformAccession = params.getIsoformAccession();
String entryAccession = isoformAccession.split("-")[0];
try {
Isoform isoform = getIsoform(isoformAccession, entryAccession);
params.setSequence(isoform.getSequence());
params.validateSequencePositions();
params.setSequence(params.getSequence().substring(params.getBeginPos() - 1, params.getEndPos()));
params.setTitle(buildTitle(params, isoform, entryAccession));
params.setEntryAccession(entryAccession);
Description queryDescription = new Description();
blastResultUpdaterService.updateDescription(queryDescription, isoformAccession, entryAccession);
params.setDescription(queryDescription);
return blastProteinSequence(params);
} catch (ExceptionWithReason exceptionWithReason) {
return new BlastProgramFailure(params, exceptionWithReason);
}
}
use of org.nextprot.api.commons.utils.ExceptionWithReason in project nextprot-api by calipho-sib.
the class BlastServiceImpl method blastProteinSequence.
@Override
public BlastProgramOutput blastProteinSequence(BlastSequenceInput params) {
try {
BlastPRunner.FastaEntry fastaEntry = new BlastPRunner.FastaEntry(params.getTitle(), params.getSequence());
Report result = new BlastPRunner(params).run(fastaEntry);
blastResultUpdaterService.update(result, fastaEntry.getSequence());
return new BlastProgramSuccess(params, result);
} catch (ExceptionWithReason exceptionWithReason) {
return new BlastProgramFailure(params, exceptionWithReason);
}
}
use of org.nextprot.api.commons.utils.ExceptionWithReason in project nextprot-api by calipho-sib.
the class BlastProgram method process.
private O process(List<String> commandLine) throws ExceptionWithReason {
SystemCommandExecutor commandExecutor = new SystemCommandExecutor(commandLine);
try {
commandExecutor.executeCommand();
String stderr = commandExecutor.getLastExecutionStandardError();
if (!stderr.isEmpty()) {
ExceptionWithReason ewr = new ExceptionWithReason();
ewr.getReason().addCause(name + " exception", stderr.replace("\n", " "));
ewr.getReason().setMessage("Error while executing " + name);
throw ewr;
}
return buildOutputFromStdout(commandExecutor.getLastExecutionStandardOutput());
} catch (InterruptedException | IOException e) {
throw new NextProtException("Internal error: cannot process " + name + " command line " + commandLine, e);
}
}
Aggregations