Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions lib2bit/2bit.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ char *twobitSequence(TwoBit *tb, char *chrom, uint32_t start, uint32_t end) {
break;
}
}
if(tid == 0 && strcmp(tb->cl->chrom[i], chrom) != 0) return NULL;
if(tid == 0 && strcmp(tb->cl->chrom[tid], chrom) != 0) return NULL;

//Get the start/end if not specified
if(start == end && end == 0) {
Expand Down Expand Up @@ -406,7 +406,7 @@ void *twobitBases(TwoBit *tb, char *chrom, uint32_t start, uint32_t end, int fra
}
}

if(tid == 0 && strcmp(tb->cl->chrom[i], chrom) != 0) return NULL;
if(tid == 0 && strcmp(tb->cl->chrom[tid], chrom) != 0) return NULL;

//Get the start/end if not specified
if(start == end && end == 0) {
Expand Down Expand Up @@ -517,7 +517,7 @@ void twobitIndexRead(TwoBit *tb, int storeMasked) {
for(i=0; i<tb->hdr->nChroms; i++) {
if(idx->nBlockSizes[i]) free(idx->nBlockSizes[i]);
}
free(idx->nBlockSizes[i]);
free(idx->nBlockSizes);
}

if(idx->maskBlockCount) free(idx->maskBlockCount);
Expand Down Expand Up @@ -587,13 +587,15 @@ void twobitChromListRead(TwoBit *tb) {
TwoBitCL *cl = calloc(1, sizeof(TwoBitCL));
uint8_t useLong = tb->hdr->version == 1;
size_t offsetSz = (useLong) ? sizeof(uint64_t) : sizeof(uint32_t);
void *offset = calloc(1, offsetSz);

//Allocate cl and do error checking
if(!cl) goto error;
cl->chrom = calloc(tb->hdr->nChroms, sizeof(char*));
cl->offset = calloc(tb->hdr->nChroms, offsetSz);
cl->offset = calloc(tb->hdr->nChroms, sizeof(uint64_t));
if(!cl->chrom) goto error;
if(!cl->offset) goto error;
if(!offset) goto error;

for(i=0; i<tb->hdr->nChroms; i++) {
//Get the string size (not null terminated!)
Expand All @@ -607,8 +609,14 @@ void twobitChromListRead(TwoBit *tb) {
str = NULL;

//Read in the size
if(twobitRead(cl->offset + i, offsetSz, 1, tb) != 1) goto error;
if(twobitRead(offset, offsetSz, 1, tb) != 1) goto error;
if(useLong) {
cl->offset[i] = *((uint64_t*) offset);
} else {
cl->offset[i] = *((uint32_t*) offset);
}
}
free(offset);

tb->cl = cl;
return;
Expand All @@ -625,6 +633,7 @@ void twobitChromListRead(TwoBit *tb) {
}
free(cl);
}
if(offset) free(offset);
}

void twobitChromListDestroy(TwoBit *tb) {
Expand Down
2 changes: 1 addition & 1 deletion py2bit.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <Python.h>
#include "2bit.h"

#define pyTwoBitVersion "1.0.0"
#define pyTwoBitVersion "1.0.1"

typedef struct {
PyObject_HEAD
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "py2bit"
version = "1.0.0"
version = "1.0.1"
description = "A package for accessing 2bit files using lib2bit"
authors = [
{ name = "Devon P. Ryan", email = "dpryan79@gmail.com" }
Expand Down
Loading