Not really, I was hoping for a way in which I can create any type of long query, and at the end of it call a method like .path that only lists the edges. As I understand it, the traversal is a pipeline from start to end so, at least conceptually, this should be possible.
Specifically I'm trying to build a query like the below cypher query:
querystr = "START clin=node(%s) MATCH path = clin-[rel1]->middle-[rel2]->target WHERE (middle.source! = '%s') AND " %(startNode._id, middleNodeType)
querystr += "("
querystr += "( (middle.label! = target.label!) AND (middle.chr! = target.chr!) AND (target.source! = '%s') ) OR " % (targetNodeType)
querystr += "( (middle.chr! = target.chr!) AND (target.source! = 'CNVR') AND ( rel2.distance! < %i ) AND ( rel2.correlation! > 0 ) ) OR " %(distanceThreshold)
querystr += "( (middle.chr! = target.chr!) AND (target.source! = 'METH') AND ( rel2.distance! < %i ) AND ( rel2.correlation! < 0 ) ) OR " %(distanceThreshold)
querystr += "( (target.source! = 'MIRN') AND ( rel2.correlation! < 0 ) )"
querystr += ")"
querystr += "RETURN EXTRACT( r in relationships(path) : ID(r) ) ORDER BY rel2.%s %s LIMIT %i" %(targetEdgeOrderAttr1, targetEdgeOrdering1, noNodes)
Which I believe would be something like
middle = null;
rel2 = null;
resultEdgeIds = [];
g.v(clinicalNodeId).out.filter{ it.getProperty('source') == 'GEXP' }.as('middle').sideEffect{ middle = it }.outE.sideEffect{rel2 = it}.inV.filter
{
return
(
( ( it.hasProperty('label') && middle.hasProperty('label') && it.getProperty('label') == middle.getProperty('label') ) &&
( it.chr == middle.chr ) && ( middle.source == targetType ) ) ||
( ( it.chr == middle.chr ) && ( it.source == 'CNVR' )
&& ( rel2.getProperty('distance') < distanceThreshold ) && ( rel2.getProperty('correlation') > 0 ) ) ||
( ( it.chr == middle.chr ) && ( it.source == 'METH' ) &&
( rel2.getProperty('distance') < distanceThreshold ) && ( rel2.getProperty('correlation') < 0 ) ) ||
( (it.source == 'MIRN') && (rel2.correlation < 0) )
);
}.paths -> something
Introducing .outE.inV like structure would require the modification of how filtering is done. I was hoping Gremlin would have a Cypher-like feature of naming the whole traversal path (path = .. above) and later I would be able to extract edges from that ( EXTRACT( r in relationships(path) ).