我有一个简单的数据库,有三种类型的节点(t:转录本,f:蛋白质家族和g:基因。两种类型的关系, PFAM_MRNA (t) - [r] - &gt;(f)和父(t) - [p] - &gt;(g)。< / p>
(g:Gene{Name:'g1'})<-[p:Parent]-(t:transcript{Name:'t1'})
(g:Gene{Name:'g1'})<-[p:Parent]-(t:transcript{Name:'t2'})
(g:Gene{Name:'g2'})<-[p:Parent]-(t:transcript{Name:'t3'})
(g:Gene{Name:'g3'})<-[p:Parent]-(t:transcript{Name:'t4'})
(g:Gene{Name:'g4'})<-[p:Parent]-(t:transcript{Name:'t5'})
(f:PFAM{ID:'PF0752'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t1'})
(f:PFAM{ID:'PF0752'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t2'})
(f:PFAM{ID:'PF0752'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t3'})
(f:PFAM{ID:'PF0752'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t4'})
(f:PFAM{ID:'PF0752'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t5'})
(f:PFAM{ID:'PF1040'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t4'})
(f:PFAM{ID:'PF1040'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t5'})
接下来,我试图将转录本(及其亲本基因)与PF0752连接,但除去也与PF1040相连的转录物(及其亲本基因)。
所以,我的CYPHER查询看起来像是
MATCH (f)<-[rel:PFAM_MRNA]-(t)-[p:Parent]->(g)
WHERE f.ID IN ['PF0752']
AND NOT f.ID IN ['PF1040']
RETURN *
但是,我得到了一个像
的图表 (g:Gene{Name:'g1'})<-[p:Parent]-(t:transcript{Name:'t1'})
(g:Gene{Name:'g1'})<-[p:Parent]-(t:transcript{Name:'t2'})
(g:Gene{Name:'g2'})<-[p:Parent]-(t:transcript{Name:'t3'})
(g:Gene{Name:'g3'})<-[p:Parent]-(t:transcript{Name:'t4'})
(g:Gene{Name:'g4'})<-[p:Parent]-(t:transcript{Name:'t5'})
(f:PFAM{ID:'PF0752'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t1'})
(f:PFAM{ID:'PF0752'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t2'})
(f:PFAM{ID:'PF0752'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t3'})
(f:PFAM{ID:'PF0752'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t4'})
(f:PFAM{ID:'PF0752'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t5'})
而不是
(g:Gene{Name:'g1'})<-[p:Parent]-(t:transcript{Name:'t1'})
(g:Gene{Name:'g1'})<-[p:Parent]-(t:transcript{Name:'t2'})
(g:Gene{Name:'g2'})<-[p:Parent]-(t:transcript{Name:'t3'})
(f:PFAM{ID:'PF0752'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t1'})
(f:PFAM{ID:'PF0752'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t2'})
(f:PFAM{ID:'PF0752'})<-[r:PFAM_MRNA]-(t:transcript{Name:'t3'})
非常感谢任何有关如何使其有效的提示/想法。
谢谢,
答案 0 :(得分:1)
您可以在模式中添加MATCH (f:PFAM {ID: 'PF0752'}), (pf:PFAM {ID:'PF1040'})
MATCH (f)<-[rel:PFAM_MRNA]-(t)-[p:Parent]->(g)
WHERE NOT (pf)<-[:PFAM_MRNA]-(t)
RETURN *
子句从t到PF1040蛋白:
@total