From 6294f39c81c9349114e191294dd0b46338aae38a Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 12 Jan 2016 08:58:01 +0000 Subject: [PATCH] JAL-1191 cache isA (great-)grandparents as well for fast isA testing --- src/jalview/io/gff/SequenceOntology.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/jalview/io/gff/SequenceOntology.java b/src/jalview/io/gff/SequenceOntology.java index 7f714ae..36ffaf8 100644 --- a/src/jalview/io/gff/SequenceOntology.java +++ b/src/jalview/io/gff/SequenceOntology.java @@ -40,10 +40,16 @@ public class SequenceOntology /* * Map where key is a Term and value is a (possibly empty) list of - * all Terms to which the key has a direct 'isA' relationship + * all Terms to which the key has an 'isA' relationship, either + * directly or indirectly (A isA B isA C) */ private Map> termIsA; + /** + * Returns singleton instance + * + * @return + */ public synchronized static SequenceOntology getInstance() { if (instance == null) @@ -296,6 +302,14 @@ public class SequenceOntology { if (termIsA(parent, parentTerm)) { + /* + * add (great-)grandparents to parents list as they are discovered, + * for faster lookup next time + */ + if (!parents.contains(parentTerm)) + { + parents.add(parentTerm); + } return true; } } -- 1.7.10.2