X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fensembl%2FEnsemblMap.java;h=f2ab1956a49712df9c162b4c3651c18b7d7f2e74;hb=2bb9cad4fa36d64cebbe09bc63732e8dbb4dcb32;hp=e9cc9e15fb11f4d7fe09b72714cba36e47c33815;hpb=17e4ea278bc9a5fb280db1252ce78b7a295215f5;p=jalview.git diff --git a/src/jalview/ext/ensembl/EnsemblMap.java b/src/jalview/ext/ensembl/EnsemblMap.java index e9cc9e1..f2ab195 100644 --- a/src/jalview/ext/ensembl/EnsemblMap.java +++ b/src/jalview/ext/ensembl/EnsemblMap.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.ext.ensembl; import jalview.datamodel.AlignmentI; @@ -84,8 +104,8 @@ public class EnsemblMap extends EnsemblRestClient * @return * @throws MalformedURLException */ - protected URL getAssemblyMapUrl(String species, String chromosome, String fromRef, - String toRef, int startPos, int endPos) + protected URL getAssemblyMapUrl(String species, String chromosome, + String fromRef, String toRef, int startPos, int endPos) throws MalformedURLException { /* @@ -132,8 +152,8 @@ public class EnsemblMap extends EnsemblRestClient URL url = null; try { - url = getAssemblyMapUrl(species, chromosome, fromRef, toRef, queryRange[0], - queryRange[1]); + url = getAssemblyMapUrl(species, chromosome, fromRef, toRef, + queryRange[0], queryRange[1]); return (parseAssemblyMappingResponse(url)); } catch (Throwable t) { @@ -164,7 +184,8 @@ public class EnsemblMap extends EnsemblRestClient try { - Iterator rvals = (Iterator) getJSON(url, null, -1, MODE_ITERATOR, MAPPINGS); + Iterator rvals = (Iterator) getJSON(url, null, -1, + MODE_ITERATOR, MAPPINGS); if (rvals == null) { return null; @@ -265,9 +286,9 @@ public class EnsemblMap extends EnsemblRestClient URL getIdMapUrl(String domain, String accession, int start, int end, String cdsOrCdna) throws MalformedURLException { - String url = String - .format("%s/map/%s/%s/%d..%d?include_original_region=1&content-type=application/json", - domain, cdsOrCdna, accession, start, end); + String url = String.format( + "%s/map/%s/%s/%d..%d?include_original_region=1&content-type=application/json", + domain, cdsOrCdna, accession, start, end); return new URL(url); } @@ -292,13 +313,13 @@ public class EnsemblMap extends EnsemblRestClient * @return */ @SuppressWarnings("unchecked") -GeneLociI parseIdMappingResponse(URL url, String accession, - String domain) + GeneLociI parseIdMappingResponse(URL url, String accession, String domain) { try { - Iterator rvals = (Iterator) getJSON(url, null, -1, MODE_ITERATOR, MAPPINGS); + Iterator rvals = (Iterator) getJSON(url, null, -1, + MODE_ITERATOR, MAPPINGS); if (rvals == null) { return null; @@ -311,7 +332,8 @@ GeneLociI parseIdMappingResponse(URL url, String accession, while (rvals.hasNext()) { Map val = (Map) rvals.next(); - Map original = (Map) val.get("original"); + Map original = (Map) val + .get("original"); fromEnd = Integer.parseInt(original.get("end").toString()); Map mapped = (Map) val.get(MAPPED); @@ -320,16 +342,16 @@ GeneLociI parseIdMappingResponse(URL url, String accession, String ass = mapped.get("assembly_name").toString(); if (assembly != null && !assembly.equals(ass)) { - System.err - .println("EnsemblMap found multiple assemblies - can't resolve"); + System.err.println( + "EnsemblMap found multiple assemblies - can't resolve"); return null; } assembly = ass; String chr = mapped.get("seq_region_name").toString(); if (chromosome != null && !chromosome.equals(chr)) { - System.err - .println("EnsemblMap found multiple chromosomes - can't resolve"); + System.err.println( + "EnsemblMap found multiple chromosomes - can't resolve"); return null; } chromosome = chr; @@ -352,8 +374,9 @@ GeneLociI parseIdMappingResponse(URL url, String accession, .getSpecies(accession); final String as = assembly; final String chr = chromosome; - List fromRange = Collections.singletonList(new int[] { 1, - fromEnd }); + List fromRange = Collections + .singletonList(new int[] + { 1, fromEnd }); Mapping mapping = new Mapping(new MapList(fromRange, regions, 1, 1)); return new GeneLocus(species == null ? "" : species, as, chr, mapping);