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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -227,7 +227,6 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v
|
||||
* @param line_selection Eventually a pointer on a list of indexes corresponding to a line selection to use with the view to clone
|
||||
* if there is one. NULL if there is no line selection or no view to clone.
|
||||
* @param comments Eventually, comments to associate with the view. NULL if not.
|
||||
* @param quality_column Whether or not a sequence quality column is associated with the view.
|
||||
*
|
||||
* @returns A pointer to the newly created view structure.
|
||||
* @retval NULL if an error occurred.
|
||||
@ -235,7 +234,51 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v
|
||||
* @since February 2016
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clones a view using a pointer on the view to clone.
|
||||
*
|
||||
* The new view has the same type as the cloned one.
|
||||
* Fails if a view with the same name already exists.
|
||||
*
|
||||
* @param dms A pointer on the OBIDMS.
|
||||
* @param view_to_clone A pointer on the opened view to clone to create the new one.
|
||||
* @param view_name The unique name of the new view.
|
||||
* @param line_selection Eventually a pointer on a list of indexes corresponding to a line selection to use with the view to clone
|
||||
* if there is one. NULL if there is no line selection or no view to clone.
|
||||
* @param comments Eventually, comments to associate with the view. NULL if not.
|
||||
*
|
||||
* @returns A pointer to the newly created view structure.
|
||||
* @retval NULL if an error occurred.
|
||||
*
|
||||
* @since April 2017
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
Obiview_p obi_clone_view(OBIDMS_p dms, Obiview_p view_to_clone, const char* view_name, index_t* line_selection, const char* comments);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clones a view using the name of the view to clone.
|
||||
*
|
||||
* The new view has the same type as the cloned one.
|
||||
* Fails if a view with the same name already exists.
|
||||
*
|
||||
* @param dms A pointer on the OBIDMS.
|
||||
* @param view_to_clone_name The name of the view to clone.
|
||||
* @param view_name The unique name of the new view.
|
||||
* @param line_selection Eventually a pointer on a list of indexes corresponding to a line selection to use with the view to clone
|
||||
* if there is one. NULL if there is no line selection or no view to clone.
|
||||
* @param comments Eventually, comments to associate with the view. NULL if not.
|
||||
*
|
||||
* @returns A pointer to the newly created view structure.
|
||||
* @retval NULL if an error occurred.
|
||||
*
|
||||
* @since April 2017
|
||||
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user