[Bio] / FigKernelScripts / complement_fasta.c Repository:
ViewVC logotype

View of /FigKernelScripts/complement_fasta.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Mon Jun 11 20:08:03 2012 UTC (7 years, 5 months ago) by golsen
Branch: MAIN
CVS Tags: rast_rel_2014_0729, rast_rel_2014_0912, HEAD
Support for codon usage analyses.

/*
 *  complement_fasta.c
 *
 *  Usage: complement_fasta [options] < fasta > fasta
 *
 *      -f  //  Flush the output after every sequence
 *      -v  //  Print version to standard output and exit
 *
 *  cc -O3 -o complement_fasta complement_fasta.c
 *
 *  Versions:
 *
 *      1.00 - Unnumbered first release
 *
 *      1.01 - Add -f, -g, -m and -v flags
 */

#include <stdio.h>
#include "gjoseqlib.h"
#include "gjoseqio.h"
#include "gjoseqlib.c"
#include "gjoseqio.c"

#define  VERSION  "1.01"

void usage( char * command );


int main( int argc, char ** argv )
{
    seq_t *entry, *compl;
    int    i;
    int    flush = 0;

    // Options:

    i = 1;
    while ( ( i < argc ) && ( argv[i][0] == '-' ) )
    {
        if ( argv[i][1] == 'f' )
        {
            flush = 1;
        }
        else if ( argv[i][1] == 'v' )
        {
            printf( "%s\n", VERSION );
            return 0;
        }
        else
        {
            fprintf( stderr, "Bad flag '%s'.\n", argv[i] );
            usage( argv[0] );
            return 1;
        }

        i++;
    }

    while ( ( entry = read_next_fasta( stdin ) ) )
    {
        if ( ( compl = complement_RNA( entry ) ) )
        {
            write_fasta_entry( stdout, compl );
            if ( flush ) fflush( stdout );
            free_sequence( compl );
        }
        free_sequence( entry );
    }

    return( 0 );
}


/*-----------------------------------------------------------------------------
 *  Usage statement:
 *
 *      void usage( char * command )
 *
 *-----------------------------------------------------------------------------
 */

void usage( char * command )
{
    fprintf( stderr, "\n" );
    fprintf( stderr, "\nUsage: %s  [options]  < fasta  > fasta\n", command );
    fprintf( stderr, "\n" );
    fprintf( stderr, "\nOptions " );
    fprintf( stderr, "\n" );
    fprintf( stderr, "    -f   #  Flush the output stream after every sequence\n" );
    fprintf( stderr, "    -v   #  Print the version number and exit\n" );
    fprintf( stderr, "\n" );

    return;
}



MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3