Class: OpenBEL::Resource::Nanopub::AnnotationGroupingTransform

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

Constant Summary collapse

ExperimentContext =
::BEL::Nanopub::ExperimentContext

Instance Method Summary collapse

Instance Method Details

#transform_nanopub!(nanopub) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'app/openbel/api/resources/nanopub_transform.rb', line 129

def transform_nanopub!(nanopub)
  experiment_context = nanopub.experiment_context
  if experiment_context != nil
    nanopub.experiment_context = ExperimentContext.new(
      experiment_context.group_by { |annotation|
        annotation[:name]
      }.values.map do |grouped_annotation|
        {
          :name  => grouped_annotation.first[:name],
          :value => grouped_annotation.flat_map { |annotation|
            annotation[:value]
          },
          :uri   => grouped_annotation.flat_map { |annotation|
            annotation[:uri]
          }
        }
      end
    )
  end
end