Skip to content

Commit 189258e

Browse files
authored
Merge pull request #11 from dpryan79/issue10
Address #10, don't write 4 bytes if fewer were requested
2 parents 9fc78d6 + 8895bfa commit 189258e

File tree

5 files changed

+36
-17
lines changed

5 files changed

+36
-17
lines changed

.github/workflows/test.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Test
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
testLinux:
7+
name: Test Linux
8+
runs-on: "ubuntu-latest"
9+
steps:
10+
- uses: actions/checkout@v2
11+
- run: |
12+
make && make test
13+
testOSX:
14+
name: Test OSX
15+
runs-on: "macos-latest"
16+
steps:
17+
- uses: actions/checkout@v2
18+
- run: |
19+
make && make test

.travis.yml

-9
This file was deleted.

2bit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void bytes2bases(char *seq, uint8_t *byte, uint32_t sz, int offset) {
6969

7070
// Deal with the first partial byte
7171
if(offset != 0) {
72-
while(offset < 4) {
72+
while(offset < 4 && pos < sz) {
7373
seq[pos++] = byte2base(foo, offset++);
7474
}
7575
if(pos >= sz) return;

test/expected

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
0 chr1 150 offset 0x4a
2+
1 chr2 100 offset 0x88
3+
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNACGTACGTACGTagctagctGATCGATCGTAGCTAGCTAGCTAGCTGATCNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
4+
NNNNNNNNNNNNNNNNNNNNNNNNNNACGTACGTACGTagctagctGATC
5+
0 0.080000
6+
1 0.080000
7+
2 0.086667
8+
3 0.086667
9+
0 0.120000
10+
1 0.120000
11+
2 0.120000
12+
3 0.120000

test/test.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99
# N.B., this MUST be run from within the source directory!
1010

1111
# Read test
12-
p1 = Popen(["./test/exampleRead", "test/foo.2bit"], stdout=PIPE)
13-
try:
14-
p2 = Popen(["md5sum"], stdin=p1.stdout, stdout=PIPE)
15-
except:
16-
p2 = Popen(["md5"], stdin=p1.stdout, stdout=PIPE)
17-
md5sum = p2.communicate()[0].strip().split()[0]
18-
assert(md5sum == "0274c32c7f3dd75e8991f6107dca6a5f")
12+
o = open("test/found", "w")
13+
check_call(["./test/exampleRead", "test/foo.2bit"], stdout=o)
14+
o.close()
15+
check_call(["diff", "test/found", "test/expected"])
1916

2017
print("Passed!")

0 commit comments

Comments
 (0)