From 8455ed0a99653ff4970a7623d8b0ac97e26178f1 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Thu, 14 Jun 2007 14:11:13 +0000 Subject: [PATCH] git-svn-id: https://www.grenoble.prabi.fr/svn/LECASofts/ecoPCR/branches/refactoring@66 60f365c0-8329-0410-b2a4-ec073aeeaa1d --- src/ecogrep.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/src/ecogrep.c b/src/ecogrep.c index 5752568..15bbbf6 100644 --- a/src/ecogrep.c +++ b/src/ecogrep.c @@ -145,10 +145,10 @@ int main(int argc, char **argv){ char *stream = ECOMALLOC(sizeof(char *)*LINE_BUFF_SIZE,"error stream buffer allocation"); char *orig = ECOMALLOC(sizeof(char *)*LINE_BUFF_SIZE,"error orig buffer allocation"); - int is_ignored = 0; + int is_ignored = 0; int is_included = 0; int is_matching = 0; - + int good = 0; seq = new_ecoseq(); /** @@ -275,42 +275,39 @@ int main(int argc, char **argv){ getLineContent(stream,seq); /* -----------------------------------------------*/ - /* ignored if : */ - /* - v mode and no ignored */ - /* OR */ - /* - at least one -i option used */ + /* is ignored if at least one option -i */ /* AND */ - /* - -i option is parent of current taxid */ + /* if current sequence is son of taxid */ /* -----------------------------------------------*/ - is_ignored = ( (v && i==0) || - ( (i > 0) && (eco_is_taxid_included( taxonomy, + is_ignored = ( (i > 0) && (eco_is_taxid_included( taxonomy, ignored_taxid, i, seq->taxid)) - ) ); /* -----------------------------------------------*/ - /* included if : */ - /* - normal mode and no restriction */ + /* is included if no -r option */ /* OR */ - /* - is -r option is parent of current taxid */ + /* if current sequence is son of taxid */ /* -----------------------------------------------*/ - is_included = ( (!v && (r == 0)) || (eco_is_taxid_included( taxonomy, + is_included = ( (r == 0) || (eco_is_taxid_included( taxonomy, restricted_taxid, r, seq->taxid)) ); - /* -----------------------------------------------*/ - /* match if no pattern or if function return 1 */ - /* -----------------------------------------------*/ - is_matching = ( (!v && !p) || (ispatternmatching(seq,pattern))); - - if ( - (!v && (!is_ignored && is_included && is_matching) ) || - ( v && (is_ignored && !is_included && !is_matching) ) - ) + /* ----------------------------------------------------------- */ + /* match if no pattern or if pattern match current sequence */ + /* ----------------------------------------------------------- */ + is_matching = ( !p || (ispatternmatching(seq,pattern))); + + + good = (is_included && is_matching && !is_ignored); + + if (v) + good=!good; + + if ( good ) { printf("%s",orig); matchingresult++;