From 57ea736ced3c474a9e8e8bc2de1a15a220384e93 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 4 Mar 2016 09:58:42 +0000 Subject: [PATCH] JAL-1705 parse 'description' from GFF as sequence description --- src/jalview/ext/ensembl/EnsemblGene.java | 23 ++++++++++++++++++++--- src/jalview/ext/ensembl/EnsemblSeqProxy.java | 2 ++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/jalview/ext/ensembl/EnsemblGene.java b/src/jalview/ext/ensembl/EnsemblGene.java index cec7a8d..aa5e0ab 100644 --- a/src/jalview/ext/ensembl/EnsemblGene.java +++ b/src/jalview/ext/ensembl/EnsemblGene.java @@ -14,6 +14,8 @@ import jalview.util.MapList; import jalview.util.StringUtils; import java.awt.Color; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -292,10 +294,25 @@ public class EnsemblGene extends EnsemblSeqProxy } Sequence transcript = new Sequence(accId, seqChars, 1, transcriptLength); - String geneName = (String) transcriptFeature.getValue(NAME); - if (geneName != null) + + /* + * Ensembl has gene name as transcript Name + * EnsemblGenomes doesn't, but has a url-encoded description field + */ + String description = (String) transcriptFeature.getValue(NAME); + if (description == null) + { + description = (String) transcriptFeature.getValue(DESCRIPTION); + } + if (description != null) { - transcript.setDescription(geneName); + try + { + transcript.setDescription(URLDecoder.decode(description, "UTF-8")); + } catch (UnsupportedEncodingException e) + { + e.printStackTrace(); // as if + } } transcript.createDatasetSequence(); diff --git a/src/jalview/ext/ensembl/EnsemblSeqProxy.java b/src/jalview/ext/ensembl/EnsemblSeqProxy.java index a878784..5e27158 100644 --- a/src/jalview/ext/ensembl/EnsemblSeqProxy.java +++ b/src/jalview/ext/ensembl/EnsemblSeqProxy.java @@ -49,6 +49,8 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient protected static final String NAME = "Name"; + protected static final String DESCRIPTION = "description"; + /* * enum for 'type' parameter to the /sequence REST service */ -- 1.7.10.2