Esempio n. 1
0
    def get_annotation(self, uri, graph_uri=None):
        #---------------------------------------------
        """
    Get an Annotation from the repository.

    :param uri: The URI of an Annotation.
    :param graph_uri: An optional URI of the graph to query.
    :rtype: :class:`~biosignalml.Annotation`
    """
        # The following line works around a Virtuoso problem
        if graph_uri is None:
            graph_uri = self.get_graph_and_recording_uri(uri)[0]
        graph = self.get_resource_as_graph(uri, BSML.Annotation, graph_uri)

        ##### Put into Annotation/Segment.load_from_graph()   ????
        for sg in graph.get_objects(uri,
                                    DCT.subject):  ## This could be improved...
            graph.append_graph(
                self.get_resource_as_graph(sg.uri, BSML.Segment, graph_uri))
            for tm in graph.get_objects(
                    sg.uri, BSML.time):  ## This could be improved...
                graph.append_graph(
                    self.get_resource_as_graph(tm.uri, BSML.Instant,
                                               graph_uri))
                graph.append_graph(
                    self.get_resource_as_graph(tm.uri, BSML.Interval,
                                               graph_uri))

        return Annotation.create_from_graph(uri, graph)
Esempio n. 2
0
    def get_annotation(self, uri):
        # -----------------------------
        """
    Get an Annotation from its recording's graph.

    :param uri: The URI of an Annotation.
    :rtype: :class:`~biosignalml.Annotation`
    """
        return Annotation.create_from_graph(uri, self)
Esempio n. 3
0
    def get_annotation(self, uri):
        #-----------------------------
        """
    Get an Annotation from its recording's graph.

    :param uri: The URI of an Annotation.
    :rtype: :class:`~biosignalml.Annotation`
    """
        return Annotation.create_from_graph(uri, self)
Esempio n. 4
0
    def get_annotation(self, uri, graph_uri=None):
        # ---------------------------------------------
        """
    Get an Annotation from the repository.

    :param uri: The URI of an Annotation.
    :param graph_uri: An optional URI of the graph to query.
    :rtype: :class:`~biosignalml.Annotation`
    """
        # The following line works around a Virtuoso problem
        if graph_uri is None:
            graph_uri = self.get_graph_and_recording_uri(uri)[0]
        graph = self.get_resource_as_graph(uri, BSML.Annotation, graph_uri)

        ##### Put into Annotation/Segment.load_from_graph()   ????
        for sg in graph.get_objects(uri, DCT.subject):  ## This could be improved...
            graph.append_graph(self.get_resource_as_graph(sg.uri, BSML.Segment, graph_uri))
            for tm in graph.get_objects(sg.uri, BSML.time):  ## This could be improved...
                graph.append_graph(self.get_resource_as_graph(tm.uri, BSML.Instant, graph_uri))
                graph.append_graph(self.get_resource_as_graph(tm.uri, BSML.Interval, graph_uri))

        return Annotation.create_from_graph(uri, graph)
Esempio n. 5
0
  r.save_metadata_to_graph(g)

  s = MyRecording.create_from_graph('http://example.org/uri1', g)
  assert(r.metadata_as_string(rdf.Format.TURTLE) == s.metadata_as_string(rdf.Format.TURTLE))
  s.comment='From graph'

  user = '******'

  a1 = 'http://example.org/annotation/1'
  a2 = 'http://example.org/annotation/2'
  a3 = 'http://example.org/annotation/3'

  t1 = 'http://example.org/onto#tag1'
  t2 = 'http://example.org/onto#tag2'
  t3 = 'http://example.org/onto#tag3'
  a = Annotation.Note(a1, s.uri, user, 'A test recording...')
  b = Annotation.Tag(a2, s.uri, user, t1)
  c = Annotation(a3, s.uri, user, tags=[t2, t3], text='Multiple tags')

  #print a.metadata_as_string(rdf.Format.TURTLE)
  #print b.metadata_as_string(rdf.Format.TURTLE)
  #print c.metadata_as_string(rdf.Format.TURTLE)

  c.save_metadata_to_graph(g)
  d = Annotation.create_from_graph(a3, g)
  assert(c.metadata_as_string(rdf.Format.TURTLE) == d.metadata_as_string(rdf.Format.TURTLE))

  s.metadata['zz'] = [ a, b, c ]
  print s.metadata_as_string(rdf.Format.TURTLE)