Skip to content

Instantly share code, notes, and snippets.

@mjdominus
Created November 2, 2010 15:02
Show Gist options
  • Save mjdominus/659737 to your computer and use it in GitHub Desktop.
Save mjdominus/659737 to your computer and use it in GitHub Desktop.
Big tree query that the RDB handled just fine
String query = "select distinct a.tree.rootNode "
+
// Find the trees with three nodes a, b, and c, such that...
"from PhyloTreeNode as a, PhyloTreeNode as b, PhyloTreeNode as c, "
+
// There's a node "ab" (which will be an ancestor of both a and b)
"PhyloTreeNode as ab "
+
// All four nodes are in the same tree
"where a.tree = b.tree " + "and a.tree = c.tree " + "and a.tree = ab.tree "
+
"and a.taxonLabel.taxonVariant in (:a) " +
"and b.taxonLabel.taxonVariant in (:b) " +
"and c.taxonLabel.taxonVariant in (:c) " +
// ab is an ancestor of a
"and ab.leftNode < a.leftNode and ab.rightNode > a.rightNode " +
// ab is an ancestor of b
"and ab.leftNode < b.leftNode and ab.rightNode > b.rightNode " +
// ab is NOT an ancestor of c
"and (ab.leftNode >= c.leftNode or ab.rightNode <= c.rightNode) ";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment