Skip to content

Commit 94c64e3

Browse files
authored
Merge pull request #5 from dpryan79/fix4
Fix #4
2 parents 9844de6 + 6fd0ff3 commit 94c64e3

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

lib2bit/2bit.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void bytes2bases(char *seq, uint8_t *byte, uint32_t sz, int offset) {
7272
while(offset < 4) {
7373
seq[pos++] = byte2base(foo, offset++);
7474
}
75+
if(pos >= sz) return;
7576
foo = byte[++i];
7677
}
7778

@@ -158,9 +159,10 @@ void softMask(char *seq, TwoBit *tb, uint32_t tid, uint32_t start, uint32_t end)
158159
*/
159160
char *constructSequence(TwoBit *tb, uint32_t tid, uint32_t start, uint32_t end) {
160161
uint32_t sz = end - start + 1;
161-
uint32_t blockStart, blockEnd, offset;
162+
uint32_t blockStart, blockEnd;
162163
char *seq = malloc(sz * sizeof(char));
163164
uint8_t *bytes = NULL;
165+
int offset;
164166
if(!seq) return NULL;
165167

166168
//There are 4 bases/byte

py2bitTest/test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ def testBases(self):
4141
assert(tb.bases("chr1", 24, 74) == {'A': 0.12, 'C': 0.12, 'T': 0.12, 'G': 0.12})
4242
assert(tb.bases("chr1", 24, 74, False) == {'A': 6, 'C': 6, 'T': 6, 'G': 6})
4343
tb.close()
44+
45+
def testSequence(self):
46+
tb = py2bit.open(self.fname, True)
47+
assert(tb.sequence("chr1", 1, 3) == "NN")
48+
assert(tb.sequence("chr1", 1, 2) == "N")

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
include_dirs = ['lib2bit', sysconfig.get_config_var("INCLUDEPY")])
1818

1919
setup(name = 'py2bit',
20-
version = '0.2.0',
20+
version = '0.2.1',
2121
description = 'A package for accessing 2bit files using lib2bit',
2222
author = "Devon P. Ryan",
2323
author_email = "ryan@ie-freiburg.mpg.de",
2424
url = "https://github.com/dpryan79/py2bit",
2525
license = "MIT",
26-
download_url = "https://github.com/dpryan79/py2bit/tarball/0.2.0",
26+
download_url = "https://github.com/dpryan79/py2bit/tarball/0.2.1",
2727
keywords = ["bioinformatics", "2bit"],
2828
classifier = ["Development Status :: 5 - Production/Stable",
2929
"Intended Audience :: Developers",

0 commit comments

Comments
 (0)