module MiGA::Dataset::Type

Helper module including specific functions for dataset type

Public Instance Methods

check_type() click to toggle source

Check that the dataset type is defined, known, and compatible with the project type and raise an exception if any of these checks fail

If the dataset type is :empty, it returns false without raising an exception, and true otherwise (and no tests are failed)

# File lib/miga/dataset/type.rb, line 35
def check_type
  raise MiGA::Error.new('Undefined dataset type') unless type
  return false if type == :empty

  unless self.class.KNOWN_TYPES[type]
    raise MiGA::Error.new("Unknown dataset type: #{type}")
  end
  unless self.class.KNOWN_TYPES[type][:project_types].include? project.type
    raise MiGA::Error.new(
      "Dataset type (#{type}) incompatible with project (#{project.type})"
    )
  end

  true
end
markers?() click to toggle source

Are universal marker genes expected to be found in this dataset?

# File lib/miga/dataset/type.rb, line 25
def markers?
  self.class.KNOWN_TYPES.dig(type, :markers)
end
multi?() click to toggle source

Is this dataset known to be multi-organism?

# File lib/miga/dataset/type.rb, line 12
def multi?
  self.class.KNOWN_TYPES.dig(type, :multi)
end
nonmulti?() click to toggle source

Is this dataset known to be single-organism?

# File lib/miga/dataset/type.rb, line 18
def nonmulti?
  y = self.class.KNOWN_TYPES.dig(type, :multi)
  y.nil? ? nil : !y
end
type() click to toggle source

Get the type of dataset as Symbol

# File lib/miga/dataset/type.rb, line 6
def type
  metadata[:type]
end