Permalink
Browse files

converted fastalint to pipeline model

  • Loading branch information...
1 parent 8f54e9c commit 9b0be196e67e96a7810390b24ddc4ae1740d23df greg committed Jun 5, 2011
Showing with 4 additions and 66 deletions.
  1. +2 −2 Makefile
  2. +2 −1 fastahead.c
  3. +0 −63 fastalint.fl
View
@@ -11,8 +11,8 @@ fastacomplement: fastacomplement.yy.o
fastastack: fastastack.yy.o
gcc -o$@ $(LDFLAGS) $^ -lfl
-fastalint: fastalint.yy.o
- gcc -o$@ $< -lfl
+fastalint: fastalint.o firstin.o lexer.yy.o
+ gcc -o$@ $^ -lfl
fastatail: fastatail.o lexer.yy.o
gcc -o$@ $^ -lfl
View
@@ -42,8 +42,9 @@ void handle_sequence(char c)
}
}
-/* comments are echoed */
void terminate_sequence() { putchar('\n'); }
+
+/* comments are echoed */
void init_comment() { printf("> "); }
void handle_comment(char c) { putchar(c); }
void terminate_comment() { putchar('\n'); }
View
@@ -1,63 +0,0 @@
-/*
- * GCB 23feb11
- *
- * Clean-up FASTA file:
- * -- normalize column width
- * -- ensure sequence ends with a newline
- * -- ensure first line is a comment, adjustable with '--comment' option
- */
-
-%x COMMENT
-%x SEQUENCE
-
-%{
-#include <stdlib.h>
-#include <getopt.h>
-#define NULL_FLAG NULL
-
- static const int column_width = 40;
- int n;
-
- static const struct option my_options[] =
- {
- {"comment", required_argument, NULL_FLAG, 'c'},
- {0,0,0,0}
- };
-
-%}
-
-%%
-<INITIAL>[;>] { BEGIN(COMMENT); ECHO; }
-<COMMENT>. ECHO;
-<COMMENT>\n { BEGIN(INITIAL); ECHO; }
-<INITIAL>[A-Z]|- {
- BEGIN(SEQUENCE);
- n = 0;
- }
-<SEQUENCE>[AGTC]|- {if (n > 0 && ((n % column_width) == 0))
- printf("\n");
- ++n;
- ECHO;
- }
-<SEQUENCE>[;>] { printf("\n"); BEGIN(COMMENT); }
-<SEQUENCE><<EOF>> { printf("\n"); yyterminate();}
-<*>.|\n {/* default rule - gobble */}
-
-%%
-
-int
-main(int argc, char *argv[])
-{
- /* option parsing */
-
- while (1)
- {
- int option_idx = 0;
- int code = getopt_long(argc, argv, "c:", my_options, &option_idx);
- if (code == -1) break;
- else if (code == 'c') printf ("> %s\n", optarg);
- }
-
- yyin = (optind < argc) ? fopen(argv[optind], "r") : stdin;
- yylex();
-}

0 comments on commit 9b0be19

Please sign in to comment.