Removed a list of column pointers kept in the OBIView class that was not

really needed
This commit is contained in:
Celine Mercier
2016-05-02 14:23:42 +02:00
parent 32cc8968e8
commit 872071b104
2 changed files with 6 additions and 48 deletions

View File

@ -45,7 +45,6 @@ cdef class OBIView:
cdef str name
cdef str comments
cdef dict columns
cdef dict columns_pp # TODO this dict might be unnecessary
cdef OBIDMS dms
cpdef delete_column(self, str column_name)

View File

@ -84,7 +84,7 @@ cdef class OBIDMS_column :
cdef OBIDMS_column_p column_p
cdef OBIDMS_column_p* column_pp
column_pp = <OBIDMS_column_p*> PyCapsule_GetPointer(((view.columns_pp)[column_name]), NULL) # or use C function
column_pp = obi_view_get_pointer_on_column_in_view(view.pointer, str2bytes(column_name))
column_p = column_pp[0] # TODO ugly cython dereferencing but can't find better
# Fill structure
@ -243,10 +243,8 @@ cdef class OBIView :
cdef str col_name
cdef OBIDMS_column column
cdef OBIDMS_column_p column_p
cdef OBIDMS_column_p* column_pp
cdef OBIDMS_column_header_p header
cdef index_t* line_selection_p
cdef object col_capsule
self.dms = dms
@ -280,18 +278,13 @@ cdef class OBIView :
# go through columns to build list and open python object (TODO make separate function?)
self.columns = {}
self.columns_pp = {}
i = 0
while i < view.column_count :
column_pp = <OBIDMS_column_p*> ((view.columns)+i)
column_p = <OBIDMS_column_p> (view.columns)[i]
header = (column_p).header
col_name = bytes2str(header.name)
col_capsule = PyCapsule_New(column_pp, NULL, NULL) # TODO discuss
(self.columns_pp)[col_name] = col_capsule
subclass = OBIDMS_column.get_subclass_type(column_p)
self.columns[col_name] = subclass(self, col_name)
@ -319,7 +312,6 @@ cdef class OBIView :
cdef Obiview_p view
cdef OBIDMS_column column
cdef OBIDMS_column_p column_p
cdef OBIDMS_column_p* column_pp
cdef OBIDMS_column_header_p header
cdef str column_n
@ -330,17 +322,6 @@ cdef class OBIView :
# Update the dictionaries of column pointers and column objects, and update pointers in column objects (make function?):
(self.columns).pop(column_name)
(self.columns_pp).pop(column_name)
i = 0
while i < view.column_count :
column_pp = <OBIDMS_column_p*> ((view.columns)+i)
column_p = <OBIDMS_column_p> (view.columns)[i]
header = (column_p).header
col_name = bytes2str(header.name)
col_capsule = PyCapsule_New(column_pp, NULL, NULL)
(self.columns_pp)[col_name] = col_capsule
i+=1
for column_n in self.columns :
(self.columns[column_n]).update_pointer()
@ -393,13 +374,8 @@ cdef class OBIView :
str2bytes(comments), create) < 0) :
raise Exception("Problem adding a column in a view")
# Store the column pointer
# Get the column pointer
column_pp = obi_view_get_pointer_on_column_in_view(self.pointer, column_name_b)
if column_pp == NULL :
raise Exception("Problem getting a column in a view")
col_capsule = PyCapsule_New(column_pp, NULL, NULL) # TODO
(self.columns_pp)[column_name] = col_capsule
# Open and store the subclass
column_p = column_pp[0] # TODO ugly cython dereferencing
@ -474,7 +450,6 @@ cdef class OBIView_NUC_SEQS(OBIView):
cdef str col_name
cdef OBIDMS_column column
cdef OBIDMS_column_p column_p
cdef OBIDMS_column_p* column_pp
cdef OBIDMS_column_header_p header
cdef index_t* line_selection_p
@ -511,17 +486,13 @@ cdef class OBIView_NUC_SEQS(OBIView):
# go through columns to build list and open python object (TODO make separate function?)
self.columns = {}
self.columns_pp = {}
i = 0
while i < view.column_count :
column_pp = <OBIDMS_column_p*> ((view.columns)+i)
column_p = <OBIDMS_column_p> (view.columns)[i]
header = (column_p).header
col_name = bytes2str(header.name)
col_capsule = PyCapsule_New(column_pp, NULL, NULL) # TODO discuss
(self.columns_pp)[col_name] = col_capsule
subclass = OBIDMS_column.get_subclass_type(column_p)
self.columns[col_name] = subclass(self, col_name)
@ -539,7 +510,6 @@ cdef class OBIView_NUC_SEQS(OBIView):
cdef Obiview_p view
cdef OBIDMS_column column
cdef OBIDMS_column_p column_p
cdef OBIDMS_column_p* column_pp
cdef OBIDMS_column_header_p header
cdef str column_n
@ -553,17 +523,6 @@ cdef class OBIView_NUC_SEQS(OBIView):
# Update the dictionaries of column pointers and column objects, and update pointers in column objects (make function?):
(self.columns).pop(column_name)
(self.columns_pp).pop(column_name)
i = 0
while i < view.column_count :
column_pp = <OBIDMS_column_p*> ((view.columns)+i)
column_p = <OBIDMS_column_p> (view.columns)[i]
header = (column_p).header
col_name = bytes2str(header.name)
col_capsule = PyCapsule_New(column_pp, NULL, NULL)
(self.columns_pp)[col_name] = col_capsule
i+=1
for column_n in self.columns :
(self.columns[column_n]).update_pointer()
@ -572,7 +531,7 @@ cdef class OBIView_NUC_SEQS(OBIView):
def __getitem__(self, object item) :
if type(item) == str :
return (self.columns)[item]
elif type(item) == int : # TODO int?
elif type(item) == int : # TODO int? (range problem)
return OBI_Nuc_Seq_Stored(self, item)