annotate PsiCLASS-1.0.2/samtools-0.1.19/sam_header.h @ 0:903fc43d6227 draft default tip

Uploaded
author lsong10
date Fri, 26 Mar 2021 16:52:45 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
1 #ifndef __SAM_HEADER_H__
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
2 #define __SAM_HEADER_H__
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
3
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
4 #ifdef __cplusplus
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
5 extern "C" {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
6 #endif
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
7
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
8 void *sam_header_parse2(const char *headerText);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
9 void *sam_header_merge(int n, const void **dicts);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
10 void sam_header_free(void *header);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
11 char *sam_header_write(const void *headerDict); // returns a newly allocated string
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
12
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
13 /*
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
14 // Usage example
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
15 const char *key, *val;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
16 void *iter = sam_header_parse2(bam->header->text);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
17 while ( iter = sam_header_key_val(iter, "RG","ID","SM" &key,&val) ) printf("%s\t%s\n", key,val);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
18 */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
19 void *sam_header2key_val(void *iter, const char type[2], const char key_tag[2], const char value_tag[2], const char **key, const char **value);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
20 char **sam_header2list(const void *_dict, char type[2], char key_tag[2], int *_n);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
21
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
22 /*
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
23 // Usage example
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
24 int i, j, n;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
25 const char *tags[] = {"SN","LN","UR","M5",NULL};
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
26 void *dict = sam_header_parse2(bam->header->text);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
27 char **tbl = sam_header2tbl_n(h->dict, "SQ", tags, &n);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
28 for (i=0; i<n; i++)
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
29 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
30 for (j=0; j<4; j++)
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
31 if ( tbl[4*i+j] ) printf("\t%s", tbl[4*i+j]);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
32 else printf("-");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
33 printf("\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
34 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
35 if (tbl) free(tbl);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
36 */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
37 char **sam_header2tbl_n(const void *dict, const char type[2], const char *tags[], int *n);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
38
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
39 void *sam_header2tbl(const void *dict, char type[2], char key_tag[2], char value_tag[2]);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
40 const char *sam_tbl_get(void *h, const char *key);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
41 int sam_tbl_size(void *h);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
42 void sam_tbl_destroy(void *h);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
43
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
44 #ifdef __cplusplus
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
45 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
46 #endif
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
47
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
48 #endif