Added functions to clone views with a simpler API
This commit is contained in:
@ -1802,6 +1802,11 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v
|
||||
obidebug(1, "Trying to clone a non-NUC SEQS view to create a NUC SEQS view");
|
||||
return NULL;
|
||||
}
|
||||
// Check if there is a quality column
|
||||
if (obi_view_get_column(view_to_clone, QUALITY_COLUMN) != NULL)
|
||||
quality_column = true;
|
||||
else
|
||||
quality_column = false;
|
||||
}
|
||||
|
||||
view = obi_new_view(dms, view_name, view_to_clone, line_selection, comments);
|
||||
@ -1874,7 +1879,7 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v
|
||||
}
|
||||
|
||||
|
||||
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, bool quality_column)
|
||||
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_to_clone;
|
||||
@ -1882,7 +1887,43 @@ 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);
|
||||
if (view_to_clone == NULL)
|
||||
return NULL;
|
||||
view = obi_new_view_nuc_seqs(dms, view_name, view_to_clone, line_selection, comments, quality_column);
|
||||
view = obi_new_view_nuc_seqs(dms, view_name, view_to_clone, line_selection, comments, false);
|
||||
|
||||
close_view(view_to_clone);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
Obiview_p obi_clone_view(OBIDMS_p dms, Obiview_p view_to_clone, const char* view_name, index_t* line_selection, const char* comments)
|
||||
{
|
||||
if (view_to_clone == NULL)
|
||||
{
|
||||
obi_set_errno(OBIVIEW_ERROR);
|
||||
obidebug(1, "\nError: pointer on view to clone is NULL");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp((view_to_clone->infos)->view_type, VIEW_TYPE_NUC_SEQS) == 0)
|
||||
return obi_new_view_nuc_seqs(dms, view_name, view_to_clone, line_selection, comments, false);
|
||||
else // Non-typed view
|
||||
return obi_new_view(dms, view_name, view_to_clone, line_selection, comments);
|
||||
}
|
||||
|
||||
|
||||
Obiview_p obi_clone_view_from_name(OBIDMS_p dms, const char* view_to_clone_name, const char* view_name, index_t* line_selection, const char* comments)
|
||||
{
|
||||
Obiview_p view;
|
||||
Obiview_p view_to_clone;
|
||||
|
||||
view_to_clone = obi_open_view(dms, view_to_clone_name);
|
||||
if (view_to_clone == NULL)
|
||||
{
|
||||
obidebug(1, "\nError: could not open view to clone");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
view = obi_clone_view(dms, view_to_clone, view_name, line_selection, comments);
|
||||
|
||||
close_view(view_to_clone);
|
||||
|
||||
@ -2242,7 +2283,6 @@ int obi_view_add_column(Obiview_p view,
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// If an alias is not defined, it's the original name of the column. // TODO discuss
|
||||
if (alias == NULL)
|
||||
alias = column_name;
|
||||
@ -2342,7 +2382,11 @@ int obi_view_delete_column(Obiview_p view, const char* column_name)
|
||||
|
||||
OBIDMS_column_p obi_view_get_column(Obiview_p view, const char* column_name)
|
||||
{
|
||||
return (OBIDMS_column_p)(*((OBIDMS_column_p*)(ht_get(view->column_dict, column_name))));
|
||||
OBIDMS_column_p* column_pp;
|
||||
column_pp = (OBIDMS_column_p*)(ht_get(view->column_dict, column_name));
|
||||
if (column_pp == NULL)
|
||||
return NULL;
|
||||
return (*column_pp);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user