From: martinahansen Date: Wed, 9 Jul 2008 06:12:51 +0000 (+0000) Subject: added --help X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c87677598ba081b7845ea37fe061d48c63384d26;p=biopieces.git added --help git-svn-id: http://biopieces.googlecode.com/svn/trunk@134 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_perl/Maasha/Biopieces.pm b/code_perl/Maasha/Biopieces.pm index 5bd992a..a797eba 100644 --- a/code_perl/Maasha/Biopieces.pm +++ b/code_perl/Maasha/Biopieces.pm @@ -52,6 +52,7 @@ use Maasha::GFF; use Maasha::TwoBit; use Maasha::Solid; use Maasha::SQL; +use Maasha::Gwiki; use vars qw( @ISA @EXPORT_OK ); @@ -86,17 +87,17 @@ $SIG{ 'TERM' } = \&sig_handler; 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; @@ -133,7 +134,7 @@ sub log $time_stamp = Maasha::Common::time_stamp(); - $user = $ENV{ "USER" }; + $user = $ENV{ 'USER' }; $script = "biopieces" if $script eq "-e"; @@ -154,16 +155,21 @@ sub run_script 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 ) } @@ -876,6 +882,7 @@ sub get_options stream_in|I=s stream_out|O=s verbose + help|? ); # print STDERR Dumper( \@options ); @@ -885,6 +892,8 @@ sub get_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" }; @@ -980,59 +989,24 @@ sub script_print_usage # 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; } @@ -5526,7 +5500,7 @@ sub read_stream 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 ); } diff --git a/code_perl/Maasha/Plot.pm b/code_perl/Maasha/Plot.pm index f7072bd..70fa315 100644 --- a/code_perl/Maasha/Plot.pm +++ b/code_perl/Maasha/Plot.pm @@ -450,7 +450,7 @@ sub karyogram $karyo = parse_karyo_data( $karyo_file ); - $svg = init_svg; + $svg = init_svg(); chromosome_layout( $svg, $karyo, $data );