From a3635c4010f77f2404bb47c4b690a1409aed99e4 Mon Sep 17 00:00:00 2001 From: "Luis M. Rodriguez-R" Date: Sat, 28 Sep 2024 11:51:27 +0200 Subject: [PATCH] Centralize handling of `db_project` --- lib/miga/dataset.rb | 15 +++++++++++++++ lib/miga/version.rb | 4 ++-- manual/part5/metadata.md | 15 +++++++++------ utils/distance/runner.rb | 4 +--- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/lib/miga/dataset.rb b/lib/miga/dataset.rb index 70b6e20..443bcc4 100644 --- a/lib/miga/dataset.rb +++ b/lib/miga/dataset.rb @@ -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 diff --git a/lib/miga/version.rb b/lib/miga/version.rb index b98e4ec..409a8d4 100644 --- a/lib/miga/version.rb +++ b/lib/miga/version.rb @@ -12,7 +12,7 @@ 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. @@ -20,7 +20,7 @@ module MiGA ## # Date of the current gem relese. - VERSION_DATE = Date.new(2024, 9, 13) + VERSION_DATE = Date.new(2024, 9, 28) ## # References of MiGA diff --git a/manual/part5/metadata.md b/manual/part5/metadata.md index 79794f9..257bb2a 100644 --- a/manual/part5/metadata.md +++ b/manual/part5/metadata.md @@ -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` @@ -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 diff --git a/utils/distance/runner.rb b/utils/distance/runner.rb index 18dda0b..8e48390 100644 --- a/utils/distance/runner.rb +++ b/utils/distance/runner.rb @@ -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