1 /*****************************************************************
2 * HMMER - Biological sequence analysis with profile HMMs
3 * Copyright (C) 1992-1999 Washington University School of Medicine
6 * This source code is distributed under the terms of the
7 * GNU General Public License. See the files COPYING and LICENSE
9 *****************************************************************/
13 * revcomp - generate reverse complement of sequences
14 * SRE, Thu Aug 5 17:36:57 1993
15 * RCS $Id: revcomp_main.c,v 1.1.1.1 2005/03/22 08:34:31 cmzmasek Exp $
25 char usage[] = "Usage: revcomp [-options] <seqfile>\n\
26 Reverse complement a nucleic acid sequence.\n\
28 -h : help; print version and usage info\n";
31 main(int argc, char **argv)
33 char *seqfile; /* name of sequence file */
34 SQFILE *dbfp; /* open sequence file */
35 int fmt; /* format of seqfile */
36 char *seq; /* sequence */
37 SQINFO sqinfo; /* additional sequence info */
38 char *rev; /* reverse complement */
41 int optchar; /* option character, command line */
44 /***********************************************
46 ***********************************************/
50 while ((optchar = getopt(argc, argv, OPTIONS)) != -1)
53 printf("revcomp %s, %s\n%s\n", RELEASE, RELEASEDATE, usage);
59 if (argc - optind != 1) Die("%s\n", usage);
60 seqfile = argv[optind];
62 if ((dbfp = SeqfileOpen(seqfile, fmt, NULL)) == NULL)
63 Die("Failed to open sequence file %s for reading", seqfile);
65 while (ReadSeq(dbfp, dbfp->format, &seq, &sqinfo))
67 if ((rev = (char *) malloc ((sqinfo.len + 1) * sizeof(char))) == NULL)
71 if (sqinfo.flags & (SQINFO_START | SQINFO_STOP))
74 sqinfo.start = sqinfo.stop;
77 /* secondary structure of reverse strand is nonsense
79 if (sqinfo.flags & SQINFO_SS)
81 sqinfo.flags = sqinfo.flags & ~SQINFO_SS;
85 WriteSeq(stdout, SQFILE_FASTA, rev, &sqinfo);
88 FreeSequence(seq, &sqinfo);