]> git.donarmstrong.com Git - biopieces.git/commitdiff
error handling and seq guess fix
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 18 Mar 2010 09:59:00 +0000 (09:59 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 18 Mar 2010 09:59:00 +0000 (09:59 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@931 74ccb610-7750-0410-82ae-013aeee3265d

code_perl/Maasha/Align.pm
code_perl/Maasha/BGB/Track.pm
code_perl/Maasha/Biopieces.pm
code_perl/Maasha/Match.pm
code_perl/Maasha/Plot.pm
code_perl/Maasha/Seq.pm
code_perl/Maasha/XHTML.pm
www/index.cgi

index 622846dc9c374117fb41d588d571f6dd550cd9b3..a01ec4b8cadc86660a9bd69965ca14564a04035f 100644 (file)
@@ -272,7 +272,7 @@ sub align_pins
 
     $type ||= Maasha::Seq::seq_guess_type( $entry1->[ SEQ ] );
 
-    $blosum = blosum_read() if $type =~ /protein/;
+    $blosum = blosum_read() if $type eq "PROTEIN";
 
     for ( $i = 0; $i < length $entry1->[ SEQ ]; $i++ )
     {
@@ -480,9 +480,9 @@ sub align_tile
 
         $type = Maasha::Seq::seq_guess_type( $seq1 );
 
-        if ( $type =~ /rna/i ) {
+        if ( $type eq "RNA" ) {
             $seq2 = Maasha::Seq::rna_revcomp( $seq1 );
-        } elsif ( $type =~ /dna/i ) {
+        } elsif ( $type eq "DNA" ) {
             $seq2 = Maasha::Seq::dna_revcomp( $seq1 );
         } else {
             Maasha::Common::error( qq(Bad sequence type->$type) );
index 5322636b7980faa62c12bc11f46c43d8179821fd..2c0822365d21c18a7aac3d418eeddb68f3b43194 100644 (file)
@@ -857,7 +857,9 @@ sub list_assembly_dir
 
     Maasha::Common::error( 'BP_WWW not set in environment' ) if not $ENV{ 'BP_WWW' };
 
-    @dirs = Maasha::Filesys::ls_dirs( "$ENV{ 'BP_WWW' }/Data/Users/$user/$clade/$genome" );
+    if ( $user and $clade and $genome ) {
+        @dirs = Maasha::Filesys::ls_dirs( "$ENV{ 'BP_WWW' }/Data/Users/$user/$clade/$genome" );
+    }
 
     @assemblies = grep { $_ !~ /\/\.\.?$/ } @dirs;
 
@@ -908,7 +910,9 @@ sub list_contig_dir
 
     Maasha::Common::error( 'BP_WWW not set in environment' ) if not $ENV{ 'BP_WWW' };
 
-    @dirs = Maasha::Filesys::ls_dirs( "$ENV{ 'BP_WWW' }/Data/Users/$user/$clade/$genome/$assembly" );
+    if ( $user and $clade and $genome and $assembly ) {
+        @dirs = Maasha::Filesys::ls_dirs( "$ENV{ 'BP_WWW' }/Data/Users/$user/$clade/$genome/$assembly" );
+    }
 
     @contigs = grep { $_ !~ /\/\.\.?$/ } @dirs;
 
index 1865cca4bb377780bb54460ef9ae0ec57cbf593e..70e332e5692857da17a40737823e15bc0e7f13c4 100644 (file)
@@ -56,6 +56,9 @@ $SIG{ 'INT' }     = \&sig_handler;
 $SIG{ 'TERM' }    = \&sig_handler;
 
 
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SUBROUTINES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
 sub status_set
 {
     my ( $time_stamp, $script, $user, $pid, $file, $fh );
index 1e971baf03b1787d351169cdf03091e3d83c9742..6ddd4132a05f6e8a3f044a17b558e81011ea09b2 100644 (file)
@@ -76,7 +76,7 @@ sub match_mummer
     push @args, "-F";
     push @args, "-l $options->{ 'word_size' }";
     push @args, "-maxmatch";
-    push @args, "-n" if not Maasha::Seq::seq_guess_type( $entries1->[ 0 ]->[ 1 ] ) eq "protein";
+    push @args, "-n" if not Maasha::Seq::seq_guess_type( $entries1->[ 0 ]->[ 1 ] ) eq "PROTEIN";
     push @args, "-b" if $options->{ "direction" } =~ /^b/;
     push @args, "-r" if $options->{ "direction" } =~ /^r/;
 
index 4ac715963e92f49e3457baeb9eae7f2789618636..06a401fdc49efc4b23b7b1b701f4ba743f3dc42e 100644 (file)
@@ -771,7 +771,7 @@ sub seq_logo
 
     $type = Maasha::Seq::seq_guess_type( $entries->[ 0 ]->[ 1 ] );
 
-    if ( $type =~ /^p/i ) {
+    if ( $type eq "PROTEIN" ) {
         $bit_max = 4;
     } else {
         $bit_max = 2;
index bc07bcecb5512c5a511d222f29d8e4116c66a868..4d6c7997665eb2ff19d4e2e44b6c035de841dbd4 100644 (file)
@@ -931,8 +931,8 @@ sub seq_alph
         PROTEIN  => [ qw(F L S Y C W P H Q R I M T N K V A D E G) ],
     );
 
-    if ( exists $alph_hash{ $type } ) {
-        $alph = $alph_hash{ $type };
+    if ( exists $alph_hash{ uc $type } ) {
+        $alph = $alph_hash{ uc $type };
     } else {
         die qq(ERROR: Unknown alphabet type: "$type"\n);
     }
index 7fd5f69221b8147cad07943befd3170253badadf..0992c7c258d6147e0b91066753912a0dbb6da3bc 100755 (executable)
@@ -1,6 +1,6 @@
 package Maasha::XHTML;
 
-# Copyright (C) 2005 Martin A. Hansen.
+# Copyright (C) 2005-2010 Martin A. Hansen.
 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -80,6 +80,48 @@ require Exporter;
 @ISA = qw( Exporter );
 
 
+# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SIGNAL HANDLERS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+use sigtrap qw( die normal-signals stack-trace any error-signals );
+
+my $WARNINGS = 0;
+
+$SIG{ '__DIE__' }  = \&sig_die;
+$SIG{ '__WARN__' } = \&sig_warn;
+
+
+sub sig_die
+{
+    my ( $sig,   # signal from the %SIG
+       ) = @_;
+
+    my ( @html );
+
+    push @html, &cgi_header;
+    push @html, p( txt => "ERROR: $sig" );
+
+    $WARNINGS++;
+
+    print "$_" for @html;
+}
+
+
+sub sig_warn
+{
+    my ( $sig,   # signal from the %SIG
+       ) = @_;
+
+    my ( @html );
+
+    push @html, &cgi_header if $WARNINGS == 0;
+    push @html, p( txt => "WARNING: $sig" );
+
+    $WARNINGS++;
+
+    print "$_" for @html;
+}
+
+
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> HEADERS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
 
@@ -96,7 +138,7 @@ sub html_header
 
     my ( @html );
 
-    push @html, &cgi_header                            if $args{ "cgi_header" };
+    push @html, &cgi_header                            if $args{ "cgi_header" } and $WARNINGS == 0;
     push @html, &doc_type;
     push @html, &head_beg;
     push @html, &title( $args{ "title" } )             if $args{ "title" };
index 9734938be5d148beb7eff7e44120e46c78c77523..9d68897d4374d9cc0e996bc5d92a5e0238eabb65 100755 (executable)
@@ -67,7 +67,6 @@ push @html, Maasha::XHTML::html_end;
 
 print "$_\n" foreach @html;
 
-
 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> SUBROUTINES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<