X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fensembl%2FEnsemblGene.java;h=4dd1bba3161075043669341275565c1fea6a1a86;hb=d547268f85f377f14dbeb169072caebad45f9e2b;hp=84b5dcfd2063f6cba073264b7fbd0112d7659ae4;hpb=d645ed1944459b6271dea2a8511a1e0f4f997530;p=jalview.git diff --git a/src/jalview/ext/ensembl/EnsemblGene.java b/src/jalview/ext/ensembl/EnsemblGene.java index 84b5dcf..4dd1bba 100644 --- a/src/jalview/ext/ensembl/EnsemblGene.java +++ b/src/jalview/ext/ensembl/EnsemblGene.java @@ -11,7 +11,6 @@ import jalview.io.gff.SequenceOntologyI; import jalview.schemes.FeatureColourAdapter; import jalview.schemes.FeatureSettingsAdapter; import jalview.util.MapList; -import jalview.util.StringUtils; import java.awt.Color; import java.io.UnsupportedEncodingException; @@ -108,47 +107,84 @@ public class EnsemblGene extends EnsemblSeqProxy public AlignmentI getSequenceRecords(String query) throws Exception { /* - * if given a transcript id, look up its gene parent + * convert to a non-duplicated list of gene identifiers */ - if (isTranscriptIdentifier(query)) + List geneIds = getGeneIds(query); + + AlignmentI al = null; + for (String geneId : geneIds) { - query = new EnsemblLookup(getDomain()).getParent(query); - if (query == null) + /* + * fetch the gene sequence(s) with features and xrefs + */ + AlignmentI geneAlignment = super.getSequenceRecords(geneId); + + if (geneAlignment.getHeight() == 1) { - return null; + getTranscripts(geneAlignment, geneId); + } + if (al == null) + { + al = geneAlignment; + } + else + { + al.append(geneAlignment); } } + return al; + } - /* - * if given a gene or other external name, lookup and fetch - * the corresponding gene for all model organisms - */ - if (!isGeneIdentifier(query)) + /** + * Converts a query, which may contain one or more gene or transcript + * identifiers, into a non-redundant list of gene identifiers. + * + * @param accessions + * @return + */ + List getGeneIds(String accessions) + { + List geneIds = new ArrayList(); + + for (String acc : accessions.split(getAccessionSeparator())) { - List geneIds = new EnsemblSymbol(getDomain()).getIds(query); - if (geneIds.isEmpty()) + if (isGeneIdentifier(acc)) { - return null; + if (!geneIds.contains(acc)) + { + geneIds.add(acc); + } } - String theIds = StringUtils.listToDelimitedString(geneIds, - getAccessionSeparator()); - return getSequenceRecords(theIds); - } - /* - * fetch the gene sequence(s) with features and xrefs - */ - AlignmentI al = super.getSequenceRecords(query); + /* + * if given a transcript id, look up its gene parent + */ + else if (isTranscriptIdentifier(acc)) + { + String geneId = new EnsemblLookup(getDomain()).getParent(acc); + if (geneId != null && !geneIds.contains(geneId)) + { + geneIds.add(geneId); + } + } - /* - * if we retrieved a single gene, get its transcripts as well - */ - if (al.getHeight() == 1) - { - getTranscripts(al, query); + /* + * if given a gene or other external name, lookup and fetch + * the corresponding gene for all model organisms + */ + else + { + List ids = new EnsemblSymbol(getDomain()).getIds(acc); + for (String geneId : ids) + { + if (!geneIds.contains(geneId)) + { + geneIds.add(geneId); + } + } + } } - - return al; + return geneIds; } /** @@ -551,10 +587,4 @@ public class EnsemblGene extends EnsemblSeqProxy }; } - @Override - public int getMaximumQueryCount() - { - return 1; - } - }