Search in sources :

Example 16 with NextProtException

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

the class ChromosomeReportController method exportChromosomeEntryWithUnconfirmedMsData.

@ApiMethod(path = "/chromosome-report/export/hpp/unconfirmed-ms-data-entries", verb = ApiVerb.GET, description = "Export list of unconfirmed MS data protein entries", produces = { MediaType.TEXT_PLAIN_VALUE })
@RequestMapping(value = "/chromosome-report/export/hpp/unconfirmed-ms-data-entries", method = { RequestMethod.GET })
public void exportChromosomeEntryWithUnconfirmedMsData(HttpServletResponse response) {
    try (OutputStream os = response.getOutputStream()) {
        response.setHeader("Content-Disposition", "attachment; filename=\"HPP_entries_with_unconfirmed_MS_data.txt\"");
        chromosomeReportExportService.exportUnconfirmedMsEntries(os);
    } catch (IOException e) {
        throw new NextProtException(e.getMessage() + ": cannot export unconfirmed MS data protein entries");
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) OutputStream(java.io.OutputStream) IOException(java.io.IOException) ApiMethod(org.jsondoc.core.annotation.ApiMethod) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with NextProtException

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

the class ChromosomeReportController method exportChromosomeEntryWithNAcetyl.

@ApiMethod(path = "/chromosome-report/export/hpp/nacetylated-entries", verb = ApiVerb.GET, description = "Export list of N-acetylated protein entries", produces = { NextprotMediaType.TSV_MEDIATYPE_VALUE })
@RequestMapping(value = "/chromosome-report/export/hpp/nacetylated-entries", method = { RequestMethod.GET })
public void exportChromosomeEntryWithNAcetyl(HttpServletResponse response) {
    try (OutputStream os = response.getOutputStream()) {
        response.setHeader("Content-Disposition", "attachment; filename=\"HPP_entries_with_nacetyl_by_chromosome.tsv\"");
        chromosomeReportExportService.exportNAcetylatedEntries(os);
    } catch (IOException e) {
        throw new NextProtException(e.getMessage() + ": cannot export N-acetylated protein entries");
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) OutputStream(java.io.OutputStream) IOException(java.io.IOException) ApiMethod(org.jsondoc.core.annotation.ApiMethod) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with NextProtException

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

the class ChromosomeReportController method exportChromosomeEntryWithPhospho.

@ApiMethod(path = "/chromosome-report/export/hpp/phosphorylated-entries", verb = ApiVerb.GET, description = "Export list of phosphorylated protein entries", produces = { NextprotMediaType.TSV_MEDIATYPE_VALUE })
@RequestMapping(value = "/chromosome-report/export/hpp/phosphorylated-entries", method = { RequestMethod.GET })
public void exportChromosomeEntryWithPhospho(HttpServletResponse response) {
    try (OutputStream os = response.getOutputStream()) {
        response.setHeader("Content-Disposition", "attachment; filename=\"HPP_entries_with_phospho_by_chromosome.tsv\"");
        chromosomeReportExportService.exportPhosphorylatedEntries(os);
    } catch (IOException e) {
        throw new NextProtException(e.getMessage() + ": cannot export phosphorylated protein entries");
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) OutputStream(java.io.OutputStream) IOException(java.io.IOException) ApiMethod(org.jsondoc.core.annotation.ApiMethod) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with NextProtException

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

the class ChromosomeReportController method exportChromosomeEntriesReportFile.

@ApiMethod(path = "/chromosome-report/export/{chromosome}", verb = ApiVerb.GET, description = "Export informations of neXtProt entries located on a given chromosome", produces = { MediaType.TEXT_PLAIN_VALUE, NextprotMediaType.TSV_MEDIATYPE_VALUE })
@RequestMapping(value = "/chromosome-report/export/{chromosome}", method = { RequestMethod.GET })
public void exportChromosomeEntriesReportFile(@ApiPathParam(name = "chromosome", description = "The chromosome number or name (X,Y..)", allowedvalues = { "Y" }) @PathVariable("chromosome") String chromosome, HttpServletRequest request, HttpServletResponse response) {
    NextprotMediaType mediaType = NextprotMediaType.valueOf(request);
    try (OutputStream os = response.getOutputStream()) {
        String filename = "nextprot_chromosome_" + chromosome + "." + mediaType.getExtension();
        response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
        chromosomeReportExportService.exportChromosomeEntryReport(chromosome, NextprotMediaType.valueOf(request), os);
    } catch (IOException e) {
        throw new NextProtException(e.getMessage() + ": cannot export chromosome " + chromosome + " as " + mediaType);
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) OutputStream(java.io.OutputStream) NextprotMediaType(org.nextprot.api.core.service.export.format.NextprotMediaType) IOException(java.io.IOException) ApiMethod(org.jsondoc.core.annotation.ApiMethod) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with NextProtException

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

the class StatementRemoteServiceImpl method getGeneNamesAndEnvironmentForRelease.

Set<String> getGeneNamesAndEnvironmentForRelease(NextProtSource source, String release) {
    Set<String> genes = new TreeSet<>();
    String urlString = source.getStatementsUrl() + "/" + release;
    LOGGER.info("Requesting " + urlString);
    try {
        String content = IOUtils.toString(getInputStreamFromUrl(urlString), "UTF8");
        Pattern pattern = Pattern.compile("href\\=\\\"(.*).json\\\"", Pattern.MULTILINE);
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()) {
            genes.add(matcher.group(1));
        }
    } catch (IOException e) {
        throw new NextProtException("Not possible to return gene names " + e.getLocalizedMessage());
    }
    return genes;
}
Also used : Pattern(java.util.regex.Pattern) NextProtException(org.nextprot.api.commons.exception.NextProtException) Matcher(java.util.regex.Matcher) TreeSet(java.util.TreeSet) IOException(java.io.IOException)

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