3 Copyright (c) 2008 Genome Research Ltd (GRL).
5 Permission is hereby granted, free of charge, to any person obtaining
6 a copy of this software and associated documentation files (the
7 "Software"), to deal in the Software without restriction, including
8 without limitation the rights to use, copy, modify, merge, publish,
9 distribute, sublicense, and/or sell copies of the Software, and to
10 permit persons to whom the Software is furnished to do so, subject to
11 the following conditions:
13 The above copyright notice and this permission notice shall be
14 included in all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 /* Contact: Heng Li <lh3@sanger.ac.uk> */
34 Index FASTA files and extract subsequence.
36 @copyright The Wellcome Trust Sanger Institute.
40 typedef struct __faidx_t faidx_t;
47 @abstract Build index for a FASTA or razip compressed FASTA file.
48 @param fn FASTA file name
49 @discussion File "fn.fai" will be generated.
51 void fai_build(const char *fn);
54 @abstract Distroy a faidx_t struct.
55 @param fai Pointer to the struct to be destroyed
57 void fai_destroy(faidx_t *fai);
60 @abstract Load index from "fn.fai".
61 @param fn File name of the FASTA file
63 faidx_t *fai_load(const char *fn);
66 @abstract Fetch the sequence in a region.
67 @param fai Pointer to the faidx_t struct
68 @param reg Region in the format "chr2:20,000-30,000"
69 @param len Length of the region
70 @return Pointer to the sequence; null on failure
72 @discussion The returned sequence is allocated by malloc family
73 and should be destroyed by end users by calling free() on it.
75 char *fai_fetch(const faidx_t *fai, const char *reg, int *len);