Skip to content

Commit

Permalink
Missing vg:Step type
Browse files Browse the repository at this point in the history
  • Loading branch information
JervenBolleman committed Nov 22, 2019
1 parent 15a1e0e commit 4dce0de
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion spodgi/OdgiStore.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
knownTypes = [VG.Node, VG.Path, VG.Step, FALDO.Region, FALDO.ExactPosition, FALDO.Position]
knownPredicates = [RDF.value, VG.rank, VG.position, VG.step, VG.path, VG.linksForwardToForward, VG.linksForwardToReverse, VG.linksReverseToForward, VG.linksReverseToReverse, VG.links, VG.reverseOfNode, VG.node, FALDO.begin, FALDO.end, FALDO.reference, FALDO.position]
nodeRelatedPredicates = [VG.linksForwardToForward, VG.linksForwardToReverse, VG.linksReverseToForward, VG.linksReverseToReverse, VG.links, RDF.value]
stepAssociatedTypes = [FALDO.Region, FALDO.ExactPosition, FALDO.Position]
stepAssociatedTypes = [FALDO.Region, FALDO.ExactPosition, FALDO.Position, VG.Step]
stepAssociatedPredicates = [VG.rank, VG.position, VG.path, VG.node, VG.reverseOfNode, FALDO.begin, FALDO.end, FALDO.reference, FALDO.position]

__all__ = [ 'OdgiStore' ]
Expand Down
7 changes: 4 additions & 3 deletions spodgi/term.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __hash__(self):
class NodeIriRef(URIRef):
__slots__ = ("_nodeHandle", "_base", "_odgi")

def __new__(cls, nodeHandle, base, odgi):
def __new__(cls, nodeHandle, base=None, odgi=None):
inst = str.__new__(cls)
inst._nodeHandle = nodeHandle
inst._base = base
Expand All @@ -98,7 +98,7 @@ def __new__(cls, nodeHandle, base, odgi):

def __eq__(self, other):
if type(self) == type(other):
return self._odgi.get_id(self._nodeHandle) == self._odgi.get_id(other._nodeHandle) and self._base == other._base
return self._odgi.get_id(self._nodeHandle) == other._odgi.get_id(other._nodeHandle) and self._base == other._base
elif (type(other) == URIRef):
return URIRef(self.unicode()) == other
else:
Expand All @@ -125,7 +125,8 @@ def toPython(self):
return self.unicode()

def unicode(self):
return f'{self._base}{self._odgi.get_id(self._nodeHandle)}'
nid = self._odgi.get_id(self._nodeHandle);
return f'{self._base}{nid}'

def __str__(self):
return self.unicode()
Expand Down
11 changes: 11 additions & 0 deletions test/test_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ def test_select_specific_step():

spodgi.close()
assert True

def test_select_specific_sequence():
plugin.register('OdgiStore', Store,'spodgi.OdgiStore', 'OdgiStore')
s = plugin.get('OdgiStore', Store)(base="http://example.org/test/")
spodgi = Graph(store=s)
spodgi.open('./test/t.odgi', create=False)
for r in spodgi.query('SELECT ?sequence WHERE {<node/2> rdf:value ?sequence}'):
assert r[0].value == 'A'

spodgi.close()
assert True

0 comments on commit 4dce0de

Please sign in to comment.