+ * Answers a (possibly empty) map of any Sequence Ontology terms (the current
+ * feature type and its parents) which incorporate additional known feature
+ * types (the map entry).
+ * <p>
+ * For example if {@code stop_gained} and {@code stop_lost} are known feature
+ * types, then SO term {@ nonsynonymous_variant} is the first common parent of
+ * both terms
+ *
+ * @param featureType
+ * the current feature type being configured
+ * @param featureTypes
+ * all known feature types on the alignment
+ * @return
+ */
+ protected static Map<String, List<String>> findSequenceOntologyGroupings(
+ String featureType, List<String> featureTypes)
+ {
+ List<String> sortedTypes = new ArrayList<>(featureTypes);
+ Collections.sort(sortedTypes);
+
+ Map<String, List<String>> parents = new HashMap<>();
+
+ /*
+ * method:
+ * walk up featureType and all of its parents
+ * find other feature types which are subsumed by each term
+ * add each distinct aggregation of included feature types to the map
+ */
+ List<String> candidates = new ArrayList<>();
+ SequenceOntologyI so = SequenceOntologyFactory.getInstance();
+ candidates.add(featureType);
+ while (!candidates.isEmpty())
+ {
+ String term = candidates.remove(0);
+ List<String> includedFeatures = new ArrayList<>();
+ for (String type : sortedTypes)
+ {
+ if (!type.equals(featureType) && so.isA(type, term))
+ {
+ includedFeatures.add(type);
+ }
+ }
+ if (!includedFeatures.isEmpty()
+ && !parents.containsValue(includedFeatures))
+ {
+ parents.put(term, includedFeatures);
+ }
+ candidates.addAll(so.getParents(term));
+ }
+
+ return parents;
+ }
+
+ /**