indexoutput.c 1.34 KB
Newer Older
Eric Coissac's avatar
Eric Coissac committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
/*
 * indexoutput.c
 *
 *  Created on: 18 sept. 2012
 *      Author: coissac
 */

#include "orgasm.h"

void writeOrdoredSequences(buffer_t *buffer,FILE* output)
{

	uint32_t i;
	uint32_t nextprint=DISPLAYSTEP;
	char* record;

	fprintf(stderr,"\nWriting sorted sequence reads...\n\n");

	for (i=0; i < buffer->readCount; i++)
	{
		if (i > nextprint)
		{
			fprintf(stderr,"%9d sequences read\r",nextprint);
			nextprint+=DISPLAYSTEP;
		}

		record = buffer->records + buffer->order1[i] * buffer->recordSize;
		fwrite(record,buffer->recordSize,1,output);
	}

	fprintf(stderr,"%9d sequences read\n",i);

}

void writeOrder1(buffer_t *buffer,FILE* output)
{
	fwrite(buffer->order1,buffer->readCount,sizeof(uint32_t),output);
}

void writeOrder2(buffer_t *buffer,FILE* output)
{
	fwrite(buffer->order2,buffer->readCount,sizeof(uint32_t),output);
}

void writePairData(buffer_t *buffer,FILE* output)
{
	fprintf(stderr,"\nWriting sequence pairing data...\n\n");

	writeOrder2(buffer,output);

	fprintf(stderr,"Done.\n");
}

void writeOrderData(buffer_t *buffer,FILE* output)
{
	fprintf(stderr,"\nWriting sequence suffix index...\n\n");

	writeOrder1(buffer,output);

	fprintf(stderr,"Done.\n");
}

void writeGeneralData(buffer_t *buffer,FILE* output)
{
	fprintf(stderr,"\nWriting global data...\n\n");

	fwrite(buffer,1,sizeof(buffer_t),output);

	fprintf(stderr,"Done.\n");
}