]> git.donarmstrong.com Git - biopieces.git/commitdiff
added --help
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 9 Jul 2008 06:12:51 +0000 (06:12 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 9 Jul 2008 06:12:51 +0000 (06:12 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@134 74ccb610-7750-0410-82ae-013aeee3265d

code_perl/Maasha/Biopieces.pm
code_perl/Maasha/Plot.pm

index 5bd992a4da42344d814430d6bcd661c77bb3ffa8..a797eba170bc0fcc9d8914fac1f221d25f5aa8fc 100644 (file)
@@ -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 );
     }
index f7072bde92b55ba85bd626c62a891e05e21b4365..70fa3159bd2fc2c5eb29ea5aae4094ac0ba9e784 100644 (file)
@@ -450,7 +450,7 @@ sub karyogram
 
     $karyo = parse_karyo_data( $karyo_file );
 
-    $svg = init_svg;
+    $svg = init_svg();
 
     chromosome_layout( $svg, $karyo, $data );