Skip to content

Commit

Permalink
Add HTS_PARSE_* parsing flags [DRAFT]
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarshall committed Aug 26, 2015
1 parent 306664a commit 10e2c7d
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions htslib/hts.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,28 +477,45 @@ hts_idx_t *hts_idx_load2(const char *fn, const char *fnidx);
int hts_idx_get_stat(const hts_idx_t* idx, int tid, uint64_t* mapped, uint64_t* unmapped);
uint64_t hts_idx_get_n_no_coor(const hts_idx_t* idx);

#define HTS_PARSE_THOUSANDS_SEP 1
// ...other parser flags may follow...

/// Parse a numeric string
/** The number may be expressed in scientific notation, and may contain commas
in the integer part (before any decimal point or E notation).
@param str String to be parsed
@param end If non-NULL, set on return to point to the first character
in @a str after those forming the parsed number
@param str String to be parsed
@param strend If non-NULL, set on return to point to the first character
in @a str after those forming the parsed number
@param flags Or'ed-together combination of HTS_PARSE_* flags
@return Converted value of the parsed number.
When @a end is NULL, a warning will be printed (if hts_verbose is 2
or more) if there are any trailing characters after the number.
*/
long long hts_parse_decimal(const char *str, char **end);
long long hts_parse_decimal(const char *str, char **strend, int flags);

/// Parse a "CHR:START-END"-style region string
/** @param str String to be parsed
@param beg Set on return to the 0-based start of the region
@param end Set on return to the 1-based end of the region
@return Pointer to the colon or '\0' after the reference sequence name,
or NULL if @a str could not be parsed.
@note Equivalent to hts_parse_region(str, NULL, beg, end, HTS_PARSE_THOUSANDS_SEP)
*/
const char *hts_parse_reg(const char *str, int *beg, int *end);

/// Parse a "CHR:START-END"-style region string
/** @param str String to be parsed
@param strend If non-NULL, set on return to point to the first character
in @a str after those forming the parsed region
@param beg Set on return to the 0-based start of the region
@param end Set on return to the 1-based end of the region
@param flags Or'ed-together combination of HTS_PARSE_* flags
@return Pointer to the colon or '\0' after the reference sequence name,
or NULL if @a str could not be parsed.
*/
const char *hts_parse_region(const char *str, char **strend, int *beg, int *end, int flags);

hts_itr_t *hts_itr_query(const hts_idx_t *idx, int tid, int beg, int end, hts_readrec_func *readrec);
void hts_itr_destroy(hts_itr_t *iter);

Expand Down

0 comments on commit 10e2c7d

Please sign in to comment.