Search in sources :

Example 1 with NextProtException

use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.

the class BlastResultUpdaterServiceImpl method update.

@Override
public void update(Report blastReport, String querySequence) {
    if (blastReport == null) {
        throw new NextProtException("nothing to update: blast result report was not defined");
    }
    updateReport(blastReport);
    updateParams(blastReport.getParams(), querySequence);
    Search search = blastReport.getResults().getSearch();
    updateSearch(search);
    for (Hit hit : search.getHits()) {
        updateHit(hit, querySequence.length());
        hit.getDescription().forEach(this::updateHitDescription);
        hit.getHsps().forEach(this::updateHsp);
    }
    updateStat(search.getStat());
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) GlobalHit(org.nextprot.api.blast.domain.GlobalHit)

Example 2 with NextProtException

use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.

the class BlastResultUpdaterServiceImpl method updateHitDescription.

private void updateHitDescription(Description description) {
    description.setId(null);
    description.setAccession(null);
    Matcher matcher = ISOFORM_ACCESSION_PATTERN.matcher(description.getTitle());
    if (matcher.find()) {
        String entryAccession = matcher.group(1);
        String isoformAccession = entryAccession + matcher.group(2);
        updateDescription(description, isoformAccession, entryAccession);
    } else {
        throw new NextProtException("blast db error: could not extract isoform information from header " + description.getTitle());
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) Matcher(java.util.regex.Matcher)

Example 3 with NextProtException

use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.

the class BlastProgram method run.

public O run(I input) throws ExceptionWithReason {
    try {
        // pre process
        File fastaFile = constructFastaFile(input);
        List<String> commandLine = buildCommandLine(config, fastaFile);
        preConfig(input, config);
        O out = process(commandLine);
        // post process
        destroyFastaFile(fastaFile);
        postConfig(config);
        return out;
    } catch (IOException e) {
        throw new NextProtException("Internal error: cannot run process " + name, e);
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) IOException(java.io.IOException) File(java.io.File)

Example 4 with NextProtException

use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.

the class StatementAnnotationBuilder method findPublicationId.

long findPublicationId(Statement statement) {
    String referenceDB = statement.getValue(StatementField.REFERENCE_DATABASE);
    String referenceAC = statement.getValue(StatementField.REFERENCE_ACCESSION);
    Publication publication = publicationService.findPublicationByDatabaseAndAccession(referenceDB, referenceAC);
    if (publication == null) {
        String message = "can 't find publication db:" + referenceDB + " id:" + referenceAC;
        LOGGER.error(message);
        throw new NextProtException(message);
    }
    return publication.getPublicationId();
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) Publication(org.nextprot.api.core.domain.Publication)

Example 5 with NextProtException

use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.

the class StatementExtractorBase method deserialize.

protected Set<Statement> deserialize(InputStream content) {
    ObjectMapper mapper = new ObjectMapper();
    Set<Statement> obj = null;
    try {
        obj = mapper.readValue(content, new TypeReference<Set<Statement>>() {
        });
    } catch (IOException e) {
        throw new NextProtException(e);
    }
    return obj;
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) Statement(org.nextprot.commons.statements.Statement) TypeReference(com.fasterxml.jackson.core.type.TypeReference) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

NextProtException (org.nextprot.api.commons.exception.NextProtException)68 IOException (java.io.IOException)30 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 ApiMethod (org.jsondoc.core.annotation.ApiMethod)8 OutputStream (java.io.OutputStream)7 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)7 Cacheable (org.springframework.cache.annotation.Cacheable)6 Isoform (org.nextprot.api.core.domain.Isoform)5 SolrServerException (org.apache.solr.client.solrj.SolrServerException)4 Annotation (org.nextprot.api.core.domain.annotation.Annotation)4 NextprotMediaType (org.nextprot.api.core.service.export.format.NextprotMediaType)4 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)4 java.util (java.util)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 CvTerm (org.nextprot.api.core.domain.CvTerm)3 AnnotationVariant (org.nextprot.api.core.domain.annotation.AnnotationVariant)3 Query (org.nextprot.api.solr.Query)3 SearchResult (org.nextprot.api.solr.SearchResult)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2