From e25e049490086a631d12bc56785f1a1845877541 Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Thu, 7 Apr 2011 13:02:37 -0700 Subject: [PATCH] man pages --- Makefile.am | 2 +- configure.ac | 16 +++++++++++----- doc/Makefile.am | 4 ++++ doc/fastq-grep.1 | 33 +++++++++++++++++++++++++++++++++ doc/fastq-kmers.1 | 46 ++++++++++++++++++++++++++++++++++++++++++++++ doc/fastq-match.1 | 27 +++++++++++++++++++++++++++ doc/fastq-uniq.1 | 35 +++++++++++++++++++++++++++++++++++ src/common.c | 8 ++++++++ src/common.h | 2 ++ src/fastq-grep.c | 34 ++++++++++++++++++---------------- src/fastq-kmers.c | 30 +++++++++++++++--------------- src/fastq-match.c | 28 ++++++++++++---------------- src/fastq-uniq.c | 36 +++++++++++++++++++----------------- src/version.h.in | 8 ++++++++ 14 files changed, 239 insertions(+), 70 deletions(-) create mode 100644 doc/Makefile.am create mode 100644 doc/fastq-grep.1 create mode 100644 doc/fastq-kmers.1 create mode 100644 doc/fastq-match.1 create mode 100644 doc/fastq-uniq.1 create mode 100644 src/version.h.in diff --git a/Makefile.am b/Makefile.am index 0576973..b91f90b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = src +SUBDIRS = src doc diff --git a/configure.ac b/configure.ac index 2681ec5..07fef16 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ -AC_INIT( [fastq-tools], [0.1], [dcjones@cs.washington.ed] ) +AC_INIT( [fastq-tools], [0.2], [dcjones@cs.washington.ed] ) AM_INIT_AUTOMAKE( [foreign -Wall -Werror] ) m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) @@ -8,8 +8,8 @@ AC_CONFIG_MACRO_DIR([m4]) AC_PROG_CC AM_PROG_CC_C_O -opt_CFLAGS="-Wall -g -O3" -dbg_CFLAGS="-Wall -g -O0" +opt_CFLAGS="--std=c99 -Wall -g -O3" +dbg_CFLAGS="--std=c99 -Wall -g -O0" AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], @@ -21,9 +21,13 @@ AS_IF([test "x$enable_debug" = xyes], [CFLAGS="$opt_CFLAGS"]) AC_DEFINE(_FILE_OFFSET_BITS, 64) +AC_DEFINE(_POSIX_SOURCE) # needed for fileno AC_PROG_LIBTOOL +AC_CHECK_FUNC(fileno, , + AC_MSG_ERROR([The 'fileno' function is missing.])) + # check zlib AX_CHECK_ZLIB @@ -44,7 +48,9 @@ AC_CHECK_HEADER(getopt.h, , CXXFLAGS=$CFLAGS -AC_CONFIG_FILES( [Makefile - src/Makefile] ) +AC_CONFIG_FILES([Makefile + src/Makefile + doc/Makefile + src/version.h]) AC_OUTPUT diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..da53738 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,4 @@ + +man_MANS = fastq-grep.1 fastq-kmers.1 fastq-match.1 fastq-uniq.1 + + diff --git a/doc/fastq-grep.1 b/doc/fastq-grep.1 new file mode 100644 index 0000000..cbd88dc --- /dev/null +++ b/doc/fastq-grep.1 @@ -0,0 +1,33 @@ +.TH FASTQ-GREP 1 + +.SH NAME +fastq-grep - print sequences matching a pattern + +.SH SYNOPSIS +.B fastq-grep [OPTION]... PATTERN [FILE]... + +.SH DESCRIPTION +Given a PATTERN, specified as a perl-compatible regular expression, print every +FASTQ entry with a matching nucleotide sequence. + +One ore more FILEs may be specified, otherwise input is read from standard input. +Input files may be gziped. + +.SH OPTIONS +.TP +\fB\-v\fR, \fB\-\-invert\-match\fR +Invert the sense of matching, to select non-matching entries. +.TP +\fB\-c\fR, \fB\-\-count\fR +Suppress normal output; instead output the number of matching (or, non-matching, +with '-v') entries. +.TP +\fB\-h\fR, \fB\-\-help\fR +Output a help message and exit. +.TP +\fB\-V\fR, \fB\-\-version\fR +Output version information and exit. + +.SH AUTHOR +Written by Daniel C. Jones + diff --git a/doc/fastq-kmers.1 b/doc/fastq-kmers.1 new file mode 100644 index 0000000..1e58256 --- /dev/null +++ b/doc/fastq-kmers.1 @@ -0,0 +1,46 @@ +.TH FASTQ-KMERS 1 + +.SH NAME +fastq-kmers - print the frequency of all k-mers for a given k + +.SH SYNOPSIS +.B fastq-kmers [OPTION]... [FILE]... + +.SH DESCRIPTION +For a given k, for example k = 4, a table in the following format is output, + +.fc # ^ +.ta T 2i +#kmer^frequency# +.br +#AAAA^1358# +.br +#AAAC^2393# +.br +#AAAG^1039# +.br +#AAAT^964# +.br +#AACA^4076# +.br +#...^...# +.br +#TTTT^876# + +One ore more FILEs may be specified, otherwise input is read from standard input. +Input files may be gziped. + +.SH OPTIONS +.TP +\fB\-k NUM\fR, \fB\-\-size=NUM\fR +The size of the k-mers to count, where 1 <= k <= 16. (default: 1) +.TP +\fB\-h\fR, \fB\-\-help\fR +Output a help message and exit. +.TP +\fB\-V\fR, \fB\-\-version\fR +Output version information and exit. + +.SH AUTHOR +Written by Daniel C. Jones + diff --git a/doc/fastq-match.1 b/doc/fastq-match.1 new file mode 100644 index 0000000..62abf02 --- /dev/null +++ b/doc/fastq-match.1 @@ -0,0 +1,27 @@ +.TH FASTQ-MATCH 1 + +.SH NAME +fastq-match - print sequences matching a pattern + +.SH SYNOPSIS +.B fastq-match [OPTION]... QUERY [FILE]... + +.SH DESCRIPTION +Given a nucleotide sequence QUERY, perform local alignment against every FASTQ +sequence using the Smith-Waterman algorithm. For each read, an alignment score +is printed, so that the output consists of a simple list of scores. + +One ore more FILEs may be specified, otherwise input is read from standard input. +Input files may be gziped. + +.SH OPTIONS +.TP +\fB\-h\fR, \fB\-\-help\fR +Output a help message and exit. +.TP +\fB\-V\fR, \fB\-\-version\fR +Output version information and exit. + +.SH AUTHOR +Written by Daniel C. Jones + diff --git a/doc/fastq-uniq.1 b/doc/fastq-uniq.1 new file mode 100644 index 0000000..e3b2923 --- /dev/null +++ b/doc/fastq-uniq.1 @@ -0,0 +1,35 @@ +.TH FASTQ-UNIQ 1 + +.SH NAME +fastq-uniq - print sequences matching a pattern + +.SH SYNOPSIS +.B fastq-uniq [OPTION]... PATTERN [FILE]... + +.SH DESCRIPTION +Print a non-redundant list of occurring sequences, removing all duplicate +sequences. Output is in FASTA format (as quality strings are ignored), with +sequence identifiers formatted as, + +>uniq-read-N (M copies) + +Where, N in a unique number assigned to the sequence and M is the number of +copies occurring. + +One ore more FILEs may be specified, otherwise input is read from standard input. +Input files may be gziped. + +.SH OPTIONS +.TP +\fB\-v\fR, \fB\-\-verbose\fR +Print status updates along the way. +.TP +\fB\-h\fR, \fB\-\-help\fR +Output a help message and exit. +.TP +\fB\-V\fR, \fB\-\-version\fR +Output version information and exit. + +.SH AUTHOR +Written by Daniel C. Jones + diff --git a/src/common.c b/src/common.c index 4598819..b3f47ed 100644 --- a/src/common.c +++ b/src/common.c @@ -8,9 +8,17 @@ #include "common.h" +#include "version.h" #include +void print_version(FILE *f, const char* prog_name) +{ + fprintf(f, "%s (fastq-tools) %s\n", + prog_name, FASTQ_TOOLS_VERSION); +} + + void or_die(int b, const char* msg) { if (b == 0) { diff --git a/src/common.h b/src/common.h index cdc89e8..163755b 100644 --- a/src/common.h +++ b/src/common.h @@ -13,6 +13,8 @@ #include +void print_version(FILE* f, const char* prog_name); + void or_die(int b, const char* msg); void* malloc_or_die(size_t); diff --git a/src/fastq-grep.c b/src/fastq-grep.c index 3eaffb7..d402cde 100644 --- a/src/fastq-grep.c +++ b/src/fastq-grep.c @@ -28,21 +28,24 @@ #endif +static const char* prog_name = "fastq-grep"; + + void print_help() { - fprintf( stderr, + fprintf(stdout, "fastq-grep [OPTION]... PATTERN [FILE]...\n" "Search for PATTERN in the read sequences in each FILE or standard input.\n" "PATTERN, by default, is a perl compatible regular expression.\n\n" "Options:\n" -" -h, --help print this message\n" " -v, --invert-match select nonmatching entries\n" " -c, --count output only the number of matching sequences\n" +" -h, --help print this message\n" +" -V, --version output version information and exit\n" ); } static int invert_flag; -static int help_flag; static int count_flag; @@ -94,7 +97,6 @@ int main(int argc, char* argv[]) invert_flag = 0; - help_flag = 0; count_flag = 0; int opt; @@ -103,14 +105,15 @@ int main(int argc, char* argv[]) static struct option long_options[] = { - {"help", no_argument, &help_flag, 1}, {"invert-match", no_argument, &invert_flag, 1}, - {"count", no_argument, &count_flag, 1}, + {"count", no_argument, &count_flag, 1}, + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'V'}, {0, 0, 0, 0} }; while (1) { - opt = getopt_long(argc, argv, "hvc", long_options, &opt_idx); + opt = getopt_long(argc, argv, "vchV", long_options, &opt_idx); if( opt == -1 ) break; @@ -121,10 +124,6 @@ int main(int argc, char* argv[]) } break; - case 'h': - help_flag = 1; - break; - case 'v': invert_flag = 1; break; @@ -133,6 +132,14 @@ int main(int argc, char* argv[]) count_flag = 1; break; + case 'h': + print_help(); + return 0; + + case 'V': + print_version(stdout, prog_name); + return 0; + case '?': return 1; @@ -141,11 +148,6 @@ int main(int argc, char* argv[]) } } - if (help_flag) { - print_help(); - return 0; - } - if (optind >= argc) { fprintf(stderr, "A pattern must be specified.\n"); return 1; diff --git a/src/fastq-kmers.c b/src/fastq-kmers.c index 57c75c2..26792de 100644 --- a/src/fastq-kmers.c +++ b/src/fastq-kmers.c @@ -27,6 +27,7 @@ # define SET_BINARY_MODE(file) #endif +static const char* prog_name = "fastq-kmers"; void print_help() { @@ -35,12 +36,12 @@ void print_help() "Print kmer counts for the given kmer size.\n" "Output is in two tab-seperated columns for kmer and frequency.\n\n" "Options:\n" +" -k NUM, --size=NUM kmer size (default: 1)\n" " -h, --help print this message\n" -" -k, --size kmer size (default: 1)\n" +" -V, --version output version information and exit\n" ); } -static int help_flag; static int k; int packkmer( const char* s, uint32_t* kmer, int k ) @@ -150,7 +151,6 @@ int main(int argc, char* argv[]) SET_BINARY_MODE(stdin); SET_BINARY_MODE(stdout); - help_flag = 0; k = 1; uint32_t n; /* number of kmers: 4^k */ @@ -162,13 +162,14 @@ int main(int argc, char* argv[]) int opt_idx; static struct option long_options[] = { - {"help", no_argument, &help_flag, 1}, - {"size", no_argument, 0, 0}, + {"size", no_argument, 0, 0}, + {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'V'}, {0, 0, 0, 0} }; while (1) { - opt = getopt_long(argc, argv, "hk:", long_options, &opt_idx); + opt = getopt_long(argc, argv, "k:hV", long_options, &opt_idx); if( opt == -1 ) break; @@ -182,14 +183,18 @@ int main(int argc, char* argv[]) } break; - case 'h': - help_flag = 1; - break; - case 'k': k = atoi(optarg); break; + case 'h': + print_help(); + return 0; + + case 'V': + print_version(stdout, prog_name); + return 0; + case '?': return 1; @@ -198,11 +203,6 @@ int main(int argc, char* argv[]) } } - if (help_flag) { - print_help(); - return 0; - } - if (k < 1) { fprintf(stderr, "Kmer size must be at least 1."); return 1; diff --git a/src/fastq-match.c b/src/fastq-match.c index 09da29b..53af134 100644 --- a/src/fastq-match.c +++ b/src/fastq-match.c @@ -27,23 +27,22 @@ #endif -static int help_flag; +static const char* prog_name = "fastq-match"; void print_help() { - fprintf(stderr, + fprintf(stdout, "fastq-match [OPTION]... QUERY [FILE]...\n" "Perform Smith-Waterman local alignment of a query sequence\n" "against each sequence in a fastq file.\n\n" "Options:\n" " -h, --help print this message\n" +" -V, --version output version information and exit\n" ); } - - void fastq_match(FILE* fin, FILE* fout, sw_t* sw, unsigned char* query, int n) @@ -80,22 +79,19 @@ int main(int argc, char* argv[]) FILE* fin; - help_flag = 0; - int opt; int opt_idx; static struct option long_options[] = { - {"help", no_argument, &help_flag, 1}, - {"gap-init", required_argument, NULL, 0}, - {"gap-extend", required_argument, NULL, 0}, + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'V'}, {0, 0, 0, 0} }; while (1) { - opt = getopt_long(argc, argv, "h", long_options, &opt_idx); + opt = getopt_long(argc, argv, "hV", long_options, &opt_idx); if (opt == -1) break; @@ -107,8 +103,12 @@ int main(int argc, char* argv[]) break; case 'h': - help_flag = 1; - break; + print_help(); + return 0; + + case 'V': + print_version(stdout, prog_name); + return 0; case '?': return 1; @@ -118,10 +118,6 @@ int main(int argc, char* argv[]) } } - if (help_flag) { - print_help(); - return 0; - } if (optind >= argc) { fprintf(stderr, "A query sequence must be specified.\n"); diff --git a/src/fastq-uniq.c b/src/fastq-uniq.c index fddb52a..32d344e 100644 --- a/src/fastq-uniq.c +++ b/src/fastq-uniq.c @@ -25,10 +25,7 @@ # define SET_BINARY_MODE(file) #endif - -static int help_flag; -static int verbose_flag; -size_t total_reads; +static const char* prog_name = "fastq-uniq"; void print_help() { @@ -37,12 +34,18 @@ void print_help() "Output a non-redundant FASTQ file, in which there are no duplicate reads.\n" "(Warning: this program can be somewhat memory intensive.)\n\n" "Options:\n" -" -h, --help print this message\n" " -v, --verbose print status along the way\n" +" -h, --help print this message\n" +" -V, --version output version information and exit\n" ); } +static int verbose_flag; +static size_t total_reads; + + + void fastq_hash(FILE* fin, hash_table* T) { fastq_t* fqf = fastq_open(fin); @@ -99,20 +102,19 @@ int main(int argc, char* argv[]) FILE* fin ; - help_flag = 0; - int opt; int opt_idx; static struct option long_options[] = { - {"help", no_argument, &help_flag, 1}, {"verbose", no_argument, &verbose_flag, 1}, + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'V'}, {0, 0, 0, 0} }; while (1) { - opt = getopt_long(argc, argv, "hv", long_options, &opt_idx); + opt = getopt_long(argc, argv, "vhV", long_options, &opt_idx); if (opt == -1) break; @@ -123,10 +125,6 @@ int main(int argc, char* argv[]) } break; - case 'h': - help_flag = 1; - break; - case 'v': verbose_flag = 1; break; @@ -134,15 +132,19 @@ int main(int argc, char* argv[]) case '?': return 1; + case 'h': + print_help(); + return 0; + + case 'V': + print_version(stdout, prog_name); + return 0; + default: abort(); } } - if (help_flag) { - print_help(); - return 0; - } if (optind >= argc || (argc - optind == 1 && strcmp(argv[optind],"-") == 0)) { fastq_hash(stdin, T); diff --git a/src/version.h.in b/src/version.h.in new file mode 100644 index 0000000..7d770e7 --- /dev/null +++ b/src/version.h.in @@ -0,0 +1,8 @@ + +#ifndef FASTQ_TOOLS_VERSION_H +#define FASTQ_TOOLS_VERSION_H + +#define FASTQ_TOOLS_VERSION "@VERSION@" + +#endif + -- 2.39.2