neo4j的最低共同祖先

时间:2013-12-26 06:00:37

标签: neo4j

如何在cypher查询中正确使用lowestCommonAncestor算法来实现neo4j的2.0实现?

start read=node:readID('readid:"HWI-ST884:57:1:1101:13989:75421#0"') match read-[r]->gi where r.bitscore > "35" with gi match lca=lowestCommonAncestor(gi) return lca;
SyntaxException: Invalid input '(': expected an identifier character, whitespace, node labels, a relationship pattern, ',', USING, WHERE, CREATE, DELETE, SET, REMOVE, RETURN, WITH, UNION, ';' or end of input (line 1, column 151)
"start read=node:readID('readid:"HWI-ST884:57:1:1101:13989:75421#0"') match read-[r]->gi where r.bitscore > "35" with gi match lca=lowestCommonAncestor(gi) return lca"
                                                                                                                                                        ^

See Here

2 个答案:

答案 0 :(得分:0)

使用您所指的lowestCommonAncestor函数的唯一方法是通过Java API。你可以,例如写一个内部使用此函数的unmanaged extension。目前,此功能未向Cypher公开。

  

请注意,AncestorUtil 是Neo4j的公共API的一部分 - 这意味着从一个版本到另一个版本可能会发生任何变化。

答案 1 :(得分:0)

也许您可以使用常规密码来查找相同的内容?

MATCH (lca)<-[:REL*]-(n)
WHERE id(n) in {ids}
WITH lca, count(distinct n) as leaves
WHERE leaves = length({ids})
RETURN lca