Closes #34
This commit is contained in:
@ -43,6 +43,7 @@ cdef class OBIView:
|
|||||||
|
|
||||||
cdef Obiview_p pointer
|
cdef Obiview_p pointer
|
||||||
cdef str name
|
cdef str name
|
||||||
|
cdef str comments
|
||||||
cdef dict columns
|
cdef dict columns
|
||||||
cdef dict columns_pp # TODO this dict might be unnecessary
|
cdef dict columns_pp # TODO this dict might be unnecessary
|
||||||
cdef OBIDMS dms
|
cdef OBIDMS dms
|
||||||
@ -86,7 +87,7 @@ cdef class OBIDMS:
|
|||||||
|
|
||||||
cpdef close(self)
|
cpdef close(self)
|
||||||
cpdef OBIView open_view(self, str view_name)
|
cpdef OBIView open_view(self, str view_name)
|
||||||
cpdef OBIView new_view(self, str view_name, object view_to_clone=*, list line_selection=*, str view_type=*)
|
cpdef OBIView new_view(self, str view_name, object view_to_clone=*, list line_selection=*, str view_type=*, str comments=*)
|
||||||
cpdef dict read_view_infos(self, str view_name)
|
cpdef dict read_view_infos(self, str view_name)
|
||||||
cpdef dict read_views(self)
|
cpdef dict read_views(self)
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ cdef class OBIDMS_column_line :
|
|||||||
|
|
||||||
cdef class OBIView :
|
cdef class OBIView :
|
||||||
|
|
||||||
def __init__(self, OBIDMS dms, str view_name, bint new=False, object view_to_clone=None, list line_selection=None):
|
def __init__(self, OBIDMS dms, str view_name, bint new=False, object view_to_clone=None, list line_selection=None, str comments=""):
|
||||||
|
|
||||||
cdef Obiview_p view = NULL
|
cdef Obiview_p view = NULL
|
||||||
cdef int i
|
cdef int i
|
||||||
@ -256,11 +256,11 @@ 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)
|
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)
|
view = obi_new_view(dms.pointer, str2bytes(view_name), (<OBIView> view_to_clone).pointer, line_selection_p, str2bytes(comments))
|
||||||
elif view_to_clone is None :
|
elif view_to_clone is None :
|
||||||
view = obi_new_view(dms.pointer, str2bytes(view_name), NULL, line_selection_p)
|
view = obi_new_view(dms.pointer, str2bytes(view_name), NULL, line_selection_p, str2bytes(comments))
|
||||||
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))
|
||||||
@ -300,7 +300,7 @@ cdef class OBIView :
|
|||||||
cdef OBIDMS_column_p column_p
|
cdef OBIDMS_column_p column_p
|
||||||
|
|
||||||
s = self.name
|
s = self.name
|
||||||
s = s + ", " + str(self.pointer.line_count) + " lines"
|
s = s + ", " + self.comments + ", " + str(self.pointer.line_count) + " lines"
|
||||||
for column_name in self.columns : # TODO make function in OBIDMS_column class
|
for column_name in self.columns : # TODO make function in OBIDMS_column class
|
||||||
column = self.columns[column_name]
|
column = self.columns[column_name]
|
||||||
column_p = (column.pointer)[0]
|
column_p = (column.pointer)[0]
|
||||||
@ -461,7 +461,7 @@ cdef class OBIView :
|
|||||||
|
|
||||||
cdef class OBIView_NUC_SEQS(OBIView):
|
cdef class OBIView_NUC_SEQS(OBIView):
|
||||||
|
|
||||||
def __init__(self, OBIDMS dms, str view_name, bint new=False, object view_to_clone=None, list line_selection=None):
|
def __init__(self, OBIDMS dms, str view_name, bint new=False, object view_to_clone=None, list line_selection=None, str comments=""):
|
||||||
|
|
||||||
cdef Obiview_p view = NULL
|
cdef Obiview_p view = NULL
|
||||||
cdef int i
|
cdef int i
|
||||||
@ -486,11 +486,11 @@ 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)
|
view = obi_new_view_nuc_seqs_cloned_from_name(dms.pointer, str2bytes(view_name), str2bytes(view_to_clone), line_selection_p, str2bytes(comments))
|
||||||
else :
|
else :
|
||||||
view = obi_new_view_nuc_seqs(dms.pointer, str2bytes(view_name), (<OBIView> view_to_clone).pointer, line_selection_p)
|
view = obi_new_view_nuc_seqs(dms.pointer, str2bytes(view_name), (<OBIView> view_to_clone).pointer, line_selection_p, str2bytes(comments))
|
||||||
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)
|
view = obi_new_view_nuc_seqs(dms.pointer, str2bytes(view_name), NULL, line_selection_p, str2bytes(comments))
|
||||||
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))
|
||||||
@ -502,6 +502,7 @@ cdef class OBIView_NUC_SEQS(OBIView):
|
|||||||
|
|
||||||
self.pointer = view
|
self.pointer = view
|
||||||
self.name = bytes2str(view.name)
|
self.name = bytes2str(view.name)
|
||||||
|
self.comments = bytes2str(view.comments)
|
||||||
|
|
||||||
# go through columns to build list and open python object (TODO make separate function?)
|
# go through columns to build list and open python object (TODO make separate function?)
|
||||||
self.columns = {}
|
self.columns = {}
|
||||||
@ -663,7 +664,7 @@ cdef class OBIDMS :
|
|||||||
return view_class(self, view_name)
|
return view_class(self, view_name)
|
||||||
|
|
||||||
|
|
||||||
cpdef OBIView new_view(self, str view_name, object view_to_clone=None, list line_selection=None, str view_type=None) :
|
cpdef OBIView new_view(self, str view_name, object view_to_clone=None, list line_selection=None, str view_type=None, str comments="") :
|
||||||
|
|
||||||
cdef object view_class
|
cdef object view_class
|
||||||
|
|
||||||
@ -673,7 +674,7 @@ cdef class OBIDMS :
|
|||||||
else :
|
else :
|
||||||
view_class = OBIView
|
view_class = OBIView
|
||||||
|
|
||||||
return view_class(self, view_name, new=True, view_to_clone=view_to_clone, line_selection=line_selection)
|
return view_class(self, view_name, new=True, view_to_clone=view_to_clone, line_selection=line_selection, comments=comments)
|
||||||
|
|
||||||
|
|
||||||
cpdef dict read_view_infos(self, str view_name) :
|
cpdef dict read_view_infos(self, str view_name) :
|
||||||
@ -700,6 +701,7 @@ cdef class OBIDMS :
|
|||||||
view_p = (<Obiview_infos_p> (all_views_p.view_infos)) + i
|
view_p = (<Obiview_infos_p> (all_views_p.view_infos)) + i
|
||||||
view_name = bytes2str(view_p.name)
|
view_name = bytes2str(view_p.name)
|
||||||
views[view_name] = {}
|
views[view_name] = {}
|
||||||
|
views[view_name]["comments"] = bytes2str(view_p.comments)
|
||||||
views[view_name]["view_type"] = bytes2str(view_p.view_type)
|
views[view_name]["view_type"] = bytes2str(view_p.view_type)
|
||||||
views[view_name]["column_count"] = <int> view_p.column_count
|
views[view_name]["column_count"] = <int> view_p.column_count
|
||||||
views[view_name]["line_count"] = <int> view_p.line_count
|
views[view_name]["line_count"] = <int> view_p.line_count
|
||||||
|
@ -16,3 +16,7 @@
|
|||||||
../../../src/private_at_functions.c
|
../../../src/private_at_functions.c
|
||||||
../../../src/obiavl.h
|
../../../src/obiavl.h
|
||||||
../../../src/obiavl.c
|
../../../src/obiavl.c
|
||||||
|
../../../src/encode.h
|
||||||
|
../../../src/encode.c
|
||||||
|
../../../src/obidmscolumn_idx.h
|
||||||
|
../../../src/obidmscolumn_idx.c
|
||||||
|
@ -33,6 +33,7 @@ cdef extern from "obiview.h" nogil:
|
|||||||
Column_reference_t line_selection_reference
|
Column_reference_t line_selection_reference
|
||||||
index_t line_count
|
index_t line_count
|
||||||
int column_count
|
int column_count
|
||||||
|
const_char_p comments
|
||||||
|
|
||||||
ctypedef Obiview_t* Obiview_p
|
ctypedef Obiview_t* Obiview_p
|
||||||
|
|
||||||
@ -48,6 +49,7 @@ cdef extern from "obiview.h" nogil:
|
|||||||
Column_reference_t line_selection
|
Column_reference_t line_selection
|
||||||
Column_reference_p column_references
|
Column_reference_p column_references
|
||||||
const_char_p view_type
|
const_char_p view_type
|
||||||
|
const_char_p comments
|
||||||
|
|
||||||
ctypedef Obiview_infos_t* Obiview_infos_p
|
ctypedef Obiview_infos_t* Obiview_infos_p
|
||||||
|
|
||||||
@ -67,13 +69,13 @@ cdef extern from "obiview.h" nogil:
|
|||||||
ctypedef Obiviews_infos_all_t* Obiviews_infos_all_p
|
ctypedef Obiviews_infos_all_t* Obiviews_infos_all_p
|
||||||
|
|
||||||
|
|
||||||
Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const_char_p view_name, Obiview_p view_to_clone, index_t* line_selection)
|
Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const_char_p view_name, Obiview_p view_to_clone, index_t* line_selection, const_char_p comments)
|
||||||
|
|
||||||
Obiview_p obi_new_view(OBIDMS_p dms, const_char_p view_name, Obiview_p view_to_clone, index_t* line_selection)
|
Obiview_p obi_new_view(OBIDMS_p dms, const_char_p view_name, Obiview_p view_to_clone, index_t* line_selection, const_char_p comments)
|
||||||
|
|
||||||
Obiview_p obi_new_view_cloned_from_name(OBIDMS_p dms, const_char_p view_name, const_char_p view_to_clone_name, index_t* line_selection)
|
Obiview_p obi_new_view_cloned_from_name(OBIDMS_p dms, const_char_p view_name, const_char_p view_to_clone_name, index_t* line_selection, const_char_p comments)
|
||||||
|
|
||||||
Obiview_p obi_new_view_nuc_seqs_cloned_from_name(OBIDMS_p dms, const_char_p view_name, const_char_p view_to_clone_name, index_t* line_selection)
|
Obiview_p obi_new_view_nuc_seqs_cloned_from_name(OBIDMS_p dms, const_char_p view_name, const_char_p view_to_clone_name, index_t* line_selection, const_char_p comments)
|
||||||
|
|
||||||
Obiview_p obi_open_view(OBIDMS_p dms, const_char_p view_name)
|
Obiview_p obi_open_view(OBIDMS_p dms, const_char_p view_name)
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ int create_obiview_file(int dms_file_descriptor)
|
|||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p view_to_clone, index_t* line_selection)
|
Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p view_to_clone, index_t* line_selection, const char* comments)
|
||||||
{
|
{
|
||||||
Obiview_p view;
|
Obiview_p view;
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view = obi_new_view(dms, view_name, view_to_clone, line_selection);
|
view = obi_new_view(dms, view_name, view_to_clone, line_selection, comments);
|
||||||
|
|
||||||
strcpy(view->view_type, VIEW_TYPE_NUC_SEQS);
|
strcpy(view->view_type, VIEW_TYPE_NUC_SEQS);
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_clone, index_t* line_selection)
|
Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_clone, index_t* line_selection, const char* comments)
|
||||||
{
|
{
|
||||||
Obiview_p view;
|
Obiview_p view;
|
||||||
int i;
|
int i;
|
||||||
@ -359,13 +359,14 @@ Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_cl
|
|||||||
}
|
}
|
||||||
|
|
||||||
strcpy(view->name, view_name);
|
strcpy(view->name, view_name);
|
||||||
|
strcpy(view->comments, comments);
|
||||||
view->read_only = 0;
|
view->read_only = 0;
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Obiview_p obi_new_view_cloned_from_name(OBIDMS_p dms, const char* view_name, const char* view_to_clone_name, index_t* line_selection)
|
Obiview_p obi_new_view_cloned_from_name(OBIDMS_p dms, const char* view_name, const char* view_to_clone_name, index_t* line_selection, const char* comments)
|
||||||
{
|
{
|
||||||
Obiview_p view;
|
Obiview_p view;
|
||||||
Obiview_p view_to_clone;
|
Obiview_p view_to_clone;
|
||||||
@ -373,7 +374,7 @@ Obiview_p obi_new_view_cloned_from_name(OBIDMS_p dms, const char* view_name, con
|
|||||||
view_to_clone = obi_open_view(dms, view_to_clone_name);
|
view_to_clone = obi_open_view(dms, view_to_clone_name);
|
||||||
if (view_to_clone == NULL)
|
if (view_to_clone == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
view = obi_new_view(dms, view_name, view_to_clone, line_selection);
|
view = obi_new_view(dms, view_name, view_to_clone, line_selection, comments);
|
||||||
|
|
||||||
obi_close_view(view_to_clone);
|
obi_close_view(view_to_clone);
|
||||||
|
|
||||||
@ -381,7 +382,7 @@ Obiview_p obi_new_view_cloned_from_name(OBIDMS_p dms, const char* view_name, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Obiview_p obi_new_view_nuc_seqs_cloned_from_name(OBIDMS_p dms, const char* view_name, const char* view_to_clone_name, index_t* line_selection)
|
Obiview_p obi_new_view_nuc_seqs_cloned_from_name(OBIDMS_p dms, const char* view_name, const char* view_to_clone_name, index_t* line_selection, const char* comments)
|
||||||
{
|
{
|
||||||
Obiview_p view;
|
Obiview_p view;
|
||||||
Obiview_p view_to_clone;
|
Obiview_p view_to_clone;
|
||||||
@ -389,7 +390,7 @@ Obiview_p obi_new_view_nuc_seqs_cloned_from_name(OBIDMS_p dms, const char* view_
|
|||||||
view_to_clone = obi_open_view(dms, view_to_clone_name);
|
view_to_clone = obi_open_view(dms, view_to_clone_name);
|
||||||
if (view_to_clone == NULL)
|
if (view_to_clone == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
view = obi_new_view_nuc_seqs(dms, view_name, view_to_clone, line_selection);
|
view = obi_new_view_nuc_seqs(dms, view_name, view_to_clone, line_selection, comments);
|
||||||
|
|
||||||
obi_close_view(view_to_clone);
|
obi_close_view(view_to_clone);
|
||||||
|
|
||||||
@ -532,6 +533,7 @@ Obiview_p obi_open_view(OBIDMS_p dms, const char* view_name)
|
|||||||
strcpy(view->created_from, view_infos->created_from);
|
strcpy(view->created_from, view_infos->created_from);
|
||||||
strcpy(view->name, view_infos->name);
|
strcpy(view->name, view_infos->name);
|
||||||
strcpy(view->view_type, view_infos->view_type);
|
strcpy(view->view_type, view_infos->view_type);
|
||||||
|
strcpy(view->comments, view_infos->comments);
|
||||||
|
|
||||||
// Open the columns to read
|
// Open the columns to read
|
||||||
for (i=0; i<(view_infos->column_count); i++)
|
for (i=0; i<(view_infos->column_count); i++)
|
||||||
@ -1033,6 +1035,7 @@ int obi_save_view(Obiview_p view)
|
|||||||
strcpy(view_infos->created_from, view->created_from);
|
strcpy(view_infos->created_from, view->created_from);
|
||||||
strcpy(view_infos->name, view->name);
|
strcpy(view_infos->name, view->name);
|
||||||
strcpy(view_infos->view_type, view->view_type);
|
strcpy(view_infos->view_type, view->view_type);
|
||||||
|
strcpy(view_infos->comments, view->comments);
|
||||||
|
|
||||||
// Store reference for the line selection associated with that view
|
// Store reference for the line selection associated with that view
|
||||||
if (view->new_line_selection != NULL)
|
if (view->new_line_selection != NULL)
|
||||||
|
@ -26,8 +26,10 @@
|
|||||||
#include "obierrno.h"
|
#include "obierrno.h"
|
||||||
|
|
||||||
|
|
||||||
#define OBIVIEW_NAME_MAX_LENGTH (10239) /**< The maximum length of an OBIDMS view name.
|
#define OBIVIEW_NAME_MAX_LENGTH (1000) /**< The maximum length of an OBIDMS view name.
|
||||||
*/
|
*/
|
||||||
|
#define OBIVIEW_COMMENTS_MAX_LENGTH (10000)
|
||||||
|
|
||||||
#define OBIVIEW_FILE_NAME "obiviews"
|
#define OBIVIEW_FILE_NAME "obiviews"
|
||||||
|
|
||||||
#define VIEW_TYPE_MAX_NAME (1024)
|
#define VIEW_TYPE_MAX_NAME (1024)
|
||||||
@ -84,6 +86,8 @@ typedef struct Obiview {
|
|||||||
|
|
||||||
char view_type[VIEW_TYPE_MAX_NAME+1];
|
char view_type[VIEW_TYPE_MAX_NAME+1];
|
||||||
|
|
||||||
|
char comments[OBIVIEW_COMMENTS_MAX_LENGTH+1];
|
||||||
|
|
||||||
} Obiview_t, *Obiview_p;
|
} Obiview_t, *Obiview_p;
|
||||||
|
|
||||||
|
|
||||||
@ -111,6 +115,8 @@ typedef struct Obiview_infos {
|
|||||||
|
|
||||||
char view_type[VIEW_TYPE_MAX_NAME+1];
|
char view_type[VIEW_TYPE_MAX_NAME+1];
|
||||||
|
|
||||||
|
char comments[OBIVIEW_COMMENTS_MAX_LENGTH+1];
|
||||||
|
|
||||||
} Obiview_infos_t, *Obiview_infos_p;
|
} Obiview_infos_t, *Obiview_infos_p;
|
||||||
|
|
||||||
|
|
||||||
@ -135,13 +141,13 @@ typedef struct Obiviews_infos_all {
|
|||||||
} Obiviews_infos_all_t, *Obiviews_infos_all_p;
|
} Obiviews_infos_all_t, *Obiviews_infos_all_p;
|
||||||
|
|
||||||
|
|
||||||
Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p view_to_clone, index_t* line_selection);
|
Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p view_to_clone, index_t* line_selection, const char* comments);
|
||||||
|
|
||||||
Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_clone, index_t* line_selection);
|
Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_clone, index_t* line_selection, const char* comments);
|
||||||
|
|
||||||
Obiview_p obi_new_view_cloned_from_name(OBIDMS_p dms, const char* view_name, const char* view_to_clone_name, index_t* line_selection);
|
Obiview_p obi_new_view_cloned_from_name(OBIDMS_p dms, const char* view_name, const char* view_to_clone_name, index_t* line_selection, const char* comments);
|
||||||
|
|
||||||
Obiview_p obi_new_view_nuc_seqs_cloned_from_name(OBIDMS_p dms, const char* view_name, const char* view_to_clone_name, index_t* line_selection);
|
Obiview_p obi_new_view_nuc_seqs_cloned_from_name(OBIDMS_p dms, const char* view_name, const char* view_to_clone_name, index_t* line_selection, const char* comments);
|
||||||
|
|
||||||
Obiview_p obi_open_view(OBIDMS_p dms, const char* view_name);
|
Obiview_p obi_open_view(OBIDMS_p dms, const char* view_name);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user