Class: MiGA::Project

Inherits:
MiGA
  • Object
show all
Includes:
Dataset, Plugins, Result
Defined in:
lib/miga/project/base.rb,
lib/miga/project.rb

Overview

MiGA representation of a project.

Defined Under Namespace

Modules: Base, Dataset, Plugins, Result

Constant Summary

Constants included from MiGA

CITATION, VERSION, VERSION_DATE, VERSION_NAME

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Plugins

#install_plugin, #load_plugins, #plugins, #uninstall_plugin

Methods included from Dataset

#add_dataset, #dataset, #dataset_names, #datasets, #done_preprocessing?, #each_dataset, #each_dataset_profile_advance, #import_dataset, #profile_datasets_advance, #unlink_dataset, #unregistered_datasets

Methods included from Result

#add_result, #next_distances, #next_inclade, #next_task, #result, #results

Methods inherited from MiGA

CITATION, DEBUG, DEBUG_OFF, DEBUG_ON, DEBUG_TRACE_OFF, DEBUG_TRACE_ON, FULL_VERSION, LONG_VERSION, VERSION, VERSION_DATE, clean_fasta_file, initialized?, #result_files_exist?, root_path, script_path, seqs_length, tabulate

Constructor Details

#initialize(path, update = false) ⇒ Project

Create a new MiGA::Project at path, if it doesn't exist and update is false, or load an existing one.


28
29
30
31
32
33
34
35
36
# File 'lib/miga/project.rb', line 28

def initialize(path, update=false)
  @datasets = {}
  @path = File.absolute_path(path)
  self.create if not update and not Project.exist? self.path
  self.load if self..nil?
  self.load_plugins
  self.[:type] = :mixed if type.nil?
  raise "Unrecognized project type: #{type}." if @@KNOWN_TYPES[type].nil?
end

Instance Attribute Details

#metadataObject (readonly)

Information about the project as MiGA::Metadata.


23
24
25
# File 'lib/miga/project.rb', line 23

def 
  @metadata
end

#pathObject (readonly)

Absolute path to the project folder.


19
20
21
# File 'lib/miga/project.rb', line 19

def path
  @path
end

Class Method Details

.DISTANCE_TASKSObject


22
# File 'lib/miga/project/base.rb', line 22

def DISTANCE_TASKS ; @@DISTANCE_TASKS ; end

.exist?(path) ⇒ Boolean

Does the project at path exist?

Returns:

  • (Boolean)

9
10
11
# File 'lib/miga/project/base.rb', line 9

def exist?(path)
  Dir.exist?(path) and File.exist?("#{path}/miga.project.json")
end

.INCLADE_TASKSObject


21
# File 'lib/miga/project/base.rb', line 21

def INCLADE_TASKS ; @@INCLADE_TASKS ; end

.KNOWN_TYPESObject


23
# File 'lib/miga/project/base.rb', line 23

def KNOWN_TYPES ; @@KNOWN_TYPES ; end

.load(path) ⇒ Object

Load the project at path. Returns MiGA::Project if project exists, nil otherwise.


16
17
18
19
# File 'lib/miga/project/base.rb', line 16

def load(path)
  return nil unless exist? path
  new path
end

.RESULT_DIRSObject


24
# File 'lib/miga/project/base.rb', line 24

def RESULT_DIRS ; @@RESULT_DIRS ; end

Instance Method Details

#createObject

Create an empty project.


40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/miga/project.rb', line 40

def create
  unless MiGA::MiGA.initialized?
    raise "Impossible to create project in uninitialized MiGA."
  end
  dirs = [path] + @@FOLDERS.map{|d| "#{path}/#{d}" } +
    @@DATA_FOLDERS.map{ |d| "#{path}/data/#{d}"}
  dirs.each{ |d| Dir.mkdir(d) unless Dir.exist? d }
  @metadata = MiGA::Metadata.new(self.path + "/miga.project.json",
    {datasets: [], name: File.basename(path)})
  FileUtils.cp("#{ENV["MIGA_HOME"]}/.miga_daemon.json",
    "#{path}/daemon/daemon.json") unless
      File.exist? "#{path}/daemon/daemon.json"
  self.load
end

#is_clade?Boolean

Is this a clade project?

Returns:

  • (Boolean)

80
# File 'lib/miga/project.rb', line 80

def is_clade? ; type==:clade ; end

#is_multi?Boolean

Is this a project for multi-organism datasets?

Returns:

  • (Boolean)

84
# File 'lib/miga/project.rb', line 84

def is_multi? ; @@KNOWN_TYPES[type][:multi] ; end

#loadObject

(Re-)load project data and metadata.


64
65
66
67
68
# File 'lib/miga/project.rb', line 64

def load
  @datasets = {}
  @metadata = MiGA::Metadata.load "#{path}/miga.project.json"
  raise "Couldn't find project metadata at #{path}" if .nil?
end

#nameObject

Name of the project.


72
# File 'lib/miga/project.rb', line 72

def name ; [:name] ; end

#saveObject

Save any changes persistently.


57
58
59
60
# File 'lib/miga/project.rb', line 57

def save
  .save
  self.load
end

#typeObject

Type of project.


76
# File 'lib/miga/project.rb', line 76

def type ; [:type] ; end