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
|
# slow5_hdr_add
## NAME
slow5_hdr_add - adds a new header data attribute to a SLOW5 header
## SYNOPSYS
`int slow5_hdr_add(const char *attr, slow5_hdr_t *header);`
## DESCRIPTION
`slow5_hdr_add()` add a new attribute name *attr* to a SLOW5 file header pointed by *header*.
The argument *header* points to a SLOW5 header of type *slow5_hdr_t* and typically this is the *s5p->header* member inside the *slow5_file_t \*s5p* returned by `slow5_open()`.
## RETURN VALUE
Upon successful completion, `slow5_hdr_add()` returns a non negative integer (>=0). Otherwise, a negative value is returned that indicates the error.
## ERRORS
A negative returned when an error occurs and can be due to following occasions (not an exhaustive list):
- if an input argument is NULL
- if the attribute already exists
- if internal error
## NOTES
In the future `slow5_errno` will be set to indicate the error.
## EXAMPLES
```
#include <stdio.h>
#include <stdlib.h>
#include <slow5/slow5.h>
#define FILE_PATH "test.slow5"
int main(){
slow5_file_t *sp = slow5_open(FILE_PATH, "w");
if(sp==NULL){
fprintf(stderr,"Error opening file!\n");
exit(EXIT_FAILURE);
}
slow5_hdr_t* header = sp->header;
//add a header group attribute called run_id
if (slow5_hdr_add("run_id", header) < 0){
fprintf(stderr,"Error adding run_id attribute\n");
exit(EXIT_FAILURE);
}
//add another header group attribute called asic_id
if (slow5_hdr_add("asic_id", header) < 0){
fprintf(stderr,"Error adding asic_id attribute\n");
exit(EXIT_FAILURE);
}
//....
}
```
|