Commit 6daa7e02 by Eric Coissac

Add a -M option to orgasmi

parent fc8356f5
......@@ -8,10 +8,11 @@
#include "orgasm.h"
buffer_t *newBuffer(size_t maxsize,size_t readSize)
buffer_t *newBuffer(size_t maxsize,size_t readSize, size_t maxread)
{
#define MASK ((size_t)0xF)
#define CLEAN ((size_t)~MASK)
#define MIN(x,y) (((x) > (y)) ? (y):(x))
buffer_t* rep;
size_t rsize=round16(readSize)/4 + 2 * sizeof(uint32_t);
......@@ -19,6 +20,9 @@ buffer_t *newBuffer(size_t maxsize,size_t readSize)
if (((maxsize-48) / rsize) > (size_t)0xFFFFFFFF)
maxsize = (size_t)0xFFFFFFFF * rsize + 48;
if (maxread>0)
maxsize = MIN(maxread*rsize+48,maxsize);
rep = MALLOC(sizeof(buffer_t));
rep->arena = MALLOC(maxsize);
......
......@@ -36,12 +36,12 @@ int main(int argc, char *argv[])
for (i=0; i < 4; i++)
nuc[3-i] = (icode >> (i*2)) & 3;
#ifdef LITTLE_END
*((uint32_t*)nuc) = *((uint32_t*)nuc) >> 24 | \
*((uint32_t*)nuc) << 24 | \
((*((uint32_t*)nuc) >> 8) & 0x0000FF00) | \
((*((uint32_t*)nuc) << 8) & 0x00FF0000);
#endif
//#ifdef LITTLE_END
// *((uint32_t*)nuc) = *((uint32_t*)nuc) >> 24 | \
// *((uint32_t*)nuc) << 24 | \
// ((*((uint32_t*)nuc) >> 8) & 0x0000FF00) | \
// ((*((uint32_t*)nuc) << 8) & 0x00FF0000);
//#endif
if (code < 0xFF)
fprintf(stdout," 0x%08XUL, // %04X\n", *((uint32_t*)nuc),code);
......
......@@ -9,6 +9,7 @@
buffer_t *buildIndex(const char *forwardFileName, const char* reverseFileName,
const char *indexname,
uint32_t minword,
size_t maxread,
size_t maxbuffersize
)
{
......@@ -32,7 +33,7 @@ buffer_t *buildIndex(const char *forwardFileName, const char* reverseFileName,
if (reverse == NULL)
FATALERROR("Cannot open file %s",reverseFileName)
reads = loadPairedFastq(forward,reverse,maxbuffersize);
reads = loadPairedFastq(forward,reverse,maxread,maxbuffersize);
fclose(forward);
fclose(reverse);
......
......@@ -140,6 +140,7 @@ uint8_t checkACGT(const char* src, size_t size)
buffer_t * loadPairedFastq(FILE* forward,
FILE* reverse,
size_t maxread,
size_t maxbuffersize
)
{
......@@ -178,7 +179,7 @@ buffer_t * loadPairedFastq(FILE* forward,
readLength = readPairedFastq(reads,forward,reverse,buffersize);
seqbuffer = newBuffer(maxbuffersize,readLength);
seqbuffer = newBuffer(maxbuffersize,readLength,maxread);
encodedseqs= (uint32_t*)(seqbuffer->records);
while (readLength && (seqbuffer->readCount+2) <= seqbuffer->maxrecord)
......
......@@ -47,7 +47,7 @@ buffer_t *loadIndexedReads(const char *indexname)
maxsize = (tmp.recordSize + \
2 * sizeof(uint32_t)) * tmp.readCount + 48;
reads = newBuffer(maxsize,tmp.readSize);
reads = newBuffer(maxsize,tmp.readSize,0);
reads->readCount = tmp.readCount;
......
......@@ -105,16 +105,18 @@ char *decodeSequence(pnuc buffer, uint32_t begin, int32_t length, char *dest);
buffer_t *loadPairedFastq(FILE* forward,
FILE* reverse,
size_t maxread,
size_t maxbuffersize
);
buffer_t *buildIndex(const char *forwardFileName, const char* reverseFileName,
const char *indexname,
uint32_t minword,
size_t maxread,
size_t maxbuffersize
);
buffer_t *newBuffer(size_t maxsize,size_t readSize);
buffer_t *newBuffer(size_t maxsize,size_t readSize,size_t maxread);
void freeBuffer(buffer_t *buffer);
void swapOrder(buffer_t *buffer);
......
......@@ -6,6 +6,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
......@@ -39,6 +40,7 @@ static void PrintHelp()
PP " <index>.orx : contains reverse index\n");
PP " <index>.opx : contains read pairing data\n\n");
PP " The assembler will need all these file to process assembling\n\n");
PP "-M : If specified the count in million of reads to index");
PP "-h : [H]elp - print <this> help\n\n");
PP "\n");
PP "------------------------------------------\n");
......@@ -73,6 +75,7 @@ int main(int argc, char *argv[])
{
buffer_t* reads;
char* indexfiles=NULL;
size_t toread=0;
int carg;
int errflag=0;
......@@ -85,7 +88,7 @@ int main(int argc, char *argv[])
while ((carg = getopt(argc, argv, "ho:")) != -1) {
while ((carg = getopt(argc, argv, "hM:o:")) != -1) {
switch (carg) {
/* -------------------- */
......@@ -102,7 +105,13 @@ while ((carg = getopt(argc, argv, "ho:")) != -1) {
strcpy(indexfiles,(const char*)optarg);
break;
break;
/* -------------------- */
case 'M': /* index name */
/* -------------------- */
toread = atoll((const char*)optarg) * 1000000;
break;
break;
case '?': /* bad option */
/* -------------------- */
......@@ -138,7 +147,7 @@ if (errflag)
#define MAXREAD 2000000000
reads = buildIndex(forwardFileName,reverseFileName,indexfiles,95,MAXREAD);
reads = buildIndex(forwardFileName,reverseFileName,indexfiles,95,toread,MAXREAD);
freeBuffer(reads);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment