#!/usr/local/bin/perl -w

use strict;
use CompBio::Simple;
use Getopt::Long;

if(! defined $ARGV[0]){
    print "fa_to_tbl <-help|-out> (seqfile.fa|-)\n";
    exit;
}#if

my $stdin = "";
my %opt = ();
# '' allows - in command args to indicate input from stdin (console or pipe)
my $result = GetOptions(\%opt,'help|h','' => \$stdin,'out|o=s','v+');
my $VERSION = '0.13';

if ($opt{"help"}) { exec "perldoc $0" }

=head1 NAME

fa_to_tbl - Convert sequence records in fasta format to table format

=head1 SYNOPSIS



=head1 DESCRIPTION

Convert sequence records in fasta format to table format. Input sequences can be
in a file or piped in on the command line (see L<examples>). Output is to standard
out or to a file if specified with the -out flag.

=cut

my $cbs = CompBio::Simple->new;

my %params = ();
$params{OUTFILE} = $opt{out} if ($opt{'out'});
$params{DEBUG} = $opt{v} if $opt{v};

$| = 1; # because I am inherently impatient
# Just bomb the code from here to TODO if not using input file. Might as well 
# remove the $stdin stuff from above too then.
my $input_file = shift; 

if ($stdin) {
    while (<>) {
        my $result = $cbs->fa_to_tbl($_,%params);
        print $result if $result;
    } # while
} # loop over std in
elsif ($input_file) {
    print join("\n",@{$cbs->fa_to_tbl($input_file,%params)}),"\n";
} # either a single sequence on the comand line or a file - let Simple handle it
else {
    die "No input to convert!\n";
} # no dna?

=head1 TODO



=head1 COPYRIGHT

Copyright Sean Quinlan, Trustees of Boston University 2001.

=head1 AUTHOR

Sean Quinlan, seanq@darwin.bu.edu

Please email me with any changes you make or suggestions for changes/additions. Thank you!

=head1 SEE ALSO

perl(1).

=cut
