diff --git a/README.md b/README.md index 54182496..b6a3f3a7 100644 --- a/README.md +++ b/README.md @@ -609,6 +609,10 @@ ulimit -n 2000 ## Version history +### 0.3.0 +* The problem with `fragment_4dnpairs.pl` of adding an extra column is now fixed. +* Fixed bug with 1D querying on 2D data. + ### 0.2.9 * `pairix` can now take 1D query for 2D data. e.g.) `pairix file.gz 'chr22:50000-60000'` is equivalent to `pairix file.gz 'chr22:50000-60000|chr22:50000-60000'` if file.gz is 2D indexed. @@ -616,7 +620,7 @@ ulimit -n 2000 * `pairix` now has option `-a` (autoflip) that flips the query in case the matching chromosome pair doesn't exist in the file. * `pairix` now has option `-W` that prints out region split character use for indexing a specific file. * `merge-pairs.sh` is now included in `util`. -* ~`pairix` can now take 1D query for 2D data. e.g.) `pairix file.gz 'chr22:50000-60000'` is equivalent to `pairix file.gz 'chr22:50000-60000|chr22:50000-60000'` if file.gz is 2D indexed.~  This one currently does not work. +* ~`pairix` can now take 1D query for 2D data. e.g.) `pairix file.gz 'chr22:50000-60000'` is equivalent to `pairix file.gz 'chr22:50000-60000|chr22:50000-60000'` if file.gz is 2D indexed.~  This one currently does not work. ### 0.2.6 * Two utils are added: `duplicate_header_remover.pl` and `column_remover.pl` for pairs file format correction. diff --git a/VERSION.txt b/VERSION.txt index 1866a362..0d91a54c 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.2.9 +0.3.0 diff --git a/src/pairix.h b/src/pairix.h index 387eb0f8..54cc8aba 100644 --- a/src/pairix.h +++ b/src/pairix.h @@ -28,7 +28,7 @@ #ifndef __TABIDX_H #define __TABIDX_H -#define PACKAGE_VERSION "0.2.9" +#define PACKAGE_VERSION "0.3.0" #include #include "kstring.h" diff --git a/test/test.py b/test/test.py index 58202f33..576f166a 100755 --- a/test/test.py +++ b/test/test.py @@ -18,7 +18,7 @@ 4DN: chr1[1] pos1[2] chr2[3] pos2[4] """ - +from __future__ import unicode_literals import unittest import gzip import sys @@ -150,17 +150,17 @@ def get_result(regions, chrom, start, end): def get_result_2D(regions, chrom, start, end, chrom2, start2, end2): retval = [] - for r in regions: - if r[0] == chrom and overlap1(r[1], r[2], start, end) and r[3] == chrom2 and overlap1(r[4], r[5], start2, end2): - retval.append(r) + for reg in regions: + if reg[0] == chrom and overlap1(reg[1], reg[2], start, end) and reg[3] == chrom2 and overlap1(reg[4], reg[5], start2, end2): + retval.append(reg) return retval -def get_result_2D_4DN(regions, chrom, start, end, chrom2, start2, end2): +def get_result_1D_on_2D(regions, chrom, start, end, chrom2, start2, end2): retval = [] - for r in regions: - if r[1] == chrom and overlap1(r[2], r[2], start, end) and r[3] == chrom2 and overlap1(r[4], r[4], start2, end2): - retval.append(r) + for reg in regions: + if reg[0] == chrom and overlap1(reg[2], reg[2], start, end) and reg[3] == chrom2 and overlap1(reg[4], reg[4], start2, end2): + retval.append(reg) return retval @@ -409,7 +409,7 @@ class PairixTest_1_on_2(unittest.TestCase): chrom2 = chrom start2 = start end2 = end - result = get_result_2D_4DN(regions, chrom, start, end, chrom2, 0, sys.maxsize) + result = get_result_1D_on_2D(regions, chrom, start, end, chrom2, start2, end2) pr = pypairix.open(TEST_FILE_2D_4DN_2) def test_querys(self): diff --git a/util/fragment_4dnpairs.pl b/util/fragment_4dnpairs.pl index d0537d2f..cd1388fb 100755 --- a/util/fragment_4dnpairs.pl +++ b/util/fragment_4dnpairs.pl @@ -91,11 +91,11 @@ elsif($headers[$i] eq 'frag2') { $frag2_colindex=$i-1; } } print STDERR "$frag1_colindex, $frag2_colindex\n"; # Soo - if($frag1_colindex == -1) { $frag1_colindex=$#headers+1; print OUTFILE "$_ frag1\n"; next; } - elsif($frag2_colindex == -1) { $frag2_colindex=$#headers+1; print OUTFILE "$_ frag2\n"; next; } + if($frag1_colindex == -1) { $frag1_colindex=$#headers; print OUTFILE "$_ frag1\n"; next; } + elsif($frag2_colindex == -1) { $frag2_colindex=$#headers; print OUTFILE "$_ frag2\n"; next; } else { print OUTFILE "$_\n"; next; } } - else { $frag1_colindex=$#headers+1; $frag2_colindex=$#headers+2; print OUTFILE "$_ frag1 frag2\n"; next; } + else { $frag1_colindex=$#headers; $frag2_colindex=$#headers+1; print OUTFILE "$_ frag1 frag2\n"; next; } } elsif(/^#/) { print OUTFILE "$_\n"; next; } my @original_record = split;