Method: OpenTox::Dataset#split

Defined in:
lib/dataset.rb

#split(compounds, features, metadata, subjectid = nil) ⇒ OpenTox::Dataset

Creates a new dataset, by splitting the current dataset, i.e. using only a subset of compounds and features

Parameters:

  • compounds (Array)

    List of compound URIs

  • features (Array)

    List of feature URIs

  • metadata (Hash)

    Hash containing the metadata for the new dataset

  • subjectid (String) (defaults to: nil)

Returns:



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# File 'lib/dataset.rb', line 373

def split( compounds, features, , subjectid=nil)
  LOGGER.debug "split dataset using "+compounds.size.to_s+"/"+@compounds.size.to_s+" compounds"
  raise "no new compounds selected" unless compounds and compounds.size>0
  dataset = OpenTox::Dataset.create(CONFIG[:services]["opentox-dataset"],subjectid)
  if features.size==0
    compounds.each{ |c| dataset.add_compound(c) }
  else
    compounds.each do |c|
      features.each do |f|
        if @data_entries[c]==nil or @data_entries[c][f]==nil
          dataset.add(c,f,nil)
        else
          @data_entries[c][f].each do |v|
            dataset.add(c,f,v)
          end
        end
      end
    end
  end
  # set feature metadata in new dataset accordingly (including accept values)      
  features.each do |f|
    self.features[f].each do |k,v|
      dataset.features[f][k] = v
    end
  end
  dataset.()
  dataset.save(subjectid)
  dataset
end