From 66441e0aef0a859ac11cd76d0ec151db294ce5f3 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Sun, 18 Aug 2019 19:43:51 +0200 Subject: [PATCH] Fixed a bug when sending a DMS path to a C function from Cython --- python/obitools3/commands/align.pyx | 2 +- python/obitools3/commands/build_ref_db.pyx | 2 +- python/obitools3/commands/clean.pyx | 2 +- python/obitools3/commands/ecopcr.pyx | 4 ++-- python/obitools3/commands/ecotag.pyx | 2 +- python/obitools3/dms/dms.pyx | 13 ++++++++++++- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/python/obitools3/commands/align.pyx b/python/obitools3/commands/align.pyx index fa6e640..bedc7db 100644 --- a/python/obitools3/commands/align.pyx +++ b/python/obitools3/commands/align.pyx @@ -229,7 +229,7 @@ def run(config): # Call cython alignment function # Using default ID columns of the view. TODO discuss adding option - align_columns(i_dms.full_path, \ + align_columns(i_dms.name_with_full_path, \ i_view_name, \ o_view_name, \ input_view_2_n = i_view_name_2, \ diff --git a/python/obitools3/commands/build_ref_db.pyx b/python/obitools3/commands/build_ref_db.pyx index f171bb5..77f2f69 100755 --- a/python/obitools3/commands/build_ref_db.pyx +++ b/python/obitools3/commands/build_ref_db.pyx @@ -81,7 +81,7 @@ def run(config): input_view_name.append("taxonomy/"+config['obi']['taxoURI'].split("/")[-1]) comments = View.print_config(config, "build_ref_db", command_line, input_dms_name=input_dms_name, input_view_name=input_view_name) - if build_reference_db(i_dms.full_path, tobytes(i_view_name), tobytes(taxonomy_name), tobytes(o_view_name), comments, config['build_ref_db']['threshold']) < 0: + if build_reference_db(i_dms.name_with_full_path, tobytes(i_view_name), tobytes(taxonomy_name), tobytes(o_view_name), comments, config['build_ref_db']['threshold']) < 0: raise Exception("Error building a reference database") # If the input and output DMS are not the same, export result view to output DMS diff --git a/python/obitools3/commands/clean.pyx b/python/obitools3/commands/clean.pyx index 00ed4bc..6cd5ede 100755 --- a/python/obitools3/commands/clean.pyx +++ b/python/obitools3/commands/clean.pyx @@ -107,7 +107,7 @@ def run(config): command_line = " ".join(sys.argv[1:]) comments = View.print_config(config, "clean", command_line, input_dms_name=[i_dms_name], input_view_name=[i_view_name]) - if obi_clean(i_dms.full_path, tobytes(i_view_name), tobytes(config['clean']['sample-tag-name']), tobytes(o_view_name), comments, \ + if obi_clean(i_dms.name_with_full_path, tobytes(i_view_name), tobytes(config['clean']['sample-tag-name']), tobytes(o_view_name), comments, \ config['clean']['distance'], config['clean']['ratio'], config['clean']['heads-only'], config['clean']['thread-count']) < 0: raise Exception("Error running obiclean") diff --git a/python/obitools3/commands/ecopcr.pyx b/python/obitools3/commands/ecopcr.pyx index 65f8a8b..d168ed2 100755 --- a/python/obitools3/commands/ecopcr.pyx +++ b/python/obitools3/commands/ecopcr.pyx @@ -178,8 +178,8 @@ def run(config): # TODO: primers in comments? - if obi_ecopcr(i_dms.full_path, tobytes(i_view_name), tobytes(taxonomy_name), \ - o_dms.full_path, tobytes(o_view_name), comments, \ + if obi_ecopcr(i_dms.name_with_full_path, tobytes(i_view_name), 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'], \ config['ecopcr']['min-length'], config['ecopcr']['max-length'], \ diff --git a/python/obitools3/commands/ecotag.pyx b/python/obitools3/commands/ecotag.pyx index d6326d2..d9270f6 100755 --- a/python/obitools3/commands/ecotag.pyx +++ b/python/obitools3/commands/ecotag.pyx @@ -101,7 +101,7 @@ def run(config): input_view_name.append("taxonomy/"+config['obi']['taxoURI'].split("/")[-1]) comments = View.print_config(config, "ecotag", command_line, input_dms_name=input_dms_name, input_view_name=input_view_name) - if obi_ecotag(i_dms.full_path, tobytes(i_view_name), \ + if obi_ecotag(i_dms.name_with_full_path, tobytes(i_view_name), \ tobytes(ref_dms_name), tobytes(ref_view_name), \ tobytes(taxo_dms_name), tobytes(taxonomy_name), \ tobytes(o_view_name), comments, diff --git a/python/obitools3/dms/dms.pyx b/python/obitools3/dms/dms.pyx index 10f1f97..dab267f 100755 --- a/python/obitools3/dms/dms.pyx +++ b/python/obitools3/dms/dms.pyx @@ -122,13 +122,24 @@ cdef class DMS(OBIWrapper): @property def full_path(self) : ''' - Returns the full path of the DMS directory + Returns the full path including the name with the extension of the DMS directory @rtype: bytes ''' return self.pointer().directory_path + # DMS name with full path property getter + @property + def name_with_full_path(self) : + ''' + Returns the full path with the name (meaning without the '.obidms' extension) of the DMS directory + + @rtype: bytes + ''' + return self.full_path[:-7] + + # command history DOT graph property getter in the form of a bytes string @property def dot_history_graph(self):