Skip to content

Commit

Permalink
Merge pull request #52 from 4dn-dcic/v0.3.3
Browse files Browse the repository at this point in the history
0.3.3
  • Loading branch information
SooLee authored Nov 16, 2017
2 parents 8848a2a + e5cdfb8 commit d74b4f8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,9 @@ ulimit -n 2000

## Version history

### 0.3.3
* The problem of `pypairix` `get_blocknames` crashing python when called twice now fixed.

### 0.3.2
* `pairix -Y` option is now available to check whether a pairix-indexed file is a triangle (i.e. a chromosome pair occurs in one direction. e.g. if chr1|chr2 exists, chr2|chr1 doesn't)
* `pypairix` `check_triangle` function is also now available to check whether a pairix-indexed file is a triangle.
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.2
0.3.3
Binary file modified samples/SRR1171591.variants.snp.vqsr.p.vcf.gz.px2
Binary file not shown.
Binary file modified samples/merged_nodup.tab.chrblock_sorted.txt.gz.px2
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions src/pairix.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef __TABIDX_H
#define __TABIDX_H

#define PACKAGE_VERSION "0.3.2"
#define PACKAGE_VERSION "0.3.3"

#include <stdint.h>
#include "kstring.h"
Expand Down Expand Up @@ -158,7 +158,7 @@ extern "C" {
int get_nblocks(ti_index_t *idx, int tid, BGZF *fp);


/* check if a pairix-indexed file is a triangle
/* check if a pairix-indexed file is a triangle
( chromosome pairs occur only in one direction. e.g. if chr1|chr2 exists, chr2|chr1 shouldn't. )
* returns 1 if triangle
* returns 0 if not a triangle
Expand Down
25 changes: 11 additions & 14 deletions src/pairixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ typedef struct {
PyObject_HEAD
pairix_t *tb;
char *fn;
PyObject *blocknames;
int linecount;
int nblocks;
} PairixObject;

typedef struct {
Expand Down Expand Up @@ -366,7 +364,6 @@ pairix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
const char *fn, *fnidx=NULL;
static char *kwnames[]={"fn", "fnidx", NULL};
pairix_t *tb;
char **blocknames;
int i;

if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|z:open",
Expand All @@ -391,23 +388,13 @@ pairix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
self->linecount = get_linecount(self->tb->idx);
blocknames = ti_seqname(self->tb->idx, &(self->nblocks));
self->blocknames = PyList_New(self->nblocks);
if(!self->blocknames) { return NULL; }
for(i=0;i<self->nblocks;i++){
PyObject *val = Py_BuildValue("s",blocknames[i]);
if(!val) { Py_DECREF(self->blocknames); return NULL; }
PyList_SET_ITEM(self->blocknames,i,val);
}
free(blocknames);
return (PyObject *)self;
}

static void
pairix_dealloc(PairixObject *self)
{
free(self->fn);
Py_DECREF(self->blocknames);
ti_close(self->tb);
PyObject_Del(self);
}
Expand Down Expand Up @@ -612,7 +599,17 @@ pairix_get_linecount(PairixObject *self)
static PyObject *
pairix_get_blocknames(PairixObject *self)
{
return self->blocknames;
int n,i;
char **blocknames = ti_seqname(self->tb->idx, &n);
PyObject *bnames = PyList_New(n);
if(!bnames) return NULL;
for(i=0;i<n;i++){
PyObject *val = Py_BuildValue("s",blocknames[i]);
if(!val) { Py_DECREF(bnames); return NULL; }
PyList_SET_ITEM(bnames,i,val);
}
free(blocknames);
return bnames;
}

static PyObject *
Expand Down

0 comments on commit d74b4f8

Please sign in to comment.