Module: MiGA::Dataset::Type

Included in:
MiGA::Dataset
Defined in:
lib/miga/dataset/type.rb

Overview

Helper module including specific functions for dataset type

Instance Method Summary collapse

Instance Method Details

#check_typeObject

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)

Raises:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 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?Boolean

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

Returns:

  • (Boolean)


25
26
27
# File 'lib/miga/dataset/type.rb', line 25

def markers?
  self.class.KNOWN_TYPES.dig(type, :markers)
end

#multi?Boolean

Is this dataset known to be multi-organism?

Returns:

  • (Boolean)


12
13
14
# File 'lib/miga/dataset/type.rb', line 12

def multi?
  self.class.KNOWN_TYPES.dig(type, :multi)
end

#nonmulti?Boolean

Is this dataset known to be single-organism?

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/miga/dataset/type.rb', line 18

def nonmulti?
  y = self.class.KNOWN_TYPES.dig(type, :multi)
  y.nil? ? nil : !y
end

#typeObject

Get the type of dataset as Symbol



6
7
8
# File 'lib/miga/dataset/type.rb', line 6

def type
  [:type]
end