Exemplo n.º 1
0
static void * downloadBamFile(void * args) {
	BamReaderData * data = (BamReaderData *) args;
	int j, tid, cnt, pos, n_plp;
	const bam_pileup1_t *plp;

	while (bam_mplp_auto(data->iter, &tid, &pos, &n_plp, &plp) > 0) {
		// Count reads in pileup
		cnt = 0;
		const bam_pileup1_t *p = plp;
		for (j = 0; j < n_plp; ++j) {
			//if (bam1_qual(p->b)[p->qpos] >= data->conf->min_baseQ) 
				cnt++;
			p++;
		}

		// Its a wrap:
		char * chrom = data->data->h->target_name[tid];

		if (data->stop > 0 && (strcmp(chrom, data->chrom) == 0 && pos >= data->stop))
			break;

		// +1 to account for 0-based indexing in BAMs:
		if (pushValuesToBuffer(data->bufferedReaderData, chrom, pos+1, pos+2, cnt))
			break;
	}

	bam_iter_destroy(data->data->iter);
	endBufferedSignal(data->bufferedReaderData);
	return NULL;
}
Exemplo n.º 2
0
static void * downloadTabixFile(void * args) {
	BCFReaderData * data = (BCFReaderData *) args;
	char * line;
	char * last_chrom = "";

	while ((line = nextLine(data))) {
		if (line[0] == '#')
			continue;

		char * chrom = strtok(line, "\t");
		if (strcmp(chrom, last_chrom)) {
			last_chrom = calloc(strlen(chrom) + 1, sizeof(char));
			strcpy(last_chrom, chrom);
		}
		int pos = atoi(strtok(NULL, "\t"));

		if (data->tabix_iterator)
			free(line);

		if (pushValuesToBuffer(data->bufferedReaderData, last_chrom, pos, pos+1, 1))
			break;
	}

	if (data->tabix_iterator) 
		ti_iter_destroy(data->tabix_iterator);

	endBufferedSignal(data->bufferedReaderData);
	return NULL;
}
Exemplo n.º 3
0
void * downloadBigFile(void * args) {
	BigFileReaderData * data = (BigFileReaderData *) args;

	if (!data->chrom)
		downloadFullGenome(data);
	else 
		downloadBigRegion(data, data->chrom, data->start, data->stop);

	endBufferedSignal(data->bufferedReaderData);
	return NULL;
}
Exemplo n.º 4
0
void * readBigBed(void * ptr) {
	BigBedReaderData * data = (BigBedReaderData *) ptr;
	if (data->chrom)
		readBigBedRegion(data, data->chrom, data->start, data->stop);
	else {
		int chrom_index;
		for (chrom_index = 0; chrom_index < data->fp->cl->nKeys; chrom_index++)
			if (readBigBedRegion(data, data->fp->cl->chrom[chrom_index], 0, data->fp->cl->len[chrom_index]))
				break;
	}

	endBufferedSignal(data->bufferedReaderData);
	return NULL;
}