Imported Upstream version 0.2.2
authorCharles Plessy <plessy@debian.org>
Thu, 19 Aug 2010 06:49:52 +0000 (15:49 +0900)
committerCharles Plessy <plessy@debian.org>
Thu, 19 Aug 2010 06:49:52 +0000 (15:49 +0900)
NEWS
TabixReader.java
index.c
main.c

diff --git a/NEWS b/NEWS
index eac654c4cc61d5f5b0ba449e863e351ec4051b82..a6f3c707e8f91cb1c15704f11c24a301a9677005 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,16 @@
+Beta Release 0.2.2 (28 June, 2010)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Notable changes:
+
+ * Dropped the VCF3 support. Added VCF4 support.
+
+ * Avoided the function name collision with samtools.
+
+(0.2.2: 28 June 2010, r603)
+
+
+
 Beta Release 0.2.1 (3 June, 2010)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
index 752f71c930daa53ec6801358ec19e50064cc2233..40d395120e4df26cbf04a7667fba2775a921a05b 100644 (file)
@@ -226,7 +226,7 @@ public class TabixReader
        private TIntv getIntv(final String s) {
                TIntv intv = new TIntv();
                int col = 0, end = 0, beg = 0;
-               while ((end = s.indexOf('\t', beg)) >= 0) {
+               while ((end = s.indexOf('\t', beg)) >= 0 || end == -1) {
                        ++col;
                        if (col == mSc) {
                                intv.tid = chr2tid(s.substring(beg, end));
@@ -236,7 +236,7 @@ public class TabixReader
                                else --intv.beg;
                                if (intv.beg < 0) intv.beg = 0;
                                if (intv.end < 1) intv.end = 1;
-                       } else { // FIXME: SAM/VCF supports are not tested yet
+                       } else { // FIXME: SAM supports are not tested yet
                                if ((mPreset&0xffff) == 0) { // generic
                                        if (col == mEc)
                                                intv.end = Integer.parseInt(s.substring(beg, end));
@@ -254,22 +254,25 @@ public class TabixReader
                                                intv.end = intv.beg + l;
                                        }
                                } else if ((mPreset&0xffff) == 2) { // VCF
-                                       if (col == 5) {
-                                               String alt = s.substring(beg, end);
-                                               int i, max = 1;
-                                               for (i = 0; i < alt.length(); ++i) {
-                                                       if (alt.charAt(i) == 'D') { // deletion
-                                                               int j;
-                                                           for (j = i; j < alt.length() && alt.charAt(j) >= '0' && alt.charAt(j) <= '9'; ++j);
-                                                               int l = Integer.parseInt(alt.substring(i, j));
-                                                               if (max < l) max = l;
-                                                               i = j - 1;
-                                                       }
+                                       String alt;
+                                       alt = end >= 0? s.substring(beg, end) : s.substring(beg);
+                                       if (col == 4) { // REF
+                                               if (alt.length() > 0) intv.end = intv.beg + alt.length();
+                                       } else if (col == 8) { // INFO
+                                               int e_off = -1, i = alt.indexOf("END=");
+                                               if (i == 0) e_off = 4;
+                                               else if (i > 0) {
+                                                       i = alt.indexOf(";END=");
+                                                       if (i >= 0) e_off = i + 5;
+                                               }
+                                               if (e_off > 0) {
+                                                       i = alt.indexOf(";", e_off);
+                                                       intv.end = Integer.parseInt(i > e_off? alt.substring(e_off, i) : alt.substring(e_off));
                                                }
-                                               intv.end = intv.beg + max;
                                        }
                                }
                        }
+                       if (end == -1) break;
                        beg = end + 1;
                }
                return intv;
diff --git a/index.c b/index.c
index e5b227c1466eea9d8be901020ffc2726dc33cc9e..8eddcecb34bab21f8d4f6de7a88639f8c67d0358 100644 (file)
--- a/index.c
+++ b/index.c
@@ -19,7 +19,7 @@ typedef struct {
 } pair64_t;
 
 #define pair64_lt(a,b) ((a).u < (b).u)
-KSORT_INIT(off, pair64_t, pair64_lt)
+KSORT_INIT(offt, pair64_t, pair64_lt)
 
 typedef struct {
        uint32_t m, n;
@@ -192,17 +192,19 @@ static int get_intv(ti_index_t *idx, kstring_t *str, ti_intv_t *intv)
                                        }
                                } else if ((idx->conf.preset&0xffff) == TI_PRESET_VCF) {
                                        // FIXME: the following is NOT tested and is likely to be buggy
-                                       if (id == 5) { // ALT
-                                               char *t;
-                                               int max = 1;
-                                               for (s = str->s + b; s < str->s + i;) {
-                                                       if (s[i] == 'D') {
-                                                               long x = strtol(s + 1, &t, 10);
-                                                               if (x > max) max = x;
-                                                               s = t + 1;
-                                                       } else ++s;
+                                       if (id == 4) {
+                                               if (b < i) intv->end = intv->beg + (i - b);
+                                       } else if (id == 8) { // look for "END="
+                                               int c = str->s[i];
+                                               str->s[i] = 0;
+                                               s = strstr(str->s + b, "END=");
+                                               if (s == str->s + b) s += 4;
+                                               else if (s) {
+                                                       s = strstr(str->s + b, ";END=");
+                                                       if (s) s += 5;
                                                }
-                                               intv->end = intv->beg + max;
+                                               if (s) intv->end = strtol(s, &s, 0);
+                                               str->s[i] = c;
                                        }
                                }
                        }
@@ -804,7 +806,7 @@ ti_iter_t ti_iter_query(const ti_index_t *idx, int tid, int beg, int end)
        free(bins);
        {
                int l;
-               ks_introsort(off, n_off, off);
+               ks_introsort(offt, n_off, off);
                // resolve completely contained adjacent blocks
                for (i = 1, l = 0; i < n_off; ++i)
                        if (off[l].v < off[i].v)
diff --git a/main.c b/main.c
index 79c37083d444016b651d03ea8408988df2282ab6..84e5cfc6c66a49e8b5406275e07cc6948e900694 100644 (file)
--- a/main.c
+++ b/main.c
@@ -6,7 +6,7 @@
 #include "bgzf.h"
 #include "tabix.h"
 
-#define PACKAGE_VERSION "0.2.1 (r582)"
+#define PACKAGE_VERSION "0.2.2 (r603)"
 
 int main(int argc, char *argv[])
 {
@@ -21,7 +21,7 @@ int main(int argc, char *argv[])
                        if (strcmp(optarg, "gff") == 0) conf = ti_conf_gff;
                        else if (strcmp(optarg, "bed") == 0) conf = ti_conf_bed;
                        else if (strcmp(optarg, "sam") == 0) conf = ti_conf_sam;
-                       else if (strcmp(optarg, "vcf") == 0) conf = ti_conf_vcf;
+                       else if (strcmp(optarg, "vcf") == 0 || strcmp(optarg, "vcf4") == 0) conf = ti_conf_vcf;
                        else if (strcmp(optarg, "psltbl") == 0) conf = ti_conf_psltbl;
                        else {
                                fprintf(stderr, "[main] unrecognized preset '%s'\n", optarg);