1 /*=========================================================================== 2 * 3 * PUBLIC DOMAIN NOTICE 4 * National Center for Biotechnology Information 5 * 6 * This software/database is a "United States Government Work" under the 7 * terms of the United States Copyright Act. It was written as part of 8 * the author's official duties as a United States Government employee and 9 * thus cannot be copyrighted. This software/database is freely available 10 * to the public for use. The National Library of Medicine and the U.S. 11 * Government have not placed any restriction on its use or reproduction. 12 * 13 * Although all reasonable efforts have been taken to ensure the accuracy 14 * and reliability of the software and data, the NLM and the U.S. 15 * Government do not and cannot warrant the performance or results that 16 * may be obtained by using this software or data. The NLM and the U.S. 17 * Government disclaim all warranties, express or implied, including 18 * warranties of performance, merchantability or fitness for any particular 19 * purpose. 20 * 21 * Please cite the author in any work or product based on this material. 22 * 23 * =========================================================================== 24 * 25 */ 26 27 #ifndef _h_svdb_ 28 #define _h_svdb_ 29 30 #ifndef _h_svdb_extern_ 31 #include <svdb/extern.h> 32 #endif 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 #define ALL_COLUMNS 0 39 #define STATIC_COLUMNS 1 40 #define NON_STATIC_COLUMNS 2 41 #define VISIBLE_COLUMNS 3 42 #define NON_VISIBLE_COLUMNS 4 43 44 /***************************************************************************** 45 (1) 46 translate an accession into a path ( if possible ) 47 48 returns: NULL, if accession is not an accession 49 path, if the accession is an accession 50 51 ! path has to be free'd by caller ! 52 */ 53 SVDB_EXTERN const char * CC svdb_accession_2_path( const char * accession ); 54 55 56 /***************************************************************************** 57 (2) 58 opens a vdb-object by path ( an accession has to be translated into a path ) 59 60 returns: NULL, if path cannot be opened 61 handle, if the path can be opened ( as db or as table ) 62 63 ! handle has to be closed by caller with svdb_close() ! 64 */ 65 SVDB_EXTERN void * CC svdb_open_path( const char * path ); 66 67 68 /***************************************************************************** 69 (3) 70 closes an open vdb-object 71 72 ! NULL ptr will be ignored ! 73 */ 74 SVDB_EXTERN void CC svdb_close( void * self ); 75 76 77 /***************************************************************************** 78 (4) 79 returns the last error as plain-text if one occured 80 81 ! NULL ptr will be ignored ! 82 returns empty string if no error occured or self == NULL 83 */ 84 SVDB_EXTERN const char * CC svdb_last_err( void ); 85 86 87 /***************************************************************************** 88 (5) 89 returns if the svdb-object is a database 90 91 ! NULL ptr will be ignored ! 92 */ 93 SVDB_EXTERN int CC svdb_is_db( void * self ); 94 95 96 /***************************************************************************** 97 (6) 98 returns how many tables are if the svdb-object 99 100 ! NULL ptr will be ignored ! 101 */ 102 SVDB_EXTERN int CC svdb_count_tabs( void * self ); 103 104 105 /***************************************************************************** 106 (7) 107 returns the name of a table, indexed by tab_id 108 109 ! NULL ptr in self will be ignored ! 110 ! returns NULL if tab_id is out of bounds ! 111 */ 112 SVDB_EXTERN const char * CC svdb_tabname( void * self, const int tab_id ); 113 114 115 /***************************************************************************** 116 (8) 117 returns the index of a table, found by name-lookup 118 119 ! NULL ptr in self will be ignored ! 120 ! returns -1 if the given name is not in the svdb-object ! 121 */ 122 SVDB_EXTERN int CC svdb_tab_idx( void * self, const char * name ); 123 124 125 /***************************************************************************** 126 (9) 127 returns how many columns a table has 128 129 ! NULL ptr in self will be ignored ! 130 ! returns 0 if tab_id is out of bounds ! 131 */ 132 SVDB_EXTERN int CC svdb_count_cols( void * self, const int tab_id, 133 const int selection ); 134 135 136 /***************************************************************************** 137 (10) 138 returns the name of a column in a table 139 140 ! NULL ptr in self will be ignored ! 141 ! returns NULL if tab_id/col_id is out of bounds ! 142 */ 143 SVDB_EXTERN const char * CC svdb_colname( void * self, const int tab_id, 144 const int selection, const int col_id ); 145 146 147 /***************************************************************************** 148 (11) 149 returns the index of a column in a table, found by name-lookup 150 151 ! NULL ptr in self will be ignored ! 152 ! returns -1 if tab_id is out of bounds ! 153 ! returns -1 if the given name is not in the svdb-object ! 154 */ 155 SVDB_EXTERN int CC svdb_col_idx( void * self, const int tab_id, 156 const int selection, const char * name ); 157 158 159 /***************************************************************************** 160 (12) 161 changes the visibility of a column 162 163 ! NULL ptr in self will be ignored ! 164 ! returns 0 if tab_id or col_id is out of bounds ! 165 ! returns 1 if suceessful ! 166 */ 167 SVDB_EXTERN int CC svdb_set_column_visibility( void * self, const int tab_id, 168 const int selection, const int col_id, const int visible ); 169 170 171 /***************************************************************************** 172 (13) 173 returns the index of the default-type of a column in a table 174 175 ! NULL ptr in self will be ignored ! 176 ! returns -1 if tab_id/col_id is out of bounds ! 177 */ 178 SVDB_EXTERN int CC svdb_dflt_type_idx( void * self, const int tab_id, 179 const int selection, const int col_id ); 180 181 182 /***************************************************************************** 183 (14) 184 returns how many types a column in a table has 185 186 ! NULL ptr in self will be ignored ! 187 ! returns 0 if tab_id/col_id is out of bounds ! 188 */ 189 SVDB_EXTERN int CC svdb_count_types( void * self, const int tab_id, 190 const int selection, const int col_id ); 191 192 193 /***************************************************************************** 194 (15) 195 returns the name of the type of a column in a table 196 197 ! NULL ptr in self will be ignored ! 198 ! returns NULL if tab_id/col_id/type_id is out of bounds ! 199 */ 200 SVDB_EXTERN const char * CC svdb_typename( void * self, const int tab_id, 201 const int selection, const int col_id, const int type_id ); 202 203 204 /***************************************************************************** 205 (16) 206 returns the index of a type in a column/table, found by name-lookup 207 208 ! NULL ptr in self will be ignored ! 209 ! returns -1 if tab_id/col_id is out of bounds ! 210 ! returns -1 if the given type is not a type of this column ! 211 */ 212 SVDB_EXTERN int CC svdb_type_idx( void * self, const int tab_id, 213 const int selection, const int col_id, const char * name ); 214 215 216 /***************************************************************************** 217 (17) 218 returns the domain-id of a type of a column in a table 219 220 ! NULL ptr in self will be ignored ! 221 ! returns -1 if tab_id/col_id/type_id is out of bounds ! 222 */ 223 SVDB_EXTERN int CC svdb_typedomain( void * self, const int tab_id, 224 const int selection, const int col_id, const int type_id ); 225 226 227 /***************************************************************************** 228 (18) 229 returns the bitsize of a type of a column in a table 230 231 ! NULL ptr in self will be ignored ! 232 ! returns -1 if tab_id/col_id/type_id is out of bounds ! 233 */ 234 SVDB_EXTERN int CC svdb_typebits( void * self, const int tab_id, 235 const int selection, const int col_id, const int type_id ); 236 237 238 /***************************************************************************** 239 (19) 240 returns the dimensionality of a type of a column in a table 241 242 ! NULL ptr in self will be ignored ! 243 ! returns -1 if tab_id/col_id/type_id is out of bounds ! 244 */ 245 SVDB_EXTERN int CC svdb_typedim( void * self, const int tab_id, 246 const int selection, const int col_id, const int type_id ); 247 248 249 /***************************************************************************** 250 (20) 251 opens a table of a svdb-object 252 253 ! NULL ptr in self will be ignored ! 254 ! returns -1 if tab_id is out of bounds ! 255 NULL or empty string as defline opens all readable columns without a cast 256 defline = "READ,QUALITY" opens only these 2 columns (if the table has them) 257 defline = "(INSDC:2na:bin)READ" opens columns with a cast 258 */ 259 SVDB_EXTERN int CC svdb_open_table( void * self, const int tab_id, 260 const char *defline ); 261 262 263 /***************************************************************************** 264 (21) 265 returns the length of the longest column-name that is enabled 266 267 ! NULL ptr in self will be ignored ! 268 ! returns 0 if tab_id is out of bounds ! 269 */ 270 SVDB_EXTERN int CC svdb_max_colname_length( void * self, const int tab_id, 271 const int selection ); 272 273 274 /***************************************************************************** 275 (22) 276 sets the element-separator-string 277 278 ! NULL ptr in self will be ignored ! 279 tab_id = -1 ... for all tables 280 col_id = -1 ... for all columns 281 s = separator-string to set 282 */ 283 SVDB_EXTERN void CC svdb_set_elem_separator( void * self, const int tab_id, 284 const int selection, const int col_id, const char * s ); 285 286 287 /***************************************************************************** 288 (23) 289 sets the dimension-separator-string 290 291 ! NULL ptr in self will be ignored ! 292 tab_id = -1 ... for all tables 293 col_id = -1 ... for all columns 294 s = separator-string to set 295 */ 296 SVDB_EXTERN void CC svdb_set_dim_separator( void * self, const int tab_id, 297 const int selection, const int col_id, const char * s ); 298 299 300 /***************************************************************************** 301 (24) 302 returns if a column is enabled... 303 304 ! NULL ptr in self will be ignored ! 305 */ 306 SVDB_EXTERN int CC svdb_is_enabled( void * self, const int tab_id, 307 const int selection, const int col_id ); 308 309 310 /***************************************************************************** 311 (25) 312 returns how many rows a table has 313 314 ! NULL ptr in self will be ignored ! 315 ! returns 0 if tab_id is out of bounds ! 316 */ 317 SVDB_EXTERN unsigned long long int CC svdb_row_range( void * self, 318 const int tab_id ); 319 320 321 /***************************************************************************** 322 (26) 323 returns the offset of the first row ( offset to zero ) 324 325 ! NULL ptr in self will be ignored ! 326 ! returns 0 if tab_id is out of bounds ! 327 */ 328 SVDB_EXTERN signed long long int CC svdb_first_row( void * self, 329 const int tab_id ); 330 331 332 /***************************************************************************** 333 (27) 334 returns a data-cell as text 335 336 ! NULL ptr in self/buf will be ignored ! 337 ! returns 0 if tab_id, col_id, row is out of bounds ! 338 returns the numbers of characters written into buf, if successful 339 */ 340 SVDB_EXTERN int CC svdb_cell( void * self, char * buf, int buflen, 341 const int tab_id, const int selection, const int col_id, 342 const unsigned long long int row ); 343 344 345 /***************************************************************************** 346 (28/29) 347 returns the row-number of the row where the pattern was found in col 348 349 ! NULL ptr in self/pattern will be ignored ! 350 ! returns 0xFFFFFFFFFFFFFFFF if tab_id, col_id, row is out of bounds ! 351 ! returns 0xFFFFFFFFFFFFFFFF if pattern not found... ! 352 */ 353 SVDB_EXTERN unsigned long long int CC svdb_find_fwd( void * self, const int tab_id, 354 const int selection, const int col_id, const unsigned long long int row, 355 const int chunksize, const char * pattern ); 356 SVDB_EXTERN unsigned long long int CC svdb_find_bwd( void * self, const int tab_id, 357 const int selection, const int col_id, const unsigned long long int row, 358 const int chunksize, const char * pattern ); 359 360 361 /***************************************************************************** 362 (30) 363 returns a the id of the meta-root-node of a table 364 365 ! NULL ptr in self will be ignored ! 366 ! returns -1 if tab_id is out of bounds, or no metadata found ! 367 */ 368 SVDB_EXTERN int CC svdb_tab_meta_root( void * self, const int tab_id ); 369 370 371 /***************************************************************************** 372 (31) 373 returns the name of a meta-node 374 375 ! NULL ptr in self/buf will be ignored ! 376 ! returns 0 if tab_id, meta_id is out of bounds ! 377 returns the numbers of characters written into buf, if successful 378 */ 379 SVDB_EXTERN int CC svdb_tab_meta_name( void * self, const int tab_id, 380 const int meta_id, char * buf, int buflen ); 381 382 383 /***************************************************************************** 384 (32) 385 returns the length of the value of a meta-node ( in bytes ) 386 387 ! NULL ptr in self will be ignored ! 388 ! returns 0 if tab_id, meta_id is out of bounds ! 389 */ 390 SVDB_EXTERN int CC svdb_tab_meta_value_len( void * self, const int tab_id, 391 const int meta_id ); 392 393 394 /***************************************************************************** 395 (33) 396 returns if the meta-value contains only printable chars 397 398 ! NULL ptr in self will be ignored ! 399 ! returns 0 if tab_id, meta_id is out of bounds ! 400 */ 401 SVDB_EXTERN int CC svdb_tab_meta_value_printable( void * self, 402 const int tab_id, const int meta_id ); 403 404 405 /***************************************************************************** 406 (34) 407 returns a ptr to the meta-node-value 408 409 ! NULL ptr in self will be ignored ! 410 ! returns 0 if tab_id, meta_id is out of bounds ! 411 */ 412 SVDB_EXTERN const char * CC svdb_tab_meta_value_ptr( void * self, const int tab_id, 413 const int meta_id ); 414 415 416 /***************************************************************************** 417 (35) 418 returns the value of a meta-node as ascii-text (this is a guess) 419 420 ! NULL ptr in self/buf will be ignored ! 421 ! returns 0 if tab_id, meta_id is out of bounds ! 422 returns the numbers of characters written into buf, if successful 423 */ 424 SVDB_EXTERN int CC svdb_tab_meta_value( void * self, const int tab_id, 425 const int meta_id, char * buf, int buflen, int trim ); 426 427 428 /***************************************************************************** 429 (36) 430 returns the number of childs of a meta-node 431 432 ! NULL ptr in self will be ignored ! 433 ! returns -1 if tab_id, meta_id is out of bounds ! 434 */ 435 SVDB_EXTERN int CC svdb_tab_meta_child_count( void * self, 436 const int tab_id, const int meta_id ); 437 438 439 /***************************************************************************** 440 (37) 441 returns the id of a meta-node child 442 443 ! NULL ptr in self will be ignored ! 444 ! returns -1 if tab_id, meta_id, child_idx is out of bounds ! 445 */ 446 SVDB_EXTERN int CC svdb_tab_meta_child_id( void * self, const int tab_id, 447 const int meta_id, const int child_idx ); 448 449 450 451 452 453 /***************************************************************************** 454 (38) 455 456 */ 457 SVDB_EXTERN void * CC svdb_open_fastq( const char * path ); 458 459 460 /***************************************************************************** 461 (39) 462 463 */ 464 SVDB_EXTERN void CC svdb_close_fastq( void * self ); 465 466 467 /***************************************************************************** 468 (40) 469 returns what the fastq-obj can produce 470 0 ... nothing, handle invalid 471 1 ... only READ ( that means fasta ) 472 2 ... READ and QUALITY ( but not spot splitting ) 473 3 ... READ, QUALITY and READ_START/READ_LEN ( splitted spots ) 474 */ 475 SVDB_EXTERN int CC svdb_fastq_scope( void * self ); 476 477 478 /***************************************************************************** 479 (41) 480 returns how many reads a fastq-row has 481 */ 482 SVDB_EXTERN int CC svdb_fastq_readcount( void * self, const unsigned long long int row ); 483 484 485 /***************************************************************************** 486 (42) 487 produces a fastq-name ( without the prefix... @/+ ) into a buffer 488 seq ... 0 the whole unsplitted spot 489 seq > 0 the read/part of the spot 1,2 490 returns the number of bytes written 491 */ 492 SVDB_EXTERN int CC svdb_fastq_name( void * self, char * buf, int buflen, 493 int seq, const unsigned long long int row ); 494 495 496 /***************************************************************************** 497 (43) 498 produces a fastq-sequence into a buffer 499 seq ... 0 the whole unsplitted spot 500 seq > 0 the read/part of the spot 1,2 501 returns the number of bytes written 502 */ 503 SVDB_EXTERN int CC svdb_fastq_sequence( void * self, char * buf, int buflen, 504 int seq, const unsigned long long int row ); 505 506 /***************************************************************************** 507 (44) 508 produces a fastq-quality into a buffer 509 seq ... 0 the whole unsplitted spot 510 seq > 0 the read/part of the spot 1,2 511 returns the number of bytes written 512 */ 513 SVDB_EXTERN int CC svdb_fastq_quality( void * self, char * buf, int buflen, 514 int seq, const unsigned long long int row ); 515 516 517 SVDB_EXTERN int CC svdb_fastq_rd_type_available( void * self ); 518 519 SVDB_EXTERN int CC svdb_fastq_rd_filter_available( void * self ); 520 521 SVDB_EXTERN int CC svdb_fastq_read_type_is_bio( void * self, int seq, const unsigned long long int row ); 522 523 SVDB_EXTERN int CC svdb_fastq_read_filter_is_pass( void * self, int seq, const unsigned long long int row ); 524 525 SVDB_EXTERN unsigned long long int CC svdb_fastq_row_count( void * self ); 526 527 #ifdef __cplusplus 528 } 529 #endif 530 531 #endif 532