Renamed private attributes as _* and removed some deprecated code
This commit is contained in:
@ -9,10 +9,9 @@ from ._obitaxo cimport OBI_Taxonomy
|
|||||||
|
|
||||||
cdef class OBIDMS_column:
|
cdef class OBIDMS_column:
|
||||||
|
|
||||||
cdef str column_alias # associated property: alias
|
cdef str _alias # associated property: alias
|
||||||
cdef OBIDMS_column_p* pointer
|
cdef OBIDMS_column_p* _pointer
|
||||||
cdef OBIDMS dms
|
cdef OBIView _view
|
||||||
cdef OBIView view
|
|
||||||
|
|
||||||
cpdef close(self)
|
cpdef close(self)
|
||||||
|
|
||||||
@ -27,15 +26,14 @@ cdef class OBIDMS_column_multi_elts(OBIDMS_column):
|
|||||||
|
|
||||||
cdef class OBIDMS_column_line:
|
cdef class OBIDMS_column_line:
|
||||||
|
|
||||||
cdef OBIDMS_column column
|
cdef OBIDMS_column _column
|
||||||
cdef index_t index
|
cdef index_t _index
|
||||||
|
|
||||||
|
|
||||||
cdef class OBIView:
|
cdef class OBIView:
|
||||||
|
|
||||||
cdef Obiview_p pointer
|
cdef Obiview_p _pointer
|
||||||
cdef OBIDMS dms
|
cdef dict _columns
|
||||||
cdef dict columns
|
|
||||||
|
|
||||||
cpdef delete_column(self, str column_name)
|
cpdef delete_column(self, str column_name)
|
||||||
cpdef add_column(self,
|
cpdef add_column(self,
|
||||||
@ -71,14 +69,13 @@ cdef class OBIView_NUC_SEQS(OBIView):
|
|||||||
|
|
||||||
cdef class OBIView_line :
|
cdef class OBIView_line :
|
||||||
|
|
||||||
cdef index_t index
|
cdef index_t _index
|
||||||
cdef OBIView view
|
cdef OBIView _view
|
||||||
|
|
||||||
|
|
||||||
cdef class OBIDMS:
|
cdef class OBIDMS:
|
||||||
|
|
||||||
cdef OBIDMS_p pointer
|
cdef OBIDMS_p _pointer
|
||||||
cdef str dms_name
|
|
||||||
|
|
||||||
cpdef close(self)
|
cpdef close(self)
|
||||||
cpdef OBI_Taxonomy open_taxonomy(self, str taxo_name)
|
cpdef OBI_Taxonomy open_taxonomy(self, str taxo_name)
|
||||||
|
@ -89,14 +89,13 @@ cdef class OBIDMS_column :
|
|||||||
cdef OBIDMS_column_p column_p
|
cdef OBIDMS_column_p column_p
|
||||||
cdef OBIDMS_column_p* column_pp
|
cdef OBIDMS_column_p* column_pp
|
||||||
|
|
||||||
column_pp = obi_view_get_pointer_on_column_in_view(view.pointer, str2bytes(column_alias))
|
column_pp = obi_view_get_pointer_on_column_in_view(view._pointer, str2bytes(column_alias))
|
||||||
column_p = column_pp[0] # TODO ugly cython dereferencing but can't find better
|
column_p = column_pp[0] # TODO ugly cython dereferencing but can't find better
|
||||||
|
|
||||||
# Fill structure
|
# Fill structure
|
||||||
self.column_alias = column_alias
|
self._alias = column_alias
|
||||||
self.pointer = column_pp
|
self._pointer = column_pp
|
||||||
self.dms = view.dms
|
self._view = view
|
||||||
self.view = view
|
|
||||||
|
|
||||||
def __setitem__(self, index_t line_nb, object value):
|
def __setitem__(self, index_t line_nb, object value):
|
||||||
self.set_line(line_nb, value)
|
self.set_line(line_nb, value)
|
||||||
@ -108,7 +107,7 @@ cdef class OBIDMS_column :
|
|||||||
return self.lines_used
|
return self.lines_used
|
||||||
|
|
||||||
def __sizeof__(self):
|
def __sizeof__(self):
|
||||||
return ((self.pointer)[0].header.header_size + (self.pointer)[0].header.data_size)
|
return ((self._pointer)[0].header.header_size + (self._pointer)[0].header.data_size)
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
# Declarations
|
# Declarations
|
||||||
@ -125,59 +124,59 @@ cdef class OBIDMS_column :
|
|||||||
return to_print
|
return to_print
|
||||||
|
|
||||||
def __repr__(self) :
|
def __repr__(self) :
|
||||||
return (self.column_alias + ", original name: " + self.original_name + ", version " + str(self.version) + ", data type: " + self.data_type)
|
return (self._alias + ", original name: " + self.original_name + ", version " + str(self.version) + ", data type: " + self.data_type)
|
||||||
|
|
||||||
cpdef close(self):
|
cpdef close(self):
|
||||||
if obi_close_column((self.pointer)[0]) < 0 :
|
if obi_close_column((self._pointer)[0]) < 0 :
|
||||||
raise Exception("Problem closing a column")
|
raise Exception("Problem closing a column")
|
||||||
|
|
||||||
# Column alias property getter and setter
|
# Column alias property getter and setter
|
||||||
@property
|
@property
|
||||||
def alias(self):
|
def alias(self):
|
||||||
return self.column_alias
|
return self._alias
|
||||||
@alias.setter
|
@alias.setter
|
||||||
def alias(self, new_alias):
|
def alias(self, new_alias):
|
||||||
self.view.change_column_alias(self.column_alias, new_alias)
|
self._view.change_column_alias(self._alias, new_alias)
|
||||||
|
|
||||||
# elements_names property getter
|
# elements_names property getter
|
||||||
@property
|
@property
|
||||||
def elements_names(self):
|
def elements_names(self):
|
||||||
return (bytes2str(((self.pointer)[0].header).elements_names)).split(';')
|
return (bytes2str(((self._pointer)[0].header).elements_names)).split(';')
|
||||||
|
|
||||||
# nb_elements_per_line property getter
|
# nb_elements_per_line property getter
|
||||||
@property
|
@property
|
||||||
def nb_elements_per_line(self):
|
def nb_elements_per_line(self):
|
||||||
return ((self.pointer)[0].header).nb_elements_per_line
|
return ((self._pointer)[0].header).nb_elements_per_line
|
||||||
|
|
||||||
# data_type property getter
|
# data_type property getter
|
||||||
@property
|
@property
|
||||||
def data_type(self):
|
def data_type(self):
|
||||||
return bytes2str(name_data_type(((self.pointer)[0].header).returned_data_type))
|
return bytes2str(name_data_type(((self._pointer)[0].header).returned_data_type))
|
||||||
|
|
||||||
# original_name property getter
|
# original_name property getter
|
||||||
@property
|
@property
|
||||||
def original_name(self):
|
def original_name(self):
|
||||||
return bytes2str(((self.pointer)[0].header).name)
|
return bytes2str(((self._pointer)[0].header).name)
|
||||||
|
|
||||||
# version property getter
|
# version property getter
|
||||||
@property
|
@property
|
||||||
def version(self):
|
def version(self):
|
||||||
return ((self.pointer)[0].header).version
|
return ((self._pointer)[0].header).version
|
||||||
|
|
||||||
# lines_used property getter
|
# lines_used property getter
|
||||||
@property
|
@property
|
||||||
def lines_used(self):
|
def lines_used(self):
|
||||||
return (self.pointer)[0].header.lines_used
|
return (self._pointer)[0].header.lines_used
|
||||||
|
|
||||||
# comments property getter
|
# comments property getter
|
||||||
@property
|
@property
|
||||||
def comments(self):
|
def comments(self):
|
||||||
return bytes2str((self.pointer)[0].header.comments)
|
return bytes2str((self._pointer)[0].header.comments)
|
||||||
|
|
||||||
# creation_date property getter
|
# creation_date property getter
|
||||||
@property
|
@property
|
||||||
def creation_date(self):
|
def creation_date(self):
|
||||||
return bytes2str(obi_format_date((self.pointer)[0].header.creation_date))
|
return bytes2str(obi_format_date((self._pointer)[0].header.creation_date))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
cdef object get_subclass_type(OBIDMS_column_p column_p) :
|
cdef object get_subclass_type(OBIDMS_column_p column_p) :
|
||||||
@ -253,20 +252,20 @@ cdef class OBIDMS_column_multi_elts(OBIDMS_column) :
|
|||||||
cdef class OBIDMS_column_line :
|
cdef class OBIDMS_column_line :
|
||||||
|
|
||||||
def __init__(self, OBIDMS_column column, index_t line_nb) :
|
def __init__(self, OBIDMS_column column, index_t line_nb) :
|
||||||
self.index = line_nb
|
self._index = line_nb
|
||||||
self.column = column
|
self._column = column
|
||||||
|
|
||||||
def __getitem__(self, str element_name) :
|
def __getitem__(self, str element_name) :
|
||||||
return self.column.get_item(self.index, element_name)
|
return self._column.get_item(self._index, element_name)
|
||||||
|
|
||||||
def __setitem__(self, str element_name, object value):
|
def __setitem__(self, str element_name, object value):
|
||||||
self.column.set_item(self.index, element_name, value)
|
self._column.set_item(self._index, element_name, value)
|
||||||
|
|
||||||
def __contains__(self, str element_name):
|
def __contains__(self, str element_name):
|
||||||
return (element_name in self.column.elements_names)
|
return (element_name in self._column.elements_names)
|
||||||
|
|
||||||
def __repr__(self) :
|
def __repr__(self) :
|
||||||
return str(self.column.get_line(self.index))
|
return str(self._column.get_line(self._index))
|
||||||
|
|
||||||
|
|
||||||
######################################################################################################
|
######################################################################################################
|
||||||
@ -283,9 +282,7 @@ cdef class OBIView :
|
|||||||
cdef str col_alias
|
cdef str col_alias
|
||||||
cdef OBIDMS_column_p column_p
|
cdef OBIDMS_column_p column_p
|
||||||
cdef object subclass
|
cdef object subclass
|
||||||
|
|
||||||
self.dms = dms
|
|
||||||
|
|
||||||
# Create the C array for the line selection if needed
|
# Create the C array for the line selection if needed
|
||||||
if line_selection is not None :
|
if line_selection is not None :
|
||||||
line_selection_p = <index_t*> malloc((len(line_selection) + 1) * sizeof(index_t))
|
line_selection_p = <index_t*> malloc((len(line_selection) + 1) * sizeof(index_t))
|
||||||
@ -299,43 +296,43 @@ cdef class OBIView :
|
|||||||
if new :
|
if new :
|
||||||
if view_to_clone is not None :
|
if view_to_clone is not None :
|
||||||
if type(view_to_clone) == str :
|
if type(view_to_clone) == str :
|
||||||
view = obi_new_view_cloned_from_name(dms.pointer, str2bytes(view_name), str2bytes(view_to_clone), line_selection_p, str2bytes(comments))
|
view = obi_new_view_cloned_from_name(dms._pointer, str2bytes(view_name), str2bytes(view_to_clone), line_selection_p, str2bytes(comments))
|
||||||
else :
|
else :
|
||||||
view = obi_new_view(dms.pointer, str2bytes(view_name), (<OBIView> view_to_clone).pointer, line_selection_p, str2bytes(comments))
|
view = obi_new_view(dms._pointer, str2bytes(view_name), (<OBIView> view_to_clone)._pointer, line_selection_p, str2bytes(comments))
|
||||||
else :
|
else :
|
||||||
view = obi_new_view(dms.pointer, str2bytes(view_name), NULL, line_selection_p, str2bytes(comments))
|
view = obi_new_view(dms._pointer, str2bytes(view_name), NULL, line_selection_p, str2bytes(comments))
|
||||||
# Else, open the existing view
|
# Else, open the existing view
|
||||||
else :
|
else :
|
||||||
view = obi_open_view(dms.pointer, str2bytes(view_name))
|
view = obi_open_view(dms._pointer, str2bytes(view_name))
|
||||||
|
|
||||||
if view == NULL :
|
if view == NULL :
|
||||||
raise Exception("Error creating/opening a view")
|
raise Exception("Error creating/opening a view")
|
||||||
|
|
||||||
self.pointer = view
|
self._pointer = view
|
||||||
|
|
||||||
# Go through columns to build dictionaries of corresponding python instances # TODO make function?
|
# Go through columns to build dictionaries of corresponding python instances # TODO make function?
|
||||||
self.columns = {}
|
self._columns = {}
|
||||||
for i in range(view.infos.column_count) :
|
for i in range(view.infos.column_count) :
|
||||||
col_alias = bytes2str(view.infos.column_references[i].alias)
|
col_alias = bytes2str(view.infos.column_references[i].alias)
|
||||||
column_p = <OBIDMS_column_p> (view.columns)[i]
|
column_p = <OBIDMS_column_p> (view.columns)[i]
|
||||||
subclass = OBIDMS_column.get_subclass_type(column_p)
|
subclass = OBIDMS_column.get_subclass_type(column_p)
|
||||||
self.columns[col_alias] = subclass(self, col_alias)
|
self._columns[col_alias] = subclass(self, col_alias)
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self) :
|
def __repr__(self) :
|
||||||
cdef str s
|
cdef str s
|
||||||
s = str(self.name) + "\n" + str(self.comments) + "\n" + str(self.line_count) + " lines\n"
|
s = str(self.name) + "\n" + str(self.comments) + "\n" + str(self.line_count) + " lines\n"
|
||||||
for column_name in self.columns :
|
for column_name in self._columns :
|
||||||
s = s + repr(self.columns[column_name]) + '\n'
|
s = s + repr(self._columns[column_name]) + '\n'
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
cpdef delete_column(self, str column_name) :
|
cpdef delete_column(self, str column_name) :
|
||||||
cdef str column_n
|
cdef str column_n
|
||||||
if obi_view_delete_column(self.pointer, str2bytes(column_name)) < 0 :
|
if obi_view_delete_column(self._pointer, str2bytes(column_name)) < 0 :
|
||||||
raise Exception("Problem deleting a column from a view")
|
raise Exception("Problem deleting a column from a view")
|
||||||
# Update the dictionary of column objects:
|
# Update the dictionary of column objects:
|
||||||
(self.columns).pop(column_name)
|
(self._columns).pop(column_name)
|
||||||
self.update_column_pointers()
|
self.update_column_pointers()
|
||||||
|
|
||||||
|
|
||||||
@ -389,7 +386,7 @@ cdef class OBIView :
|
|||||||
else :
|
else :
|
||||||
raise Exception("Invalid provided data type")
|
raise Exception("Invalid provided data type")
|
||||||
|
|
||||||
if (obi_view_add_column(self.pointer, column_name_b, version_number, alias_b,
|
if (obi_view_add_column(self._pointer, column_name_b, version_number, alias_b,
|
||||||
data_type, nb_lines, nb_elements_per_line,
|
data_type, nb_lines, nb_elements_per_line,
|
||||||
elements_names_b, str2bytes(indexer_name),
|
elements_names_b, str2bytes(indexer_name),
|
||||||
str2bytes(associated_column_name), associated_column_version,
|
str2bytes(associated_column_name), associated_column_version,
|
||||||
@ -397,34 +394,34 @@ cdef class OBIView :
|
|||||||
raise Exception("Problem adding a column in a view")
|
raise Exception("Problem adding a column in a view")
|
||||||
|
|
||||||
# Get the column pointer
|
# Get the column pointer
|
||||||
column_p = obi_view_get_column(self.pointer, alias_b)
|
column_p = obi_view_get_column(self._pointer, alias_b)
|
||||||
|
|
||||||
# Open and store the subclass
|
# Open and store the subclass
|
||||||
subclass = OBIDMS_column.get_subclass_type(column_p)
|
subclass = OBIDMS_column.get_subclass_type(column_p)
|
||||||
(self.columns)[alias] = subclass(self, alias)
|
(self._columns)[alias] = subclass(self, alias)
|
||||||
|
|
||||||
|
|
||||||
cpdef change_column_alias(self, str current_alias, str new_alias):
|
cpdef change_column_alias(self, str current_alias, str new_alias):
|
||||||
cdef OBIDMS_column column
|
cdef OBIDMS_column column
|
||||||
if (obi_view_create_column_alias(self.pointer, str2bytes(current_alias), str2bytes(new_alias)) < 0) :
|
if (obi_view_create_column_alias(self._pointer, str2bytes(current_alias), str2bytes(new_alias)) < 0) :
|
||||||
raise Exception("Problem changing a column alias")
|
raise Exception("Problem changing a column alias")
|
||||||
# Update the dictionaries of column objects
|
# Update the dictionaries of column objects
|
||||||
self.columns[new_alias] = self.columns[current_alias]
|
self._columns[new_alias] = self._columns[current_alias]
|
||||||
column = self.columns[new_alias]
|
column = self._columns[new_alias]
|
||||||
column.column_alias = new_alias
|
column._alias = new_alias
|
||||||
(self.columns).pop(current_alias)
|
(self._columns).pop(current_alias)
|
||||||
|
|
||||||
|
|
||||||
cpdef update_column_pointers(self):
|
cpdef update_column_pointers(self):
|
||||||
cdef str column_n
|
cdef str column_n
|
||||||
cdef OBIDMS_column column
|
cdef OBIDMS_column column
|
||||||
for column_n in self.columns :
|
for column_n in self._columns :
|
||||||
column = self.columns[column_n]
|
column = self._columns[column_n]
|
||||||
column.pointer = <OBIDMS_column_p*> obi_view_get_pointer_on_column_in_view(self.pointer, str2bytes(column_n))
|
column._pointer = <OBIDMS_column_p*> obi_view_get_pointer_on_column_in_view(self._pointer, str2bytes(column_n))
|
||||||
|
|
||||||
|
|
||||||
cpdef save_and_close(self) :
|
cpdef save_and_close(self) :
|
||||||
if (obi_save_and_close_view(self.pointer) < 0) :
|
if (obi_save_and_close_view(self._pointer) < 0) :
|
||||||
raise Exception("Problem closing a view")
|
raise Exception("Problem closing a view")
|
||||||
|
|
||||||
|
|
||||||
@ -443,13 +440,13 @@ cdef class OBIView :
|
|||||||
|
|
||||||
def __getitem__(self, object item) :
|
def __getitem__(self, object item) :
|
||||||
if type(item) == str :
|
if type(item) == str :
|
||||||
return (self.columns)[item]
|
return (self._columns)[item]
|
||||||
elif type(item) == int :
|
elif type(item) == int :
|
||||||
return OBIView_line(self, item)
|
return OBIView_line(self, item)
|
||||||
|
|
||||||
|
|
||||||
def __contains__(self, str column_name):
|
def __contains__(self, str column_name):
|
||||||
return (column_name in self.columns)
|
return (column_name in self._columns)
|
||||||
|
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
@ -468,22 +465,22 @@ cdef class OBIView :
|
|||||||
# line_count property getter
|
# line_count property getter
|
||||||
@property
|
@property
|
||||||
def line_count(self):
|
def line_count(self):
|
||||||
return self.pointer.infos.line_count
|
return self._pointer.infos.line_count
|
||||||
|
|
||||||
# name property getter
|
# name property getter
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return bytes2str(self.pointer.infos.name)
|
return bytes2str(self._pointer.infos.name)
|
||||||
|
|
||||||
# columns property getter
|
# columns property getter
|
||||||
@property
|
@property
|
||||||
def columns(self):
|
def columns(self):
|
||||||
return self.columns
|
return self._columns
|
||||||
|
|
||||||
# comments property getter
|
# comments property getter
|
||||||
@property
|
@property
|
||||||
def comments(self):
|
def comments(self):
|
||||||
return bytes2str(self.pointer.infos.comments)
|
return bytes2str(self._pointer.infos.comments)
|
||||||
# TODO setter that concatenates new comments?
|
# TODO setter that concatenates new comments?
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
@ -499,8 +496,6 @@ cdef class OBIView_NUC_SEQS(OBIView):
|
|||||||
cdef OBIDMS_column_p column_p
|
cdef OBIDMS_column_p column_p
|
||||||
cdef object subclass
|
cdef object subclass
|
||||||
|
|
||||||
self.dms = dms
|
|
||||||
|
|
||||||
if line_selection is not None :
|
if line_selection is not None :
|
||||||
line_selection_p = <index_t*> malloc((len(line_selection) + 1) * sizeof(index_t))
|
line_selection_p = <index_t*> malloc((len(line_selection) + 1) * sizeof(index_t))
|
||||||
for i in range(len(line_selection)) :
|
for i in range(len(line_selection)) :
|
||||||
@ -512,33 +507,33 @@ cdef class OBIView_NUC_SEQS(OBIView):
|
|||||||
if new :
|
if new :
|
||||||
if view_to_clone is not None :
|
if view_to_clone is not None :
|
||||||
if type(view_to_clone) == str :
|
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)
|
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)
|
||||||
else :
|
else :
|
||||||
view = obi_new_view_nuc_seqs(dms.pointer, str2bytes(view_name), (<OBIView> view_to_clone).pointer, line_selection_p, str2bytes(comments), quality_column)
|
view = obi_new_view_nuc_seqs(dms._pointer, str2bytes(view_name), (<OBIView> view_to_clone)._pointer, line_selection_p, str2bytes(comments), quality_column)
|
||||||
elif view_to_clone is None :
|
elif view_to_clone is None :
|
||||||
view = obi_new_view_nuc_seqs(dms.pointer, str2bytes(view_name), NULL, line_selection_p, str2bytes(comments), quality_column)
|
view = obi_new_view_nuc_seqs(dms._pointer, str2bytes(view_name), NULL, line_selection_p, str2bytes(comments), quality_column)
|
||||||
elif not new :
|
elif not new :
|
||||||
if view_name is not None :
|
if view_name is not None :
|
||||||
view = obi_open_view(dms.pointer, str2bytes(view_name))
|
view = obi_open_view(dms._pointer, str2bytes(view_name))
|
||||||
elif view_name is None :
|
elif view_name is None :
|
||||||
view = obi_open_view(dms.pointer, NULL)
|
view = obi_open_view(dms._pointer, NULL)
|
||||||
|
|
||||||
if view == NULL :
|
if view == NULL :
|
||||||
raise Exception("Error creating/opening view")
|
raise Exception("Error creating/opening view")
|
||||||
|
|
||||||
self.pointer = view
|
self._pointer = view
|
||||||
|
|
||||||
# Go through columns to build dictionaries of corresponding python instances # TODO make function?
|
# Go through columns to build dictionaries of corresponding python instances # TODO make function?
|
||||||
self.columns = {}
|
self._columns = {}
|
||||||
for i in range(view.infos.column_count) :
|
for i in range(view.infos.column_count) :
|
||||||
col_alias = bytes2str(view.infos.column_references[i].alias)
|
col_alias = bytes2str(view.infos.column_references[i].alias)
|
||||||
column_p = <OBIDMS_column_p> (view.columns)[i]
|
column_p = <OBIDMS_column_p> (view.columns)[i]
|
||||||
subclass = OBIDMS_column.get_subclass_type(column_p)
|
subclass = OBIDMS_column.get_subclass_type(column_p)
|
||||||
self.columns[col_alias] = subclass(self, col_alias)
|
self._columns[col_alias] = subclass(self, col_alias)
|
||||||
|
|
||||||
def __getitem__(self, object item) :
|
def __getitem__(self, object item) :
|
||||||
if type(item) == str :
|
if type(item) == str :
|
||||||
return (self.columns)[item]
|
return (self._columns)[item]
|
||||||
elif type(item) == int :
|
elif type(item) == int :
|
||||||
return OBI_Nuc_Seq_Stored(self, item)
|
return OBI_Nuc_Seq_Stored(self, item)
|
||||||
|
|
||||||
@ -582,24 +577,24 @@ cdef class OBIView_NUC_SEQS(OBIView):
|
|||||||
score_col_name = "score"
|
score_col_name = "score"
|
||||||
|
|
||||||
iview1= self
|
iview1= self
|
||||||
iview1_p = iview1.pointer
|
iview1_p = iview1._pointer
|
||||||
icol1 = iview1[bytes2str(NUC_SEQUENCE_COLUMN)]
|
icol1 = iview1[bytes2str(NUC_SEQUENCE_COLUMN)]
|
||||||
icol1_pp = icol1.pointer
|
icol1_pp = icol1._pointer
|
||||||
icol1_p = icol1_pp[0]
|
icol1_p = icol1_pp[0]
|
||||||
|
|
||||||
oview.add_column(id1_col_name, type='OBI_STR', create=True)
|
oview.add_column(id1_col_name, type='OBI_STR', create=True)
|
||||||
oview.add_column(id2_col_name, type='OBI_STR', create=True)
|
oview.add_column(id2_col_name, type='OBI_STR', create=True)
|
||||||
oview.add_column(score_col_name, type='OBI_FLOAT', create=True)
|
oview.add_column(score_col_name, type='OBI_FLOAT', create=True)
|
||||||
|
|
||||||
oview_p = oview.pointer
|
oview_p = oview._pointer
|
||||||
ocol = oview[score_col_name]
|
ocol = oview[score_col_name]
|
||||||
ocol_pp = ocol.pointer
|
ocol_pp = ocol._pointer
|
||||||
ocol_p = ocol_pp[0]
|
ocol_p = ocol_pp[0]
|
||||||
|
|
||||||
id1_col = oview[id1_col_name]
|
id1_col = oview[id1_col_name]
|
||||||
id2_col = oview[id2_col_name]
|
id2_col = oview[id2_col_name]
|
||||||
id1_col_pp = id1_col.pointer
|
id1_col_pp = id1_col._pointer
|
||||||
id2_col_pp = id2_col.pointer
|
id2_col_pp = id2_col._pointer
|
||||||
id1_col_p = id1_col_pp[0]
|
id1_col_p = id1_col_pp[0]
|
||||||
id2_col_p = id2_col_pp[0]
|
id2_col_p = id2_col_pp[0]
|
||||||
|
|
||||||
@ -612,18 +607,18 @@ cdef class OBIView_NUC_SEQS(OBIView):
|
|||||||
cdef class OBIView_line :
|
cdef class OBIView_line :
|
||||||
|
|
||||||
def __init__(self, OBIView view, index_t line_nb) :
|
def __init__(self, OBIView view, index_t line_nb) :
|
||||||
self.index = line_nb
|
self._index = line_nb
|
||||||
self.view = view
|
self._view = view
|
||||||
|
|
||||||
def __getitem__(self, str column_name) :
|
def __getitem__(self, str column_name) :
|
||||||
return ((self.view).columns)[column_name][self.index]
|
return ((self._view)._columns)[column_name][self._index]
|
||||||
|
|
||||||
def __setitem__(self, str column_name, object value):
|
def __setitem__(self, str column_name, object value):
|
||||||
# TODO detect multiple elements (dict type)? put somewhere else? but more risky (in get)
|
# TODO detect multiple elements (dict type)? put somewhere else? but more risky (in get)
|
||||||
# TODO OBI_QUAL ?
|
# TODO OBI_QUAL ?
|
||||||
cdef type value_type
|
cdef type value_type
|
||||||
cdef str value_obitype
|
cdef str value_obitype
|
||||||
if column_name not in self.view :
|
if column_name not in self._view :
|
||||||
if value == None :
|
if value == None :
|
||||||
raise Exception("Trying to create a column from a None value (can't guess type)")
|
raise Exception("Trying to create a column from a None value (can't guess type)")
|
||||||
value_type = type(value)
|
value_type = type(value)
|
||||||
@ -642,22 +637,22 @@ cdef class OBIView_line :
|
|||||||
value_obitype = 'OBI_STR'
|
value_obitype = 'OBI_STR'
|
||||||
else :
|
else :
|
||||||
raise Exception("Could not guess the type of a value to create a new column")
|
raise Exception("Could not guess the type of a value to create a new column")
|
||||||
self.view.add_column(column_name, type=value_obitype)
|
self._view.add_column(column_name, type=value_obitype)
|
||||||
|
|
||||||
(((self.view).columns)[column_name]).set_line(self.index, value)
|
(((self._view)._columns)[column_name]).set_line(self._index, value)
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
for column_name in ((self.view).columns) :
|
for column_name in ((self._view)._columns) :
|
||||||
yield column_name
|
yield column_name
|
||||||
|
|
||||||
def __contains__(self, str column_name):
|
def __contains__(self, str column_name):
|
||||||
return (column_name in self.view.columns)
|
return (column_name in self._view._columns)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
cdef dict line
|
cdef dict line
|
||||||
cdef str column_name
|
cdef str column_name
|
||||||
line = {}
|
line = {}
|
||||||
for column_name in self.view.columns :
|
for column_name in self._view._columns :
|
||||||
line[column_name] = self[column_name]
|
line[column_name] = self[column_name]
|
||||||
return str(line)
|
return str(line)
|
||||||
|
|
||||||
@ -674,14 +669,19 @@ cdef class OBIDMS :
|
|||||||
dms_name_b = str2bytes(dms_name)
|
dms_name_b = str2bytes(dms_name)
|
||||||
|
|
||||||
# Fill structure and create or open the DMS
|
# Fill structure and create or open the DMS
|
||||||
self.dms_name = dms_name
|
self._pointer = obi_dms(<const_char_p> dms_name_b)
|
||||||
self.pointer = obi_dms(<const_char_p> dms_name_b)
|
if self._pointer == NULL :
|
||||||
if self.pointer == NULL :
|
|
||||||
raise Exception("Failed opening or creating an OBIDMS")
|
raise Exception("Failed opening or creating an OBIDMS")
|
||||||
|
|
||||||
|
|
||||||
|
# name property getter
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return bytes2str(self._pointer.dms_name)
|
||||||
|
|
||||||
|
|
||||||
cpdef close(self) :
|
cpdef close(self) :
|
||||||
if (obi_close_dms(self.pointer)) < 0 :
|
if (obi_close_dms(self._pointer)) < 0 :
|
||||||
raise Exception("Problem closing an OBIDMS")
|
raise Exception("Problem closing an OBIDMS")
|
||||||
|
|
||||||
|
|
||||||
@ -731,7 +731,7 @@ cdef class OBIDMS :
|
|||||||
cdef int i, j
|
cdef int i, j
|
||||||
cdef str column_name
|
cdef str column_name
|
||||||
|
|
||||||
view_infos_p = obi_view_map_file(self.pointer, str2bytes(view_name))
|
view_infos_p = obi_view_map_file(self._pointer, str2bytes(view_name))
|
||||||
view_infos_d = {}
|
view_infos_d = {}
|
||||||
view_infos_d["name"] = bytes2str(view_infos_p.name)
|
view_infos_d["name"] = bytes2str(view_infos_p.name)
|
||||||
view_infos_d["comments"] = bytes2str(view_infos_p.comments)
|
view_infos_d["comments"] = bytes2str(view_infos_p.comments)
|
||||||
@ -754,7 +754,7 @@ cdef class OBIDMS :
|
|||||||
view_infos_d["column_references"][column_name]["original_name"] = bytes2str((column_references[j]).column_refs.column_name)
|
view_infos_d["column_references"][column_name]["original_name"] = bytes2str((column_references[j]).column_refs.column_name)
|
||||||
view_infos_d["column_references"][column_name]["version"] = (column_references[j]).column_refs.version
|
view_infos_d["column_references"][column_name]["version"] = (column_references[j]).column_refs.version
|
||||||
|
|
||||||
obi_view_unmap_file(self.pointer, view_infos_p)
|
obi_view_unmap_file(self._pointer, view_infos_p)
|
||||||
|
|
||||||
return view_infos_d
|
return view_infos_d
|
||||||
|
|
||||||
@ -772,7 +772,7 @@ cdef class OBIDMS :
|
|||||||
# cdef bytes name_b
|
# cdef bytes name_b
|
||||||
#
|
#
|
||||||
# views = {}
|
# views = {}
|
||||||
# all_views_p = obi_read_view_infos(self.pointer)
|
# all_views_p = obi_read_view_infos(self._pointer)
|
||||||
# if all_views_p == NULL :
|
# if all_views_p == NULL :
|
||||||
# raise Exception("No views to read")
|
# raise Exception("No views to read")
|
||||||
# nb_views = <int> (all_views_p.header).view_count
|
# nb_views = <int> (all_views_p.header).view_count
|
||||||
|
@ -17,7 +17,7 @@ cdef class OBIDMS_column_bool(OBIDMS_column):
|
|||||||
cpdef object get_line(self, index_t line_nb):
|
cpdef object get_line(self, index_t line_nb):
|
||||||
cdef obibool_t value
|
cdef obibool_t value
|
||||||
cdef object result
|
cdef object result
|
||||||
value = obi_get_bool_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0)
|
value = obi_get_bool_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIBool_NA :
|
if value == OBIBool_NA :
|
||||||
@ -29,7 +29,7 @@ cdef class OBIDMS_column_bool(OBIDMS_column):
|
|||||||
cpdef set_line(self, index_t line_nb, object value):
|
cpdef set_line(self, index_t line_nb, object value):
|
||||||
if value is None :
|
if value is None :
|
||||||
value = OBIBool_NA
|
value = OBIBool_NA
|
||||||
if obi_set_bool_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0, <obibool_t> value) < 0:
|
if obi_set_bool_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0, <obibool_t> value) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ cdef class OBIDMS_column_multi_elts_bool(OBIDMS_column_multi_elts):
|
|||||||
cpdef object get_item(self, index_t line_nb, str element_name):
|
cpdef object get_item(self, index_t line_nb, str element_name):
|
||||||
cdef obibool_t value
|
cdef obibool_t value
|
||||||
cdef object result
|
cdef object result
|
||||||
value = obi_get_bool_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name))
|
value = obi_get_bool_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name))
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb, element_name)
|
raise IndexError(line_nb, element_name)
|
||||||
if value == OBIBool_NA :
|
if value == OBIBool_NA :
|
||||||
@ -56,7 +56,7 @@ cdef class OBIDMS_column_multi_elts_bool(OBIDMS_column_multi_elts):
|
|||||||
result = {}
|
result = {}
|
||||||
all_NA = True
|
all_NA = True
|
||||||
for i in range(self.nb_elements_per_line) :
|
for i in range(self.nb_elements_per_line) :
|
||||||
value = obi_get_bool_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, i)
|
value = obi_get_bool_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, i)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIBool_NA :
|
if value == OBIBool_NA :
|
||||||
@ -73,5 +73,5 @@ cdef class OBIDMS_column_multi_elts_bool(OBIDMS_column_multi_elts):
|
|||||||
cpdef set_item(self, index_t line_nb, str element_name, object value):
|
cpdef set_item(self, index_t line_nb, str element_name, object value):
|
||||||
if value is None :
|
if value is None :
|
||||||
value = OBIBool_NA
|
value = OBIBool_NA
|
||||||
if obi_set_bool_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name), <obibool_t> value) < 0:
|
if obi_set_bool_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name), <obibool_t> value) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
@ -15,7 +15,7 @@ cdef class OBIDMS_column_char(OBIDMS_column):
|
|||||||
cpdef object get_line(self, index_t line_nb):
|
cpdef object get_line(self, index_t line_nb):
|
||||||
cdef obichar_t value
|
cdef obichar_t value
|
||||||
cdef object result
|
cdef object result
|
||||||
value = obi_get_char_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0)
|
value = obi_get_char_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIChar_NA :
|
if value == OBIChar_NA :
|
||||||
@ -27,7 +27,7 @@ cdef class OBIDMS_column_char(OBIDMS_column):
|
|||||||
cpdef set_line(self, index_t line_nb, object value):
|
cpdef set_line(self, index_t line_nb, object value):
|
||||||
if value is None :
|
if value is None :
|
||||||
value = OBIChar_NA
|
value = OBIChar_NA
|
||||||
if obi_set_char_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0, str2bytes(value)[0]) < 0:
|
if obi_set_char_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0, str2bytes(value)[0]) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ cdef class OBIDMS_column_multi_elts_char(OBIDMS_column_multi_elts):
|
|||||||
cpdef object get_item(self, index_t line_nb, str element_name):
|
cpdef object get_item(self, index_t line_nb, str element_name):
|
||||||
cdef obichar_t value
|
cdef obichar_t value
|
||||||
cdef object result
|
cdef object result
|
||||||
value = obi_get_char_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name))
|
value = obi_get_char_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name))
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb, element_name)
|
raise IndexError(line_nb, element_name)
|
||||||
if value == OBIChar_NA :
|
if value == OBIChar_NA :
|
||||||
@ -54,7 +54,7 @@ cdef class OBIDMS_column_multi_elts_char(OBIDMS_column_multi_elts):
|
|||||||
result = {}
|
result = {}
|
||||||
all_NA = True
|
all_NA = True
|
||||||
for i in range(self.nb_elements_per_line) :
|
for i in range(self.nb_elements_per_line) :
|
||||||
value = obi_get_char_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, i)
|
value = obi_get_char_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, i)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIChar_NA :
|
if value == OBIChar_NA :
|
||||||
@ -71,6 +71,6 @@ cdef class OBIDMS_column_multi_elts_char(OBIDMS_column_multi_elts):
|
|||||||
cpdef set_item(self, index_t line_nb, str element_name, object value):
|
cpdef set_item(self, index_t line_nb, str element_name, object value):
|
||||||
if value is None :
|
if value is None :
|
||||||
value = OBIChar_NA
|
value = OBIChar_NA
|
||||||
if obi_set_char_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name), str2bytes(value)[0]) < 0:
|
if obi_set_char_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name), str2bytes(value)[0]) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ cdef class OBIDMS_column_float(OBIDMS_column):
|
|||||||
cpdef object get_line(self, index_t line_nb):
|
cpdef object get_line(self, index_t line_nb):
|
||||||
cdef obifloat_t value
|
cdef obifloat_t value
|
||||||
cdef object result
|
cdef object result
|
||||||
value = obi_get_float_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0)
|
value = obi_get_float_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIFloat_NA :
|
if value == OBIFloat_NA :
|
||||||
@ -27,7 +27,7 @@ cdef class OBIDMS_column_float(OBIDMS_column):
|
|||||||
cpdef set_line(self, index_t line_nb, object value):
|
cpdef set_line(self, index_t line_nb, object value):
|
||||||
if value is None :
|
if value is None :
|
||||||
value = OBIFloat_NA
|
value = OBIFloat_NA
|
||||||
if obi_set_float_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0, <obifloat_t> value) < 0:
|
if obi_set_float_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0, <obifloat_t> value) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ cdef class OBIDMS_column_multi_elts_float(OBIDMS_column_multi_elts):
|
|||||||
cpdef object get_item(self, index_t line_nb, str element_name):
|
cpdef object get_item(self, index_t line_nb, str element_name):
|
||||||
cdef obifloat_t value
|
cdef obifloat_t value
|
||||||
cdef object result
|
cdef object result
|
||||||
value = obi_get_float_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name))
|
value = obi_get_float_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name))
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb, element_name)
|
raise IndexError(line_nb, element_name)
|
||||||
if value == OBIFloat_NA :
|
if value == OBIFloat_NA :
|
||||||
@ -54,7 +54,7 @@ cdef class OBIDMS_column_multi_elts_float(OBIDMS_column_multi_elts):
|
|||||||
result = {}
|
result = {}
|
||||||
all_NA = True
|
all_NA = True
|
||||||
for i in range(self.nb_elements_per_line) :
|
for i in range(self.nb_elements_per_line) :
|
||||||
value = obi_get_float_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, i)
|
value = obi_get_float_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, i)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIFloat_NA :
|
if value == OBIFloat_NA :
|
||||||
@ -71,6 +71,6 @@ cdef class OBIDMS_column_multi_elts_float(OBIDMS_column_multi_elts):
|
|||||||
cpdef set_item(self, index_t line_nb, str element_name, object value):
|
cpdef set_item(self, index_t line_nb, str element_name, object value):
|
||||||
if value is None :
|
if value is None :
|
||||||
value = OBIFloat_NA
|
value = OBIFloat_NA
|
||||||
if obi_set_float_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name), <obifloat_t> value) < 0:
|
if obi_set_float_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name), <obifloat_t> value) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
|
@ -17,7 +17,7 @@ cdef class OBIDMS_column_int(OBIDMS_column):
|
|||||||
cpdef object get_line(self, index_t line_nb):
|
cpdef object get_line(self, index_t line_nb):
|
||||||
cdef obiint_t value
|
cdef obiint_t value
|
||||||
cdef object result
|
cdef object result
|
||||||
value = obi_get_int_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0)
|
value = obi_get_int_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIInt_NA :
|
if value == OBIInt_NA :
|
||||||
@ -29,7 +29,7 @@ cdef class OBIDMS_column_int(OBIDMS_column):
|
|||||||
cpdef set_line(self, index_t line_nb, object value):
|
cpdef set_line(self, index_t line_nb, object value):
|
||||||
if value is None :
|
if value is None :
|
||||||
value = OBIInt_NA
|
value = OBIInt_NA
|
||||||
if obi_set_int_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0, <obiint_t> value) < 0:
|
if obi_set_int_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0, <obiint_t> value) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ cdef class OBIDMS_column_multi_elts_int(OBIDMS_column_multi_elts):
|
|||||||
cpdef object get_item(self, index_t line_nb, str element_name):
|
cpdef object get_item(self, index_t line_nb, str element_name):
|
||||||
cdef obiint_t value
|
cdef obiint_t value
|
||||||
cdef object result
|
cdef object result
|
||||||
value = obi_get_int_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name))
|
value = obi_get_int_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name))
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb, element_name)
|
raise IndexError(line_nb, element_name)
|
||||||
if value == OBIInt_NA :
|
if value == OBIInt_NA :
|
||||||
@ -56,7 +56,7 @@ cdef class OBIDMS_column_multi_elts_int(OBIDMS_column_multi_elts):
|
|||||||
result = {}
|
result = {}
|
||||||
all_NA = True
|
all_NA = True
|
||||||
for i in range(self.nb_elements_per_line) :
|
for i in range(self.nb_elements_per_line) :
|
||||||
value = obi_get_int_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, i)
|
value = obi_get_int_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, i)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIInt_NA :
|
if value == OBIInt_NA :
|
||||||
@ -73,6 +73,6 @@ cdef class OBIDMS_column_multi_elts_int(OBIDMS_column_multi_elts):
|
|||||||
cpdef set_item(self, index_t line_nb, str element_name, object value):
|
cpdef set_item(self, index_t line_nb, str element_name, object value):
|
||||||
if value is None :
|
if value is None :
|
||||||
value = OBIInt_NA
|
value = OBIInt_NA
|
||||||
if obi_set_int_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name), <obiint_t> value) < 0:
|
if obi_set_int_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name), <obiint_t> value) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ cdef class OBIDMS_column_qual(OBIDMS_column):
|
|||||||
cdef int value_length
|
cdef int value_length
|
||||||
cdef object result
|
cdef object result
|
||||||
cdef int i
|
cdef int i
|
||||||
value = obi_get_qual_int_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0, &value_length)
|
value = obi_get_qual_int_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0, &value_length)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIQual_int_NA :
|
if value == OBIQual_int_NA :
|
||||||
@ -44,7 +44,7 @@ cdef class OBIDMS_column_qual(OBIDMS_column):
|
|||||||
cdef char* value
|
cdef char* value
|
||||||
cdef object result
|
cdef object result
|
||||||
cdef int i
|
cdef int i
|
||||||
value = obi_get_qual_char_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0)
|
value = obi_get_qual_char_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIQual_char_NA :
|
if value == OBIQual_char_NA :
|
||||||
@ -58,28 +58,28 @@ cdef class OBIDMS_column_qual(OBIDMS_column):
|
|||||||
cdef uint8_t* value_b
|
cdef uint8_t* value_b
|
||||||
cdef int value_length
|
cdef int value_length
|
||||||
if value is None :
|
if value is None :
|
||||||
if obi_set_qual_int_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0, OBIQual_int_NA, 0) < 0:
|
if obi_set_qual_int_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0, OBIQual_int_NA, 0) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
else :
|
else :
|
||||||
value_length = len(value)
|
value_length = len(value)
|
||||||
value_b = <uint8_t*> malloc(value_length * sizeof(uint8_t))
|
value_b = <uint8_t*> malloc(value_length * sizeof(uint8_t))
|
||||||
for i in range(value_length) :
|
for i in range(value_length) :
|
||||||
value_b[i] = <uint8_t>value[i]
|
value_b[i] = <uint8_t>value[i]
|
||||||
if obi_set_qual_int_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0, value_b, value_length) < 0:
|
if obi_set_qual_int_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0, value_b, value_length) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
free(value_b)
|
free(value_b)
|
||||||
|
|
||||||
cpdef set_str_line(self, index_t line_nb, object value):
|
cpdef set_str_line(self, index_t line_nb, object value):
|
||||||
cdef bytes value_b
|
cdef bytes value_b
|
||||||
if value is None :
|
if value is None :
|
||||||
if obi_set_qual_char_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0, OBIQual_char_NA) < 0:
|
if obi_set_qual_char_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0, OBIQual_char_NA) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
else :
|
else :
|
||||||
if type(value) == str:
|
if type(value) == str:
|
||||||
value_b = str2bytes(value)
|
value_b = str2bytes(value)
|
||||||
else :
|
else :
|
||||||
value_b = value
|
value_b = value
|
||||||
if obi_set_qual_char_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0, value_b) < 0:
|
if obi_set_qual_char_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0, value_b) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ cdef class OBIDMS_column_multi_elts_qual(OBIDMS_column_multi_elts):
|
|||||||
cdef int value_length
|
cdef int value_length
|
||||||
cdef object result
|
cdef object result
|
||||||
cdef int i
|
cdef int i
|
||||||
value = obi_get_qual_int_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name), &value_length)
|
value = obi_get_qual_int_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name), &value_length)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb, element_name)
|
raise IndexError(line_nb, element_name)
|
||||||
if value == OBIQual_int_NA :
|
if value == OBIQual_int_NA :
|
||||||
@ -104,7 +104,7 @@ cdef class OBIDMS_column_multi_elts_qual(OBIDMS_column_multi_elts):
|
|||||||
cpdef object get_str_item(self, index_t line_nb, str element_name):
|
cpdef object get_str_item(self, index_t line_nb, str element_name):
|
||||||
cdef char* value
|
cdef char* value
|
||||||
cdef object result
|
cdef object result
|
||||||
value = obi_get_qual_char_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name))
|
value = obi_get_qual_char_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name))
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb, element_name)
|
raise IndexError(line_nb, element_name)
|
||||||
if value == OBIQual_char_NA :
|
if value == OBIQual_char_NA :
|
||||||
@ -125,7 +125,7 @@ cdef class OBIDMS_column_multi_elts_qual(OBIDMS_column_multi_elts):
|
|||||||
result = {}
|
result = {}
|
||||||
all_NA = True
|
all_NA = True
|
||||||
for i in range(self.nb_elements_per_line) :
|
for i in range(self.nb_elements_per_line) :
|
||||||
value = obi_get_qual_int_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, i, &value_length)
|
value = obi_get_qual_int_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, i, &value_length)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIQual_int_NA :
|
if value == OBIQual_int_NA :
|
||||||
@ -150,7 +150,7 @@ cdef class OBIDMS_column_multi_elts_qual(OBIDMS_column_multi_elts):
|
|||||||
result = {}
|
result = {}
|
||||||
all_NA = True
|
all_NA = True
|
||||||
for i in range(self.nb_elements_per_line) :
|
for i in range(self.nb_elements_per_line) :
|
||||||
value = obi_get_qual_char_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, i)
|
value = obi_get_qual_char_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, i)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIQual_char_NA :
|
if value == OBIQual_char_NA :
|
||||||
@ -169,21 +169,21 @@ cdef class OBIDMS_column_multi_elts_qual(OBIDMS_column_multi_elts):
|
|||||||
cdef uint8_t* value_b
|
cdef uint8_t* value_b
|
||||||
cdef int value_length
|
cdef int value_length
|
||||||
if value is None :
|
if value is None :
|
||||||
if obi_set_qual_int_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name), OBIQual_int_NA, 0) < 0:
|
if obi_set_qual_int_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name), OBIQual_int_NA, 0) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
else :
|
else :
|
||||||
value_length = len(value)
|
value_length = len(value)
|
||||||
value_b = <uint8_t*> malloc(value_length * sizeof(uint8_t))
|
value_b = <uint8_t*> malloc(value_length * sizeof(uint8_t))
|
||||||
for i in range(value_length) :
|
for i in range(value_length) :
|
||||||
value_b[i] = <uint8_t>value[i]
|
value_b[i] = <uint8_t>value[i]
|
||||||
if obi_set_qual_int_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name), value_b, value_length) < 0:
|
if obi_set_qual_int_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name), value_b, value_length) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
free(value_b)
|
free(value_b)
|
||||||
|
|
||||||
cpdef set_str_item(self, index_t line_nb, str element_name, object value):
|
cpdef set_str_item(self, index_t line_nb, str element_name, object value):
|
||||||
if value is None :
|
if value is None :
|
||||||
if obi_set_qual_char_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name), OBIQual_char_NA) < 0:
|
if obi_set_qual_char_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name), OBIQual_char_NA) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
else :
|
else :
|
||||||
if obi_set_qual_char_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name), str2bytes(value)) < 0:
|
if obi_set_qual_char_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name), str2bytes(value)) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
@ -20,7 +20,7 @@ cdef class OBIDMS_column_seq(OBIDMS_column):
|
|||||||
cpdef object get_line(self, index_t line_nb):
|
cpdef object get_line(self, index_t line_nb):
|
||||||
cdef char* value
|
cdef char* value
|
||||||
cdef object result
|
cdef object result
|
||||||
value = obi_get_seq_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0)
|
value = obi_get_seq_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBISeq_NA :
|
if value == OBISeq_NA :
|
||||||
@ -44,7 +44,7 @@ cdef class OBIDMS_column_seq(OBIDMS_column):
|
|||||||
else:
|
else:
|
||||||
raise TypeError('Sequence value must be of type Bytes, Str or None')
|
raise TypeError('Sequence value must be of type Bytes, Str or None')
|
||||||
|
|
||||||
if obi_set_seq_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0, value_b) < 0:
|
if obi_set_seq_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0, value_b) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ cdef class OBIDMS_column_multi_elts_seq(OBIDMS_column_multi_elts):
|
|||||||
cpdef object get_item(self, index_t line_nb, str element_name):
|
cpdef object get_item(self, index_t line_nb, str element_name):
|
||||||
cdef char* value
|
cdef char* value
|
||||||
cdef object result
|
cdef object result
|
||||||
value = obi_get_seq_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name))
|
value = obi_get_seq_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name))
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb, element_name)
|
raise IndexError(line_nb, element_name)
|
||||||
if value == OBISeq_NA :
|
if value == OBISeq_NA :
|
||||||
@ -75,7 +75,7 @@ cdef class OBIDMS_column_multi_elts_seq(OBIDMS_column_multi_elts):
|
|||||||
result = {}
|
result = {}
|
||||||
all_NA = True
|
all_NA = True
|
||||||
for i in range(self.nb_elements_per_line) :
|
for i in range(self.nb_elements_per_line) :
|
||||||
value = obi_get_seq_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, i)
|
value = obi_get_seq_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, i)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBISeq_NA :
|
if value == OBISeq_NA :
|
||||||
@ -104,6 +104,6 @@ cdef class OBIDMS_column_multi_elts_seq(OBIDMS_column_multi_elts):
|
|||||||
else:
|
else:
|
||||||
raise TypeError('Sequence value must be of type Bytes, Str or None')
|
raise TypeError('Sequence value must be of type Bytes, Str or None')
|
||||||
|
|
||||||
if obi_set_seq_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name), value_b) < 0:
|
if obi_set_seq_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name), value_b) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ cdef class OBIDMS_column_str(OBIDMS_column):
|
|||||||
cpdef object get_line(self, index_t line_nb):
|
cpdef object get_line(self, index_t line_nb):
|
||||||
cdef const_char_p value
|
cdef const_char_p value
|
||||||
cdef object result
|
cdef object result
|
||||||
value = obi_get_str_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0)
|
value = obi_get_str_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIStr_NA :
|
if value == OBIStr_NA :
|
||||||
@ -27,10 +27,10 @@ cdef class OBIDMS_column_str(OBIDMS_column):
|
|||||||
|
|
||||||
cpdef set_line(self, index_t line_nb, object value):
|
cpdef set_line(self, index_t line_nb, object value):
|
||||||
if value is None :
|
if value is None :
|
||||||
if obi_set_str_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0, OBIStr_NA) < 0:
|
if obi_set_str_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0, OBIStr_NA) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
else :
|
else :
|
||||||
if obi_set_str_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0, str2bytes(value)) < 0:
|
if obi_set_str_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, 0, str2bytes(value)) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ cdef class OBIDMS_column_multi_elts_str(OBIDMS_column_multi_elts):
|
|||||||
cpdef object get_item(self, index_t line_nb, str element_name):
|
cpdef object get_item(self, index_t line_nb, str element_name):
|
||||||
cdef const_char_p value
|
cdef const_char_p value
|
||||||
cdef object result
|
cdef object result
|
||||||
value = obi_get_str_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name))
|
value = obi_get_str_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name))
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb, element_name)
|
raise IndexError(line_nb, element_name)
|
||||||
if value == OBIStr_NA :
|
if value == OBIStr_NA :
|
||||||
@ -58,7 +58,7 @@ cdef class OBIDMS_column_multi_elts_str(OBIDMS_column_multi_elts):
|
|||||||
result = {}
|
result = {}
|
||||||
all_NA = True
|
all_NA = True
|
||||||
for i in range(self.nb_elements_per_line) :
|
for i in range(self.nb_elements_per_line) :
|
||||||
value = obi_get_str_with_elt_idx_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, i)
|
value = obi_get_str_with_elt_idx_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, i)
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
raise IndexError(line_nb)
|
raise IndexError(line_nb)
|
||||||
if value == OBIStr_NA :
|
if value == OBIStr_NA :
|
||||||
@ -79,6 +79,6 @@ cdef class OBIDMS_column_multi_elts_str(OBIDMS_column_multi_elts):
|
|||||||
value_b = OBIStr_NA
|
value_b = OBIStr_NA
|
||||||
else :
|
else :
|
||||||
value_b = str2bytes(value)
|
value_b = str2bytes(value)
|
||||||
if obi_set_str_with_elt_name_and_col_p_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name), value_b) < 0:
|
if obi_set_str_with_elt_name_and_col_p_in_view(self._view._pointer, (self._pointer)[0], line_nb, str2bytes(element_name), value_b) < 0:
|
||||||
raise Exception("Problem setting a value in a column")
|
raise Exception("Problem setting a value in a column")
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ from .capi.obiview cimport NUC_SEQUENCE_COLUMN, \
|
|||||||
DEFINITION_COLUMN, \
|
DEFINITION_COLUMN, \
|
||||||
QUALITY_COLUMN
|
QUALITY_COLUMN
|
||||||
|
|
||||||
|
|
||||||
cdef class OBI_Seq(dict) :
|
cdef class OBI_Seq(dict) :
|
||||||
|
|
||||||
def __init__(self, object id, object seq, object definition=None) :
|
def __init__(self, object id, object seq, object definition=None) :
|
||||||
|
@ -16,7 +16,7 @@ cdef class OBI_Taxonomy :
|
|||||||
def __init__(self, OBIDMS dms, str name) :
|
def __init__(self, OBIDMS dms, str name) :
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
self.pointer = obi_read_taxonomy(dms.pointer, str2bytes(name), True) # TODO discuss
|
self.pointer = obi_read_taxonomy(dms._pointer, str2bytes(name), True) # TODO discuss
|
||||||
|
|
||||||
|
|
||||||
def __getitem__(self, object ref):
|
def __getitem__(self, object ref):
|
||||||
|
@ -4,7 +4,7 @@ from .obitypes cimport const_char_p
|
|||||||
|
|
||||||
cdef extern from "obidms.h" nogil:
|
cdef extern from "obidms.h" nogil:
|
||||||
struct OBIDMS_t:
|
struct OBIDMS_t:
|
||||||
pass
|
const_char_p dms_name
|
||||||
|
|
||||||
ctypedef OBIDMS_t* OBIDMS_p
|
ctypedef OBIDMS_t* OBIDMS_p
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user