Module: BEL::Gen::SampleResources

Includes:
Annotation
Defined in:
lib/bel/gen/sample_resources.rb

Overview

The SampleResources module defines methods that sample data from actual resources.

BEL parameters are sampled from a Namespace::NamespaceDefinition.

Annotations are sampled from a Annotation::AnnotationDefinition.

Constant Summary

Constants included from Annotation

Annotation::ANNOTATIONS

Instance Method Summary collapse

Methods included from Annotation

#referenced_annotations

Instance Method Details

#annotationHash

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

Returns:

  • (Hash)

    sampled annotation; hash of :name and :value



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bel/gen/sample_resources.rb', line 21

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

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

  {
    :name  => anno.keyword,
    :value => anno.values.keys.sample
  }
end

#bel_parameter_with_namespaceBEL::Nanopub::Parameter

Returns a BEL parameter with a value sampled from a random namespace.

Returns:



40
41
42
43
44
45
46
47
48
49
# File 'lib/bel/gen/sample_resources.rb', line 40

def bel_parameter_with_namespace
  ns    = namespace
  value = ns.values.keys.sample
  enc   = ns.values[value]
  BEL::Nanopub::Parameter.new(
    ns,
    value,
    enc
  )
end