Class: OpenBEL::Resource::Evidence::AnnotationTransform

Inherits:
Object
  • Object
show all
Defined in:
app/openbel/api/resources/evidence_transform.rb

Constant Summary collapse

SERVER_PATTERN =
%r{/api/annotations/([^/]*)/values/([^/]*)/?}
RDFURI_PATTERN =
%r{/bel/namespace/([^/]*)/([^/]*)/?}
URI_PATTERNS =
[
  %r{/api/annotations/([^/]*)/values/([^/]*)/?},
  %r{/bel/namespace/([^/]*)/([^/]*)/?}
]
ANNOTATION_VALUE_URI =
"%s/api/annotations/%s/values/%s"

Instance Method Summary collapse

Constructor Details

#initialize(annotations) ⇒ AnnotationTransform

Returns a new instance of AnnotationTransform.



17
18
19
# File 'app/openbel/api/resources/evidence_transform.rb', line 17

def initialize(annotations)
  @annotations = annotations
end

Instance Method Details

#transform_annotation(annotation, base_url) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/openbel/api/resources/evidence_transform.rb', line 32

def transform_annotation(annotation, base_url)
  if annotation[:uri]
    transformed = transform_uri(annotation[:uri], base_url)
    return transformed if transformed != nil
  end

  if annotation[:name] && annotation[:value]
    name  = annotation[:name]
    value = annotation[:value]
    transform_name_value(name, value, base_url)
  elsif annotation.respond_to?(:each)
    name  = annotation[0]
    value = annotation[1]
    transform_name_value(name, value, base_url)
  end
end

#transform_evidence!(evidence, base_url) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'app/openbel/api/resources/evidence_transform.rb', line 21

def transform_evidence!(evidence, base_url)
  if evidence
    experiment_context = evidence.experiment_context
    if experiment_context != nil
      experiment_context.values.map! { |annotation|
        transform_annotation(annotation, base_url)
      }
    end
  end
end