From 359578814b45d180512d1f4f3681b8dfc5d002c8 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Tue, 8 Nov 2016 17:49:59 +0100 Subject: [PATCH] Added view type property to OBIView cython class and updated obi export to use it --- python/obitools3/commands/export.pyx | 6 ++++-- python/obitools3/obidms/_obidms.pyx | 11 ++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/python/obitools3/commands/export.pyx b/python/obitools3/commands/export.pyx index e4b0e2b..8c17662 100644 --- a/python/obitools3/commands/export.pyx +++ b/python/obitools3/commands/export.pyx @@ -1,5 +1,5 @@ from obitools3.apps.progress cimport ProgressBar # @UnresolvedImport -from obitools3.obidms._obidms import OBIDMS, OBIView_NUC_SEQS # TODO cimport doesn't work +from obitools3.obidms._obidms import OBIDMS # TODO cimport doesn't work from obitools3.utils cimport bytes2str import time @@ -56,8 +56,10 @@ def run(config): # Open input view iview = d.open_view(config['obi']['inputview']) + print(iview.type) + # TODO check that the view has the type NUC_SEQS - if ((config['export']['format'] == "fasta") or (config['export']['format'] == "fastq")) and (isinstance(iview, OBIView_NUC_SEQS) == False) : + if ((config['export']['format'] == "fasta") or (config['export']['format'] == "fastq")) and (iview.type != "NUC_SEQS_VIEW") : # TODO find a way to import those macros raise Exception("Error: the view to export in fasta or fastq format is not a NUC_SEQS view") # Initialize the progress bar diff --git a/python/obitools3/obidms/_obidms.pyx b/python/obitools3/obidms/_obidms.pyx index 8832133..487d52a 100644 --- a/python/obitools3/obidms/_obidms.pyx +++ b/python/obitools3/obidms/_obidms.pyx @@ -489,7 +489,12 @@ cdef class OBIView : @property def name(self): return bytes2str(self._pointer.infos.name) - + + # view type property getter + @property + def type(self): + return bytes2str(self._pointer.infos.view_type) + # columns property getter @property def columns(self): @@ -724,8 +729,8 @@ cdef class OBIDMS : # Check the type of the view to clone if there is one # TODO make generic for future other view types if (view_to_clone is not None and \ ((type(view_to_clone) == str and self.read_view_infos(view_to_clone)["view_type"] == bytes2str(VIEW_TYPE_NUC_SEQS)) or \ - isinstance(view_to_clone, OBIView_NUC_SEQS))) or \ - (line_selection is not None and isinstance(line_selection._view, OBIView_NUC_SEQS)) : + (view_to_clone.type == bytes2str(VIEW_TYPE_NUC_SEQS)))) or \ + (line_selection is not None and (line_selection._view.type == bytes2str(VIEW_TYPE_NUC_SEQS))) : view_type = bytes2str(VIEW_TYPE_NUC_SEQS) view_class = OBIView_NUC_SEQS