diff --git a/src/libecoprimer/ecoprimer.h b/src/libecoprimer/ecoprimer.h index 31a4ef1..9fdac9b 100644 --- a/src/libecoprimer/ecoprimer.h +++ b/src/libecoprimer/ecoprimer.h @@ -104,7 +104,7 @@ typedef struct { * on all sequences as a list of primer_t */ typedef struct { - pprimer_t primers; + pprimer_t primers; uint32_t size; } primercount_t, *pprimercount_t; @@ -300,6 +300,6 @@ int32_t getrankdbstats(pecodnadb_t seqdb, ecotaxonomy_t *taxonomy, poptions_t options); float taxonomycoverage(ppair_t pair, poptions_t options); - +char ecoComplementChar(char base); #endif /* EPSORT_H_ */ diff --git a/src/libecoprimer/hashsequence.c b/src/libecoprimer/hashsequence.c index 8dfe6d4..1b2033a 100644 --- a/src/libecoprimer/hashsequence.c +++ b/src/libecoprimer/hashsequence.c @@ -201,3 +201,13 @@ uint32_t ecoFindWord(pwordcount_t table,word_t word) return ~0; } +char ecoComplementChar(char base) +{ + switch(base){ + case 'A': return T; + case 'C': return G; + case 'G': return C; + case 'T': return A; + } +} + diff --git a/src/libecoprimer/pairs.c b/src/libecoprimer/pairs.c index 838bbc7..f48f509 100644 --- a/src/libecoprimer/pairs.c +++ b/src/libecoprimer/pairs.c @@ -296,6 +296,7 @@ static void buildPrimerPairsForOneSeq(uint32_t seqid, current.asdirect1=current.asdirect2; current.asdirect2=bswp; } + // Look for the new pair in already seen pairs diff --git a/src/libecoprimer/taxstats.c b/src/libecoprimer/taxstats.c index b67823d..c058c69 100644 --- a/src/libecoprimer/taxstats.c +++ b/src/libecoprimer/taxstats.c @@ -121,3 +121,45 @@ float taxonomycoverage(ppair_t pair, poptions_t options) pair->outtaxa=outcount; return (float)incount/options->intaxa; } + + + +static int cmpamp(const void *ampf1, const void* ampf2) +{ + int i; + int j = 0; + int incr = 1; + char cd1; + char cd2; + int chd = 0; + + pamplifia_t pampf1 = (pamplifia_t) ampf1; + pamplifia_t pampf2 = (pamplifia_t) ampf2; + + + if (pampf1->strand != pampf2->strand) + { + incr = -1; + j = pampf1->length - 1; + if (pampf2->strand) + { + pampf1 = (pamplifia_t) ampf2; + pampf2 = (pamplifia_t) ampf1; + chd = 1; + } + } + + for (i = 0; i < pampf1->length; i++, j += incr;) + { + cd1 = pampf1->amplifia[i]; + if (incr == -1) + cd2 = ecoComplementChar(pampf2->amplifia[j]); + else + cd2 = pampf2->amplifia[j]; + + if (cd1 < cd2) (chd)? return 1: return -1; + if (cd2 < cd1) (chd)? return -1: return 1; + } + return 0; +} +