Skip to content

Commit a0ee4cd

Browse files
committed
new index
1 parent 8481aef commit a0ee4cd

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: Rpairix
22
Title: Rpairix
3-
Version: 0.1.5
3+
Version: 0.1.6
44
Authors@R: person("Soo", "Lee", email = "duplexa@gmail.com", role = c("aut", "cre"))
55
Description: R binder for pairix, tool for querying a pair of genomic ranges in a pairs file (pairix-indexed bgzipped text file)
66
Depends:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,10 @@ Individual R functions are written and documented in `R/`. The `src/rpairixlib.c
312312

313313
## Version history
314314
### 0.1.6
315-
* `px_query` : input query can be a GInteractions object or a list of GRanges objects. Argument 'querystr' is now 'query'.
315+
* The index is now consistent with the new index adopted by pairix/pypairix 0.1.7. Re-index for older files.
316316

317317
### 0.1.5
318+
* `px_query` : input query can be a GInteractions object or a list of GRanges objects. Argument 'querystr' is now 'query'.
318319
* `px_query` : wild card (\*) in a query now allowed (queries like 'chr11|\*' or '\*|chr2:1-20000' possible. '\*' means whole genome.
319320
* `px_exists` and `px_exists2` now returns TRUE/FALSE instead of 1/0.
320321
* Function `px_colnames` is added (identical to `px_get_column_names`)

Rpairix.Rproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Version: 0.1.5
1+
Version: 0.1.6
22

33
RestoreWorkspace: No
44
SaveWorkspace: No

src/index.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ void ti_index_save(const ti_index_t *idx, BGZF *fp)
467467
int32_t i, size, ti_is_be;
468468
khint_t k;
469469
ti_is_be = bam_is_big_endian();
470-
bgzf_write(fp, "TBI\1", 4);
470+
bgzf_write(fp, "PX2\1", 4);
471471
if (ti_is_be) {
472472
uint32_t x = idx->n;
473473
bgzf_write(fp, bam_swap_endian_4p(&x), 4);
@@ -552,8 +552,8 @@ static ti_index_t *ti_index_load_core(BGZF *fp)
552552
return 0;
553553
}
554554
bgzf_read(fp, magic, 4);
555-
if (strncmp(magic, "TBI\1", 4)) {
556-
fprintf(stderr, "[ti_index_load] wrong magic number.\n");
555+
if (strncmp(magic, "PX2\1", 4)) {
556+
fprintf(stderr, "[ti_index_load] wrong magic number. Re-index if your index file was created by an earlier version of pairix.\n");
557557
return 0;
558558
}
559559
idx = (ti_index_t*)calloc(1, sizeof(ti_index_t));
@@ -687,7 +687,7 @@ static void download_from_remote(const char *url)
687687

688688
static char *get_local_version(const char *fn)
689689
{
690-
struct stat sbuf;
690+
struct stat sbuf;
691691
char *fnidx = (char*)calloc(strlen(fn) + 5, 1);
692692
strcat(strcpy(fnidx, fn), ".px2");
693693
if ((strstr(fnidx, "ftp://") == fnidx || strstr(fnidx, "http://") == fnidx)) {
@@ -704,8 +704,9 @@ static char *get_local_version(const char *fn)
704704
download_from_remote(url);
705705
free(url);
706706
}
707-
if (stat(fnidx, &sbuf) == 0) return fnidx;
708-
free(fnidx); return 0;
707+
if (stat(fnidx, &sbuf) == 0) return fnidx;
708+
free(fnidx);
709+
return 0;
709710
}
710711

711712
const char **ti_seqname(const ti_index_t *idx, int *n)
@@ -723,11 +724,11 @@ const char **ti_seqname(const ti_index_t *idx, int *n)
723724
ti_index_t *ti_index_load(const char *fn)
724725
{
725726
ti_index_t *idx;
726-
char *fname = get_local_version(fn);
727+
char *fname = get_local_version(fn);
727728
if (fname == 0) return 0;
728729
idx = ti_index_load_local(fname);
729730
if (idx == 0) fprintf(stderr, "[ti_index_load] fail to load the index: %s\n", fname);
730-
free(fname);
731+
if(fname) free(fname);
731732
return idx;
732733
}
733734

0 commit comments

Comments
 (0)