Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with: Defining and using custom functions #705

Open
versant2612 opened this issue Jul 2, 2023 · 1 comment
Open

Help with: Defining and using custom functions #705

versant2612 opened this issue Jul 2, 2023 · 1 comment

Comments

@versant2612
Copy link

Describe the bug
I want to manipulate geometry data of node2 from my kgtk file using pygeos (python library)

To Reproduce

  1. pygeos instalation
  2. data definition
    CKG-H4-geo.txt
  3. query

export GRAPH_CKG_GEO=/app/kgtk/data/H4/CKG-H4-geo.tsv

A)
\time --format='Elapsed time: %e seconds' kgtk --debug query -i $GRAPH_CKG_GEO --as geo --force --import 'pygeos as pg'
--match 'geo: (:h4v9)-[r1:h4r2]->(v1), (y)-[r2:h4r2]->(v2) '
--where 'y != "h4v9"'
--return '"h4v9" as node1, y as node2, v1, v2, pycall("pg.Geometry", v1) as geo1, pycall("pg.Geometry", v2) as geo2, pycall("pg.intersects", geo1, geo2) as hasIntersection'
-o /app/kgtk/data/H4/CKG-H4-K7-geo.tsv

B)
\time --format='Elapsed time: %e seconds' kgtk --debug query -i $GRAPH_CKG_GEO --as geo --force --import 'pygeos as pg'
--match 'geo: (:h4v9)-[r1:h4r2]->(v1), (y)-[r2:h4r2]->(v2) '
--where 'y != "h4v9"'
--return '"h4v9" as node1, y as node2, pycall("pg.intersection", v1, v2) as hasIntersection'
-o /app/kgtk/data/H4/CKG-H4-K7-geo.tsv

Expected behavior
Return True or False from the pg.intersects function but it returns no values. Or at least return intersection points from pg.intersection function.

CKG-H4-K7-geo.txt

@versant2612
Copy link
Author

I created a function in python that receives two strings, turns them into geometry, checks the intersection, returns True or False as a string but I am also not getting the kgtk query to recognize.

kgtk --debug query -i $GRAPH_CKG_GEO --as geo --force --import 'geo_functions.py' --match 'geo: (:h4v9)-[r1:h4r2]->(v1), (y)-[r2:h4r2]->(v2) ' --where 'y != "h4v9"' --return '"h4v9" as node1, y as node2, pycall("geo_intersection", v1, v2) as hasIntersection'

Traceback (most recent call last):
  File "/app/kgtk/miniconda3/bin/kgtk", line 8, in
    sys.exit(cli_entry())
  File "/app/kgtk/miniconda3/lib/python3.9/site-packages/kgtk/cli_entry.py", line 478, in cli_entry
    subp = mod.parser()
AttributeError: module 'kgtk.cli.geo_functions' has no attribute 'parser'
Command exited with non-zero status 1
Elapsed time: 0.69 seconds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant