Added view type property to OBIView cython class and updated obi export

to use it
This commit is contained in:
Celine Mercier
2016-11-08 17:49:59 +01:00
parent 51b23915ca
commit 359578814b
2 changed files with 12 additions and 5 deletions

View File

@ -1,5 +1,5 @@
from obitools3.apps.progress cimport ProgressBar # @UnresolvedImport 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 from obitools3.utils cimport bytes2str
import time import time
@ -56,8 +56,10 @@ def run(config):
# Open input view # Open input view
iview = d.open_view(config['obi']['inputview']) iview = d.open_view(config['obi']['inputview'])
print(iview.type)
# TODO check that the view has the type NUC_SEQS # 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") raise Exception("Error: the view to export in fasta or fastq format is not a NUC_SEQS view")
# Initialize the progress bar # Initialize the progress bar

View File

@ -490,6 +490,11 @@ cdef class OBIView :
def name(self): def name(self):
return bytes2str(self._pointer.infos.name) return bytes2str(self._pointer.infos.name)
# view type property getter
@property
def type(self):
return bytes2str(self._pointer.infos.view_type)
# columns property getter # columns property getter
@property @property
def columns(self): 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 # 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 \ 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 \ ((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 \ (view_to_clone.type == bytes2str(VIEW_TYPE_NUC_SEQS)))) or \
(line_selection is not None and isinstance(line_selection._view, OBIView_NUC_SEQS)) : (line_selection is not None and (line_selection._view.type == bytes2str(VIEW_TYPE_NUC_SEQS))) :
view_type = bytes2str(VIEW_TYPE_NUC_SEQS) view_type = bytes2str(VIEW_TYPE_NUC_SEQS)
view_class = OBIView_NUC_SEQS view_class = OBIView_NUC_SEQS