Class: BEL::Nanopub::Parameter

Inherits:
Object
  • Object
show all
Defined in:
lib/bel/translator/plugins/rdf/monkey_patch.rb

Constant Summary collapse

CONCEPT_ENCODING =
{
  :G => BELRDF::BELV.GeneConcept,
  :R => BELRDF::BELV.RNAConcept,
  :P => BELRDF::BELV.ProteinConcept,
  :M => BELRDF::BELV.MicroRNAConcept,
  :C => BELRDF::BELV.ComplexConcept,
  :B => BELRDF::BELV.BiologicalProcessConcept,
  :A => BELRDF::BELV.AbundanceConcept,
  :O => BELRDF::BELV.PathologyConcept,
}

Instance Method Summary collapse

Instance Method Details

#to_rdf(graph_name = nil, remap = nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/bel/translator/plugins/rdf/monkey_patch.rb', line 39

def to_rdf(graph_name = nil, remap = nil)
  # resolve encoding to make rdf:type assertions
  if !@enc && @ns.is_a?(BEL::Namespace::NamespaceDefinition)
    @enc = @ns[@value].enc
  end

  # update namespace resource
  if remap && remap['namespaces']
    ro_ind = remap['namespaces'].index { |mapping|
      mapping['remap'] && mapping['remap'].is_a?(Hash) &&
      mapping['remap']['from'] && mapping['remap']['from'].is_a?(Hash) &&
      mapping['remap']['from']['prefix'] == @ns.prefix.to_s &&
      mapping['remap']['from']['url'] == @ns.url
    }
    if ro_ind
      @ns.prefix = remap['namespaces'][ro_ind]['remap']['to']['prefix']
      @ns.url = remap['namespaces'][ro_ind]['remap']['to']['url']
      @ns.rdf_uri = remap['namespaces'][ro_ind]['remap']['to']['rdf_uri']
    end
  end

  uri = to_uri
  encodings = ['A'].concat(@enc.to_s.each_char.to_a).uniq
  encodings.map! { |enc| concept_statement(enc, uri, graph_name)}
  [uri, encodings]
end

#to_uriObject



35
36
37
# File 'lib/bel/translator/plugins/rdf/monkey_patch.rb', line 35

def to_uri
  @ns.to_rdf_vocabulary[URI::encode(@value)]
end