NVBIO
|
Go to the source code of this file.
Macros | |
#define | K(a) (((a)[0]<<8)|((a)[1])) |
#define K | ( | a) | (((a)[0]<<8)|((a)[1])) |
Definition at line 746 of file sam_header.c.
Adds a single line to a SAM header.
Specify type and one or more key,value pairs, ending with the NULL key. Eg. sam_hdr_add(h, "SQ", "ID", "foo", "LN", "100", NULL).
Definition at line 416 of file sam_header.c.
Appends a formatted line to an existing SAM header.
Line is a full SAM header record, eg "@SQ\tSN:foo\tLN:100", with optional new-line. If it contains more than 1 line then multiple lines will be added in order.
Len is the length of the text data, or 0 if unknown (in which case it should be null terminated).
Definition at line 276 of file sam_header.c.
Add an line.
If we wish complete control over this use sam_hdr_add() directly. This function uses that, but attempts to do a lot of tedious house work for you too.
Call it as per sam_hdr_add() with a series of key,value pairs ending in NULL.
Definition at line 1147 of file sam_header.c.
void sam_hdr_decr_ref | ( | SAM_hdr * | hdr) |
Increments a reference count on hdr.
This permits multiple files to share the same header, all calling sam_hdr_free when done, without causing errors for other open files.
If the reference count hits zero then the header is automatically freed. This makes it a synonym for sam_hdr_free().
Definition at line 948 of file sam_header.c.
void sam_hdr_dump | ( | SAM_hdr * | hdr) |
Definition at line 53 of file sam_header.c.
Produces a duplicate copy of hdr and returns it.
Definition at line 924 of file sam_header.c.
SAM_hdr_type* sam_hdr_find | ( | SAM_hdr * | hdr, |
char * | type, | ||
char * | ID_key, | ||
char * | ID_value | ||
) |
Returns NULL if no type/ID is found
Definition at line 565 of file sam_header.c.
SAM_hdr_tag* sam_hdr_find_key | ( | SAM_hdr * | sh, |
SAM_hdr_type * | type, | ||
char * | key, | ||
SAM_hdr_tag ** | prev | ||
) |
Looks for a specific key in a single sam header line.
If prev is non-NULL it also fills this out with the previous tag, to permit use in key removal. *prev is set to NULL when the tag is the first key in the list. When a tag isn't found, prev (if non NULL) will be the last tag in the existing list.
Definition at line 672 of file sam_header.c.
char* sam_hdr_find_line | ( | SAM_hdr * | hdr, |
char * | type, | ||
char * | ID_key, | ||
char * | ID_value | ||
) |
As per SAM_hdr_type, but returns a complete line of formatted text for a specific head type/ID combination. If ID is NULL then it returns the first line of the specified type.
The returned string is malloced and should be freed by the calling function with free().
Definition at line 635 of file sam_header.c.
Looks up a read-group by name and returns a pointer to the start of the associated tag list.
Definition at line 1044 of file sam_header.c.
void sam_hdr_free | ( | SAM_hdr * | hdr) |
Deallocates all storage used by a SAM_hdr struct.
This also decrements the header reference count. If after decrementing it is still non-zero then the header is assumed to be in use by another caller and the free is not done.
This is a synonym for sam_hdr_dec_ref().
Definition at line 960 of file sam_header.c.
void sam_hdr_incr_ref | ( | SAM_hdr * | hdr) |
Increments a reference count on hdr.
This permits multiple files to share the same header, all calling sam_hdr_free when done, without causing errors for other open files.
Definition at line 936 of file sam_header.c.
int sam_hdr_length | ( | SAM_hdr * | hdr) |
Returns the current length of the SAM_hdr in text form.
Call sam_hdr_rebuild() first if editing has taken place.
Definition at line 1021 of file sam_header.c.
int sam_hdr_link_pg | ( | SAM_hdr * | hdr) |
Fixes any PP links in headers.
If the entries are in order then this doesn't need doing, but incase our header is out of order this goes through the sh->pg[] array setting the prev_id field.
Definition at line 1065 of file sam_header.c.
Looks up a reference sequence by name and returns the numerical ID.
Definition at line 1033 of file sam_header.c.
SAM_hdr* sam_hdr_new | ( | void | ) |
Creates an empty SAM header, ready to be populated.
Definition at line 822 of file sam_header.c.
Tokenises a SAM header into a hash table.
Also extracts a few bits on specific data types, such as lines.
Definition at line 891 of file sam_header.c.
Definition at line 1118 of file sam_header.c.
int sam_hdr_rebuild | ( | SAM_hdr * | hdr) |
Reconstructs the kstring from the header hash table.
Definition at line 753 of file sam_header.c.
char* sam_hdr_str | ( | SAM_hdr * | hdr) |
Returns the string form of the SAM_hdr.
Call sam_hdr_rebuild() first if editing has taken place.
Definition at line 1025 of file sam_header.c.
int sam_hdr_update | ( | SAM_hdr * | hdr, |
SAM_hdr_type * | type, | ||
... | |||
) |
Adds or updates tag key,value pairs in a header line.
Eg for adding M5 tags to lines or updating sort order for the line (although use the sam_hdr_sort_order() function for HD manipulation, which is a wrapper around this funuction).
Specify multiple key,value pairs ending in NULL.
Definition at line 704 of file sam_header.c.
Adds a single line to a SAM header.
This is much like sam_hdr_add() but with the additional va_list argument. This is followed by specifying type and one or more key,value pairs, ending with the NULL key.
Eg. sam_hdr_vadd(h, "SQ", args, "ID", "foo", "LN", "100", NULL).
The purpose of the additional va_list parameter is to permit other varargs functions to call this while including their own additional parameters; an example is in sam_hdr_add_PG().
Definition at line 422 of file sam_header.c.
char* stringify_argv | ( | int | argc, |
char * | argv[] | ||
) |
A function to help with construction of CL tags in records. Takes an argc, argv pair and returns a single space-separated string. This string should be deallocated by the calling function.
Definition at line 1194 of file sam_header.c.