+ * Parses and saves fields of an Ensembl-style description e.g.
+ * chromosome:GRCh38:17:45051610:45109016:1
+ *
+ * @param alignment
+ */
+ private void parseChromosomeLocations(AlignmentI alignment)
+ {
+ for (SequenceI seq : alignment.getSequences())
+ {
+ String description = seq.getDescription();
+ if (description == null)
+ {
+ continue;
+ }
+ String[] tokens = description.split(":");
+ if (tokens.length == 6 && tokens[0].startsWith(DBRefEntry.CHROMOSOME))
+ {
+ String ref = tokens[1];
+ String chrom = tokens[2];
+ try
+ {
+ int chStart = Integer.parseInt(tokens[3]);
+ int chEnd = Integer.parseInt(tokens[4]);
+ boolean forwardStrand = "1".equals(tokens[5]);
+ String species = ""; // dunno yet!
+ int[] from = new int[] { seq.getStart(), seq.getEnd() };
+ int[] to = new int[] { forwardStrand ? chStart : chEnd,
+ forwardStrand ? chEnd : chStart };
+ MapList map = new MapList(from, to, 1, 1);
+ seq.setGeneLoci(species, ref, chrom, map);
+ } catch (NumberFormatException e)
+ {
+ System.err.println("Bad integers in description " + description);
+ }
+ }
+ }
+ }
+
+ /**
+ * Converts a query, which may contain one or more gene, transcript, or
+ * external (to Ensembl) identifiers, into a non-redundant list of gene
+ * identifiers.
+ *
+ * @param accessions
+ * @return
+ */
+ List<String> getGeneIds(String accessions)
+ {
+ List<String> geneIds = new ArrayList<String>();
+
+ for (String acc : accessions.split(getAccessionSeparator()))
+ {
+ /*
+ * First try lookup as an Ensembl (gene or transcript) identifier
+ */
+ String geneId = new EnsemblLookup(getDomain()).getGeneId(acc);
+ if (geneId != null)
+ {
+ if (!geneIds.contains(geneId))
+ {
+ geneIds.add(geneId);
+ }
+ }
+ else
+ {
+ /*
+ * if given a gene or other external name, lookup and fetch
+ * the corresponding gene for all model organisms
+ */
+ List<String> ids = new EnsemblSymbol(getDomain(), getDbSource(),
+ getDbVersion()).getGeneIds(acc);
+ for (String id : ids)
+ {
+ if (!geneIds.contains(id))
+ {
+ geneIds.add(id);
+ }
+ }
+ }
+ }
+ return geneIds;
+ }
+
+ /**