Search in sources :

Example 1 with ExceptionWithReason

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);
    }
}
Also used : Description(org.nextprot.api.blast.domain.gen.Description) Isoform(org.nextprot.api.core.domain.Isoform) ExceptionWithReason(org.nextprot.api.commons.utils.ExceptionWithReason)

Example 2 with 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);
    }
}
Also used : Report(org.nextprot.api.blast.domain.gen.Report) ExceptionWithReason(org.nextprot.api.commons.utils.ExceptionWithReason)

Example 3 with 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);
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) IOException(java.io.IOException) ExceptionWithReason(org.nextprot.api.commons.utils.ExceptionWithReason) SystemCommandExecutor(org.nextprot.api.commons.utils.SystemCommandExecutor)

Aggregations

ExceptionWithReason (org.nextprot.api.commons.utils.ExceptionWithReason)3 IOException (java.io.IOException)1 Description (org.nextprot.api.blast.domain.gen.Description)1 Report (org.nextprot.api.blast.domain.gen.Report)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 SystemCommandExecutor (org.nextprot.api.commons.utils.SystemCommandExecutor)1 Isoform (org.nextprot.api.core.domain.Isoform)1