Fixed bugs with python view type when creating a new view, and a bug
when trying to guess the obi type of a nucleotide sequence when its type was bytes
This commit is contained in:
@ -289,7 +289,7 @@ cdef class OBIView :
|
||||
line_selection_p[i] = line_selection[i]
|
||||
line_selection_p[len(line_selection)] = -1 # flagging the end of the array
|
||||
|
||||
self._pointer = self._open_or_create_view(dms, view_name, new=new, view_to_clone=view_to_clone, line_selection_p=line_selection_p, comments=comments, quality_column=quality_column, view_type=None)
|
||||
self._pointer = self._open_or_create_view(dms, view_name, new=new, view_to_clone=view_to_clone, line_selection_p=line_selection_p, comments=comments, quality_column=quality_column, view_type=view_type)
|
||||
|
||||
# Go through columns to build dictionaries of corresponding python instances # TODO make function?
|
||||
self._columns = {}
|
||||
@ -314,7 +314,7 @@ cdef class OBIView :
|
||||
view = obi_new_view(dms._pointer, str2bytes(view_name), (<OBIView> view_to_clone)._pointer, line_selection_p, str2bytes(comments))
|
||||
else :
|
||||
view = obi_new_view(dms._pointer, str2bytes(view_name), NULL, line_selection_p, str2bytes(comments))
|
||||
elif view_type == VIEW_TYPE_NUC_SEQS :
|
||||
elif view_type == bytes2str(VIEW_TYPE_NUC_SEQS) :
|
||||
if view_to_clone is not None :
|
||||
if type(view_to_clone) == str :
|
||||
view = obi_new_view_nuc_seqs_cloned_from_name(dms._pointer, str2bytes(view_name), str2bytes(view_to_clone), line_selection_p, str2bytes(comments), quality_column)
|
||||
@ -322,6 +322,8 @@ cdef class OBIView :
|
||||
view = obi_new_view_nuc_seqs(dms._pointer, str2bytes(view_name), (<OBIView> view_to_clone)._pointer, line_selection_p, str2bytes(comments), quality_column)
|
||||
else :
|
||||
view = obi_new_view_nuc_seqs(dms._pointer, str2bytes(view_name), NULL, line_selection_p, str2bytes(comments), quality_column)
|
||||
else :
|
||||
raise Exception("View type not recognized")
|
||||
|
||||
# Else, open the existing view
|
||||
else :
|
||||
@ -595,6 +597,8 @@ cdef class OBIView_line :
|
||||
# TODO OBI_QUAL ?
|
||||
cdef type value_type
|
||||
cdef str value_obitype
|
||||
cdef bytes value_b
|
||||
|
||||
if column_name not in self._view :
|
||||
if value == None :
|
||||
raise Exception("Trying to create a column from a None value (can't guess type)")
|
||||
@ -605,8 +609,12 @@ cdef class OBIView_line :
|
||||
value_obitype = 'OBI_FLOAT'
|
||||
elif value_type == bool :
|
||||
value_obitype = 'OBI_BOOL'
|
||||
elif value_type == str :
|
||||
if only_ATGC(str2bytes(value)) : # TODO detect IUPAC?
|
||||
elif value_type == str or value_type == bytes :
|
||||
if value_type == str :
|
||||
value_b = str2bytes(value)
|
||||
else :
|
||||
value_b = value
|
||||
if only_ATGC(value_b) : # TODO detect IUPAC?
|
||||
value_obitype = 'OBI_SEQ'
|
||||
elif len(value) == 1 :
|
||||
value_obitype = 'OBI_CHAR'
|
||||
@ -714,9 +722,10 @@ cdef class OBIDMS :
|
||||
else :
|
||||
view_class = OBIView
|
||||
# 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 \
|
||||
isinstance(view_to_clone, OBIView_NUC_SEQS)) :
|
||||
isinstance(view_to_clone, OBIView_NUC_SEQS))) or \
|
||||
(line_selection is not None and isinstance(line_selection._view, OBIView_NUC_SEQS)) :
|
||||
view_type = bytes2str(VIEW_TYPE_NUC_SEQS)
|
||||
view_class = OBIView_NUC_SEQS
|
||||
|
||||
|
Reference in New Issue
Block a user