Files
ecoprimers/src/libecoprimer/readdnadb.c
Eric Coissac 6f5f2a16f3 Change 1 : patch the help message to take into account option added and the new output format.
Change 2 : Change the used rules to define example and counter example taxon sets.
			By default all taxa are example taxa and no counterexample taxa are used.
			By using -r option (one or several time) you could restict example taxa to a subset of taxa
			In old version all taxa not in example set are in the counterexample set.
			Now restrict example set with -r option doesn't define the counter example set.
			You must use -i to define the conterexample set in a similar way or -r option for example taxa.  

git-svn-id: https://www.grenoble.prabi.fr/svn/LECASofts/ecoPrimers/trunk@234 60f365c0-8329-0410-b2a4-ec073aeeaa1d
2009-10-12 13:31:41 +00:00

60 lines
1.1 KiB
C

/*
* readdnadb.c
*
* Created on: 7 nov. 2008
* Author: coissac
*/
#include "ecoprimer.h"
pecodnadb_t readdnadb(const char *name, ecotaxonomy_t *taxonomy, uint32_t *size,poptions_t options)
{
ecoseq_t *seq;
uint32_t buffsize=100;
pecodnadb_t db;
db = ECOMALLOC(buffsize*sizeof(ecoseq_t*),"I cannot allocate db memory");
for(seq=ecoseq_iterator(name), *size=0;
seq;
seq=ecoseq_iterator(NULL)
)
{
if (isExampleTaxon(taxonomy,seq->taxid,options) ||
isCounterExampleTaxon(taxonomy,seq->taxid,options))
{
if (*size==buffsize)
{
buffsize*=2;
db = ECOREALLOC(db,buffsize*sizeof(ecoseq_t*),"I cannot allocate db memory");
}
db[*size]=seq;
(*size)++;
}
else
{
delete_ecoseq(seq);
}
};
db = ECOREALLOC(db,(*size)*sizeof(ecoseq_t*),"I cannot allocate db memory");
return db;
}
void printSeqTest(pecodnadb_t seqdb,uint32_t seqdbsize)
{
uint32_t i;
char ch[11];
ch [10] = '\0';
for (i=0; i < seqdbsize; i++)
{
strncpy (ch, seqdb[i]->SQ, 10);
fprintf (stderr, "seq %d = %s\n", i, ch);
}
exit (0);
}