From 89168271ef0c4c46c075855a9f05b495930b4bb7 Mon Sep 17 00:00:00 2001 From: mercierc Date: Thu, 5 Aug 2021 11:28:57 +1200 Subject: [PATCH] ecopcr: now accepting taxonomy from a different DMS than the reference sequences --- python/obitools3/commands/ecopcr.pyx | 11 ++++++++++- python/obitools3/dms/capi/obiecopcr.pxd | 1 + src/obi_ecopcr.c | 14 ++++++++++++-- src/obi_ecopcr.h | 4 +++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/python/obitools3/commands/ecopcr.pyx b/python/obitools3/commands/ecopcr.pyx index d33bc6b..344f54c 100755 --- a/python/obitools3/commands/ecopcr.pyx +++ b/python/obitools3/commands/ecopcr.pyx @@ -175,6 +175,14 @@ def run(config): o_dms_name = output[0].name o_view_name = output[1] + # Open the taxonomy DMS + taxdms = open_uri(config['obi']['taxoURI'], + dms_only=True) + if taxdms is None: + raise Exception("Could not open taxonomy DMS") + tax_dms = taxdms[0] + tax_dms_name = taxdms[0].name + # Read taxonomy name taxonomy_name = config['obi']['taxoURI'].split("/")[-1] # Robust in theory @@ -197,7 +205,8 @@ def run(config): # TODO: primers in comments? - if obi_ecopcr(i_dms.name_with_full_path, tobytes(i_view_name), tobytes(taxonomy_name), \ + if obi_ecopcr(i_dms.name_with_full_path, tobytes(i_view_name), + tax_dms.name_with_full_path, tobytes(taxonomy_name), \ o_dms.name_with_full_path, tobytes(o_view_name), comments, \ tobytes(config['ecopcr']['primer1']), tobytes(config['ecopcr']['primer2']), \ config['ecopcr']['error'], \ diff --git a/python/obitools3/dms/capi/obiecopcr.pxd b/python/obitools3/dms/capi/obiecopcr.pxd index 400cea0..e7566a6 100755 --- a/python/obitools3/dms/capi/obiecopcr.pxd +++ b/python/obitools3/dms/capi/obiecopcr.pxd @@ -8,6 +8,7 @@ cdef extern from "obi_ecopcr.h" nogil: int obi_ecopcr(const char* input_dms_name, const char* i_view_name, + const char* tax_dms_name, const char* taxonomy_name, const char* output_dms_name, const char* o_view_name, diff --git a/src/obi_ecopcr.c b/src/obi_ecopcr.c index 5f605fa..9aa94ca 100644 --- a/src/obi_ecopcr.c +++ b/src/obi_ecopcr.c @@ -645,7 +645,8 @@ static int print_seq(Obiview_p i_view, Obiview_p o_view, int obi_ecopcr(const char* i_dms_name, const char* i_view_name, - const char* taxonomy_name, // TODO discuss that input dms assumed + const char* tax_dms_name, + const char* taxonomy_name, const char* o_dms_name, const char* o_view_name, const char* o_view_comments, @@ -678,6 +679,7 @@ int obi_ecopcr(const char* i_dms_name, OBIDMS_p i_dms = NULL; OBIDMS_p o_dms = NULL; + OBIDMS_p tax_dms = NULL; OBIDMS_taxonomy_p taxonomy = NULL; Obiview_p i_view = NULL; Obiview_p o_view = NULL; @@ -965,8 +967,16 @@ int obi_ecopcr(const char* i_dms_name, return -1; } + // Open taxonomy DMS + tax_dms = obi_open_dms(tax_dms_name, false); + if (tax_dms == NULL) + { + obidebug(1, "\nError opening the taxonomy DMS"); + return -1; + } + // Open the taxonomy - taxonomy = obi_read_taxonomy(i_dms, taxonomy_name, false); + taxonomy = obi_read_taxonomy(tax_dms, taxonomy_name, false); if (taxonomy == NULL) { obidebug(1, "\nError opening the taxonomy"); diff --git a/src/obi_ecopcr.h b/src/obi_ecopcr.h index 5fa6c7d..5d31799 100755 --- a/src/obi_ecopcr.h +++ b/src/obi_ecopcr.h @@ -77,7 +77,8 @@ * * @param i_dms_name The path to the input DMS. * @param i_view_name The name of the input view. - * @param taxonomy_name The name of the taxonomy in the input DMS. + * @param tax_dms_name The path to the DMS containing the taxonomy. + * @param taxonomy_name The name of the taxonomy. * @param o_dms_name The path to the output DMS. * @param o_view_name The name of the output view. * @param o_view_comments The comments to associate with the output view. @@ -106,6 +107,7 @@ */ int obi_ecopcr(const char* i_dms_name, const char* i_view_name, + const char* tax_dms_name, const char* taxonomy_name, const char* o_dms_name, const char* o_view_name,