obiview.h 104 KB
Newer Older
Celine Mercier committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/********************************************************************
 * Obiview header file                                              *
 ********************************************************************/

/**
 * @file obiview.h
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 * @date 16 December 2015
 * @brief Header file for the OBIDMS view functions and structures.
 */


#ifndef OBIVIEW_H_
#define OBIVIEW_H_


#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
20
#include <stdint.h>
Celine Mercier committed
21 22 23 24 25 26 27
#include <stdbool.h>
#include <time.h>
#include <math.h>

#include "obidms.h"
#include "obidmscolumn.h"
#include "obierrno.h"
28
#include "hashtable.h"
29
#include "linked_list.h"
30
#include "obiblob.h"
Celine Mercier committed
31 32


33
#define OBIVIEW_NAME_MAX_LENGTH (249)   		/**< The maximum length of an OBIDMS view name, without the extension.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
                                	 	  	  	 */
#define VIEW_TYPE_MAX_LENGTH (1024)   			/**< The maximum length of the type name of a view.
                                	 	  	  	 */
#define LINES_COLUMN_NAME "LINES"				/**< The name of the column containing the line selections
 	 	 	 	 	 	 	 	 	 	 	 	 *   in all views.
                                	 	  	  	 */
#define VIEW_TYPE_NUC_SEQS "NUC_SEQS_VIEW"   	/**< The type name of views based on nucleotide sequences
												 *   and their metadata.
                                	 	  	  	 */
#define NUC_SEQUENCE_COLUMN "NUC_SEQ"			/**< The name of the column containing the nucleotide sequences
 	 	 	 	 	 	 	 	 	 	 	 	 *   in NUC_SEQS_VIEW views.
                                	 	  	  	 */
#define ID_COLUMN "ID"							/**< The name of the column containing the sequence identifiers
 	 	 	 	 	 	 	 	 	 	 	 	 *   in NUC_SEQS_VIEW views.
                                	 	  	  	 */
#define DEFINITION_COLUMN "DEFINITION"			/**< The name of the column containing the sequence definitions
 	 	 	 	 	 	 	 	 	 	 	 	 *   in NUC_SEQS_VIEW views.
                                	 	  	  	 */
52 53
#define QUALITY_COLUMN "QUALITY"				/**< The name of the column containing the sequence qualities
 	 	 	 	 	 	 	 	 	 	 	 	 *   in NUC_SEQS_VIEW views.
54 55 56
                                	 	  	   	 */
#define COUNT_COLUMN "COUNT"				    /**< The name of the column containing the sequence counts
 	 	 	 	 	 	 	 	 	 	 	 	 *   in NUC_SEQS_VIEW views.
57
                                	 	  	  	 */
58 59
#define TAXID_COLUMN "TAXID"				    /**< The name of the column containing the taxids.       TODO subtype of INT column?
                                	             */
60 61 62 63 64 65 66 67
#define MERGED_TAXID_COLUMN "MERGED_TAXID"		/**< The name of the column containing the merged taxids information.
                                	             */
#define MERGED_PREFIX "MERGED_"		            /**< The prefix to prepend to column names when merging informations during obi uniq.
                                	             */
#define TAXID_DIST_COLUMN "TAXID_DIST"			/**< The name of the column containing a dictionary of taxid:[list of ids] when merging informations during obi uniq.
                                	             */
#define MERGED_COLUMN "MERGED"					/**< The name of the column containing a list of ids when merging informations during obi uniq.
                                	             */
68 69
#define ID_PREFIX "seq"						    /**< The default prefix of sequence identifiers in automatic ID columns.
                                	 	  	  	 */
70 71
#define PREDICATE_KEY "predicates"		        /**< The key used in the json-formatted view comments to store predicates.
                                	 	  	  	 */
Celine Mercier committed
72

Celine Mercier committed
73

74 75 76 77 78 79 80 81 82 83 84 85
/**
 * @brief Structure for column aliases.
 * 		  Column aliases are alternative names used to identify a column in the context of a view.
 */
typedef struct Alias_column_pair {
	Column_reference_t	column_refs;   						/**< References (name and version) of the column.
		 	 	 	 	 	 	 	 	 	 	 	 	 	 */
	char 				alias[OBIDMS_COLUMN_MAX_NAME+1];	/**< Alias of the column in the context of a view.
	 	 	 								 	 	 	 	 */
} Alias_column_pair_t, *Alias_column_pair_p;


Celine Mercier committed
86
/**
87 88 89
 * @brief Structure for a closed view stored in the view file.
 * 		  Views are identified by their name.
 * 		  Once a view has been written in the view file, it can not be modified and can only be read.
Celine Mercier committed
90
 */
91
typedef struct Obiview_infos {
92 93 94 95
	size_t				file_size;    								/**< View file size in bytes.
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
	size_t				used_size;    								/**< Used size in bytes.
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
96
	time_t 		 		creation_date;    							/**< Time at which the view was created.
97 98 99 100 101
		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
	char   				name[OBIVIEW_NAME_MAX_LENGTH+1];    		/**< Name of the view, used to identify it.
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
	char				created_from[OBIVIEW_NAME_MAX_LENGTH+1];    /**< Name of the view from which that view was cloned, if it was cloned.
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
102
	char				view_type[VIEW_TYPE_MAX_LENGTH+1];			/**< Type of the view if there is one.
103 104 105 106
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 *   Types existing: NUC_SEQS_VIEW.
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
	bool				all_lines;									/**< Whether there is a line selection associated with the view.
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
107
	Column_reference_t	line_selection;								/**< The references of the line selection associated with the view if there is one.
108 109 110 111 112
 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
	index_t             line_count;    								/**< The number of lines in the view.
																	 */
	int 				column_count;    							/**< The number of columns in the view.
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
113 114
	Alias_column_pair_t column_references[MAX_NB_OPENED_COLUMNS];   /**< References (name, version and alias) for all the columns in the view.
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
115 116
	bool				finished;									/** Whether the view is finished and can be read.
																	 */
117
	char 				comments[];									/**< Comments, additional informations on the view.
118 119
 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
} Obiview_infos_t, *Obiview_infos_p;
120

Celine Mercier committed
121

122 123 124 125
/**
 * @brief Structure for an opened view.
 */
typedef struct Obiview {
126
	Obiview_infos_p     infos;											/**< A pointer on the mapped view informations.
127
		 	 	 	  	 	 	 	 	 	 	 	 	 	 	 	 	 */
128
	OBIDMS_p            dms;    										/**< A pointer on the DMS to which the view belongs.
129
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
130
	bool                read_only;    									/**< Whether the view is read-only or can be modified.
131
																	 	 */
132
	OBIDMS_column_p     line_selection;    								/**< A pointer on the column containing the line selection
133 134 135 136
																	 	 *   associated with the view if there is one.
																	 	 *   This line selection is read-only, and when a line from the view is read,
																	 	 *   it is this line selection that is used.
																	 	 */
137
	Linked_list_node_p  columns;					    				/**< Double linked chain containing the pointers on all the columns of the view.
138
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
139
	hashtable_p		    column_dict;									/**< Hash table storing the pairs of column names or aliases with the associated
140
																		 *   pointers on column pointers (OBIDMS_column_p*).
141
																		 */
142 143 144
	int			        nb_predicates; 									/**< Number of predicates to test when closing the view.
 	 	 	 	  	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
	char* 			    (**predicate_functions)(struct Obiview* view);     /**< Array of pointers on all predicate functions to test when closing the view.
145
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 */
146
} Obiview_t, *Obiview_p;
Celine Mercier committed
147 148


149 150 151 152 153 154 155 156 157 158 159 160 161 162
/**
 * Function checking if a view (either finished or unfinished) with a given name already exists in a DMS.
 *
 * @param dms The DMS.
 * @param view_name The name of the view.
 *
 * @returns A boolean value indicating whether the view already exists or not.
 *
 * @since September 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
bool obi_view_exists(OBIDMS_p dms, const char* view_name);


163 164 165 166 167 168
/**
 * @brief Creates a new view.
 *
 * Fails if a view with the same name already exists.
 *
 * @param dms A pointer on the OBIDMS.
169
 * @param view_name The unique name of the view. Can not be 'taxonomy' (used for URIs).
170 171 172
 * @param view_to_clone Eventually a pointer on the opened view to clone to create the new one, if there is one. NULL if not.
 * @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.
173
 * 						 The end of the index array is flagged by a -1 value.
174 175 176 177 178 179 180 181 182
 * @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 December 2015
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
Obiview_p obi_new_view(OBIDMS_p dms, const char* view_name, Obiview_p view_to_clone, index_t* line_selection, const char* comments);
Celine Mercier committed
183 184 185


/**
186 187 188 189 190 191 192 193
 * @brief Creates a new view by cloning another view written in the view file and identified by its name.
 *
 * Note : obi_new_view can clone from a pointer on an opened view, while this function will read the view to clone
 * 		  from the view file.
 *
 * Fails if a view with the same name already exists.
 *
 * @param dms A pointer on the OBIDMS.
194
 * @param view_name The unique name of the new view. Can not be 'taxonomy' (used for URIs).
195 196 197 198 199 200 201 202 203 204
 * @param view_to_clone_name The name of the view to clone stored in the view file of the OBIDMS.
 * @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 December 2015
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
Celine Mercier committed
205
 */
206
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);
Celine Mercier committed
207 208 209


/**
210 211 212 213 214 215 216 217
 * @brief Creates a new view with the type NUC_SEQ_VIEW, based on nucleotide sequences and their metadata.
 *
 * Fails if a view with the same name already exists.
 *
 * The obligatory columns specific to the view type are created too and opened:
 * 	- NUC_SEQUENCE_COLUMN where nucleotide sequences are stored
 * 	- ID_COLUMN			  where sequence identifiers are stored
 * 	- DEFINITION_COLUMN   where sequence definitions are stored
218
 * 	And, if quality_column is True:
219
 * 	- QUALITY_COLUMN   	  where sequence qualities are stored
220 221
 *
 * @param dms A pointer on the OBIDMS.
222
 * @param view_name The unique name of the view. Can not be 'taxonomy' (used for URIs).
223 224 225 226
 * @param view_to_clone Eventually a pointer on the opened view to clone to create the new one, if there is one. NULL if not.
 * @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.
227
 * @param quality_column Whether or not a sequence quality column is associated with the view.
228
 * @param create_default_columns Whether to create the default columns associated with the view type (false when importing all columns from a view for example).
229 230 231 232 233 234
 *
 * @returns A pointer to the newly created view structure.
 * @retval NULL if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
Celine Mercier committed
235
 */
236
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, bool quality_column, bool create_default_columns);
237

Celine Mercier committed
238

239 240 241 242 243 244 245 246 247 248 249 250 251 252
/**
 * @brief Creates a new view with the type NUC_SEQ_VIEW, based on nucleotide sequences and their metadata,
 *        by cloning another NUC_SEQ_VIEW view written in the view file and identified by its name.
 *
 * Note : obi_new_view_nuc_seqs can clone from a pointer on an opened view, while this function will read the view to clone
 * 		  from the view file.
 *
 * Fails if a view with the same name already exists.
 * Fails if the view to clone doesn't have the type NUC_SEQ_VIEW.
 *
 * The obligatory columns specific to the view type are created too and opened:
 * 	- NUC_SEQUENCE_COLUMN where nucleotide sequences are stored
 * 	- ID_COLUMN			  where sequence identifiers are stored
 * 	- DEFINITION_COLUMN   where sequence definitions are stored
253
 * 	And, if quality_column is True:
254
 * 	- QUALITY_COLUMN   	  where sequence qualities are stored
255 256
 *
 * @param dms A pointer on the OBIDMS.
257
 * @param view_name The unique name of the new view. Can not be 'taxonomy' (used for URIs).
258 259 260 261 262 263 264 265 266 267 268
 * @param view_to_clone_name The name of the view to clone stored in the view file of the OBIDMS.
 * @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 February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
269 270 271 272 273 274 275 276 277 278 279
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.
280
 * @param view_name The unique name of the new view. Can not be 'taxonomy' (used for URIs).
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
 * @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.
302
 * @param view_name The unique name of the new view. Can not be 'taxonomy' (used for URIs).
303 304 305 306 307 308 309 310 311 312 313
 * @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);
Celine Mercier committed
314 315


316 317 318 319 320
/**
 * @brief Maps a view file and returns the mapped structure stored in it.
 *
 * @param dms A pointer on the OBIDMS.
 * @param view_name The unique name identifying the view.
321
 * @param finished Whether the view is finished or not.
322 323 324 325 326 327 328
 *
 * @returns A pointer on the mapped view infos structure.
 * @retval NULL if an error occurred.
 *
 * @since June 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
329
Obiview_infos_p obi_view_map_file(OBIDMS_p dms, const char* view_name, bool finished);
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347


/**
 * @brief Unmaps a view file.
 *
 * @param dms A pointer on the OBIDMS.
 * @param view_infos A pointer on the mapped view infos structure.
 *
 * @returns A value indicating the success of the operation.
 * @retval 0 if the operation was successfully completed.
 * @retval -1 if an error occurred.
 *
 * @since June 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
int obi_view_unmap_file(OBIDMS_p dms, Obiview_infos_p view_infos);


348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
/**
 * @brief Opens a view identified by its name stored in the view file.
 *
 * When opening a view, all the columns and eventually the line selection belonging to it are opened with it.
 *
 * @warning The opened view is read-only.
 *
 * @param dms A pointer on the OBIDMS.
 * @param view_name The unique name identifying the view.
 *
 * @returns A pointer on the opened view structure.
 * @retval NULL if an error occurred.
 *
 * @since December 2015
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
Obiview_p obi_open_view(OBIDMS_p dms, const char* view_name);
Celine Mercier committed
365 366


367 368 369
/**
 * @brief Adds a column to a view.
 *
370 371 372 373 374 375 376 377
 * - If there is a line selection:
 * 		- The column's lines_used attribute must be at least the view's line count
 * - If there is no line selection:
 *    	- If it's the first column in the view:
 *		 	-  The view's line count is set to the column's lines_used attribute
 *  	- If it's not the first column in the view:
 *  		- The column's lines_used attribute must be equal to the view's line count
 *
378 379 380 381
 * @warning The view must be writable.
 *
 * @param view A pointer on the view.
 * @param column_name The name of the column.
382 383
 * @param version_number The version of the column if it should be opened and not created
 * 						 (if -1, the latest version is retrieved).
384
 * @param alias The unique name used to identify the column in the context of this view.
385 386 387 388
 * 			    If NULL or "", column_name is used.
 * @param data_type The OBIType code of the data, if the column is created.
 * @param nb_lines The number of lines to be stored (can be 0 if not known), if the column is created.
 * @param nb_elements_per_line The number of elements per line, if the column is created.
389
 * @param elements_names The names of the elements with ';' as separator (no terminal ';'),
390
 * 						 if the column is created; NULL or "" if the default names are to be used ("0\01\02\0...\0n").
391
 * @param elt_names_formatted Whether the separator for the elements names is ';' (false), or '\0' (true, as formatted by format_elements_names()).
392
 * @param tuples A boolean indicating whether the column should contain indices referring to indexed tuples.
393 394
 * @param to_eval A boolean indicating whether the column contains expressions that should be evaluated
 *                (typically OBI_STR columns containing character strings to be evaluated by Python).
395
 * @param indexer_name The name of the indexer if there is one associated with the column, if the column is created.
396
 *                     If NULL or "", the indexer name is set as the column name.
397 398 399
 * @param associated_column_name The name of the associated column if there is one (otherwise NULL or ""), if the column is created.
 * @param associated_column_version The version of the associated column if there is one (otherwise -1), if the column is created.
 * @param comments Optional comments associated with the column if it is created (NULL or "" if no comments associated).
400 401 402 403 404 405 406 407 408
 * @param create Whether the column should be created (create == true) or opened (create == false).
 *
 * @returns A value indicating the success of the operation.
 * @retval 0 if the operation was successfully completed.
 * @retval -1 if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
409 410
int obi_view_add_column(Obiview_p    view,
						const char*  column_name,
Celine Mercier committed
411
						obiversion_t version_number,
412 413 414 415 416
						const char*  alias,
						OBIType_t    data_type,
						index_t      nb_lines,
						index_t      nb_elements_per_line,
						char*        elements_names,
417
						bool         elt_names_formatted,
418
						bool         tuples,
419
						bool         to_eval,
420 421
						const char*  indexer_name,
						const char*  associated_column_name,
422
						obiversion_t associated_column_version,
423 424
						const char*  comments,
						bool         create);
Celine Mercier committed
425

426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441

/**
 * @brief Deletes a column from a view.
 *
 * @warning The view must be writable.
 *
 * @param view A pointer on the view.
 * @param column_name The name of the column that should be deleted from the view.
 *
 * @returns A value indicating the success of the operation.
 * @retval 0 if the operation was successfully completed.
 * @retval -1 if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
Celine Mercier committed
442 443
int obi_view_delete_column(Obiview_p view, const char* column_name);

444

445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
/**
 * @brief Gets the pointer on a column from its name in a view.
 *
 * @param view A pointer on the view.
 * @param column_name The name of the column in the view.
 *
 * @returns A pointer on the column.
 * @retval NULL if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
OBIDMS_column_p obi_view_get_column(Obiview_p view, const char* column_name);


460 461 462 463 464 465 466 467 468 469 470 471 472 473
/**
 * @brief Checks if a column exists in a view.
 *
 * @param view A pointer on the view.
 * @param column_name The name of the column in the view.
 *
 * @returns A boolean indicating whether or not the column exists in the view.
 *
 * @since July 2017
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
bool obi_view_column_exists(Obiview_p view, const char* column_name);


474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
/**
 * @brief Gets the pointer on the pointer on a column from its name in a view.
 *
 * Note: This is used to replace old cloned columns with new ones in views in layers above the C layer.
 *
 * @param view A pointer on the view.
 * @param column_name The name of the column in the view.
 *
 * @returns A pointer on the pointer on the column.
 * @retval NULL if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
OBIDMS_column_p* obi_view_get_pointer_on_column_in_view(Obiview_p view, const char* column_name);


491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
/**
 * @brief Changes the name that identifies a column in the context of a view.
 *
 * In the context of a view, each column is identified by a name that is unique in this view.
 *
 * @warning The view must be writable.
 *
 * @param view A pointer on the view.
 * @param current_name The current name that identifies the column in this view.
 * @param alias The new name that should be used to identify the column in this view.
 *
 * @returns A value indicating the success of the operation.
 * @retval 0 if the operation was successfully completed.
 * @retval -1 if an error occurred.
 *
 * @since July 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
int obi_view_create_column_alias(Obiview_p view, const char* current_name, const char* alias);


512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549
/**
 * @brief Internal function writing new comments in a view file.
 *
 * The new comments replace the pre-existing ones.
 * The view file is enlarged if necessary.
 *
 * @param view A pointer on the view.
 * @param comments The new comments that should be written.
 *
 * @retval 0 if the operation was successfully completed.
 * @retval -1 if an error occurred.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
int obi_view_write_comments(Obiview_p view, const char* comments);


/**
 * @brief Adds comments to a view file.
 *
 * This reads the comments in the JSON format and adds the key value pair.
 * If the key already exists, the value format is turned into an array and the new value is appended
 * if it is not already in the array.
 *
 * @param column A pointer on an OBIDMS column.
 * @param key The key.
 * @param value The value associated with the key.
 *
 * @retval 0 if the operation was successfully completed.
 * @retval -1 if an error occurred.
 *
 * @since August 2018
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
int obi_view_add_comment(Obiview_p view, const char* key, const char* value);


550
/**
551
 * @brief Closes an opened view, and saves it if it is not read-only (meaning it is not already saved in the view file).
552
 *
553 554 555
 * The predicates associated with the view are checked before saving it, and -1 is returned if at
 * least one predicate is not respected.
 *
556 557 558 559 560 561 562 563 564
 * @param view A pointer on the view.
 *
 * @returns A value indicating the success of the operation.
 * @retval 0 if the operation was successfully completed.
 * @retval -1 if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
565
int obi_save_and_close_view(Obiview_p view);
Celine Mercier committed
566

567

568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
/**
 * @brief Goes through all the view files of a DMS and deletes views that have
 *        not been flagged as finished (file extension renamed from '.obiview_unfinished'
 *        to '.obiview' and finished boolean set to true in the file, done by finish_view()).
 *
 * @param dms A pointer on an OBIDMS.
 *
 * @returns A value indicating the success of the operation.
 * @retval 0 if the operation was successfully completed.
 * @retval -1 if an error occurred.
 *
 * @since October 2017
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
int obi_clean_unfinished_views(OBIDMS_p dms);


/**
 * @brief Frees and deletes an opened, writable view and the columns it created.
 *
 * The view and column files are deleted and the structures are freed.
 *
 * @warning The view pointer becomes invalid, as well as the pointers on
 *          the columns created by the view.
 *
 * @param view A pointer on the writable view to rollback.
 *
 * @returns A value indicating the success of the operation.
 * @retval 0 if the operation was successfully completed.
 * @retval -1 if an error occurred.
 *
 * @since October 2017
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
int obi_rollback_view(Obiview_p view);


605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
/**
 * @brief Deletes a finished view file.
 *
 * Only the view informations file is deleted.
 * This function should only be used to delete 'temporary views' not meant to appear in the DMS history.
 *
 * @warning The view needs to be closed. The function checks that the view exists and is finished, but not that it is closed.
 *          If it was not closed, memory errors will be generated when the system tries to read the deleted file.
 *          // TODO maybe take opened view as argument in order to close it? but doesn't guarantee that it isn't open elsewhere.
 *
 * @param dms A pointer on the DMS to which the view belongs.
 * @param view_name The name of the view to delete.
 *
 * @returns A value indicating the success of the operation.
 * @retval 0 if the operation was successfully completed.
 * @retval -1 if an error occurred.
 *
 * @since October 2018
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
int obi_delete_view(OBIDMS_p dms, const char* view_name);


628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
/**
 * @brief Creates an OBI_INT column with the line count of the view it belongs to, and sets all lines to 1.
 *
 * @warning The number of lines set corresponds to the line count of the view.
 *
 * @param view A pointer on the view.
 *
 * @returns A value indicating the success of the operation.
 * @retval 0 if the operation was successfully completed.
 * @retval -1 if an error occurred.
 *
 * @since July 2017
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
int obi_create_auto_count_column(Obiview_p view);


645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663
/**
 * @brief Creates an OBI_STR column with the line count of the view it belongs to, and sets all lines with automatic identifiers
 *        with the form prefix_index.
 *
 * @warning The number of lines set corresponds to the line count of the view.
 *
 * @param view A pointer on the view.
 * @param prefix The prefix of automatic ids. The ids have the form prefix_index. If NULL, the default ID_PREFIX is used.
 *
 * @returns A value indicating the success of the operation.
 * @retval 0 if the operation was successfully completed.
 * @retval -1 if an error occurred.
 *
 * @since July 2017
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
int obi_create_auto_id_column(Obiview_p view, const char* prefix);


664
/**
665 666
 * @brief Recovers an obiblob from an OBIDMS column containing indices referring to obiblobs,
 *        using the index of the element in the line, and the column pointer, in the context of a view.
667 668 669 670 671 672 673 674 675 676 677 678 679 680
 *
 * @param view A pointer on the opened view.
 * @param column_p A pointer on the column.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
 *
 * @returns The recovered obiblob.
 * @retval OBIBlob_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since November 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
Obi_blob_p obi_get_blob_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx);

681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696

/**
 * @brief Recovers an obiblob from an OBIDMS column containing indices referring to obiblobs,
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
 *
 * @returns The recovered obiblob.
 * @retval OBIBlob_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since November 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
697 698 699 700 701
Obi_blob_p obi_get_blob_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx);


/**
 * @brief Recovers an obiblob from an OBIDMS column containing indices referring to obiblobs,
702
 *        using the name of the element in the line, and the column pointer, in the context of a view.
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
 *
 * @param view A pointer on the opened view.
 * @param column_p A pointer on the column.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
 *
 * @returns The recovered obiblob.
 * @retval OBIBlob_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since November 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
Obi_blob_p obi_get_blob_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name);


718 719 720 721 722 723 724 725 726 727 728 729 730 731 732
/**
 * @brief Recovers an obiblob from an OBIDMS column containing indices referring to obiblobs,
 *        using the name of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
 *
 * @returns The recovered obiblob.
 * @retval OBIBlob_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since November 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
733 734 735
Obi_blob_p obi_get_blob_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name);


736
/**
737 738
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_BOOL,
 *        using the index of the element in the line, and the column pointer, in the context of a view.
739
 *
740
 *  Note: If the column is read-only or if there is a line selection associated with the view (making columns non-writable), it is cloned.
741
 *
742
 * @param view A pointer on the opened writable view.
743
 * @param column_p A pointer on the column.
744 745 746 747 748 749 750 751 752 753 754
 * @param line_nb The number of the line where the value should be set.
 * @param element_idx The index of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
755 756
int obi_set_bool_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx, obibool_t value);

757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776

/**
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_BOOL,
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 *  Note: If the column is read-only or if there is a line selection associated with the view (making columns non-writable), it is cloned.
 *
 * @param view A pointer on the opened writable view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be set.
 * @param element_idx The index of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
777
int obi_set_bool_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx, obibool_t value);
778 779 780


/**
781 782
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_BOOL,
 *        using the index of the element in the line, and the column pointer, in the context of a view.
783
 *
784
 * @param view A pointer on the opened view.
785
 * @param column_p A pointer on the column.
786 787 788 789 790 791 792 793 794
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIBool_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
795 796
obibool_t obi_get_bool_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx);

797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812

/**
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_BOOL,
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIBool_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
813
obibool_t obi_get_bool_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx);
814 815 816 817


/**
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_BOOL,
818
 *        using the name of the element in the line, and the column pointer, in the context of a view.
819
 *
820
 * @param view A pointer on the opened writable view.
821
 * @param column_p A pointer on the column.
822 823 824 825 826 827 828 829 830 831 832
 * @param line_nb The number of the line where the value should be set.
 * @param element_name The name of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
833 834 835
int obi_set_bool_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name, obibool_t value);


836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852
/**
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_BOOL,
 *        using the name of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened writable view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be set.
 * @param element_name The name of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
853
int obi_set_bool_with_elt_name_and_column_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name, obibool_t value);
854 855 856 857


/**
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_BOOL,
858
 *        using the name of the element in the line, and the column pointer, in the context of a view.
859
 *
860
 * @param view A pointer on the opened view.
861
 * @param column_p A pointer on the column.
862 863 864 865 866 867 868 869 870
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIBool_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
871 872 873
obibool_t obi_get_bool_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name);


874 875 876 877 878 879 880 881 882 883 884 885 886 887 888
/**
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_BOOL,
 *        using the name of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIBool_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
889
obibool_t obi_get_bool_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name);
890 891 892


/**
893 894
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_CHAR,
 *        using the index of the element in the line, and the column pointer, in the context of a view.
895
 *
896
 *  Note: If the column is read-only or if there is a line selection associated with the view (making columns non-writable), it is cloned.
897
 *
898
 * @param view A pointer on the opened writable view.
899
 * @param column_p A pointer on the column.
900 901 902 903 904 905 906 907 908 909 910
 * @param line_nb The number of the line where the value should be set.
 * @param element_idx The index of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
911 912 913
int obi_set_char_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx, obichar_t value);


914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932
/**
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_CHAR,
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 *  Note: If the column is read-only or if there is a line selection associated with the view (making columns non-writable), it is cloned.
 *
 * @param view A pointer on the opened writable view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be set.
 * @param element_idx The index of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
933
int obi_set_char_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx, obichar_t value);
934 935 936


/**
937 938
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_CHAR,
 *        using the index of the element in the line, and the column pointer, in the context of a view.
939
 *
940
 * @param view A pointer on the opened view.
941
 * @param column_p A pointer on the column.
942 943 944 945 946 947 948 949 950
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIChar_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
951 952 953
obichar_t obi_get_char_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx);


954 955 956 957 958 959 960 961 962 963 964 965 966 967 968
/**
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_CHAR,
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIChar_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
969
obichar_t obi_get_char_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx);
970 971 972 973


/**
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_CHAR,
974
 *        using the name of the element in the line, and the column pointer, in the context of a view.
975
 *
976
 * @param view A pointer on the opened writable view.
977
 * @param column_p A pointer on the column.
978 979 980 981 982 983 984 985 986 987 988
 * @param line_nb The number of the line where the value should be set.
 * @param element_name The name of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
989 990 991
int obi_set_char_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name, obichar_t value);


992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008
/**
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_CHAR,
 *        using the name of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened writable view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be set.
 * @param element_name The name of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1009
int obi_set_char_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name, obichar_t value);
1010 1011 1012 1013


/**
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_CHAR,
1014
 *        using the name of the element in the line, and the column pointer, in the context of a view.
1015
 *
1016
 * @param view A pointer on the opened view.
1017
 * @param column_p A pointer on the column.
1018 1019 1020 1021 1022 1023 1024 1025 1026
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIChar_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1027 1028 1029
obichar_t obi_get_char_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name);


1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044
/**
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_CHAR,
 *        using the name of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIChar_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1045
obichar_t obi_get_char_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name);
1046 1047 1048


/**
1049 1050
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_FLOAT,
 *        using the index of the element in the line, and the column pointer, in the context of a view.
1051
 *
1052
 *  Note: If the column is read-only or if there is a line selection associated with the view (making columns non-writable), it is cloned.
1053
 *
1054
 * @param view A pointer on the opened writable view.
1055
 * @param column_p A pointer on the column.
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066
 * @param line_nb The number of the line where the value should be set.
 * @param element_idx The index of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1067 1068 1069
int obi_set_float_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx, obifloat_t value);


1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088
/**
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_FLOAT,
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 *  Note: If the column is read-only or if there is a line selection associated with the view (making columns non-writable), it is cloned.
 *
 * @param view A pointer on the opened writable view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be set.
 * @param element_idx The index of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1089
int obi_set_float_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx, obifloat_t value);
1090 1091 1092


/**
1093 1094
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_FLOAT,
 *        using the index of the element in the line, and the column pointer, in the context of a view.
1095
 *
1096
 * @param view A pointer on the opened view.
1097
 * @param column_p A pointer on the column.
1098 1099 1100 1101 1102 1103 1104 1105 1106
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIFloat_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1107 1108 1109
obifloat_t obi_get_float_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx);


1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124
/**
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_FLOAT,
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIFloat_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1125
obifloat_t obi_get_float_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx);
1126 1127 1128 1129


/**
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_FLOAT,
1130
 *        using the name of the element in the line, and the column pointer, in the context of a view.
1131
 *
1132
 * @param view A pointer on the opened writable view.
1133
 * @param column_p A pointer on the column.
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
 * @param line_nb The number of the line where the value should be set.
 * @param element_name The name of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1145 1146 1147
int obi_set_float_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name, obifloat_t value);


1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164
/**
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_FLOAT,
 *        using the name of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened writable view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be set.
 * @param element_name The name of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1165
int obi_set_float_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name, obifloat_t value);
1166 1167 1168 1169


/**
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_FLOAT,
1170
 *        using the name of the element in the line, and the column pointer, in the context of a view.
1171
 *
1172
 * @param view A pointer on the opened view.
1173
 * @param column_p A pointer on the column.
1174 1175 1176 1177 1178 1179 1180 1181 1182
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIFloat_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1183 1184 1185
obifloat_t obi_get_float_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name);


1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200
/**
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_FLOAT,
 *        using the name of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIFloat_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1201
obifloat_t obi_get_float_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name);
1202 1203 1204


/**
1205 1206
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_INT,
 *        using the index of the element in the line, and the column pointer, in the context of a view.
1207
 *
1208
 *  Note: If the column is read-only or if there is a line selection associated with the view (making columns non-writable), it is cloned.
1209
 *
1210
 * @param view A pointer on the opened writable view.
1211
 * @param column_p A pointer on the column.
1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222
 * @param line_nb The number of the line where the value should be set.
 * @param element_idx The index of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1223 1224 1225
int obi_set_int_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx, obiint_t value);


1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244
/**
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_INT,
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 *  Note: If the column is read-only or if there is a line selection associated with the view (making columns non-writable), it is cloned.
 *
 * @param view A pointer on the opened writable view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be set.
 * @param element_idx The index of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1245
int obi_set_int_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx, obiint_t value);
1246 1247 1248


/**
1249 1250
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_INT,
 *        using the index of the element in the line, and the column pointer, in the context of a view.
1251
 *
1252
 * @param view A pointer on the opened view.
1253
 * @param column_p A pointer on the column.
1254 1255 1256 1257
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
 *
 * @returns The recovered value.
1258
 * @retval OBIInt_NA the NA value of the type if an error occurred and obi_errno is set.
1259 1260 1261 1262
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1263 1264 1265
obiint_t obi_get_int_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx);


1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280
/**
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_INT,
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIInt_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1281
obiint_t obi_get_int_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx);
1282 1283 1284 1285


/**
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_INT,
1286
 *        using the index of the element in the line, and the column pointer, in the context of a view.
1287
 *
1288
 * @param view A pointer on the opened writable view.
1289
 * @param column_p A pointer on the column.
1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300
 * @param line_nb The number of the line where the value should be set.
 * @param element_name The name of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1301 1302 1303
int obi_set_int_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name, obiint_t value);


1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320
/**
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_INT,
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened writable view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be set.
 * @param element_name The name of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1321
int obi_set_int_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name, obiint_t value);
1322 1323 1324 1325


/**
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_INT,
1326
 *        using the name of the element in the line, and the column pointer, in the context of a view.
1327
 *
1328
 * @param view A pointer on the opened view.
1329
 * @param column_p A pointer on the column.
1330 1331 1332 1333
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
 *
 * @returns The recovered value.
1334
 * @retval OBIInt_NA the NA value of the type if an error occurred and obi_errno is set.
1335 1336 1337 1338
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1339 1340 1341
obiint_t obi_get_int_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name);


1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358
/**
 * @brief Recovers a value in an OBIDMS column containing data with the type OBI_INT,
 *        using the name of the element in the line, and the column name, in the context of a view.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
 *
 * @returns The recovered value.
 * @retval OBIInt_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
obiint_t obi_get_int_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name);

1359

1360 1361
/**
 * @brief Sets a value in an OBIDMS column containing data in the form of indices referring
1362 1363
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the index of the element in the line, and the column pointer, in the context of a view.
1364 1365 1366 1367 1368 1369
 *
 * This function is for qualities in the character string format.
 *
 * @warning Pointers returned by obi_open_column() don't allow writing.
 *
 * @param view A pointer on the opened view.
1370
 * @param column_p A pointer as returned by obi_create_column() or obi_clone_column().
1371 1372 1373
 * @param line_nb The number of the line where the value should be set.
 * @param element_idx The index of the element that should be set in the line.
 * @param value The value that should be set, in the character string format.
1374 1375
 * @param offset The ASCII base of sequence quality, used to convert sequence qualities from characters to integers
 *				 and the other way around.
1376 1377 1378 1379 1380 1381 1382 1383
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since May 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1384
int obi_set_qual_char_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx, const char* value, int offset);
1385 1386


1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400
/**
 * @brief Sets a value in an OBIDMS column containing data in the form of indices referring
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 * This function is for qualities in the character string format.
 *
 * @warning Pointers returned by obi_open_column() don't allow writing.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be set.
 * @param element_idx The index of the element that should be set in the line.
 * @param value The value that should be set, in the character string format.
1401 1402
 * @param offset The ASCII base of sequence quality, used to convert sequence qualities from characters to integers
 *				 and the other way around.
1403 1404 1405 1406 1407 1408 1409 1410
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1411
int obi_set_qual_char_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx, const char* value, int offset);
1412 1413 1414 1415


/**
 * @brief Sets a value in an OBIDMS column containing data in the form of indices referring
1416 1417
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the index of the element in the line, and the column pointer, in the context of a view.
1418
 *
1419
 * This function is for qualities in the integer array format.
1420 1421 1422 1423
 *
 * @warning Pointers returned by obi_open_column() don't allow writing.
 *
 * @param view A pointer on the opened view.
1424
 * @param column_p A pointer as returned by obi_create_column() or obi_clone_column().
1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436
 * @param line_nb The number of the line where the value should be set.
 * @param element_idx The index of the element that should be set in the line.
 * @param value The value that should be set, in the integer array format.
 * @param value_length The length of the integer array.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since May 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1437 1438 1439
int obi_set_qual_int_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx, const uint8_t* value, int value_length);


1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462
/**
 * @brief Sets a value in an OBIDMS column containing data in the form of indices referring
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 * This function is for qualities in the integer array format.
 *
 * @warning Pointers returned by obi_open_column() don't allow writing.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be set.
 * @param element_idx The index of the element that should be set in the line.
 * @param value The value that should be set, in the integer array format.
 * @param value_length The length of the integer array.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1463
int obi_set_qual_int_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx, const uint8_t* value, int value_length);
1464 1465 1466 1467


/**
 * @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
1468 1469
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the index of the element in the line, and the column pointer, in the context of a view.
1470 1471 1472 1473
 *
 * This function returns quality scores in the character string format.
 *
 * @param view A pointer on the opened view.
1474
 * @param column_p A pointer as returned by obi_create_column().
1475 1476
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
1477 1478
 * @param offset The ASCII base of sequence quality, used to convert sequence qualities from characters to integers
 *				 and the other way around.
1479 1480
 *
 * @returns The recovered value, in the character string format.
Celine Mercier committed
1481
 * @retval OBIQual_char_NA the NA value of the type if an error occurred and obi_errno is set.
1482 1483 1484 1485
 *
 * @since May 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1486
char* obi_get_qual_char_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx, int offset);
1487 1488


1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499
/**
 * @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 * This function returns quality scores in the character string format.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
1500 1501
 * @param offset The ASCII base of sequence quality, used to convert sequence qualities from characters to integers
 *				 and the other way around.
1502 1503 1504 1505 1506 1507 1508
 *
 * @returns The recovered value, in the character string format.
 * @retval OBIQual_char_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1509
char* obi_get_qual_char_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx, int offset);
1510 1511 1512 1513


/**
 * @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
1514 1515
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the index of the element in the line, and the column pointer, in the context of a view.
1516
 *
1517
 * This function returns quality scores in the integer array format.
1518 1519
 *
 * @param view A pointer on the opened view.
1520
 * @param column_p A pointer as returned by obi_create_column().
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
 * @param value_length A pointer on an integer to store the length of the integer array recovered.
 *
 * @returns The recovered value, in the integer array format.
 * @retval OBIQual_int_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since May 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1531 1532 1533
const uint8_t* obi_get_qual_int_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx, int* value_length);


1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552
/**
 * @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the index of the element in the line, and the column name, in the context of a view.
 *
 * This function returns quality scores in the integer array format.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_idx The index of the element that should be recovered in the line.
 * @param value_length A pointer on an integer to store the length of the integer array recovered.
 *
 * @returns The recovered value, in the integer array format.
 * @retval OBIQual_int_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1553
const uint8_t* obi_get_qual_int_with_elt_idx_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, index_t element_idx, int* value_length);
1554 1555 1556 1557


/**
 * @brief Sets a value in an OBIDMS column containing data in the form of indices referring
1558 1559
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the name of the element in the line, and the column pointer, in the context of a view.
1560 1561 1562 1563 1564 1565
 *
 * This function is for quality scores in the character string format.
 *
 * @warning Pointers returned by obi_open_column() don't allow writing.
 *
 * @param view A pointer on the opened view.
1566
 * @param column_p A pointer as returned by obi_create_column() or obi_clone_column().
1567 1568 1569
 * @param line_nb The number of the line where the value should be set.
 * @param element_name The name of the element that should be set in the line.
 * @param value The value that should be set, in the character string format.
1570 1571
 * @param offset The ASCII base of sequence quality, used to convert sequence qualities from characters to integers
 *				 and the other way around.
1572 1573 1574 1575 1576 1577 1578 1579
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since May 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1580
int obi_set_qual_char_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name, const char* value, int offset);
1581 1582


1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596
/**
 * @brief Sets a value in an OBIDMS column containing data in the form of indices referring
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the name of the element in the line, and the column name, in the context of a view.
 *
 * This function is for quality scores in the character string format.
 *
 * @warning Pointers returned by obi_open_column() don't allow writing.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be set.
 * @param element_name The name of the element that should be set in the line.
 * @param value The value that should be set, in the character string format.
1597 1598
 * @param offset The ASCII base of sequence quality, used to convert sequence qualities from characters to integers
 *				 and the other way around.
1599 1600 1601 1602 1603 1604 1605 1606
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1607
int obi_set_qual_char_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name, const char* value, int offset);
1608 1609 1610 1611


/**
 * @brief Sets a value in an OBIDMS column containing data in the form of indices referring
1612 1613
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the name of the element in the line, and the column pointer, in the context of a view.
1614 1615 1616 1617 1618 1619
 *
 * This function is for quality scores in the integer array format.
 *
 * @warning Pointers returned by obi_open_column() don't allow writing.
 *
 * @param view A pointer on the opened view.
1620
 * @param column_p A pointer as returned by obi_create_column() or obi_clone_column().
1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632
 * @param line_nb The number of the line where the value should be set.
 * @param element_name The name of the element that should be set in the line.
 * @param value The value that should be set, in the integer format.
 * @param value_length The length of the integer array.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since May 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1633 1634 1635
int obi_set_qual_int_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name, const uint8_t* value, int value_length);


1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658
/**
 * @brief Sets a value in an OBIDMS column containing data in the form of indices referring
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the name of the element in the line, and the column name, in the context of a view.
 *
 * This function is for quality scores in the integer array format.
 *
 * @warning Pointers returned by obi_open_column() don't allow writing.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be set.
 * @param element_name The name of the element that should be set in the line.
 * @param value The value that should be set, in the integer format.
 * @param value_length The length of the integer array.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1659
int obi_set_qual_int_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name, const uint8_t* value, int value_length);
1660 1661 1662 1663


/**
 * @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
1664 1665
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the name of the element in the line, and the column pointer, in the context of a view.
1666 1667 1668 1669
 *
 * This function returns quality scores in the character string format.
 *
 * @param view A pointer on the opened view.
1670
 * @param column_p A pointer as returned by obi_create_column() or obi_clone_column().
1671 1672
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
1673 1674
 * @param offset The ASCII base of sequence quality, used to convert sequence qualities from characters to integers
 *				 and the other way around.
1675 1676
 *
 * @returns The recovered value, in the character string format.
Celine Mercier committed
1677
 * @retval OBIQual_char_NA the NA value of the type if an error occurred and obi_errno is set.
1678 1679 1680 1681
 *
 * @since May 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1682
char* obi_get_qual_char_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name, int offset);
1683 1684


1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695
/**
 * @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the name of the element in the line, and the column name, in the context of a view.
 *
 * This function returns quality scores in the character string format.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
1696 1697
 * @param offset The ASCII base of sequence quality, used to convert sequence qualities from characters to integers
 *				 and the other way around.
1698 1699 1700 1701 1702 1703 1704
 *
 * @returns The recovered value, in the character string format.
 * @retval OBIQual_char_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1705
char* obi_get_qual_char_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name, int offset);
1706 1707 1708 1709


/**
 * @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
1710 1711
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the name of the element in the line, and the column pointer, in the context of a view.
1712 1713 1714 1715
 *
 * This function returns quality scores in the integer array format.
 *
 * @param view A pointer on the opened view.
1716
 * @param column_p A pointer as returned by obi_create_column() or obi_clone_column().
1717 1718 1719 1720 1721 1722 1723 1724 1725 1726
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
 * @param value_length A pointer on an integer to store the length of the integer array recovered.
 *
 * @returns The recovered value, in the integer format.
 * @retval OBIQual_int_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since May 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1727 1728 1729
const uint8_t* obi_get_qual_int_with_elt_name_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, const char* element_name, int* value_length);


1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748
/**
 * @brief Recovers a value in an OBIDMS column containing data in the form of indices referring
 * 		  to sequence qualities handled by an indexer (OBI_QUAL data type),
 *        using the name of the element in the line, and the column name, in the context of a view.
 *
 * This function returns quality scores in the integer array format.
 *
 * @param view A pointer on the opened view.
 * @param column_name The alias of the column in the view.
 * @param line_nb The number of the line where the value should be recovered.
 * @param element_name The name of the element that should be recovered in the line.
 * @param value_length A pointer on an integer to store the length of the integer array recovered.
 *
 * @returns The recovered value, in the integer format.
 * @retval OBIQual_int_NA the NA value of the type if an error occurred and obi_errno is set.
 *
 * @since August 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1749
const uint8_t* obi_get_qual_int_with_elt_name_and_col_name_in_view(Obiview_p view, const char* column_name, index_t line_nb, const char* element_name, int* value_length);
1750 1751


1752
/**
1753 1754
 * @brief Sets a value in an OBIDMS column containing data with the type OBI_SEQ,
 *        using the index of the element in the line, and the column pointer, in the context of a view.
1755
 *
1756
 *  Note: If the column is read-only or if there is a line selection associated with the view (making columns non-writable), it is cloned.
1757
 *
1758
 * @param view A pointer on the opened writable view.
1759
 * @param column_p A pointer on the column.
1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770
 * @param line_nb The number of the line where the value should be set.
 * @param element_idx The index of the element that should be set in the line.
 * @param value The value that should be set.
 *
 * @returns An integer value indicating the success of the operation.
 * @retval 0 on success.
 * @retval -1 if an error occurred.
 *
 * @since February 2016
 * @author Celine Mercier (celine.mercier@metabarcoding.org)
 */
1771 1772 1773
int obi_set_seq_with_elt_idx_and_col_p_in_view(Obiview_p view, OBIDMS_column_p column_p, index_t line_nb, index_t element_idx, const char* value);