Module: BEL::Gen::Annotation

Included in:
Nanopub, SampleResources
Defined in:
lib/bel/gen/annotation.rb

Overview

The Annotation module defines methods that generate random annotations to be used in a nanopub’s Nanopub::ExperimentContext.

Constant Summary collapse

ANNOTATIONS =

Array of the latest OpenBEL Annotation::AnnotationDefinition.

BEL::Annotation::ANNOTATION_LATEST.map { |keyword, (url, rdf_uri)|
  BEL::Annotation::AnnotationDefinition.new(keyword, url, rdf_uri)
}

Instance Method Summary collapse

Instance Method Details

#annotationHash

Returns a random annotation as a hash of :name and :value. These can be added directly to a nanopub’s Nanopub::ExperimentContext.

Returns:

  • (Hash)

    random annotation; hash of :name and :value



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/bel/gen/annotation.rb', line 29

def annotation
  # pick annotation definition
  anno = Rantly {
    choose(*ANNOTATIONS)
  }

  # track annotation definitions
  referenced_annotations[anno.keyword] = anno

  {
    :name  => anno.keyword,
    :value => Rantly {
      sized(range(5, 20)) {
        string(/[[:alnum:]]|[[:blank:]]|[[:punct:]]/)
      }
    }
  }
end

#referenced_annotationsHash

Retrieve the annotations chosen during use of #annotation.

Returns:



19
20
21
22
23
# File 'lib/bel/gen/annotation.rb', line 19

def referenced_annotations
  @referenced_annotations ||= Hash[
    ANNOTATIONS.map { |anno| [anno.keyword, anno] }
  ]
end