Skip to content

Commit

Permalink
Centralize handling of db_project
Browse files Browse the repository at this point in the history
  • Loading branch information
lmrodriguezr committed Sep 28, 2024
1 parent 8f6f7b8 commit a3635c4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
15 changes: 15 additions & 0 deletions lib/miga/dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,19 @@ def closest_relatives(how_many = 1, ref_project = false, metric = :aai)
[name, how_many]
)
end

##
# Retrieves the option with name +key+ from the dataset's metadata
# extending support to relative paths in +:db_project+
def option_by_metadata(key)
case key.to_sym
when :db_project
y = metadata[key] or return
ref_location = project.option(:db_proj_dir) || File.dirname(project.path)
y = File.expand_path(y, ref_location)
return y
end

super
end
end
4 changes: 2 additions & 2 deletions lib/miga/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ module MiGA
# - String indicating release status:
# - rc* release candidate, not released as gem
# - [0-9]+ stable release, released as gem
VERSION = [1.3, 20, 11].freeze
VERSION = [1.3, 21, 0].freeze

##
# Nickname for the current major.minor version.
VERSION_NAME = 'mezzotint'

##
# Date of the current gem relese.
VERSION_DATE = Date.new(2024, 9, 13)
VERSION_DATE = Date.new(2024, 9, 28)

##
# References of MiGA
Expand Down
15 changes: 9 additions & 6 deletions manual/part5/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ Metadata entries that trigger specific behaviors in MiGA:
| min_qual | Float (or 'no') | Min. genome quality (or no filter; def: 25)
| distances_checkpoint | Integer | Comparisons before storing data (def: 10)

> **{1}** This path can be either absolute or relative to the project's path.
> **{1}** This path can either be absolute or relative to the project's path
>
> **{2}** This is the location of the databases used by
> [db_project](#dataset-flags). If not set, it is assumed to be the parent
> folder of the current project.
> folder of the current project
>
> **{3}** Supported values: `blast`, `blat`, `diamond`
> (only for hAAI and AAI), `fastani` (only for ANI), `no` (only for hAAI),
> and `fastaai` (only for hAAI).
> and `fastaai` (only for hAAI)
>
> **{4}** One of: `dupont_2012` (default), or `lee_2019`
Expand Down Expand Up @@ -176,10 +176,13 @@ Metadata entries that trigger specific behaviors in MiGA:
| Field | Supported values | Description
| ------------:|:----------------:|:----------------------------------
| run_`step` | Boolean | Forces running or not `step`
| db_project | Path | Project to use as database
| dist_req | Array of String | Run distances against these datasets*
| db_project | Path | Project to use as database {1}
| dist_req | Array of String | Run distances against these datasets {2}

> **\*** When searching best-matching datasets, include these datasets even if
> **{1}** By default, it uses its own project as database. The path can be
> absolute or relative to the parent folder of the project
>
> **{2}** When searching best-matching datasets, include these datasets even if
> they are not visited using the medoid tree

Expand Down
4 changes: 1 addition & 3 deletions utils/distance/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ def initialize(project_path, dataset_name, opts_hash = {})
@ref_project = MiGA::Project.load(ref_path)
raise "Cannot load reference project: #{ref_path}" if @ref_project.nil?
elsif !opts[:run_taxonomy] && dataset.option(:db_project)
ref_location = project.option(:db_proj_dir) || File.dirname(project.path)
ref_path = File.expand_path(dataset.option(:db_project), ref_location)
@ref_project = MiGA::Project.load(ref_path)
@ref_project = MiGA::Project.load(dataset.option(:db_project))
raise "Cannot load reference project: #{ref_path}" if @ref_project.nil?
else
@ref_project = project
Expand Down

0 comments on commit a3635c4

Please sign in to comment.