1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
# slow5_get_rids
## NAME
slow5_get_rids - gets the pointer to the list of read IDs associated with a SLOW5 file
## SYNOPSYS
`char **slow5_get_rids(const slow5_file_t *s5p, uint64_t *len)`
## DESCRIPTION
`slow5_get_rids()` gets the pointer to the list of read IDs associated with a SLOW5 file pointed by *s5p*. The SLOW5 index should have been already loaded before by calling `slow5_idx_load()`.
The number of reads will be set on the address specified by *len*.
## RETURN VALUE
Upon successful completion, `slow5_get_rids()` returns a *char*** pointer. Otherwise, a negative value is returned that indicates the error and `slow5_errno` is set to indicate the error.
## ERRORS
* `SLOW5_ERR_NOIDX`
SLOW5 index has not been loaded.
* `SLOW5_ERR_OTH`:
Other error.
## NOTES
`slow5_get_rids()` returns the list of read IDs stored in the index. Thus, returned pointer is from an internal data structure and must NOT be freed by user.
## EXAMPLES
```
#include <stdio.h>
#include <stdlib.h>
#include <slow5/slow5.h>
#define FILE_PATH "examples/example.slow5"
int main(){
slow5_file_t *sp = slow5_open(FILE_PATH,"r");
if(sp==NULL){
fprintf(stderr,"Error in opening file\n");
exit(EXIT_FAILURE);
}
int ret=0;
ret = slow5_idx_load(sp);
if(ret<0){
fprintf(stderr,"Error in loading index\n");
exit(EXIT_FAILURE);
}
uint64_t num_reads = 0;
char **read_ids = slow5_get_rids(sp, &num_reads);
if(read_ids==NULL){
fprintf(stderr,"Error in getting list of read IDs\n");
exit(EXIT_FAILURE);
}
for(uint64_t i=0; i<num_reads; i++) {
printf("%s\n",read_ids[i]);
}
slow5_idx_unload(sp);
slow5_close(sp);
}
```
## SEE ALSO
[slow5_idx_load()](../slow5_idx_load.md)
|