Search in sources :

Example 1 with EnsemblDbsnpVersionJson

use of uk.ac.ebi.spot.goci.model.EnsemblDbsnpVersionJson in project goci by EBISPOT.

the class EnsemblDbsnpVersion method getDbsnpVersion.

/**
     * Getter for the dbSNP version
     *
     * @return the dbSNP version
     */
public int getDbsnpVersion() throws EnsemblRestIOException {
    RestTemplate restTemplate = new RestTemplate();
    String url = getServer() + getEndpoint();
    String version = "";
    try {
        getLog().info("Querying " + url);
        //Ensembl returns an array data structure for this call
        // Have to do some wrangling to get dbSNP version
        EnsemblDbsnpVersionJson[] response = restTemplate.getForObject(url, EnsemblDbsnpVersionJson[].class);
        version = response[0].getVersion();
        if (version.isEmpty()) {
            throw new EnsemblRestIOException("Unable to determine Ensembl dbSNP version");
        }
    } catch (Exception e) {
        throw new EnsemblRestIOException("Problem querying Ensembl API for dbSNP version");
    }
    return Integer.parseInt(version);
}
Also used : RestTemplate(org.springframework.web.client.RestTemplate) EnsemblDbsnpVersionJson(uk.ac.ebi.spot.goci.model.EnsemblDbsnpVersionJson) EnsemblRestIOException(uk.ac.ebi.spot.goci.exception.EnsemblRestIOException) EnsemblRestIOException(uk.ac.ebi.spot.goci.exception.EnsemblRestIOException)

Aggregations

RestTemplate (org.springframework.web.client.RestTemplate)1 EnsemblRestIOException (uk.ac.ebi.spot.goci.exception.EnsemblRestIOException)1 EnsemblDbsnpVersionJson (uk.ac.ebi.spot.goci.model.EnsemblDbsnpVersionJson)1