use Maasha::TwoBit;
use Maasha::Solid;
use Maasha::SQL;
+use Maasha::Gwiki;
use vars qw( @ISA @EXPORT_OK );
my ( $script, $BP_TMP );
$script = Maasha::Common::get_scriptname();
-$BP_TMP = Maasha::Common::get_tmpdir();
+$BP_TMP = Maasha::Common::get_tmpdir();
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> LOG <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-my $log_fh = Maasha::Common::append_open( $ENV{ "LOG_DIR" } . "/biopieces.log" );
+my $log_fh = Maasha::Common::append_open( "$ENV{ 'BP_TMP' }/biopieces.log" );
$log_fh->autoflush( 1 );
-log( $log_fh, $script, \@ARGV );
+&log( $log_fh, $script, \@ARGV );
close $log_fh;
$time_stamp = Maasha::Common::time_stamp();
- $user = $ENV{ "USER" };
+ $user = $ENV{ 'USER' };
$script = "biopieces" if $script eq "-e";
my ( $options, $in, $out );
- script_list_biopieces( $ENV{ 'INST_DIR'} . "/biopieces/usage/" ) if $script eq "list_biopieces";
-
- script_print_usage( $ENV{ 'INST_DIR'} . "/biopieces/usage/$script" ) if -t STDIN and not @ARGV;
+# script_list_biopieces( $ENV{ 'INST_DIR'} . "/biopieces/usage/" ) if $script eq "list_biopieces";
$options = get_options( $script );
+ if ( -t STDIN and not @ARGV )
+ {
+ $options->{ "path" } = "$ENV{ 'BP_DIR' }/bp_usage/$script";
+ $script = "print_usage";
+ }
+
$in = read_stream( $options->{ "stream_in" } );
$out = write_stream( $options->{ "stream_out" } );
- if ( $script eq "read_fasta" ) { script_read_fasta( $in, $out, $options ) }
+ if ( $script eq "print_usage" ) { script_print_usage( $in, $out, $options ) }
+ elsif ( $script eq "read_fasta" ) { script_read_fasta( $in, $out, $options ) }
elsif ( $script eq "read_tab" ) { script_read_tab( $in, $out, $options ) }
elsif ( $script eq "read_psl" ) { script_read_psl( $in, $out, $options ) }
elsif ( $script eq "read_bed" ) { script_read_bed( $in, $out, $options ) }
stream_in|I=s
stream_out|O=s
verbose
+ help|?
);
# print STDERR Dumper( \@options );
@options,
);
+# print STDERR Dumper( \%options ) and exit;
+
$options{ "cols" } = [ split ",", $options{ "cols" } ] if defined $options{ "cols" };
$options{ "keys" } = [ split ",", $options{ "keys" } ] if defined $options{ "keys" };
$options{ "no_keys" } = [ split ",", $options{ "no_keys" } ] if defined $options{ "no_keys" };
# Retrieves usage information from file and
# prints this nicely formatted.
- my ( $path, # full path to usage file
+ my ( $in, # handle to in stream
+ $out, # handle to out stream
+ $options, # options hash
) = @_;
# Returns nothing.
- my ( $script, $fh, $line, @lines, @list, %hash, $key );
+ my ( $wiki, $lines );
- $script = ( split "/", $path )[ -1 ];
+ $wiki = Maasha::Gwiki::gwiki_read( "$options->{ 'path' }.wiki" );
- $fh = Maasha::Common::read_open( $path );
-
- push @list, "Program name";
-
- $hash{ "Program name" } = [ $script ];
-
- while ( $line = <$fh> )
- {
- chomp $line;
-
- $line =~ s/\$script/$script/g;
-
- if ( $line =~ /^([^:]+):\s+(.+)$/ )
- {
- push @list, $1 if not exists $hash{ $1 };
- push @{ $hash{ $1 } }, $2;
- }
+ if ( not $options->{ "help" } ) {
+ @{ $wiki } = grep { $_->[ 0 ]->{ 'SECTION' } =~ /Biopiece|Synopsis|Usage|Options|Help/ } @{ $wiki };
}
- close $fh;
-
- print "\n";
-
- foreach $key ( @list )
- {
- if ( scalar @{ $hash{ $key } } == 1 )
- {
- @lines = Maasha::Common::wrap_line( $hash{ $key }->[ 0 ], 80 );
-
- printf( "%-15s%s\n", "$key:", shift @lines );
-
- map { printf( "%-15s%s\n", "", $_ ) } @lines;
+ $lines = Maasha::Gwiki::gwiki2ascii( $wiki );
- print "\n";
- }
- else
- {
- print "$key:\n";
-
- map { print " $_\n" } @{ $hash{ $key } };
-
- print "\n";
- }
- }
+ print STDERR "$_\n" foreach @{ $lines };
exit;
}
if ( not -t STDIN ) {
$fh = Maasha::Common::read_stdin();
} elsif ( not $path ) {
- Maasha::Common::error( qq(no data stream) );
+# Maasha::Common::error( qq(no data stream) );
} else {
$fh = Maasha::Common::read_open( $path );
}