]> git.donarmstrong.com Git - samtools.git/commitdiff
* samtools-0.1.6-2 (r458)
authorHeng Li <lh3@live.co.uk>
Mon, 7 Sep 2009 09:10:28 +0000 (09:10 +0000)
committerHeng Li <lh3@live.co.uk>
Mon, 7 Sep 2009 09:10:28 +0000 (09:10 +0000)
 * added more interface to faidx (by Nils)
 * updated documentation

bamtk.c
faidx.c
faidx.h
samtools.1

diff --git a/bamtk.c b/bamtk.c
index 8db8bcb30b368fde4351c72cbada5f5984d8b410..97f65607d9969e74004a204fc73d0ca22f7244a2 100644 (file)
--- a/bamtk.c
+++ b/bamtk.c
@@ -9,7 +9,7 @@
 #endif
 
 #ifndef PACKAGE_VERSION
-#define PACKAGE_VERSION "0.1.6-2 (r457)"
+#define PACKAGE_VERSION "0.1.6-3 (r458)"
 #endif
 
 int bam_taf2baf(int argc, char *argv[]);
diff --git a/faidx.c b/faidx.c
index 055445f266cbdb429fe65c2aeb58c763af86d1d9..77adbde781d393ff09d264e05385b347aa22090c 100644 (file)
--- a/faidx.c
+++ b/faidx.c
@@ -323,6 +323,40 @@ int faidx_main(int argc, char *argv[])
        return 0;
 }
 
+int faidx_fetch_nseq(const faidx_t *fai) 
+{
+       return fai->n;
+}
+
+char *faidx_fetch_seq(const faidx_t *fai, char *c_name, int p_beg_i, int p_end_i, int *len)
+{
+       int l;
+       char c;
+    khiter_t iter;
+    faidx1_t val;
+       char *seq=NULL;
+
+    // Adjust position
+    iter = kh_get(s, fai->hash, c_name);
+    if(iter == kh_end(fai->hash)) return 0;
+    val = kh_value(fai->hash, iter);
+       if(p_end_i < p_beg_i) p_beg_i = p_end_i;
+    if(p_beg_i < 0) p_beg_i = 0;
+    else if(val.len <= p_beg_i) p_beg_i = val.len - 1;
+    if(p_end_i < 0) p_end_i = 0;
+    else if(val.len <= p_end_i) p_end_i = val.len - 1;
+
+    // Now retrieve the sequence 
+       l = 0;
+       seq = (char*)malloc(p_end_i - p_beg_i + 2);
+       razf_seek(fai->rz, val.offset + p_beg_i / val.line_blen * val.line_len + p_beg_i % val.line_blen, SEEK_SET);
+       while (razf_read(fai->rz, &c, 1) == 1 && l < p_end_i - p_beg_i + 1)
+               if (isgraph(c)) seq[l++] = c;
+       seq[l] = '\0';
+       *len = l;
+       return seq;
+}
+
 #ifdef FAIDX_MAIN
 int main(int argc, char *argv[]) { return faidx_main(argc, argv); }
 #endif
diff --git a/faidx.h b/faidx.h
index 1a52fb7eb73afc36529c263061c93c46cc525217..1fb1b1fcfab22385f3463c2138fcf1bf6533fef8 100644 (file)
--- a/faidx.h
+++ b/faidx.h
@@ -75,6 +75,27 @@ extern "C" {
         */
        char *fai_fetch(const faidx_t *fai, const char *reg, int *len);
 
+       /*!
+         @abstract        Fetch the number of sequences. 
+         @param  fai  Pointer to the faidx_t struct
+         @return          The number of sequences
+        */
+       int faidx_fetch_nseq(const faidx_t *fai);
+
+       /*!
+         @abstract    Fetch the sequence in a region.
+         @param  fai  Pointer to the faidx_t struct
+         @param  c_name Region name
+         @param  p_beg_i  Beginning position number (zero-based)
+         @param  p_end_i  End position number (zero-based)
+         @param  len  Length of the region
+         @return      Pointer to the sequence; null on failure
+
+         @discussion The returned sequence is allocated by malloc family
+         and should be destroyed by end users by calling free() on it.
+        */
+       char *faidx_fetch_seq(const faidx_t *fai, char *c_name, int p_beg_i, int p_end_i, int *len);
+
 #ifdef __cplusplus
 }
 #endif
index d2c78f1b32aeb00f4487f7944122ef9c7f5d596d..0108fdc72554e1f03d9a4dc32512f6fe3f572817 100644 (file)
@@ -220,14 +220,16 @@ mapping quality. A symbol `$' marks the end of a read segment.
 
 If option
 .B -c
-is applied, the consensus base, consensus quality, SNP quality and RMS
-mapping quality of the reads covering the site will be inserted between
-the `reference base' and the `read bases' columns. An indel occupies an
-additional line. Each indel line consists of chromosome name,
-coordinate, a star, the genotype, consensus quality, SNP quality, RMS
-mapping quality, # covering reads, the first alllele, the second allele,
-# reads supporting the first allele, # reads supporting the second
-allele and # reads containing indels different from the top two alleles.
+is applied, the consensus base, Phred-scaled consensus quality, SNP
+quality (i.e. the Phred-scaled probability of the consensus being
+identical to the reference) and root mean square (RMS) mapping quality
+of the reads covering the site will be inserted between the `reference
+base' and the `read bases' columns. An indel occupies an additional
+line. Each indel line consists of chromosome name, coordinate, a star,
+the genotype, consensus quality, SNP quality, RMS mapping quality, #
+covering reads, the first alllele, the second allele, # reads supporting
+the first allele, # reads supporting the second allele and # reads
+containing indels different from the top two alleles.
 
 .B OPTIONS:
 .RS