From 1857bbfaab292d6c0f2b7de86b6a5e283d332f4e Mon Sep 17 00:00:00 2001 From: martinahansen Date: Wed, 9 Jul 2008 04:53:08 +0000 Subject: [PATCH] removed & from all Perl Modules git-svn-id: http://biopieces.googlecode.com/svn/trunk@133 74ccb610-7750-0410-82ae-013aeee3265d --- bp_bin/read_align | 6 - code_perl/Maasha/Align.pm | 52 +- code_perl/Maasha/AlignTwoSeq.pm | 58 +- code_perl/Maasha/Berkeley_DB.pm | 2 +- code_perl/Maasha/Biopieces.pm | 1272 ++++++++++++++----------------- code_perl/Maasha/Blast.pm | 20 +- code_perl/Maasha/Calc.pm | 2 +- code_perl/Maasha/Common.pm | 60 +- code_perl/Maasha/Config.pm | 18 +- code_perl/Maasha/EMBL.pm | 30 +- code_perl/Maasha/Fasta.pm | 40 +- code_perl/Maasha/GFF.pm | 4 +- code_perl/Maasha/Gwiki.pm | 4 +- code_perl/Maasha/Match.pm | 38 +- code_perl/Maasha/Matrix.pm | 152 ++-- code_perl/Maasha/NCBI.pm | 4 +- code_perl/Maasha/Patscan.pm | 2 +- code_perl/Maasha/Plot.pm | 42 +- code_perl/Maasha/SQL.pm | 46 +- code_perl/Maasha/Seq.pm | 24 +- code_perl/Maasha/Test.pm | 2 +- code_perl/Maasha/TwoBit.pm | 38 +- code_perl/Maasha/UCSC.pm | 110 +-- 23 files changed, 945 insertions(+), 1081 deletions(-) delete mode 100755 bp_bin/read_align diff --git a/bp_bin/read_align b/bp_bin/read_align deleted file mode 100755 index 4cd1d44..0000000 --- a/bp_bin/read_align +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env perl - -use warnings; -use strict; - -use Maasha::Biopieces; diff --git a/code_perl/Maasha/Align.pm b/code_perl/Maasha/Align.pm index b0d270f..986a9b7 100644 --- a/code_perl/Maasha/Align.pm +++ b/code_perl/Maasha/Align.pm @@ -68,7 +68,7 @@ sub align $muscle_args = "-quiet"; $muscle_args .= $args if $args; - @aligned_entries = &align_muscle( $entries, $muscle_args ); + @aligned_entries = align_muscle( $entries, $muscle_args ); return wantarray ? @aligned_entries : \@aligned_entries; } @@ -94,11 +94,11 @@ sub align_muscle $pid = open2( $fh_out, $fh_in, $cmd ); - map { &Maasha::Fasta::put_entry( $_, $fh_in ) } @{ $entries }; + map { Maasha::Fasta::put_entry( $_, $fh_in ) } @{ $entries }; close $fh_in; - while ( $entry = &Maasha::Fasta::get_entry( $fh_out ) ) { + while ( $entry = Maasha::Fasta::get_entry( $fh_out ) ) { push @aligned_entries, $entry; } @@ -126,13 +126,13 @@ sub align_print_pairwise my ( @entries, $ruler1, $ruler2, $pins ); - $ruler1 = &align_ruler( $entry1, 1 ); - $ruler2 = &align_ruler( $entry2, 1 ); - $pins = &align_pins( $entry1, $entry2 ); + $ruler1 = align_ruler( $entry1, 1 ); + $ruler2 = align_ruler( $entry2, 1 ); + $pins = align_pins( $entry1, $entry2 ); push @entries, $ruler1, $entry1, $pins, $entry2, $ruler2; - &align_print( \@entries, $fh, $wrap ); + align_print( \@entries, $fh, $wrap ); } @@ -153,13 +153,13 @@ sub align_print_multi my ( @entries, $ruler, $consensus ); - $ruler = &align_ruler( $entries->[ 0 ] ); - $consensus = &align_consensus( $entries ) if not $no_cons; + $ruler = align_ruler( $entries->[ 0 ] ); + $consensus = align_consensus( $entries ) if not $no_cons; unshift @{ $entries }, $ruler if not $no_ruler; push @{ $entries }, $consensus; - &align_print( $entries, $fh, $wrap ); + align_print( $entries, $fh, $wrap ); } @@ -182,7 +182,7 @@ sub align_print map { $max = length $_->[ HEAD ] if length $_->[ HEAD ] > $max } @{ $entries }; - $blocks = &align_wrap( $entries, $wrap ); + $blocks = align_wrap( $entries, $wrap ); foreach $block ( @{ $blocks } ) { @@ -269,9 +269,9 @@ sub align_pins my ( $blosum, $i, $char1, $char2, $pins ); - $type ||= &Maasha::Seq::seq_guess_type( $entry1->[ SEQ ] ); + $type ||= Maasha::Seq::seq_guess_type( $entry1->[ SEQ ] ); - $blosum = &blosum_read() if $type =~ /protein/; + $blosum = blosum_read() if $type =~ /protein/; for ( $i = 0; $i < length $entry1->[ SEQ ]; $i++ ) { @@ -373,7 +373,7 @@ sub align_consensus my ( $bit_max, $data, $pos, $char, $score, $entry ); - $type ||= &Maasha::Seq::seq_guess_type( $entries->[ 0 ]->[ SEQ ] ); + $type ||= Maasha::Seq::seq_guess_type( $entries->[ 0 ]->[ SEQ ] ); $min_sim ||= 50; if ( $type =~ /protein/ ) { @@ -382,7 +382,7 @@ sub align_consensus $bit_max = 2; } - $data = &Maasha::Seq::seqlogo_calc( $bit_max, $entries ); + $data = Maasha::Seq::seqlogo_calc( $bit_max, $entries ); foreach $pos ( @{ $data } ) { @@ -446,7 +446,7 @@ sub align_sim_global $match_tot++ if substr( $entry1->[ SEQ ], $i, 1 ) eq substr( $entry2->[ SEQ ], $i, 1 ); } - $min = &Maasha::Calc::min( $len1, $len2 ); + $min = Maasha::Calc::min( $len1, $len2 ); $sim = sprintf( "%.2f", ( $match_tot / $min ) * 100 ); @@ -477,27 +477,27 @@ sub align_tile { $seq1 = $entry->[ SEQ ]; - $type = &Maasha::Seq::seq_guess_type( $seq1 ); + $type = Maasha::Seq::seq_guess_type( $seq1 ); if ( $type eq "rna" ) { - $seq2 = &Maasha::Seq::rna_revcomp( $seq1 ); + $seq2 = Maasha::Seq::rna_revcomp( $seq1 ); } elsif ( $type eq "dna" ) { - $seq2 = &Maasha::Seq::dna_revcomp( $seq1 ); + $seq2 = Maasha::Seq::dna_revcomp( $seq1 ); } else { - &Maasha::Common::error( qq(Bad sequence type->$type) ); + Maasha::Common::error( qq(Bad sequence type->$type) ); } - $align1 = &Maasha::Align::align_muscle( [ $ref_entry, [ $entry->[ HEAD ] . "_+", $seq1 ] ], "-quiet -maxiters 1" ); - $align2 = &Maasha::Align::align_muscle( [ $ref_entry, [ $entry->[ HEAD ] . "_-", $seq2 ] ], "-quiet -maxiters 1" ); + $align1 = Maasha::Align::align_muscle( [ $ref_entry, [ $entry->[ HEAD ] . "_+", $seq1 ] ], "-quiet -maxiters 1" ); + $align2 = Maasha::Align::align_muscle( [ $ref_entry, [ $entry->[ HEAD ] . "_-", $seq2 ] ], "-quiet -maxiters 1" ); if ( $args->{ "supress_indels" } ) { - &align_supress_indels( $align1 ); - &align_supress_indels( $align2 ); + align_supress_indels( $align1 ); + align_supress_indels( $align2 ); } - $sim1 = &Maasha::Align::align_sim_global( $align1->[ 0 ], $align1->[ 1 ] ); - $sim2 = &Maasha::Align::align_sim_global( $align2->[ 0 ], $align2->[ 1 ] ); + $sim1 = Maasha::Align::align_sim_global( $align1->[ 0 ], $align1->[ 1 ] ); + $sim2 = Maasha::Align::align_sim_global( $align2->[ 0 ], $align2->[ 1 ] ); if ( $sim1 < $args->{ "identity" } and $sim2 < $args->{ "identity" } ) { diff --git a/code_perl/Maasha/AlignTwoSeq.pm b/code_perl/Maasha/AlignTwoSeq.pm index 7d18643..3f861a8 100644 --- a/code_perl/Maasha/AlignTwoSeq.pm +++ b/code_perl/Maasha/AlignTwoSeq.pm @@ -88,34 +88,34 @@ sub align_two_seq my ( $wordsize, @chain, $match, $best_match, @long_matches ); - $matches = &select_matches( $matches, $q_min, $q_max, $s_min, $s_max ); + $matches = select_matches( $matches, $q_min, $q_max, $s_min, $s_max ); if ( scalar @{ $matches } == 0 ) # no matches - find some! { - # $wordsize = &find_wordsize( $q_min, $q_max, $s_min, $s_max, $args ); + # $wordsize = find_wordsize( $q_min, $q_max, $s_min, $s_max, $args ); $wordsize = 4; - $matches = &find_matches( $q_seq, $s_seq, $wordsize, $q_min, $q_max, $s_min, $s_max ); + $matches = find_matches( $q_seq, $s_seq, $wordsize, $q_min, $q_max, $s_min, $s_max ); while ( scalar @{ $matches } == 0 and $wordsize > 1 ) { $wordsize--; - $matches = &find_matches( $q_seq, $s_seq, $wordsize, $q_min, $q_max, $s_min, $s_max ); + $matches = find_matches( $q_seq, $s_seq, $wordsize, $q_min, $q_max, $s_min, $s_max ); } if ( scalar @{ $matches } > 0 ) { - push @chain, &align_two_seq( $q_seq, $s_seq, $matches, $q_min, $q_max, $s_min, $s_max, $args ); + push @chain, align_two_seq( $q_seq, $s_seq, $matches, $q_min, $q_max, $s_min, $s_max, $args ); } } elsif ( @long_matches = grep { $_->[ LEN ] >= $args->{ "long_matches" } } @{ $matches } ) # long matches found - include all that don't overlap! { - @long_matches = &order_matches( \@long_matches ); + @long_matches = order_matches( \@long_matches ); foreach $match ( @long_matches ) { push @chain, $match; if ( $match->[ Q_BEG ] - $q_min >= 2 and $match->[ S_BEG ] - $s_min >= 2 ) { - push @chain, &align_two_seq( $q_seq, $s_seq, $matches, $q_min, $match->[ Q_BEG ] - 1, $s_min, $match->[ S_BEG ] - 1, $args ); # intermediate search space + push @chain, align_two_seq( $q_seq, $s_seq, $matches, $q_min, $match->[ Q_BEG ] - 1, $s_min, $match->[ S_BEG ] - 1, $args ); # intermediate search space } $q_min = $match->[ Q_END ] + 1; @@ -123,14 +123,14 @@ sub align_two_seq } if ( $q_min + 1 < $q_max and $s_min + 1 < $s_max ) { - push @chain, &align_two_seq( $q_seq, $s_seq, $matches, $q_min, $q_max, $s_min, $s_max, $args ); # remaining search space + push @chain, align_two_seq( $q_seq, $s_seq, $matches, $q_min, $q_max, $s_min, $s_max, $args ); # remaining search space } } else # shorter matches are included according to score { foreach $match ( @{ $matches } ) { - # $match->[ SCORE ] = &score_match( $match, $q_min, $q_max, $s_min, $s_max ); - $match->[ SCORE ] = &score_match_niels( $match, $q_seq, $q_min, $q_max, $s_min, $s_max ); + # $match->[ SCORE ] = score_match( $match, $q_min, $q_max, $s_min, $s_max ); + $match->[ SCORE ] = score_match_niels( $match, $q_seq, $q_min, $q_max, $s_min, $s_max ); } # @{ $matches } = grep { $_->[ SCORE ] > 0 } @{ $matches }; @@ -145,11 +145,11 @@ sub align_two_seq push @chain, $best_match; if ( $best_match->[ Q_BEG ] - $q_min >= 2 and $best_match->[ S_BEG ] - $s_min >= 2 ) { - push @chain, &align_two_seq( $q_seq, $s_seq, $matches, $q_min, $best_match->[ Q_BEG ] - 1, $s_min, $best_match->[ S_BEG ] - 1, $args ); # left search space + push @chain, align_two_seq( $q_seq, $s_seq, $matches, $q_min, $best_match->[ Q_BEG ] - 1, $s_min, $best_match->[ S_BEG ] - 1, $args ); # left search space } if ( $q_max - $best_match->[ Q_END ] >= 2 and $s_max - $best_match->[ S_END ] >= 2 ) { - push @chain, &align_two_seq( $q_seq, $s_seq, $matches, $best_match->[ Q_END ] + 1, $q_max, $best_match->[ S_END ] + 1, $s_max, $args ); # right search space + push @chain, align_two_seq( $q_seq, $s_seq, $matches, $best_match->[ Q_END ] + 1, $q_max, $best_match->[ S_END ] + 1, $s_max, $args ); # right search space } } } @@ -255,7 +255,7 @@ sub find_wordsize $q_dim = $q_max - $q_min + 1; $s_dim = $s_max - $s_min + 1; - $dim_min = &Maasha::Calc::min( $q_dim, $s_dim ); + $dim_min = Maasha::Calc::min( $q_dim, $s_dim ); $wordsize = 1; @@ -333,7 +333,7 @@ sub find_matches } else { - $match = &expand_match( $q_seq, $s_seq, $match, $q_max, $q_min, $s_max, $s_min ); + $match = expand_match( $q_seq, $s_seq, $match, $q_max, $q_min, $s_max, $s_min ); $match->[ LEN ] = $match->[ Q_END ] - $match->[ Q_BEG ] + 1; push @matches, $match; @@ -372,7 +372,7 @@ sub find_matches } else { - $match = &expand_match( $q_seq, $s_seq, $match, $q_max, $q_min, $s_max, $s_min ); + $match = expand_match( $q_seq, $s_seq, $match, $q_max, $q_min, $s_max, $s_min ); $match->[ LEN ] = $match->[ Q_END ] - $match->[ Q_BEG ] + 1; push @matches, $match; @@ -476,16 +476,16 @@ sub score_match if ( $q_dim >= $s_dim ) # s_dim is the narrow end { - $beg_diag_dist = &Maasha::Calc::dist_point2line( $match->[ Q_BEG ], $match->[ S_BEG ], $q_min, $s_min, $q_min + $s_dim, $s_min + $s_dim ); - $end_diag_dist = &Maasha::Calc::dist_point2line( $match->[ Q_BEG ], $match->[ S_BEG ], $q_max - $s_dim, $s_max - $s_dim, $q_max, $s_max ); + $beg_diag_dist = Maasha::Calc::dist_point2line( $match->[ Q_BEG ], $match->[ S_BEG ], $q_min, $s_min, $q_min + $s_dim, $s_min + $s_dim ); + $end_diag_dist = Maasha::Calc::dist_point2line( $match->[ Q_BEG ], $match->[ S_BEG ], $q_max - $s_dim, $s_max - $s_dim, $q_max, $s_max ); } else { - $beg_diag_dist = &Maasha::Calc::dist_point2line( $match->[ Q_BEG ], $match->[ S_BEG ], $q_min, $s_min, $q_min + $q_dim, $s_min + $q_dim ); - $end_diag_dist = &Maasha::Calc::dist_point2line( $match->[ Q_BEG ], $match->[ S_BEG ], $q_max - $q_dim, $s_max - $q_dim, $q_max, $s_max ); + $beg_diag_dist = Maasha::Calc::dist_point2line( $match->[ Q_BEG ], $match->[ S_BEG ], $q_min, $s_min, $q_min + $q_dim, $s_min + $q_dim ); + $end_diag_dist = Maasha::Calc::dist_point2line( $match->[ Q_BEG ], $match->[ S_BEG ], $q_max - $q_dim, $s_max - $q_dim, $q_max, $s_max ); } - $min_diag_dist = &Maasha::Calc::min( $beg_diag_dist, $end_diag_dist ); + $min_diag_dist = Maasha::Calc::min( $beg_diag_dist, $end_diag_dist ); $score_diag = 2 * $min_diag_dist ** 2; @@ -496,14 +496,14 @@ sub score_match $beg_narrow_dist = $match->[ Q_BEG ] - $q_min; $end_narrow_dist = $q_max - $match->[ Q_BEG ]; - $max_narrow_dist = &Maasha::Calc::max( $beg_narrow_dist, $end_narrow_dist ); + $max_narrow_dist = Maasha::Calc::max( $beg_narrow_dist, $end_narrow_dist ); } elsif ( $q_dim < $s_dim ) { $beg_narrow_dist = $match->[ S_BEG ] - $s_min; $end_narrow_dist = $s_max - $match->[ S_BEG ]; - $max_narrow_dist = &Maasha::Calc::max( $beg_narrow_dist, $end_narrow_dist ); + $max_narrow_dist = Maasha::Calc::max( $beg_narrow_dist, $end_narrow_dist ); } else { @@ -835,8 +835,8 @@ sub print_matches $pins .= " " x ( $s_nomatch - $q_nomatch ); } - $q_ruler = &make_ruler( $q_aseq ); - $s_ruler = &make_ruler( $s_aseq ); + $q_ruler = make_ruler( $q_aseq ); + $s_ruler = make_ruler( $s_aseq ); $entries = [ [ "ruler", $q_ruler ], @@ -846,7 +846,7 @@ sub print_matches [ "ruler", $s_ruler ], ]; - &align_print_multi( $entries, undef, $args->{ "wrap" } ) + align_print_multi( $entries, undef, $args->{ "wrap" } ) } @@ -949,7 +949,7 @@ sub align_sim_local $q_diff = $q_end - $q_beg + 1; $s_diff = $s_end - $s_beg + 1; - $max = &Maasha::Calc::max( $q_diff, $s_diff ); + $max = Maasha::Calc::max( $q_diff, $s_diff ); $sim = sprintf( "%.2f", ( $match_tot / $max ) * 100 ); @@ -981,7 +981,7 @@ sub align_sim_global map { $match_tot += $_->[ LEN ] } @{ $chain }; - $min = &Maasha::Calc::min( length( ${ $q_seq } ), length( ${ $s_seq } ) ); + $min = Maasha::Calc::min( length( ${ $q_seq } ), length( ${ $s_seq } ) ); $sim = sprintf( "%.2f", ( $match_tot / $min ) * 100 ); @@ -1008,7 +1008,7 @@ sub align_consensus my ( $bit_max, $data, $pos, $char, $score, $entry ); - $type ||= &Maasha::Seq::seq_guess_type( $entries->[ 0 ] ); + $type ||= Maasha::Seq::seq_guess_type( $entries->[ 0 ] ); $min_sim ||= 50; if ( $type =~ /protein/ ) { @@ -1017,7 +1017,7 @@ sub align_consensus $bit_max = 2; } - $data = &Maasha::Seq::seqlogo_calc( $bit_max, $entries ); + $data = Maasha::Seq::seqlogo_calc( $bit_max, $entries ); foreach $pos ( @{ $data } ) { diff --git a/code_perl/Maasha/Berkeley_DB.pm b/code_perl/Maasha/Berkeley_DB.pm index be6639c..08cf6c8 100644 --- a/code_perl/Maasha/Berkeley_DB.pm +++ b/code_perl/Maasha/Berkeley_DB.pm @@ -57,7 +57,7 @@ sub db_init my ( %hash ); - tie %hash, "DB_File", $path or &Maasha::Common::error( "Could not tie-open DB file '$path': $!" ); + tie %hash, "DB_File", $path or Maasha::Common::error( "Could not tie-open DB file '$path': $!" ); return wantarray ? %hash : \%hash; } diff --git a/code_perl/Maasha/Biopieces.pm b/code_perl/Maasha/Biopieces.pm index e3b765c..5bd992a 100644 --- a/code_perl/Maasha/Biopieces.pm +++ b/code_perl/Maasha/Biopieces.pm @@ -85,18 +85,18 @@ $SIG{ 'TERM' } = \&sig_handler; my ( $script, $BP_TMP ); -$script = &Maasha::Common::get_scriptname(); -$BP_TMP = &Maasha::Common::get_tmpdir(); +$script = Maasha::Common::get_scriptname(); +$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{ "LOG_DIR" } . "/biopieces.log" ); $log_fh->autoflush( 1 ); -&log( $log_fh, $script, \@ARGV ); +log( $log_fh, $script, \@ARGV ); close $log_fh; @@ -106,7 +106,7 @@ close $log_fh; my $t0 = gettimeofday(); -&run_script( $script ); +run_script( $script ); my $t1 = gettimeofday(); @@ -131,7 +131,7 @@ sub log my ( $time_stamp, $user ); - $time_stamp = &Maasha::Common::time_stamp(); + $time_stamp = Maasha::Common::time_stamp(); $user = $ENV{ "USER" }; @@ -154,100 +154,98 @@ 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; - - $options = &get_options( $script ); - - $in = &read_stream( $options->{ "stream_in" } ); - $out = &write_stream( $options->{ "stream_out" } ); - - if ( $script eq "read_fasta" ) { &script_read_fasta( $in, $out, $options ) } - elsif ( $script eq "read_align" ) { &script_read_align( $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 ) } - elsif ( $script eq "read_blast_tab" ) { &script_read_blast_tab( $in, $out, $options ) } - elsif ( $script eq "read_embl" ) { &script_read_embl( $in, $out, $options ) } - elsif ( $script eq "read_stockholm" ) { &script_read_stockholm( $in, $out, $options ) } - elsif ( $script eq "read_phastcons" ) { &script_read_phastcons( $in, $out, $options ) } - elsif ( $script eq "read_soft" ) { &script_read_soft( $in, $out, $options ) } - elsif ( $script eq "read_gff" ) { &script_read_gff( $in, $out, $options ) } - elsif ( $script eq "read_2bit" ) { &script_read_2bit( $in, $out, $options ) } - elsif ( $script eq "read_solexa" ) { &script_read_solexa( $in, $out, $options ) } - elsif ( $script eq "read_solid" ) { &script_read_solid( $in, $out, $options ) } - elsif ( $script eq "read_mysql" ) { &script_read_mysql( $in, $out, $options ) } - elsif ( $script eq "count_seq" ) { &script_count_seq( $in, $out, $options ) } - elsif ( $script eq "length_seq" ) { &script_length_seq( $in, $out, $options ) } - elsif ( $script eq "uppercase_seq" ) { &script_uppercase_seq( $in, $out, $options ) } - elsif ( $script eq "shuffle_seq" ) { &script_shuffle_seq( $in, $out, $options ) } - elsif ( $script eq "analyze_seq" ) { &script_analyze_seq( $in, $out, $options ) } - elsif ( $script eq "analyze_tags" ) { &script_analyze_tags( $in, $out, $options ) } - elsif ( $script eq "complexity_seq" ) { &script_complexity_seq( $in, $out, $options ) } - elsif ( $script eq "oligo_freq" ) { &script_oligo_freq( $in, $out, $options ) } - elsif ( $script eq "create_weight_matrix" ) { &script_create_weight_matrix( $in, $out, $options ) } - elsif ( $script eq "calc_bit_scores" ) { &script_calc_bit_scores( $in, $out, $options ) } - elsif ( $script eq "reverse_seq" ) { &script_reverse_seq( $in, $out, $options ) } - elsif ( $script eq "complement_seq" ) { &script_complement_seq( $in, $out, $options ) } - elsif ( $script eq "remove_indels" ) { &script_remove_indels( $in, $out, $options ) } - elsif ( $script eq "transliterate_seq" ) { &script_transliterate_seq( $in, $out, $options ) } - elsif ( $script eq "transliterate_vals" ) { &script_transliterate_vals( $in, $out, $options ) } - elsif ( $script eq "translate_seq" ) { &script_translate_seq( $in, $out, $options ) } - elsif ( $script eq "extract_seq" ) { &script_extract_seq( $in, $out, $options ) } - elsif ( $script eq "get_genome_seq" ) { &script_get_genome_seq( $in, $out, $options ) } - elsif ( $script eq "get_genome_align" ) { &script_get_genome_align( $in, $out, $options ) } - elsif ( $script eq "get_genome_phastcons" ) { &script_get_genome_phastcons( $in, $out, $options ) } - elsif ( $script eq "fold_seq" ) { &script_fold_seq( $in, $out, $options ) } - elsif ( $script eq "split_seq" ) { &script_split_seq( $in, $out, $options ) } - elsif ( $script eq "split_bed" ) { &script_split_bed( $in, $out, $options ) } - elsif ( $script eq "align_seq" ) { &script_align_seq( $in, $out, $options ) } - elsif ( $script eq "tile_seq" ) { &script_tile_seq( $in, $out, $options ) } - elsif ( $script eq "invert_align" ) { &script_invert_align( $in, $out, $options ) } - elsif ( $script eq "patscan_seq" ) { &script_patscan_seq( $in, $out, $options ) } - elsif ( $script eq "create_blast_db" ) { &script_create_blast_db( $in, $out, $options ) } - elsif ( $script eq "blast_seq" ) { &script_blast_seq( $in, $out, $options ) } - elsif ( $script eq "blat_seq" ) { &script_blat_seq( $in, $out, $options ) } - elsif ( $script eq "match_seq" ) { &script_match_seq( $in, $out, $options ) } - elsif ( $script eq "create_vmatch_index" ) { &script_create_vmatch_index( $in, $out, $options ) } - elsif ( $script eq "vmatch_seq" ) { &script_vmatch_seq( $in, $out, $options ) } - elsif ( $script eq "write_fasta" ) { &script_write_fasta( $in, $out, $options, $options ) } - elsif ( $script eq "write_align" ) { &script_write_align( $in, $out, $options ) } - elsif ( $script eq "write_blast" ) { &script_write_blast( $in, $out, $options ) } - elsif ( $script eq "write_tab" ) { &script_write_tab( $in, $out, $options ) } - elsif ( $script eq "write_bed" ) { &script_write_bed( $in, $out, $options ) } - elsif ( $script eq "write_psl" ) { &script_write_psl( $in, $out, $options ) } - elsif ( $script eq "write_2bit" ) { &script_write_2bit( $in, $out, $options, $options ) } - elsif ( $script eq "write_solid" ) { &script_write_solid( $in, $out, $options, $options ) } - elsif ( $script eq "head_records" ) { &script_head_records( $in, $out, $options ) } - elsif ( $script eq "remove_keys" ) { &script_remove_keys( $in, $out, $options ) } - elsif ( $script eq "rename_keys" ) { &script_rename_keys( $in, $out, $options ) } - elsif ( $script eq "uniq_vals" ) { &script_uniq_vals( $in, $out, $options ) } - elsif ( $script eq "merge_vals" ) { &script_merge_vals( $in, $out, $options ) } - elsif ( $script eq "grab" ) { &script_grab( $in, $out, $options ) } - elsif ( $script eq "compute" ) { &script_compute( $in, $out, $options ) } - elsif ( $script eq "flip_tab" ) { &script_flip_tab( $in, $out, $options ) } - elsif ( $script eq "add_ident" ) { &script_add_ident( $in, $out, $options ) } - elsif ( $script eq "count_records" ) { &script_count_records( $in, $out, $options ) } - elsif ( $script eq "random_records" ) { &script_random_records( $in, $out, $options ) } - elsif ( $script eq "sort_records" ) { &script_sort_records( $in, $out, $options ) } - elsif ( $script eq "count_vals" ) { &script_count_vals( $in, $out, $options ) } - elsif ( $script eq "plot_histogram" ) { &script_plot_histogram( $in, $out, $options ) } - elsif ( $script eq "plot_lendist" ) { &script_plot_lendist( $in, $out, $options ) } - elsif ( $script eq "plot_chrdist" ) { &script_plot_chrdist( $in, $out, $options ) } - elsif ( $script eq "plot_karyogram" ) { &script_plot_karyogram( $in, $out, $options ) } - elsif ( $script eq "plot_matches" ) { &script_plot_matches( $in, $out, $options ) } - elsif ( $script eq "plot_seqlogo" ) { &script_plot_seqlogo( $in, $out, $options ) } - elsif ( $script eq "plot_phastcons_profiles" ) { &script_plot_phastcons_profiles( $in, $out, $options ) } - elsif ( $script eq "analyze_bed" ) { &script_analyze_bed( $in, $out, $options ) } - elsif ( $script eq "analyze_vals" ) { &script_analyze_vals( $in, $out, $options ) } - elsif ( $script eq "length_vals" ) { &script_length_vals( $in, $out, $options ) } - elsif ( $script eq "sum_vals" ) { &script_sum_vals( $in, $out, $options ) } - elsif ( $script eq "mean_vals" ) { &script_mean_vals( $in, $out, $options ) } - elsif ( $script eq "median_vals" ) { &script_median_vals( $in, $out, $options ) } - elsif ( $script eq "max_vals" ) { &script_max_vals( $in, $out, $options ) } - elsif ( $script eq "min_vals" ) { &script_min_vals( $in, $out, $options ) } - elsif ( $script eq "upload_to_ucsc" ) { &script_upload_to_ucsc( $in, $out, $options ) } + 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; + + $options = get_options( $script ); + + $in = read_stream( $options->{ "stream_in" } ); + $out = write_stream( $options->{ "stream_out" } ); + + if ( $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 ) } + elsif ( $script eq "read_blast_tab" ) { script_read_blast_tab( $in, $out, $options ) } + elsif ( $script eq "read_embl" ) { script_read_embl( $in, $out, $options ) } + elsif ( $script eq "read_stockholm" ) { script_read_stockholm( $in, $out, $options ) } + elsif ( $script eq "read_phastcons" ) { script_read_phastcons( $in, $out, $options ) } + elsif ( $script eq "read_soft" ) { script_read_soft( $in, $out, $options ) } + elsif ( $script eq "read_gff" ) { script_read_gff( $in, $out, $options ) } + elsif ( $script eq "read_2bit" ) { script_read_2bit( $in, $out, $options ) } + elsif ( $script eq "read_solexa" ) { script_read_solexa( $in, $out, $options ) } + elsif ( $script eq "read_solid" ) { script_read_solid( $in, $out, $options ) } + elsif ( $script eq "read_mysql" ) { script_read_mysql( $in, $out, $options ) } + elsif ( $script eq "length_seq" ) { script_length_seq( $in, $out, $options ) } + elsif ( $script eq "uppercase_seq" ) { script_uppercase_seq( $in, $out, $options ) } + elsif ( $script eq "shuffle_seq" ) { script_shuffle_seq( $in, $out, $options ) } + elsif ( $script eq "analyze_seq" ) { script_analyze_seq( $in, $out, $options ) } + elsif ( $script eq "analyze_tags" ) { script_analyze_tags( $in, $out, $options ) } + elsif ( $script eq "complexity_seq" ) { script_complexity_seq( $in, $out, $options ) } + elsif ( $script eq "oligo_freq" ) { script_oligo_freq( $in, $out, $options ) } + elsif ( $script eq "create_weight_matrix" ) { script_create_weight_matrix( $in, $out, $options ) } + elsif ( $script eq "calc_bit_scores" ) { script_calc_bit_scores( $in, $out, $options ) } + elsif ( $script eq "reverse_seq" ) { script_reverse_seq( $in, $out, $options ) } + elsif ( $script eq "complement_seq" ) { script_complement_seq( $in, $out, $options ) } + elsif ( $script eq "remove_indels" ) { script_remove_indels( $in, $out, $options ) } + elsif ( $script eq "transliterate_seq" ) { script_transliterate_seq( $in, $out, $options ) } + elsif ( $script eq "transliterate_vals" ) { script_transliterate_vals( $in, $out, $options ) } + elsif ( $script eq "translate_seq" ) { script_translate_seq( $in, $out, $options ) } + elsif ( $script eq "extract_seq" ) { script_extract_seq( $in, $out, $options ) } + elsif ( $script eq "get_genome_seq" ) { script_get_genome_seq( $in, $out, $options ) } + elsif ( $script eq "get_genome_align" ) { script_get_genome_align( $in, $out, $options ) } + elsif ( $script eq "get_genome_phastcons" ) { script_get_genome_phastcons( $in, $out, $options ) } + elsif ( $script eq "fold_seq" ) { script_fold_seq( $in, $out, $options ) } + elsif ( $script eq "split_seq" ) { script_split_seq( $in, $out, $options ) } + elsif ( $script eq "split_bed" ) { script_split_bed( $in, $out, $options ) } + elsif ( $script eq "align_seq" ) { script_align_seq( $in, $out, $options ) } + elsif ( $script eq "tile_seq" ) { script_tile_seq( $in, $out, $options ) } + elsif ( $script eq "invert_align" ) { script_invert_align( $in, $out, $options ) } + elsif ( $script eq "patscan_seq" ) { script_patscan_seq( $in, $out, $options ) } + elsif ( $script eq "create_blast_db" ) { script_create_blast_db( $in, $out, $options ) } + elsif ( $script eq "blast_seq" ) { script_blast_seq( $in, $out, $options ) } + elsif ( $script eq "blat_seq" ) { script_blat_seq( $in, $out, $options ) } + elsif ( $script eq "match_seq" ) { script_match_seq( $in, $out, $options ) } + elsif ( $script eq "create_vmatch_index" ) { script_create_vmatch_index( $in, $out, $options ) } + elsif ( $script eq "vmatch_seq" ) { script_vmatch_seq( $in, $out, $options ) } + elsif ( $script eq "write_fasta" ) { script_write_fasta( $in, $out, $options, $options ) } + elsif ( $script eq "write_align" ) { script_write_align( $in, $out, $options ) } + elsif ( $script eq "write_blast" ) { script_write_blast( $in, $out, $options ) } + elsif ( $script eq "write_tab" ) { script_write_tab( $in, $out, $options ) } + elsif ( $script eq "write_bed" ) { script_write_bed( $in, $out, $options ) } + elsif ( $script eq "write_psl" ) { script_write_psl( $in, $out, $options ) } + elsif ( $script eq "write_2bit" ) { script_write_2bit( $in, $out, $options, $options ) } + elsif ( $script eq "write_solid" ) { script_write_solid( $in, $out, $options, $options ) } + elsif ( $script eq "head_records" ) { script_head_records( $in, $out, $options ) } + elsif ( $script eq "remove_keys" ) { script_remove_keys( $in, $out, $options ) } + elsif ( $script eq "rename_keys" ) { script_rename_keys( $in, $out, $options ) } + elsif ( $script eq "uniq_vals" ) { script_uniq_vals( $in, $out, $options ) } + elsif ( $script eq "merge_vals" ) { script_merge_vals( $in, $out, $options ) } + elsif ( $script eq "grab" ) { script_grab( $in, $out, $options ) } + elsif ( $script eq "compute" ) { script_compute( $in, $out, $options ) } + elsif ( $script eq "flip_tab" ) { script_flip_tab( $in, $out, $options ) } + elsif ( $script eq "add_ident" ) { script_add_ident( $in, $out, $options ) } + elsif ( $script eq "count_records" ) { script_count_records( $in, $out, $options ) } + elsif ( $script eq "random_records" ) { script_random_records( $in, $out, $options ) } + elsif ( $script eq "sort_records" ) { script_sort_records( $in, $out, $options ) } + elsif ( $script eq "count_vals" ) { script_count_vals( $in, $out, $options ) } + elsif ( $script eq "plot_histogram" ) { script_plot_histogram( $in, $out, $options ) } + elsif ( $script eq "plot_lendist" ) { script_plot_lendist( $in, $out, $options ) } + elsif ( $script eq "plot_chrdist" ) { script_plot_chrdist( $in, $out, $options ) } + elsif ( $script eq "plot_karyogram" ) { script_plot_karyogram( $in, $out, $options ) } + elsif ( $script eq "plot_matches" ) { script_plot_matches( $in, $out, $options ) } + elsif ( $script eq "plot_seqlogo" ) { script_plot_seqlogo( $in, $out, $options ) } + elsif ( $script eq "plot_phastcons_profiles" ) { script_plot_phastcons_profiles( $in, $out, $options ) } + elsif ( $script eq "analyze_bed" ) { script_analyze_bed( $in, $out, $options ) } + elsif ( $script eq "analyze_vals" ) { script_analyze_vals( $in, $out, $options ) } + elsif ( $script eq "length_vals" ) { script_length_vals( $in, $out, $options ) } + elsif ( $script eq "sum_vals" ) { script_sum_vals( $in, $out, $options ) } + elsif ( $script eq "mean_vals" ) { script_mean_vals( $in, $out, $options ) } + elsif ( $script eq "median_vals" ) { script_median_vals( $in, $out, $options ) } + elsif ( $script eq "max_vals" ) { script_max_vals( $in, $out, $options ) } + elsif ( $script eq "min_vals" ) { script_min_vals( $in, $out, $options ) } + elsif ( $script eq "upload_to_ucsc" ) { script_upload_to_ucsc( $in, $out, $options ) } close $in if defined $in; close $out; @@ -277,13 +275,6 @@ sub get_options num|n=s ); } - elsif ( $script eq "read_align" ) - { - @options = qw( - data_in|i=s - num|n=s - ); - } elsif ( $script eq "read_tab" ) { @options = qw( @@ -391,13 +382,6 @@ sub get_options password|p=s ); } - elsif ( $script eq "count_seq" ) - { - @options = qw( - no_stream|x - data_out|o=s - ); - } elsif ( $script eq "length_seq" ) { @options = qw( @@ -913,12 +897,12 @@ sub get_options if ( $options{ 'data_in' } ) { - $options{ "files" } = &getopt_files( $options{ 'data_in' } ); + $options{ "files" } = getopt_files( $options{ 'data_in' } ); - &Maasha::Common::error( qq(Argument to --data_in must be a valid file or fileglob expression) ) if scalar @{ $options{ "files" } } == 0; + Maasha::Common::error( qq(Argument to --data_in must be a valid file or fileglob expression) ) if scalar @{ $options{ "files" } } == 0; } - map { &Maasha::Common::error( qq(Argument to --cols must be a whole numbers - not "$_") ) if $_ !~ /^\d+$/ } @{ $options{ "cols" } } if $options{ "cols" }; + map { Maasha::Common::error( qq(Argument to --cols must be a whole numbers - not "$_") ) if $_ !~ /^\d+$/ } @{ $options{ "cols" } } if $options{ "cols" }; # print STDERR Dumper( \%options ); @@ -926,60 +910,60 @@ sub get_options { if ( $opt =~ /stream_in|pattern_in|exact_in/ and not -f $options{ $opt } ) { - &Maasha::Common::error( qq(Argument to --$opt must be a valid file or fileglob expression - not "$options{ $opt }") ); + Maasha::Common::error( qq(Argument to --$opt must be a valid file or fileglob expression - not "$options{ $opt }") ); } elsif ( $opt =~ /beg|end|word_size|wrap|chunk_size|tile_size|len|prefix_length|num|skip|cpus|window_size|step_size/ and $options{ $opt } !~ /^\d+$/ ) { - &Maasha::Common::error( qq(Argument to --$opt must be a whole number - not "$options{ $opt }") ); + Maasha::Common::error( qq(Argument to --$opt must be a whole number - not "$options{ $opt }") ); } elsif ( $opt =~ /max_hits|max_hits|max_misses|dist|edit_dist|flank|gap|hamming_dist|priority/ and $options{ $opt } !~ /^-?\d+$/ ) { - &Maasha::Common::error( qq(Argument to --$opt must be an integer - not "$options{ $opt }") ); + Maasha::Common::error( qq(Argument to --$opt must be an integer - not "$options{ $opt }") ); } elsif ( $opt =~ /identity|threshold/ and $options{ $opt } !~ /^-?(?:\d+(?:\.\d*)?|\.\d+)$/ ) { - &Maasha::Common::error( qq(Argument to --$opt must be a decimal number - not "$options{ $opt }") ); + Maasha::Common::error( qq(Argument to --$opt must be a decimal number - not "$options{ $opt }") ); } elsif ( $opt =~ /e_val/ and $options{ $opt } !~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/ ) { - &Maasha::Common::error( qq(Argument to --$opt must be a float - not "$options{ $opt }") ); + Maasha::Common::error( qq(Argument to --$opt must be a float - not "$options{ $opt }") ); } elsif ( $opt =~ /strand/ and $options{ $opt } !~ /^(\+|-)$/ ) { - &Maasha::Common::error( qq(Argument to --$opt must be "+" or "-" - not "$options{ $opt }") ); + Maasha::Common::error( qq(Argument to --$opt must be "+" or "-" - not "$options{ $opt }") ); } elsif ( $opt eq "genome" ) { - @genomes = &Maasha::Config::genomes(); + @genomes = Maasha::Config::genomes(); if ( not grep $options{ $opt }, @genomes ) { - &Maasha::Common::error( qq(Genome $options{ $opt } not found in "$ENV{ 'INST_DIR' }/conf/genomes.conf") ); + Maasha::Common::error( qq(Genome $options{ $opt } not found in "$ENV{ 'INST_DIR' }/conf/genomes.conf") ); } } elsif ( $opt eq "terminal" and not $options{ $opt } =~ /^(svg|post|dumb)/ ) { - &Maasha::Common::error( qq(Bad --$opt argument "$options{ $opt }") ); + Maasha::Common::error( qq(Bad --$opt argument "$options{ $opt }") ); } elsif ( $opt eq "table" and $options{ $opt } =~ /-\./ ) { - &Maasha::Common::error( qq(Character '$options{ $opt }' is not allowed in table names) ); + Maasha::Common::error( qq(Character '$options{ $opt }' is not allowed in table names) ); } } - &Maasha::Common::error( qq(no --database specified) ) if $script eq "create_blast_db" and not $options{ "database" }; - &Maasha::Common::error( qq(no --index_name specified) ) if $script eq "create_vmatch_index" and not $options{ "index_name" }; - &Maasha::Common::error( qq(no --database or --genome specified) ) if $script eq "blast_seq" and not $options{ "genome" } and not $options{ "database" }; - &Maasha::Common::error( qq(both --database and --genome specified) ) if $script eq "blast_seq" and $options{ "genome" } and $options{ "database" }; - &Maasha::Common::error( qq(no --index_name or --genome specified) ) if $script eq "vmatch_seq" and not $options{ "genome" } and not $options{ "index_name" }; - &Maasha::Common::error( qq(both --index and --genome specified) ) if $script eq "vmatch_seq" and $options{ "genome" } and $options{ "index" }; - &Maasha::Common::error( qq(no --genome specified) ) if $script =~ /get_genome_seq|get_genome_align|get_genome_phastcons|blat_seq|plot_phastcons_profiles|plot_karyogram/ and not $options{ "genome" }; - &Maasha::Common::error( qq(no --key specified) ) if $script =~ /plot_lendist|plot_histogram/ and not $options{ "key" }; - &Maasha::Common::error( qq(no --keys speficied) ) if $script =~ /sort_records|count_vals|sum_vals|mean_vals|median_vals|length_vals/ and not $options{ "keys" }; + Maasha::Common::error( qq(no --database specified) ) if $script eq "create_blast_db" and not $options{ "database" }; + Maasha::Common::error( qq(no --index_name specified) ) if $script eq "create_vmatch_index" and not $options{ "index_name" }; + Maasha::Common::error( qq(no --database or --genome specified) ) if $script eq "blast_seq" and not $options{ "genome" } and not $options{ "database" }; + Maasha::Common::error( qq(both --database and --genome specified) ) if $script eq "blast_seq" and $options{ "genome" } and $options{ "database" }; + Maasha::Common::error( qq(no --index_name or --genome specified) ) if $script eq "vmatch_seq" and not $options{ "genome" } and not $options{ "index_name" }; + Maasha::Common::error( qq(both --index and --genome specified) ) if $script eq "vmatch_seq" and $options{ "genome" } and $options{ "index" }; + Maasha::Common::error( qq(no --genome specified) ) if $script =~ /get_genome_seq|get_genome_align|get_genome_phastcons|blat_seq|plot_phastcons_profiles|plot_karyogram/ and not $options{ "genome" }; + Maasha::Common::error( qq(no --key specified) ) if $script =~ /plot_lendist|plot_histogram/ and not $options{ "key" }; + Maasha::Common::error( qq(no --keys speficied) ) if $script =~ /sort_records|count_vals|sum_vals|mean_vals|median_vals|length_vals/ and not $options{ "keys" }; if ( $script eq "upload_to_ucsc" ) { - &Maasha::Common::error( qq(no --database specified) ) if not $options{ "database" }; - &Maasha::Common::error( qq(no --table specified) ) if not $options{ "table" }; + Maasha::Common::error( qq(no --database specified) ) if not $options{ "database" }; + Maasha::Common::error( qq(no --table specified) ) if not $options{ "table" }; } return wantarray ? %options : \%options; @@ -1005,7 +989,7 @@ sub script_print_usage $script = ( split "/", $path )[ -1 ]; - $fh = &Maasha::Common::read_open( $path ); + $fh = Maasha::Common::read_open( $path ); push @list, "Program name"; @@ -1032,7 +1016,7 @@ sub script_print_usage { if ( scalar @{ $hash{ $key } } == 1 ) { - @lines = &Maasha::Common::wrap_line( $hash{ $key }->[ 0 ], 80 ); + @lines = Maasha::Common::wrap_line( $hash{ $key }->[ 0 ], 80 ); printf( "%-15s%s\n", "$key:", shift @lines ); @@ -1067,13 +1051,13 @@ sub script_list_biopieces my ( @files, $file, $fh, $line, @lines, $program ); - @files = &Maasha::Common::ls_files( $path ); + @files = Maasha::Common::ls_files( $path ); foreach $file ( sort @files ) { $program = ( split "/", $file )[ -1 ]; - $fh = &Maasha::Common::read_open( $file ); + $fh = Maasha::Common::read_open( $file ); while ( $line = <$fh> ) { @@ -1081,7 +1065,7 @@ sub script_list_biopieces if ( $line =~ /^Description:\s+(.+)/ ) { - @lines = &Maasha::Common::wrap_line( $1, 60 ); + @lines = Maasha::Common::wrap_line( $1, 60 ); printf( "%-30s%s\n", $program, shift @lines ); @@ -1111,17 +1095,17 @@ sub script_read_fasta my ( $record, $file, $data_in, $entry, $num ); - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $num = 1; foreach $file ( @{ $options->{ "files" } } ) { - $data_in = &Maasha::Common::read_open( $file ); + $data_in = Maasha::Common::read_open( $file ); - while ( $entry = &Maasha::Fasta::get_entry( $data_in ) ) + while ( $entry = Maasha::Fasta::get_entry( $data_in ) ) { if ( defined $entry->[ SEQ_NAME ] and $entry->[ SEQ ] ) { @@ -1131,60 +1115,7 @@ sub script_read_fasta SEQ_LEN => length $entry->[ SEQ ], }; - &put_record( $record, $out ); - } - - goto NUM if $options->{ "num" } and $num == $options->{ "num" }; - - $num++; - } - - close $data_in; - } - - NUM: - - close $data_in if $data_in; -} - - -sub script_read_align -{ - # Martin A. Hansen, August 2007. - - # Read aligned sequences from FASTA file. - - my ( $in, # handle to in stream - $out, # handle to out stream - $options, # options hash - ) = @_; - - # Returns nothing. - - my ( $entry, $record, $file, $data_in, $num ); - - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); - } - - $num = 1; - - foreach $file ( @{ $options->{ "files" } } ) - { - $data_in = &Maasha::Common::read_open( $file ); - - while ( $entry = &Maasha::Fasta::get_entry( $data_in ) ) - { - if ( $entry->[ SEQ_NAME ] and $entry->[ SEQ ] ) - { - $record = { - ALIGN => 1, - SEQ_NAME => $entry->[ SEQ_NAME ], - SEQ => $entry->[ SEQ ], - ALIGN_LEN => length $entry->[ SEQ ], - }; - - &put_record( $record, $out ); + put_record( $record, $out ); } goto NUM if $options->{ "num" } and $num == $options->{ "num" }; @@ -1218,8 +1149,8 @@ sub script_read_tab $options->{ 'delimit' } ||= '\s+'; - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $skip = $options->{ 'skip' } ||= 0; @@ -1227,7 +1158,7 @@ sub script_read_tab foreach $file ( @{ $options->{ "files" } } ) { - $data_in = &Maasha::Common::read_open( $file ); + $data_in = Maasha::Common::read_open( $file ); while ( $line = <$data_in> ) { @@ -1261,7 +1192,7 @@ sub script_read_tab } } - &put_record( $record, $out ); + put_record( $record, $out ); goto NUM if $options->{ "num" } and $num == $options->{ "num" }; @@ -1292,19 +1223,19 @@ sub script_read_psl my ( $record, @files, $file, $entries, $entry, $num ); - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $num = 1; foreach $file ( @{ $options->{ "files" } } ) { - $entries = &Maasha::UCSC::psl_get_entries( $file ); + $entries = Maasha::UCSC::psl_get_entries( $file ); foreach $entry ( @{ $entries } ) { - &put_record( $entry, $out ); + put_record( $entry, $out ); goto NUM if $options->{ "num" } and $num == $options->{ "num" }; @@ -1331,19 +1262,19 @@ sub script_read_bed my ( $file, $record, $entry, $data_in, $num ); - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $num = 1; foreach $file ( @{ $options->{ "files" } } ) { - $data_in = &Maasha::Common::read_open( $file ); + $data_in = Maasha::Common::read_open( $file ); - while ( $entry = &Maasha::UCSC::bed_get_entry( $data_in ) ) + while ( $entry = Maasha::UCSC::bed_get_entry( $data_in ) ) { - &put_record( $entry, $out ); + put_record( $entry, $out ); goto NUM if $options->{ "num" } and $num == $options->{ "num" }; @@ -1374,15 +1305,15 @@ sub script_read_blast_tab my ( $file, $line, @fields, $strand, $record, $data_in, $num ); - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $num = 1; foreach $file ( @{ $options->{ "files" } } ) { - $data_in = &Maasha::Common::read_open( $file ); + $data_in = Maasha::Common::read_open( $file ); while ( $line = <$data_in> ) { @@ -1417,7 +1348,7 @@ sub script_read_blast_tab $record->{ "STRAND" } = '+'; } - &put_record( $record, $out ); + put_record( $record, $out ); goto NUM if $options->{ "num" } and $num == $options->{ "num" }; @@ -1452,19 +1383,19 @@ sub script_read_embl map { $options2{ "feats" }{ $_ } = 1 } @{ $options->{ "feats" } }; map { $options2{ "quals" }{ $_ } = 1 } @{ $options->{ "quals" } }; - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $num = 1; foreach $file ( @{ $options->{ "files" } } ) { - $data_in = &Maasha::Common::read_open( $file ); + $data_in = Maasha::Common::read_open( $file ); - while ( $entry = &Maasha::EMBL::get_embl_entry( $data_in ) ) + while ( $entry = Maasha::EMBL::get_embl_entry( $data_in ) ) { - $record = &Maasha::EMBL::parse_embl_entry( $entry, \%options2 ); + $record = Maasha::EMBL::parse_embl_entry( $entry, \%options2 ); my ( $feat, $feat2, $qual, $qual_val, $record_copy ); @@ -1472,7 +1403,7 @@ sub script_read_embl delete $record_copy->{ "FT" }; - &put_record( $record_copy, $out ); + put_record( $record_copy, $out ); delete $record_copy->{ "SEQ" }; @@ -1492,7 +1423,7 @@ sub script_read_embl $record_copy->{ $qual } = $qual_val; } - &put_record( $record_copy, $out ); + put_record( $record_copy, $out ); } } @@ -1525,19 +1456,19 @@ sub script_read_stockholm my ( $data_in, $file, $num, $entry, $record, $record_anno, $record_align, $key, $seq ); - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $num = 1; foreach $file ( @{ $options->{ "files" } } ) { - $data_in = &Maasha::Common::read_open( $file ); + $data_in = Maasha::Common::read_open( $file ); - while ( $entry = &Maasha::Stockholm::get_stockholm_entry( $data_in ) ) + while ( $entry = Maasha::Stockholm::get_stockholm_entry( $data_in ) ) { - $record = &Maasha::Stockholm::parse_stockholm_entry( $entry ); + $record = Maasha::Stockholm::parse_stockholm_entry( $entry ); undef $record_anno; @@ -1547,19 +1478,18 @@ sub script_read_stockholm $record_anno->{ "ALIGN" } = $num; - &put_record( $record_anno, $out ); + put_record( $record_anno, $out ); foreach $seq ( @{ $record->{ "ALIGN" } } ) { undef $record_align; $record_align = { - ALIGN => $num, SEQ_NAME => $seq->[ 0 ], SEQ => $seq->[ 1 ], }; - &put_record( $record_align, $out ); + put_record( $record_align, $out ); } goto NUM if $options->{ "num" } and $num == $options->{ "num" }; @@ -1596,26 +1526,26 @@ sub script_read_phastcons $options->{ "threshold" } ||= 0.8; $options->{ "gap" } ||= 5; - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $num = 1; foreach $file ( @{ $options->{ "files" } } ) { - $data_in = &Maasha::Common::read_open( $file ); + $data_in = Maasha::Common::read_open( $file ); - while ( $entry = &Maasha::UCSC::phastcons_get_entry( $data_in ) ) + while ( $entry = Maasha::UCSC::phastcons_get_entry( $data_in ) ) { - @records = &Maasha::UCSC::phastcons_parse_entry( $entry, $options ); + @records = Maasha::UCSC::phastcons_parse_entry( $entry, $options ); foreach $record ( @records ) { $record->{ "REC_TYPE" } = "BED"; $record->{ "BED_LEN" } = $record->{ "CHR_END" } - $record->{ "CHR_BEG" } + 1; - &put_record( $record, $out ); + put_record( $record, $out ); goto NUM if $options->{ "num" } and $num == $options->{ "num" }; @@ -1648,21 +1578,21 @@ sub script_read_soft my ( $data_in, $file, $num, $records, $record, $soft_index, $fh, @platforms, $plat_table, @samples, $sample, $old_end ); - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $num = 1; foreach $file ( @{ $options->{ "files" } } ) { - $soft_index = &Maasha::NCBI::soft_index_file( $file ); + $soft_index = Maasha::NCBI::soft_index_file( $file ); - $fh = &Maasha::Common::read_open( $file ); + $fh = Maasha::Common::read_open( $file ); @platforms = grep { $_->[ 0 ] =~ /PLATFORM/ } @{ $soft_index }; - $plat_table = &Maasha::NCBI::soft_get_platform( $fh, $platforms[ 0 ]->[ 1 ], $platforms[ -1 ]->[ 2 ] ); + $plat_table = Maasha::NCBI::soft_get_platform( $fh, $platforms[ 0 ]->[ 1 ], $platforms[ -1 ]->[ 2 ] ); @samples = grep { $_->[ 0 ] =~ /SAMPLE/ } @{ $soft_index }; @@ -1670,11 +1600,11 @@ sub script_read_soft foreach $sample ( @samples ) { - $records = &Maasha::NCBI::soft_get_sample( $fh, $plat_table, $sample->[ 1 ] - $old_end - 1, $sample->[ 2 ] - $old_end - 1 ); + $records = Maasha::NCBI::soft_get_sample( $fh, $plat_table, $sample->[ 1 ] - $old_end - 1, $sample->[ 2 ] - $old_end - 1 ); foreach $record ( @{ $records } ) { - &put_record( $record, $out ); + put_record( $record, $out ); goto NUM if $options->{ "num" } and $num == $options->{ "num" }; @@ -1710,19 +1640,19 @@ sub script_read_gff my ( $data_in, $file, $fh, $num, $record, $entry ); - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $num = 1; foreach $file ( @{ $options->{ "files" } } ) { - $fh = &Maasha::Common::read_open( $file ); + $fh = Maasha::Common::read_open( $file ); - while ( $entry = &Maasha::GFF::get_entry( $fh ) ) + while ( $entry = Maasha::GFF::get_entry( $fh ) ) { - &put_record( $entry, $out ); + put_record( $entry, $out ); goto NUM if $options->{ "num" } and $num == $options->{ "num" }; @@ -1755,25 +1685,25 @@ sub script_read_2bit $mask = 1 if not $options->{ "no_mask" }; - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $num = 1; foreach $file ( @{ $options->{ "files" } } ) { - $data_in = &Maasha::Common::read_open( $file ); + $data_in = Maasha::Common::read_open( $file ); - $toc = &Maasha::TwoBit::twobit_get_TOC( $data_in ); + $toc = Maasha::TwoBit::twobit_get_TOC( $data_in ); foreach $line ( @{ $toc } ) { $record->{ "SEQ_NAME" } = $line->[ 0 ]; - $record->{ "SEQ" } = &Maasha::TwoBit::twobit_get_seq( $data_in, $line->[ 1 ], undef, undef, $mask ); + $record->{ "SEQ" } = Maasha::TwoBit::twobit_get_seq( $data_in, $line->[ 1 ], undef, undef, $mask ); $record->{ "SEQ_LEN" } = length $record->{ "SEQ" }; - &put_record( $record, $out ); + put_record( $record, $out ); goto NUM if $options->{ "num" } and $num == $options->{ "num" }; @@ -1806,16 +1736,16 @@ sub script_read_solexa $options->{ "quality" } ||= 20; - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $num = 1; foreach $file ( @{ $options->{ "files" } } ) { - $data_in = &Maasha::Common::read_open( $file ); - $base_name = &Maasha::Common::get_basename( $file ); + $data_in = Maasha::Common::read_open( $file ); + $base_name = Maasha::Common::get_basename( $file ); $base_name =~ s/\..*//; $seq_count = 0; @@ -1835,9 +1765,9 @@ sub script_read_solexa $record->{ "SEQ_NAME" } = sprintf( "%s_ID%08d", $base_name, $seq_count ); $record->{ "SEQ" } = $seq; $record->{ "SEQ_LEN" } = length $seq; - $record->{ "SCORE_MEAN" } = sprintf ( "%.2f", &Maasha::Calc::mean( \@scores ) ); + $record->{ "SCORE_MEAN" } = sprintf ( "%.2f", Maasha::Calc::mean( \@scores ) ); - &put_record( $record, $out ); + put_record( $record, $out ); goto NUM if $options->{ "num" } and $num == $options->{ "num" }; @@ -1871,15 +1801,15 @@ sub script_read_solid $options->{ "quality" } ||= 15; - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $num = 1; foreach $file ( @{ $options->{ "files" } } ) { - $data_in = &Maasha::Common::read_open( $file ); + $data_in = Maasha::Common::read_open( $file ); while ( $line = <$data_in> ) { @@ -1888,7 +1818,7 @@ sub script_read_solid ( $seq_name, $seq_cs, $seq_qual ) = split /\t/, $line; @scores = split /,/, $seq_qual; - @seqs = split //, &Maasha::Solid::color_space2seq( $seq_cs ); + @seqs = split //, Maasha::Solid::color_space2seq( $seq_cs ); for ( $i = 0; $i < @seqs; $i++ ) { $seqs[ $i ] = lc $seqs[ $i ] if $scores[ $i ] < $options->{ "quality" }; @@ -1900,10 +1830,10 @@ sub script_read_solid SEQ_QUAL => $seq_qual, SEQ_LEN => length $seq_cs, SEQ => join( "", @seqs ), - SCORE_MEAN => sprintf( "%.2f", &Maasha::Calc::mean( \@scores ) ), + SCORE_MEAN => sprintf( "%.2f", Maasha::Calc::mean( \@scores ) ), }; - &put_record( $record, $out ); + put_record( $record, $out ); goto NUM if $options->{ "num" } and $num == $options->{ "num" }; @@ -1934,54 +1864,20 @@ sub script_read_mysql my ( $record, $dbh, $results ); - $options->{ "user" } ||= &Maasha::UCSC::ucsc_get_user(); - $options->{ "password" } ||= &Maasha::UCSC::ucsc_get_password(); + $options->{ "user" } ||= Maasha::UCSC::ucsc_get_user(); + $options->{ "password" } ||= Maasha::UCSC::ucsc_get_password(); - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } - $dbh = &Maasha::SQL::connect( $options->{ "database" }, $options->{ "user" }, $options->{ "password" } ); + $dbh = Maasha::SQL::connect( $options->{ "database" }, $options->{ "user" }, $options->{ "password" } ); - $results = &Maasha::SQL::query_hashref_list( $dbh, $options->{ "query" } ); + $results = Maasha::SQL::query_hashref_list( $dbh, $options->{ "query" } ); - &Maasha::SQL::disconnect( $dbh ); + Maasha::SQL::disconnect( $dbh ); - map { &put_record( $_ ) } @{ $results }; -} - - -sub script_count_seq -{ - # Martin A. Hansen, August 2007. - - # Count sequences in stream. - - my ( $in, # handle to in stream - $out, # handle to out stream - $options, # options hash - ) = @_; - - # Returns nothing. - - my ( $record, $count, $result, $fh ); - - $count = 0; - - while ( $record = &get_record( $in ) ) - { - $count++ if $record->{ "SEQ" }; - - &put_record( $record, $out ) if not $options->{ "no_stream" }; - } - - $result = { "count_seq" => $count }; - - $fh = &write_stream( $options->{ "data_out" } ); - - &put_record( $result, $fh ); - - close $fh; + map { put_record( $_ ) } @{ $results }; } @@ -2000,7 +1896,7 @@ sub script_length_seq my ( $record, $total ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ" } ) { @@ -2008,10 +1904,10 @@ sub script_length_seq $total += $record->{ "SEQ_LEN" }; } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } - &put_record( { TOTAL_SEQ_LEN => $total }, $out ); + put_record( { TOTAL_SEQ_LEN => $total }, $out ); } @@ -2029,11 +1925,11 @@ sub script_uppercase_seq my ( $record ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { $record->{ "SEQ" } = uc $record->{ "SEQ" } if $record->{ "SEQ" }; - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2052,11 +1948,11 @@ sub script_shuffle_seq my ( $record ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { - $record->{ "SEQ" } = &Maasha::Seq::seq_shuffle( $record->{ "SEQ" } ) if $record->{ "SEQ" }; + $record->{ "SEQ" } = Maasha::Seq::seq_shuffle( $record->{ "SEQ" } ) if $record->{ "SEQ" }; - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2075,16 +1971,16 @@ sub script_analyze_seq my ( $record, $analysis ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ" } ) { - $analysis = &Maasha::Seq::seq_analyze( $record->{ "SEQ" } ); + $analysis = Maasha::Seq::seq_analyze( $record->{ "SEQ" } ); map { $record->{ $_ } = $analysis->{ $_ } } keys %{ $analysis }; } - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2103,7 +1999,7 @@ sub script_analyze_tags my ( $record, $analysis, %len_hash, %clone_hash, $clones, $key, $tag_record ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { @@ -2133,7 +2029,7 @@ sub script_analyze_tags $tag_record->{ "TAG_COUNT" } = $len_hash{ $key }; $tag_record->{ "TAG_CLONES" } = $clone_hash{ $key }; - &put_record( $tag_record, $out ); + put_record( $tag_record, $out ); } } @@ -2153,11 +2049,11 @@ sub script_complexity_seq my ( $record, $index ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { - $record->{ "SEQ_COMPLEXITY" } = sprintf( "%.2f", &Maasha::Seq::seq_complexity( $record->{ "SEQ" } ) ) if $record->{ "SEQ" }; + $record->{ "SEQ_COMPLEXITY" } = sprintf( "%.2f", Maasha::Seq::seq_complexity( $record->{ "SEQ" } ) ) if $record->{ "SEQ" }; - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2179,30 +2075,30 @@ sub script_oligo_freq $options->{ "word_size" } ||= 7; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ" } ) { - map { $oligos{ $_ }++ } &Maasha::Seq::seq2oligos( \$record->{ "SEQ" }, $options->{ "word_size" } ); + map { $oligos{ $_ }++ } Maasha::Seq::seq2oligos( \$record->{ "SEQ" }, $options->{ "word_size" } ); if ( not $options->{ "all" } ) { - @freq_table = &Maasha::Seq::oligo_freq( \%oligos ); + @freq_table = Maasha::Seq::oligo_freq( \%oligos ); - map { &put_record( $_, $out ) } @freq_table; + map { put_record( $_, $out ) } @freq_table; undef %oligos; } } - &put_record( $record, $out ); + put_record( $record, $out ); } if ( $options->{ "all" } ) { - @freq_table = &Maasha::Seq::oligo_freq( \%oligos ); + @freq_table = Maasha::Seq::oligo_freq( \%oligos ); - map { &put_record( $_, $out ) } @freq_table; + map { put_record( $_, $out ) } @freq_table; } } @@ -2224,7 +2120,7 @@ sub script_create_weight_matrix $count = 0; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ" } ) { @@ -2240,7 +2136,7 @@ sub script_create_weight_matrix } else { - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2261,7 +2157,7 @@ sub script_create_weight_matrix $record->{ "V" . ( $i + 1 ) } = $freq; } - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2282,11 +2178,11 @@ sub script_calc_bit_scores $count = 0; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ" } ) { - $type = &Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) if not $type; + $type = Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) if not $type; for ( $i = 0; $i < length $record->{ "SEQ" }; $i++ ) { @@ -2301,7 +2197,7 @@ sub script_calc_bit_scores } else { - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2315,14 +2211,14 @@ sub script_calc_bit_scores for ( $i = 0; $i < keys %freq_hash; $i++ ) { - $bit_height = &Maasha::Seq::seqlogo_calc_bit_height( $freq_hash{ $i }, $count ); + $bit_height = Maasha::Seq::seqlogo_calc_bit_height( $freq_hash{ $i }, $count ); $bit_diff = $bit_max - $bit_height; $record->{ "V" . ( $i ) } = sprintf( "%.2f", $bit_diff ); } - &put_record( $record, $out ); + put_record( $record, $out ); } @@ -2340,13 +2236,13 @@ sub script_reverse_seq my ( $record ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ" } ) { $record->{ "SEQ" } = reverse $record->{ "SEQ" }; } - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2365,22 +2261,22 @@ sub script_complement_seq my ( $record, $type ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ" } ) { if ( not $type ) { - $type = &Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ); + $type = Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ); } if ( $type eq "rna" ) { - &Maasha::Seq::rna_comp( \$record->{ "SEQ" } ); + Maasha::Seq::rna_comp( \$record->{ "SEQ" } ); } elsif ( $type eq "dna" ) { - &Maasha::Seq::dna_comp( \$record->{ "SEQ" } ); + Maasha::Seq::dna_comp( \$record->{ "SEQ" } ); } } - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2399,11 +2295,11 @@ sub script_remove_indels my ( $record ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { $record->{ 'SEQ' } =~ tr/-~.//d if $record->{ "SEQ" }; - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2427,7 +2323,7 @@ sub script_transliterate_seq $replace = $options->{ "replace" } || ""; $delete = $options->{ "delete" } || ""; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ" } ) { @@ -2438,7 +2334,7 @@ sub script_transliterate_seq } } - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2462,7 +2358,7 @@ sub script_transliterate_vals $replace = $options->{ "replace" } || ""; $delete = $options->{ "delete" } || ""; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { foreach $key ( @{ $options->{ "keys" } } ) { @@ -2476,7 +2372,7 @@ sub script_transliterate_vals } } - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2498,27 +2394,27 @@ sub script_translate_seq $options->{ "frames" } ||= [ 1, 2, 3, -1, -2, -3 ]; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ" } ) { - if ( &Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) eq "dna" ) + if ( Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) eq "dna" ) { foreach $frame ( @{ $options->{ "frames" } } ) { %new_record = %{ $record }; - $new_record{ "SEQ" } = &Maasha::Seq::translate( $record->{ "SEQ" }, $frame ); + $new_record{ "SEQ" } = Maasha::Seq::translate( $record->{ "SEQ" }, $frame ); $new_record{ "SEQ_LEN" } = length $record->{ "SEQ" }; $new_record{ "FRAME" } = $frame; - &put_record( \%new_record, $out ); + put_record( \%new_record, $out ); } } } else { - &put_record( $record, $out ); + put_record( $record, $out ); } } } @@ -2555,7 +2451,7 @@ sub script_extract_seq # print "beg->$beg, end->$end, len->$len\n"; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ" } ) { @@ -2581,7 +2477,7 @@ sub script_extract_seq } } - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2605,11 +2501,11 @@ sub script_get_genome_seq if ( $options->{ "genome" } ) { - $genome_file = &Maasha::Config::genome_fasta( $options->{ 'genome' } ); - $index_file = &Maasha::Config::genome_fasta_index( $options->{ 'genome' } ); + $genome_file = Maasha::Config::genome_fasta( $options->{ 'genome' } ); + $index_file = Maasha::Config::genome_fasta_index( $options->{ 'genome' } ); - $fh = &Maasha::Common::read_open( $genome_file ); - $index = &Maasha::Fasta::index_retrieve( $index_file ); + $fh = Maasha::Common::read_open( $genome_file ); + $index = Maasha::Fasta::index_retrieve( $index_file ); shift @{ $index }; # Get rid of the file size info @@ -2644,14 +2540,14 @@ sub script_get_genome_seq $record->{ "CHR_BEG" } = $beg - $index_beg; $record->{ "CHR_END" } = $record->{ "CHR_BEG" } + $len - 1; - $record->{ "SEQ" } = &Maasha::Common::file_read( $fh, $beg, $len ); + $record->{ "SEQ" } = Maasha::Common::file_read( $fh, $beg, $len ); $record->{ "SEQ_LEN" } = $len; - &put_record( $record, $out ); + put_record( $record, $out ); } } - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $options->{ "genome" } and not $record->{ "SEQ" } ) { @@ -2693,11 +2589,11 @@ sub script_get_genome_seq $record->{ "CHR_BEG" } = $beg - $index_beg; $record->{ "CHR_END" } = $record->{ "CHR_BEG" } + $len - 1; - $record->{ "SEQ" } = &Maasha::Common::file_read( $fh, $beg, $len ); + $record->{ "SEQ" } = Maasha::Common::file_read( $fh, $beg, $len ); if ( $record->{ "STRAND" } and $record->{ "STRAND" } eq "-" ) { - &Maasha::Seq::dna_comp( \$record->{ "SEQ" } ); + Maasha::Seq::dna_comp( \$record->{ "SEQ" } ); $record->{ "SEQ" } = reverse $record->{ "SEQ" }; } @@ -2717,7 +2613,7 @@ sub script_get_genome_seq } } - &put_record( $record, $out ); + put_record( $record, $out ); } close $fh if $fh; @@ -2743,7 +2639,7 @@ sub script_get_genome_align $align_num = 1; - $maf_track = &Maasha::Config::maf_track( $options->{ "genome" } ); + $maf_track = Maasha::Config::maf_track( $options->{ "genome" } ); if ( $options->{ "chr" } and $options->{ "beg" } and ( $options->{ "end" } or $options->{ "len" } ) ) { @@ -2755,11 +2651,10 @@ sub script_get_genome_align $end = $beg + $options->{ "len" }; } - $align = &Maasha::UCSC::maf_extract( $BP_TMP, $options->{ "genome" }, $maf_track, $options->{ "chr" }, $beg, $end, $options->{ "strand" } ); + $align = Maasha::UCSC::maf_extract( $BP_TMP, $options->{ "genome" }, $maf_track, $options->{ "chr" }, $beg, $end, $options->{ "strand" } ); foreach $entry ( @{ $align } ) { - $entry->{ "ALIGN" } = $align_num; $entry->{ "CHR" } = $record->{ "CHR" }; $entry->{ "CHR_BEG" } = $record->{ "CHR_BEG" }; $entry->{ "CHR_END" } = $record->{ "CHR_END" }; @@ -2767,28 +2662,27 @@ sub script_get_genome_align $entry->{ "Q_ID" } = $record->{ "Q_ID" }; $entry->{ "SCORE" } = $record->{ "SCORE" }; - &put_record( $entry, $out ); + put_record( $entry, $out ); } } - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "REC_TYPE" } eq "BED" ) { - $align = &Maasha::UCSC::maf_extract( $BP_TMP, $options->{ "genome" }, $maf_track, $record->{ "CHR" }, $record->{ "CHR_BEG" }, $record->{ "CHR_END" }, $record->{ "STRAND" } ); + $align = Maasha::UCSC::maf_extract( $BP_TMP, $options->{ "genome" }, $maf_track, $record->{ "CHR" }, $record->{ "CHR_BEG" }, $record->{ "CHR_END" }, $record->{ "STRAND" } ); } elsif ( $record->{ "REC_TYPE" } eq "PSL" ) { - $align = &Maasha::UCSC::maf_extract( $BP_TMP, $options->{ "genome" }, $maf_track, $record->{ "S_ID" }, $record->{ "S_BEG" }, $record->{ "S_END" }, $record->{ "STRAND" } ); + $align = Maasha::UCSC::maf_extract( $BP_TMP, $options->{ "genome" }, $maf_track, $record->{ "S_ID" }, $record->{ "S_BEG" }, $record->{ "S_END" }, $record->{ "STRAND" } ); } elsif ( $record->{ "REC_TYPE" } eq "BLAST" ) { - $align = &Maasha::UCSC::maf_extract( $BP_TMP, $options->{ "genome" }, $maf_track, $record->{ "S_ID" }, $record->{ "S_BEG" }, $record->{ "S_END" }, $record->{ "STRAND" } ); + $align = Maasha::UCSC::maf_extract( $BP_TMP, $options->{ "genome" }, $maf_track, $record->{ "S_ID" }, $record->{ "S_BEG" }, $record->{ "S_END" }, $record->{ "STRAND" } ); } foreach $entry ( @{ $align } ) { - $entry->{ "ALIGN" } = $align_num; $entry->{ "CHR" } = $record->{ "CHR" }; $entry->{ "CHR_BEG" } = $record->{ "CHR_BEG" }; $entry->{ "CHR_END" } = $record->{ "CHR_END" }; @@ -2796,7 +2690,7 @@ sub script_get_genome_align $entry->{ "Q_ID" } = $record->{ "Q_ID" }; $entry->{ "SCORE" } = $record->{ "SCORE" }; - &put_record( $entry, $out ); + put_record( $entry, $out ); } $align_num++; @@ -2821,11 +2715,11 @@ sub script_get_genome_phastcons $options->{ "flank" } ||= 0; - $phastcons_file = &Maasha::Config::genome_phastcons( $options->{ "genome" } ); - $phastcons_index = &Maasha::Config::genome_phastcons_index( $options->{ "genome" } ); + $phastcons_file = Maasha::Config::genome_phastcons( $options->{ "genome" } ); + $phastcons_index = Maasha::Config::genome_phastcons_index( $options->{ "genome" } ); - $index = &Maasha::UCSC::phastcons_index_retrieve( $phastcons_index ); - $fh_phastcons = &Maasha::Common::read_open( $phastcons_file ); + $index = Maasha::UCSC::phastcons_index_retrieve( $phastcons_index ); + $fh_phastcons = Maasha::Common::read_open( $phastcons_file ); if ( defined $options->{ "chr" } and defined $options->{ "beg" } and ( defined $options->{ "end" } or defined $options->{ "len" } ) ) { @@ -2836,7 +2730,7 @@ sub script_get_genome_phastcons $options->{ "end" } = $options->{ "beg" } + $options->{ "len" } - 1; } - $scores = &Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $options->{ "chr" }, $options->{ "beg" }, $options->{ "end" }, $options->{ "flank" } ); + $scores = Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $options->{ "chr" }, $options->{ "beg" }, $options->{ "end" }, $options->{ "flank" } ); $record->{ "CHR" } = $options->{ "chr" }; $record->{ "CHR_BEG" } = $options->{ "beg" } - $options->{ "flank" }; @@ -2845,28 +2739,28 @@ sub script_get_genome_phastcons $record->{ "PHASTCONS" } = join ",", @{ $scores }; $record->{ "PHAST_COUNT" } = scalar @{ $scores }; # DEBUG - &put_record( $record, $out ); + put_record( $record, $out ); } - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "REC_TYPE" } eq "BED" ) { - $scores = &Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $record->{ "CHR" }, $record->{ "CHR_BEG" }, $record->{ "CHR_END" }, $options->{ "flank" } ); + $scores = Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $record->{ "CHR" }, $record->{ "CHR_BEG" }, $record->{ "CHR_END" }, $options->{ "flank" } ); } elsif ( $record->{ "REC_TYPE" } eq "PSL" ) { - $scores = &Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $record->{ "S_ID" }, $record->{ "S_BEG" }, $record->{ "S_END" }, $options->{ "flank" } ); + $scores = Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $record->{ "S_ID" }, $record->{ "S_BEG" }, $record->{ "S_END" }, $options->{ "flank" } ); } elsif ( $record->{ "REC_TYPE" } eq "BLAST" ) { - $scores = &Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $record->{ "S_ID" }, $record->{ "S_BEG" }, $record->{ "S_END" }, $options->{ "flank" } ); + $scores = Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $record->{ "S_ID" }, $record->{ "S_BEG" }, $record->{ "S_END" }, $options->{ "flank" } ); } $record->{ "PHASTCONS" } = join ",", @{ $scores } if @{ $scores }; # $record->{ "PHAST_COUNT" } = @{ $scores } if @{ $scores }; # DEBUG - &put_record( $record, $out ); + put_record( $record, $out ); } close $fh_phastcons if $fh_phastcons; @@ -2887,17 +2781,17 @@ sub script_fold_seq my ( $record, $type, $struct, $index ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ" } ) { if ( not $type ) { - $type = &Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ); + $type = Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ); } if ( $type ne "protein" ) { - ( $struct, $index ) = &Maasha::Seq::fold_struct_rnafold( $record->{ "SEQ" } ); + ( $struct, $index ) = Maasha::Seq::fold_struct_rnafold( $record->{ "SEQ" } ); $record->{ "SEC_STRUCT" } = $struct; $record->{ "FREE_ENERGY" } = $index; $record->{ "SCORE" } = abs int $index; @@ -2906,7 +2800,7 @@ sub script_fold_seq } } - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -2928,7 +2822,7 @@ sub script_split_seq $options->{ "word_size" } ||= 7; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { @@ -2942,7 +2836,7 @@ sub script_split_seq $new_record->{ "SEQ_NAME" } = $record->{ "SEQ_NAME" } . "[" . ( $i + 1 ) . "-" . ( $i + $options->{ "word_size" } ) . "]"; $new_record->{ "SEQ" } = $subseq; - &put_record( $new_record, $out ); + put_record( $new_record, $out ); $lookup{ $subseq } = 1; } @@ -2952,13 +2846,13 @@ sub script_split_seq $new_record->{ "SEQ_NAME" } = $record->{ "SEQ_NAME" } . "[" . ( $i + 1 ) . "-" . ( $i + $options->{ "word_size" } ) . "]"; $new_record->{ "SEQ" } = $subseq; - &put_record( $new_record, $out ); + put_record( $new_record, $out ); } } } else { - &put_record( $record, $out ); + put_record( $record, $out ); } } } @@ -2982,7 +2876,7 @@ sub script_split_bed $options->{ "window_size" } ||= 20; $options->{ "step_size" } ||= 1; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "CHR" } and $record->{ "CHR_BEG" } and $record->{ "CHR_END" } ) { @@ -2999,12 +2893,12 @@ sub script_split_bed $new_record->{ "SCORE" } = $record->{ "SCORE" }; $new_record->{ "STRAND" } = $record->{ "STRAND" }; - &put_record( $new_record, $out ); + put_record( $new_record, $out ); } } else { - &put_record( $record, $out ); + put_record( $record, $out ); } } } @@ -3024,30 +2918,29 @@ sub script_align_seq my ( $record, @entries, $entry ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { push @entries, [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ]; } elsif ( $record->{ "Q_ID" } and $record->{ "SEQ" } ) { push @entries, [ $record->{ "Q_ID" }, $record->{ "SEQ" } ]; } else { - &put_record( $record, $out ); + put_record( $record, $out ); } } - @entries = &Maasha::Align::align( \@entries ); + @entries = Maasha::Align::align( \@entries ); foreach $entry ( @entries ) { if ( $entry->[ SEQ_NAME ] and $entry->[ SEQ ] ) { $record = { - ALIGN => 1, SEQ_NAME => $entry->[ SEQ_NAME ], SEQ => $entry->[ SEQ ], }; - &put_record( $record, $out ); + put_record( $record, $out ); } } } @@ -3071,7 +2964,7 @@ sub script_tile_seq $first = 1; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { @@ -3088,13 +2981,13 @@ sub script_tile_seq } else { - &put_record( $record, $out ); + put_record( $record, $out ); } } - @entries = &Maasha::Align::align_tile( $ref_entry, \@entries, $options ); + @entries = Maasha::Align::align_tile( $ref_entry, \@entries, $options ); - map { &put_record( { SEQ_NAME => $_->[ SEQ_NAME ], SEQ => $_->[ SEQ ], ALIGN => 1 }, $out ) } @entries; + map { put_record( { SEQ_NAME => $_->[ SEQ_NAME ], SEQ => $_->[ SEQ ] }, $out ) } @entries; } @@ -3114,21 +3007,21 @@ sub script_invert_align my ( $record, @entries ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { - if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } and $record->{ "ALIGN" } ) + if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { push @entries, [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ]; } else { - &put_record( $record, $out ); + put_record( $record, $out ); } } - &Maasha::Align::align_invert( \@entries, $options->{ "soft" } ); + Maasha::Align::align_invert( \@entries, $options->{ "soft" } ); - map { &put_record( { SEQ_NAME => $_->[ SEQ_NAME ], SEQ => $_->[ SEQ ], ALIGN => 1 }, $out ) } @entries; + map { put_record( { SEQ_NAME => $_->[ SEQ_NAME ], SEQ => $_->[ SEQ ] }, $out ) } @entries; } @@ -3148,12 +3041,12 @@ sub script_patscan_seq my ( $genome_file, @args, $arg, $type, $seq_file, $pat_file, $out_file, $fh_in, $fh_out, $record, $patterns, $pattern, $entry, $result, %head_hash, $i ); if ( $options->{ "patterns" } ) { - $patterns = &Maasha::Patscan::parse_patterns( $options->{ "patterns" } ); + $patterns = Maasha::Patscan::parse_patterns( $options->{ "patterns" } ); } elsif ( -f $options->{ "patterns_in" } ) { - $patterns = &Maasha::Patscan::read_patterns( $options->{ "patterns_in" } ); + $patterns = Maasha::Patscan::read_patterns( $options->{ "patterns_in" } ); } - $genome_file = &Maasha::Config::genome_fasta( $options->{ 'genome' } ) if $options->{ 'genome' }; + $genome_file = Maasha::Config::genome_fasta( $options->{ 'genome' } ) if $options->{ 'genome' }; push @args, "-c" if $options->{ "comp" }; push @args, "-m $options->{ 'max_hits' }" if $options->{ 'max_hits' }; @@ -3163,24 +3056,24 @@ sub script_patscan_seq $pat_file = "$BP_TMP/patscan.pat"; $out_file = "$BP_TMP/patscan.out"; - $fh_out = &Maasha::Common::write_open( $seq_file ); + $fh_out = Maasha::Common::write_open( $seq_file ); $i = 0; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ" } and $record->{ "SEQ_NAME" } ) { - $type = &Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) if not $type; + $type = Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) if not $type; - &Maasha::Fasta::put_entry( [ $i, $record->{ "SEQ" } ], $fh_out ); + Maasha::Fasta::put_entry( [ $i, $record->{ "SEQ" } ], $fh_out ); $head_hash{ $i } = $record->{ "SEQ_NAME" }; $i++; } -# &put_record( $record, $out ); +# put_record( $record, $out ); } close $fh_out; @@ -3190,7 +3083,7 @@ sub script_patscan_seq foreach $pattern ( @{ $patterns } ) { - $fh_out = &Maasha::Common::write_open( $pat_file ); + $fh_out = Maasha::Common::write_open( $pat_file ); print $fh_out "$pattern\n"; @@ -3198,17 +3091,17 @@ sub script_patscan_seq if ( $options->{ 'genome' } ) { `scan_for_matches $arg $pat_file < $genome_file > $out_file`; - # &Maasha::Common::run( "scan_for_matches", "$arg $pat_file < $genome_file > $out_file" ); + # Maasha::Common::run( "scan_for_matches", "$arg $pat_file < $genome_file > $out_file" ); } else { `scan_for_matches $arg $pat_file < $seq_file > $out_file`; - # &Maasha::Common::run( "scan_for_matches", "$arg $pat_file < $seq_file > $out_file" ); + # Maasha::Common::run( "scan_for_matches", "$arg $pat_file < $seq_file > $out_file" ); } - $fh_in = &Maasha::Common::read_open( $out_file ); + $fh_in = Maasha::Common::read_open( $out_file ); - while ( $entry = &Maasha::Fasta::get_entry( $fh_in ) ) + while ( $entry = Maasha::Fasta::get_entry( $fh_in ) ) { - $result = &Maasha::Patscan::parse_scan_result( $entry, $pattern ); + $result = Maasha::Patscan::parse_scan_result( $entry, $pattern ); if ( $options->{ 'genome' } ) { @@ -3225,7 +3118,7 @@ sub script_patscan_seq $result->{ "S_ID" } = $head_hash{ $result->{ "S_ID" } }; } - &put_record( $result, $out ); + put_record( $result, $out ); } close $fh_in; @@ -3254,26 +3147,26 @@ sub script_create_blast_db $path = $options->{ "database" }; - $fh = &Maasha::Common::write_open( $path ); + $fh = Maasha::Common::write_open( $path ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; if ( $record->{ "SEQ" } and $record->{ "SEQ_NAME" } ) { - $seq_type = &Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) if not $seq_type; + $seq_type = Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) if not $seq_type; - &Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh ); + Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh ); } } close $fh; if ( $seq_type eq "protein" ) { - &Maasha::Common::run( "formatdb", "-p T -i $path -t $options->{ 'database' }" ); + Maasha::Common::run( "formatdb", "-p T -i $path -t $options->{ 'database' }" ); } else { - &Maasha::Common::run( "formatdb", "-p F -i $path -t $options->{ 'database' }" ); + Maasha::Common::run( "formatdb", "-p F -i $path -t $options->{ 'database' }" ); } unlink $path; @@ -3300,23 +3193,23 @@ sub script_blast_seq $options->{ "filter" } = "T" if $options->{ "filter" }; $options->{ "cpus" } ||= 1; - $options->{ "database" } = &Maasha::Config::genome_blast( $options->{ 'genome' } ) if $options->{ 'genome' }; + $options->{ "database" } = Maasha::Config::genome_blast( $options->{ 'genome' } ) if $options->{ 'genome' }; $tmp_in = "$BP_TMP/blast_query.seq"; $tmp_out = "$BP_TMP/blast.result"; - $fh_out = &Maasha::Common::write_open( $tmp_in ); + $fh_out = Maasha::Common::write_open( $tmp_in ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { - $q_type = &Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) if not $q_type; + $q_type = Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) if not $q_type; - &Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh_out ); + Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh_out ); } - &put_record( $record, $out ); + put_record( $record, $out ); } close $fh_out; @@ -3340,11 +3233,11 @@ sub script_blast_seq } } - &Maasha::Common::run( "blastall", "-p $options->{ 'program' } -e $options->{ 'e_val' } -a $options->{ 'cpus' } -m 8 -i $tmp_in -d $options->{ 'database' } -F $options->{ 'filter' } -o $tmp_out > /dev/null 2>&1", 1 ); + Maasha::Common::run( "blastall", "-p $options->{ 'program' } -e $options->{ 'e_val' } -a $options->{ 'cpus' } -m 8 -i $tmp_in -d $options->{ 'database' } -F $options->{ 'filter' } -o $tmp_out > /dev/null 2>&1", 1 ); unlink $tmp_in; - $fh_out = &Maasha::Common::read_open( $tmp_out ); + $fh_out = Maasha::Common::read_open( $tmp_out ); undef $record; @@ -3381,7 +3274,7 @@ sub script_blast_seq $record->{ "STRAND" } = '+'; } - &put_record( $record, $out ); + put_record( $record, $out ); } close $fh_out; @@ -3405,7 +3298,7 @@ sub script_blat_seq my ( $blat_args, $genome_file, $query_file, $fh_in, $fh_out, $type, $record, $result_file, $entries ); - $genome_file = &Maasha::Config::genome_fasta( $options->{ "genome" } ); + $genome_file = Maasha::Config::genome_fasta( $options->{ "genome" } ); $options->{ 'tile_size' } ||= 11; $options->{ 'one_off' } ||= 0; @@ -3418,21 +3311,21 @@ sub script_blat_seq $blat_args .= " -minIdentity=$options->{ 'min_identity' }"; $blat_args .= " -minScore=$options->{ 'min_score' }"; $blat_args .= " -stepSize=$options->{ 'step_size' }"; - $blat_args .= " -ooc=" . &Maasha::Config::genome_blat_ooc( $options->{ "genome" }, 11 ) if $options->{ 'ooc' }; + $blat_args .= " -ooc=" . Maasha::Config::genome_blat_ooc( $options->{ "genome" }, 11 ) if $options->{ 'ooc' }; $query_file = "$BP_TMP/blat.seq"; - $fh_out = &Maasha::Common::write_open( $query_file ); + $fh_out = Maasha::Common::write_open( $query_file ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { - &Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh_out, 80 ); - $type = &Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) if not $type; + Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh_out, 80 ); + $type = Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) if not $type; } - &put_record( $record, $out ); + put_record( $record, $out ); } close $fh_out; @@ -3442,13 +3335,13 @@ sub script_blat_seq $result_file = "$BP_TMP/blat.psl"; - &Maasha::Common::run( "blat", "$genome_file $query_file $blat_args $result_file > /dev/null 2>&1" ); + Maasha::Common::run( "blat", "$genome_file $query_file $blat_args $result_file > /dev/null 2>&1" ); unlink $query_file; - $entries = &Maasha::UCSC::psl_get_entries( $result_file ); + $entries = Maasha::UCSC::psl_get_entries( $result_file ); - map { &put_record( $_, $out ) } @{ $entries }; + map { put_record( $_, $out ) } @{ $entries }; unlink $result_file; } @@ -3472,26 +3365,26 @@ sub script_match_seq $options->{ "word_size" } ||= 20; $options->{ "direction" } ||= "both"; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { push @entries, [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ]; } - &put_record( $record, $out ); + put_record( $record, $out ); } if ( @entries == 1 ) { - $results = &Maasha::Match::match_mummer( [ $entries[ 0 ] ], [ $entries[ 0 ] ], $options, $BP_TMP ); + $results = Maasha::Match::match_mummer( [ $entries[ 0 ] ], [ $entries[ 0 ] ], $options, $BP_TMP ); - map { &put_record( $_, $out ) } @{ $results }; + map { put_record( $_, $out ) } @{ $results }; } elsif ( @entries == 2 ) { - $results = &Maasha::Match::match_mummer( [ $entries[ 0 ] ], [ $entries[ 1 ] ], $options, $BP_TMP ); + $results = Maasha::Match::match_mummer( [ $entries[ 0 ] ], [ $entries[ 1 ] ], $options, $BP_TMP ); - map { &put_record( $_, $out ) } @{ $results }; + map { put_record( $_, $out ) } @{ $results }; } } @@ -3514,19 +3407,19 @@ sub script_create_vmatch_index if ( $options->{ "index_name" } ) { $file_tmp = $options->{ 'index_name' }; - $fh_tmp = &Maasha::Common::write_open( $file_tmp ); + $fh_tmp = Maasha::Common::write_open( $file_tmp ); } - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $options->{ "index_name" } and $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { - &Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh_tmp ); + Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh_tmp ); - $type = &Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) if not $type; + $type = Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) if not $type; } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } if ( $options->{ "index_name" } ) @@ -3534,9 +3427,9 @@ sub script_create_vmatch_index close $fh_tmp; if ( $type eq "protein" ) { - &Maasha::Common::run( "mkvtree", "-db $file_tmp -protein -pl $options->{ 'prefix_length' } -allout -indexname $file_tmp > /dev/null 2>&1" ); + Maasha::Common::run( "mkvtree", "-db $file_tmp -protein -pl $options->{ 'prefix_length' } -allout -indexname $file_tmp > /dev/null 2>&1" ); } else { - &Maasha::Common::run( "mkvtree", "-db $file_tmp -dna -pl $options->{ 'prefix_length' } -allout -indexname $file_tmp > /dev/null 2>&1" ); + Maasha::Common::run( "mkvtree", "-db $file_tmp -dna -pl $options->{ 'prefix_length' } -allout -indexname $file_tmp > /dev/null 2>&1" ); } unlink $file_tmp; @@ -3564,24 +3457,24 @@ sub script_vmatch_seq if ( $options->{ "index_name" } ) { @index_files = $options->{ "index_name" }; } else { - @index_files = &Maasha::Config::genome_vmatch( $options->{ "genome" } ); + @index_files = Maasha::Config::genome_vmatch( $options->{ "genome" } ); } - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { push @records, $record; - &put_record( $record, $out ); + put_record( $record, $out ); } - $result_file = &Maasha::Match::match_vmatch( $BP_TMP, \@records, \@index_files, $options ); + $result_file = Maasha::Match::match_vmatch( $BP_TMP, \@records, \@index_files, $options ); undef @records; - $fh_in = &Maasha::Common::read_open( $result_file ); + $fh_in = Maasha::Common::read_open( $result_file ); - while ( $record = &Maasha::Match::vmatch_get_entry( $fh_in ) ) { - &put_record( $record, $out ); + while ( $record = Maasha::Match::vmatch_get_entry( $fh_in ) ) { + put_record( $record, $out ); } close $fh_in; @@ -3605,15 +3498,15 @@ sub script_write_fasta my ( $record, $fh ); - $fh = &write_stream( $options->{ "data_out" }, $options->{ "compress" } ); + $fh = write_stream( $options->{ "data_out" }, $options->{ "compress" } ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { - &Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh, $options->{ "wrap" } ); + Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh, $options->{ "wrap" } ); } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } close $fh; @@ -3633,46 +3526,23 @@ sub script_write_align # Returns nothing. - my ( $fh, $record, $align, $old_align, @entries ); + my ( $fh, $record, @entries ); - $fh = &write_stream( $options->{ "data_out" } ) ; + $fh = write_stream( $options->{ "data_out" } ) ; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { - if ( $record->{ "ALIGN" } and $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) - { - $align = $record->{ "ALIGN" }; - - if ( not $old_align ) - { - push @entries, [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ]; - - $old_align = $align; - } - elsif ( $align == $old_align ) - { - push @entries, [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ]; - } - else - { - if ( scalar( @entries ) == 2 ) { - &Maasha::Align::align_print_pairwise( $entries[ 0 ], $entries[ 1 ], $fh, $options->{ "wrap" } ); - } elsif ( scalar ( @entries ) > 2 ) { - &Maasha::Align::align_print_multi( \@entries, $fh, $options->{ "wrap" }, $options->{ "no_ruler" }, $options->{ "no_consensus" } ); - } - - undef @entries; - $old_align = $align; - } + if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { + push @entries, [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ]; } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } if ( scalar( @entries ) == 2 ) { - &Maasha::Align::align_print_pairwise( $entries[ 0 ], $entries[ 1 ], $fh, $options->{ "wrap" } ); + Maasha::Align::align_print_pairwise( $entries[ 0 ], $entries[ 1 ], $fh, $options->{ "wrap" } ); } elsif ( scalar ( @entries ) > 2 ) { - &Maasha::Align::align_print_multi( \@entries, $fh, $options->{ "wrap" }, $options->{ "no_ruler" }, $options->{ "no_consensus" } ); + Maasha::Align::align_print_multi( \@entries, $fh, $options->{ "wrap" }, $options->{ "no_ruler" }, $options->{ "no_consensus" } ); } close $fh if $fh; @@ -3694,11 +3564,11 @@ sub script_write_blast my ( $fh, $record, $first ); - $fh = &write_stream( $options->{ "data_out" }, $options->{ "compress" } ) ; + $fh = write_stream( $options->{ "data_out" }, $options->{ "compress" } ) ; $first = 1; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "REC_TYPE" } eq "BLAST" ) { @@ -3729,7 +3599,7 @@ sub script_write_blast ), "\n"; } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } close $fh; @@ -3755,9 +3625,9 @@ sub script_write_tab map { $no_keys{ $_ } = 1 } @{ $options->{ "no_keys" } }; - $fh = &write_stream( $options->{ "data_out" }, $options->{ "compress" } ); + $fh = write_stream( $options->{ "data_out" }, $options->{ "compress" } ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { undef @vals; $ok = 1; @@ -3798,7 +3668,7 @@ sub script_write_tab print $fh join( $options->{ "delimit" }, @vals ), "\n" if @vals; - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } close $fh; @@ -3822,13 +3692,13 @@ sub script_write_bed my ( $fh, $record, $new_record ); - $fh = &write_stream( $options->{ "data_out" }, $options->{ "compress" } ); + $fh = write_stream( $options->{ "data_out" }, $options->{ "compress" } ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "REC_TYPE" } eq "BED" ) # ---- Hits from BED ---- { - &Maasha::UCSC::bed_put_entry( $record, $fh, $record->{ "BED_COLS" } ); + Maasha::UCSC::bed_put_entry( $record, $fh, $record->{ "BED_COLS" } ); } elsif ( $record->{ "REC_TYPE" } eq "PSL" and $record->{ "S_ID" } =~ /^chr/i ) # ---- Hits from BLAT (PSL) ---- { @@ -3839,11 +3709,11 @@ sub script_write_bed $new_record->{ "SCORE" } = $record->{ "SCORE" } || 999; $new_record->{ "STRAND" } = $record->{ "STRAND" }; - &Maasha::UCSC::bed_put_entry( $new_record, $fh, 6 ); + Maasha::UCSC::bed_put_entry( $new_record, $fh, 6 ); } elsif ( $record->{ "REC_TYPE" } eq "PATSCAN" and $record->{ "CHR" } ) # ---- Hits from patscan_seq ---- { - &Maasha::UCSC::bed_put_entry( $record, $fh, 6 ); + Maasha::UCSC::bed_put_entry( $record, $fh, 6 ); } elsif ( $record->{ "REC_TYPE" } eq "BLAST" and $record->{ "S_ID" } =~ /^chr/i ) # ---- Hits from BLAST ---- { @@ -3854,7 +3724,7 @@ sub script_write_bed $new_record->{ "SCORE" } = $record->{ "SCORE" } || 999; # or use E_VAL somehow $new_record->{ "STRAND" } = $record->{ "STRAND" }; - &Maasha::UCSC::bed_put_entry( $new_record, $fh, 6 ); + Maasha::UCSC::bed_put_entry( $new_record, $fh, 6 ); } elsif ( $record->{ "REC_TYPE" } eq "VMATCH" and $record->{ "S_ID" } =~ /^chr/i ) # ---- Hits from Vmatch ---- { @@ -3865,14 +3735,14 @@ sub script_write_bed $new_record->{ "SCORE" } = $record->{ "SCORE" } || 999; # or use E_VAL somehow $new_record->{ "STRAND" } = $record->{ "STRAND" }; - &Maasha::UCSC::bed_put_entry( $new_record, $fh, 6 ); + Maasha::UCSC::bed_put_entry( $new_record, $fh, 6 ); } elsif ( $record->{ "CHR" } and defined $record->{ "CHR_BEG" } and $record->{ "CHR_END" } ) # ---- Generic data from tables ---- { - &Maasha::UCSC::bed_put_entry( $record, $fh ); + Maasha::UCSC::bed_put_entry( $record, $fh ); } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } close $fh; @@ -3896,16 +3766,16 @@ sub script_write_psl $first = 1; - $fh = &write_stream( $options->{ "data_out" }, $options->{ "compress" } ); + $fh = write_stream( $options->{ "data_out" }, $options->{ "compress" } ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; if ( $record->{ "REC_TYPE" } and $record->{ "REC_TYPE" } eq "PSL" ) { - &Maasha::UCSC::psl_put_header( $fh ) if $first; - &Maasha::UCSC::psl_put_entry( $record, $fh ); + Maasha::UCSC::psl_put_header( $fh ) if $first; + Maasha::UCSC::psl_put_entry( $record, $fh ); $first = 0; } } @@ -3932,24 +3802,24 @@ sub script_write_2bit $mask = 1 if not $options->{ "no_mask" }; $tmp_file = "$BP_TMP/write_2bit.fna"; - $fh_tmp = &Maasha::Common::write_open( $tmp_file ); + $fh_tmp = Maasha::Common::write_open( $tmp_file ); - $fh_out = &write_stream( $options->{ "data_out" } ); + $fh_out = write_stream( $options->{ "data_out" } ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { - &Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh_tmp ); + Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh_tmp ); } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } close $fh_tmp; - $fh_in = &Maasha::Common::read_open( $tmp_file ); + $fh_in = Maasha::Common::read_open( $tmp_file ); - &Maasha::TwoBit::fasta2twobit( $fh_in, $fh_out, $mask ); + Maasha::TwoBit::fasta2twobit( $fh_in, $fh_out, $mask ); close $fh_in; close $fh_out; @@ -3973,18 +3843,18 @@ sub script_write_solid my ( $record, $fh, $seq_cs ); - $fh = &write_stream( $options->{ "data_out" }, $options->{ "compress" } ); + $fh = write_stream( $options->{ "data_out" }, $options->{ "compress" } ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { - $seq_cs = &Maasha::Solid::seq2color_space( $record->{ "SEQ" } ); + $seq_cs = Maasha::Solid::seq2color_space( $record->{ "SEQ" } ); - &Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $seq_cs ], $fh, $options->{ "wrap" } ); + Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $seq_cs ], $fh, $options->{ "wrap" } ); } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } close $fh; @@ -4006,18 +3876,18 @@ sub script_plot_seqlogo my ( $record, @entries, $logo, $fh ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) { push @entries, [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ]; } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } - $logo = &Maasha::Plot::seq_logo( \@entries ); + $logo = Maasha::Plot::seq_logo( \@entries ); - $fh = &write_stream( $options->{ "data_out" } ); + $fh = write_stream( $options->{ "data_out" } ); print $fh $logo; @@ -4042,34 +3912,34 @@ sub script_plot_phastcons_profiles $options->{ "title" } ||= "PhastCons Profiles"; - $phastcons_file = &Maasha::Config::genome_phastcons( $options->{ "genome" } ); - $phastcons_index = &Maasha::Config::genome_phastcons_index( $options->{ "genome" } ); + $phastcons_file = Maasha::Config::genome_phastcons( $options->{ "genome" } ); + $phastcons_index = Maasha::Config::genome_phastcons_index( $options->{ "genome" } ); - $index = &Maasha::UCSC::phastcons_index_retrieve( $phastcons_index ); - $fh_phastcons = &Maasha::Common::read_open( $phastcons_file ); + $index = Maasha::UCSC::phastcons_index_retrieve( $phastcons_index ); + $fh_phastcons = Maasha::Common::read_open( $phastcons_file ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "CHR" } and $record->{ "CHR_BEG" } and $record->{ "CHR_END" } ) { - $scores = &Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $record->{ "CHR" }, $record->{ "CHR_BEG" }, $record->{ "CHR_END" }, $options->{ "flank" } ); + $scores = Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $record->{ "CHR" }, $record->{ "CHR_BEG" }, $record->{ "CHR_END" }, $options->{ "flank" } ); push @{ $AoA }, [ @{ $scores } ]; } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } - &Maasha::UCSC::phastcons_normalize( $AoA ); + Maasha::UCSC::phastcons_normalize( $AoA ); - $AoA = [ [ &Maasha::UCSC::phastcons_mean( $AoA ) ] ] if $options->{ "mean" }; - $AoA = [ [ &Maasha::UCSC::phastcons_median( $AoA ) ] ] if $options->{ "median" }; + $AoA = [ [ Maasha::UCSC::phastcons_mean( $AoA ) ] ] if $options->{ "mean" }; + $AoA = [ [ Maasha::UCSC::phastcons_median( $AoA ) ] ] if $options->{ "median" }; - $AoA = &Maasha::Matrix::matrix_flip( $AoA ); + $AoA = Maasha::Matrix::matrix_flip( $AoA ); - $plot = &Maasha::Plot::lineplot_simple( $AoA, $options, $BP_TMP ); + $plot = Maasha::Plot::lineplot_simple( $AoA, $options, $BP_TMP ); - $fh = &write_stream( $options->{ "data_out" } ); + $fh = write_stream( $options->{ "data_out" } ); print $fh "$_\n" foreach @{ $plot }; @@ -4092,11 +3962,11 @@ sub script_analyze_bed my ( $record ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { - $record = &Maasha::UCSC::bed_analyze( $record ) if $record->{ "REC_TYPE" } eq "BED"; + $record = Maasha::UCSC::bed_analyze( $record ) if $record->{ "REC_TYPE" } eq "BED"; - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -4118,7 +3988,7 @@ sub script_analyze_vals map { $key_hash{ $_ } = 1 } @{ $options->{ "keys" } }; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { foreach $key ( keys %{ $record } ) { @@ -4126,7 +3996,7 @@ sub script_analyze_vals $analysis->{ $key }->{ "COUNT" }++; - if ( &Maasha::Calc::is_a_number( $record->{ $key } ) ) + if ( Maasha::Calc::is_a_number( $record->{ $key } ) ) { $analysis->{ $key }->{ "TYPE" } = "num"; $analysis->{ $key }->{ "SUM" } += $record->{ $key }; @@ -4144,7 +4014,7 @@ sub script_analyze_vals } } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } foreach $key ( keys %{ $analysis } ) @@ -4209,11 +4079,11 @@ sub script_head_records $count = 0; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { $count++; - &put_record( $record, $out ); + put_record( $record, $out ); last if $count == $options->{ "num" }; } @@ -4235,7 +4105,7 @@ sub script_remove_keys my ( $record, $new_record ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $options->{ "keys" } ) { @@ -4248,7 +4118,7 @@ sub script_remove_keys $record = $new_record; } - &put_record( $record, $out ) if keys %{ $record }; + put_record( $record, $out ) if keys %{ $record }; } } @@ -4268,7 +4138,7 @@ sub script_rename_keys my ( $record ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( exists $record->{ $options->{ "keys" }->[ 0 ] } ) { @@ -4277,7 +4147,7 @@ sub script_rename_keys delete $record->{ $options->{ "keys" }->[ 0 ] }; } - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -4297,19 +4167,19 @@ sub script_uniq_vals my ( %hash, $record ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ $options->{ "key" } } ) { if ( not $hash{ $record->{ $options->{ "key" } } } and not $options->{ "invert" } ) { - &put_record( $record, $out ); + put_record( $record, $out ); $hash{ $record->{ $options->{ "key" } } } = 1; } elsif ( $hash{ $record->{ $options->{ "key" } } } and $options->{ "invert" } ) { - &put_record( $record, $out ); + put_record( $record, $out ); } else { @@ -4318,7 +4188,7 @@ sub script_uniq_vals } else { - &put_record( $record, $out ); + put_record( $record, $out ); } } } @@ -4341,7 +4211,7 @@ sub script_merge_vals $options->{ "delimit" } ||= '_'; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( exists $record->{ $options->{ "keys" }->[ 0 ] } ) { @@ -4354,7 +4224,7 @@ sub script_merge_vals $record->{ $options->{ "keys" }->[ 0 ] } = join $options->{ "delimit" }, @join; } - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -4380,11 +4250,11 @@ sub script_grab } elsif ( -f $options->{ "patterns_in" } ) { - $patterns = &Maasha::Patscan::read_patterns( $options->{ "patterns_in" } ); + $patterns = Maasha::Patscan::read_patterns( $options->{ "patterns_in" } ); } elsif ( -f $options->{ "exact_in" } ) { - $patterns = &Maasha::Patscan::read_patterns( $options->{ "exact_in" } ); + $patterns = Maasha::Patscan::read_patterns( $options->{ "exact_in" } ); map { $lookup_hash{ $_ } = 1 } @{ $patterns }; @@ -4401,7 +4271,7 @@ sub script_grab } } - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { $pos = -1; @@ -4546,9 +4416,9 @@ sub script_grab FOUND: if ( $pos >= 0 and not $options->{ "invert" } ) { - &put_record( $record, $out ); + put_record( $record, $out ); } elsif ( $pos < 0 and $options->{ "invert" } ) { - &put_record( $record, $out ); + put_record( $record, $out ); } } } @@ -4569,7 +4439,7 @@ sub script_compute my ( $record, $eval_key, $eval_val, $check, @keys ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $options->{ "eval" } ) { @@ -4589,10 +4459,10 @@ sub script_compute map { $eval_val =~ s/$_/$record->{ $_ }/g } @keys; - $record->{ $eval_key } = eval "$eval_val" or &Maasha::Common::error( "eval failed -> $@" ); + $record->{ $eval_key } = eval "$eval_val" or Maasha::Common::error( "eval failed -> $@" ); } - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -4612,7 +4482,7 @@ sub script_flip_tab my ( $record, $key, $A, $B, @rows, @matrix, $row, $i ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { undef @rows; @@ -4627,7 +4497,7 @@ sub script_flip_tab undef $record; - @matrix = &Maasha::Matrix::matrix_flip( \@matrix ); + @matrix = Maasha::Matrix::matrix_flip( \@matrix ); foreach $row ( @matrix ) { @@ -4635,7 +4505,7 @@ sub script_flip_tab $record->{ "V$i" } = $row->[ $i ]; } - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -4660,11 +4530,11 @@ sub script_add_ident $i = 0; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { $record->{ $key } = sprintf( "$prefix%08d", $i ); - &put_record( $record, $out ); + put_record( $record, $out ); $i++; } @@ -4699,9 +4569,9 @@ sub script_count_records } else { - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { - &put_record( $record, $out ); + put_record( $record, $out ); $count++; } @@ -4709,9 +4579,9 @@ sub script_count_records $result = { "count_records" => $count }; - $fh = &write_stream( $options->{ "data_out" } ); + $fh = write_stream( $options->{ "data_out" } ); - &put_record( $result, $fh ); + put_record( $result, $fh ); close $fh; } @@ -4736,13 +4606,13 @@ sub script_random_records $tmp_file = "$BP_TMP/random_records.tmp"; - $fh_out = &Maasha::Common::write_open( $tmp_file ); + $fh_out = Maasha::Common::write_open( $tmp_file ); $count = 0; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { - &put_record( $record, $fh_out ); + put_record( $record, $fh_out ); $count++; } @@ -4752,7 +4622,7 @@ sub script_random_records $max = 0; $i = 0; - &Maasha::Common::error( qq(Requested random records > records in stream) ) if $options->{ "num" } > $count; + Maasha::Common::error( qq(Requested random records > records in stream) ) if $options->{ "num" } > $count; while ( $i < $options->{ "num" } ) { @@ -4768,13 +4638,13 @@ sub script_random_records } } - $fh_in = &Maasha::Common::read_open( $tmp_file ); + $fh_in = Maasha::Common::read_open( $tmp_file ); $count = 0; - while ( $record = &get_record( $fh_in ) ) + while ( $record = get_record( $fh_in ) ) { - &put_record( $record, $out ) if exists $rand_hash{ $count }; + put_record( $record, $out ) if exists $rand_hash{ $count }; last if $count == $max; @@ -4814,7 +4684,7 @@ sub script_sort_records $sort_str = join " or ", @sort_cmd; $sort_sub = eval "sub { $sort_str }"; # NB security issue! - while ( $record = &get_record( $in ) ) { + while ( $record = get_record( $in ) ) { push @records, $record; } @@ -4823,13 +4693,13 @@ sub script_sort_records if ( $options->{ "reverse" } ) { for ( $i = scalar @records - 1; $i >= 0; $i-- ) { - &put_record( $records[ $i ], $out ); + put_record( $records[ $i ], $out ); } } else { for ( $i = 0; $i < scalar @records; $i++ ) { - &put_record( $records[ $i ], $out ); + put_record( $records[ $i ], $out ); } } } @@ -4852,11 +4722,11 @@ sub script_count_vals $tmp_file = "$BP_TMP/count_cache.tmp"; - $fh_out = &Maasha::Common::write_open( $tmp_file ); + $fh_out = Maasha::Common::write_open( $tmp_file ); $num = 0; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { map { $count_hash{ $_ }{ $record->{ $_ } }++ if exists $record->{ $_ } } @{ $options->{ "keys" } }; @@ -4864,7 +4734,7 @@ sub script_count_vals if ( scalar @records > 5_000_000 ) # too many records to hold in memory - use disk cache { - map { &put_record( $_, $fh_out ) } @records; + map { put_record( $_, $fh_out ) } @records; undef @records; @@ -4882,13 +4752,13 @@ sub script_count_vals { $num = 0; - $fh_in = &Maasha::Common::read_open( $tmp_file ); + $fh_in = Maasha::Common::read_open( $tmp_file ); - while ( $record = &get_record( $fh_in ) ) + while ( $record = get_record( $fh_in ) ) { map { $record->{ $_ . "_COUNT" } = $count_hash{ $_ }{ $record->{ $_ } } if exists $record->{ $_ } } @{ $options->{ "keys" } }; - &put_record( $record, $out ); + put_record( $record, $out ); print STDERR "verbose: cache read $num\n" if ( $options->{ 'verbose' } and ( $num % 1_000_000 ) == 0 ); @@ -4902,7 +4772,7 @@ sub script_count_vals { map { $record->{ $_ . "_COUNT" } = $count_hash{ $_ }{ $record->{ $_ } } if exists $record->{ $_ } } @{ $options->{ "keys" } }; - &put_record( $record, $out ); + put_record( $record, $out ); } unlink $tmp_file; @@ -4927,11 +4797,11 @@ sub script_plot_histogram $options->{ "title" } ||= "Histogram"; $options->{ "sort" } ||= "num"; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { $data_hash{ $record->{ $options->{ "key" } } }++ if $record->{ $options->{ "key" } }; - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } if ( $options->{ "sort" } eq "num" ) { @@ -4940,9 +4810,9 @@ sub script_plot_histogram map { push @data_list, [ $_, $data_hash{ $_ } ] } sort keys %data_hash; } - $result = &Maasha::Plot::histogram_simple( \@data_list, $options ); + $result = Maasha::Plot::histogram_simple( \@data_list, $options ); - $fh = &write_stream( $options->{ "data_out" } ); + $fh = write_stream( $options->{ "data_out" } ); print $fh "$_\n" foreach @{ $result }; @@ -4967,22 +4837,22 @@ sub script_plot_lendist $options->{ "title" } ||= "Length Distribution"; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { $data_hash{ $record->{ $options->{ "key" } } }++ if $record->{ $options->{ "key" } }; - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } - $max = &Maasha::Calc::list_max( [ keys %data_hash ] ); + $max = Maasha::Calc::list_max( [ keys %data_hash ] ); for ( $i = 0; $i < $max; $i++ ) { push @data_list, [ $i, $data_hash{ $i } || 0 ]; } - $result = &Maasha::Plot::histogram_lendist( \@data_list, $options ); + $result = Maasha::Plot::histogram_lendist( \@data_list, $options ); - $fh = &write_stream( $options->{ "data_out" } ); + $fh = write_stream( $options->{ "data_out" } ); print $fh "$_\n" foreach @{ $result }; @@ -5007,7 +4877,7 @@ sub script_plot_chrdist $options->{ "title" } ||= "Chromosome Distribution"; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "CHR" } ) { # generic $data_hash{ $record->{ "CHR" } }++; @@ -5019,7 +4889,7 @@ sub script_plot_chrdist $data_hash{ $record->{ "S_ID" } }++; } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } foreach $elem ( keys %data_hash ) @@ -5043,9 +4913,9 @@ sub script_plot_chrdist @data_list = sort { $a->[ 2 ] <=> $b->[ 2 ] } @data_list; - $result = &Maasha::Plot::histogram_chrdist( \@data_list, $options ); + $result = Maasha::Plot::histogram_chrdist( \@data_list, $options ); - $fh = &write_stream( $options->{ "data_out" } ); + $fh = write_stream( $options->{ "data_out" } ); print $fh "$_\n" foreach @{ $result }; @@ -5071,19 +4941,19 @@ sub script_plot_karyogram $options->{ "genome" } ||= "human"; $options->{ "feat_color" } ||= "black"; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( $record->{ "CHR" } and $record->{ "CHR_BEG" } and $record->{ "CHR_END" } ) { push @{ $data_hash{ $record->{ "CHR" } } }, [ $record->{ "CHR_BEG" }, $record->{ "CHR_END" }, $options->{ "feat_color" } ]; } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } - $result = &Maasha::Plot::karyogram( \%data_hash, \%options ); + $result = Maasha::Plot::karyogram( \%data_hash, \%options ); - $fh = &write_stream( $options->{ "data_out" } ); + $fh = write_stream( $options->{ "data_out" } ); print $fh $result; @@ -5108,22 +4978,22 @@ sub script_plot_matches $options->{ "direction" } ||= "both"; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { if ( defined $record->{ "Q_BEG" } and defined $record->{ "S_BEG" } and $record->{ "Q_END" } and $record->{ "S_END" } ) { push @data, $record; } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } $options->{ "title" } ||= "plot_matches"; $options->{ "xlabel" } ||= $data[ 0 ]->{ "Q_ID" }; $options->{ "ylabel" } ||= $data[ 0 ]->{ "S_ID" }; - $result = &Maasha::Plot::dotplot_matches( \@data, $options, $BP_TMP ); + $result = Maasha::Plot::dotplot_matches( \@data, $options, $BP_TMP ); - $fh = &write_stream( $options->{ "data_out" } ); + $fh = write_stream( $options->{ "data_out" } ); print $fh "$_\n" foreach @{ $result }; @@ -5146,7 +5016,7 @@ sub script_length_vals my ( $record, $key ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { foreach $key ( @{ $options->{ "keys" } } ) { @@ -5155,7 +5025,7 @@ sub script_length_vals } } - &put_record( $record, $out ); + put_record( $record, $out ); } } @@ -5175,7 +5045,7 @@ sub script_sum_vals my ( $record, $key, %sum_hash, $fh ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { foreach $key ( @{ $options->{ "keys" } } ) { @@ -5184,13 +5054,13 @@ sub script_sum_vals } } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } - $fh = &write_stream( $options->{ "data_out" } ); + $fh = write_stream( $options->{ "data_out" } ); foreach $key ( @{ $options->{ "keys" } } ) { - &put_record( { $key . "_SUM" => $sum_hash{ $key } || 0 } , $fh ); + put_record( { $key . "_SUM" => $sum_hash{ $key } || 0 } , $fh ); } close $fh; @@ -5212,7 +5082,7 @@ sub script_mean_vals my ( $record, $key, %sum_hash, %count_hash, $mean, $fh ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { foreach $key ( @{ $options->{ "keys" } } ) { @@ -5223,10 +5093,10 @@ sub script_mean_vals } } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } - $fh = &write_stream( $options->{ "data_out" } ); + $fh = write_stream( $options->{ "data_out" } ); foreach $key ( @{ $options->{ "keys" } } ) { @@ -5236,7 +5106,7 @@ sub script_mean_vals $mean = "N/A"; } - &put_record( { $key . "_MEAN" => $mean } , $fh ); + put_record( { $key . "_MEAN" => $mean } , $fh ); } close $fh; @@ -5258,26 +5128,26 @@ sub script_median_vals my ( $record, $key, %median_hash, $median, $fh ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { foreach $key ( @{ $options->{ "keys" } } ) { push @{ $median_hash{ $key } }, $record->{ $key } if defined $record->{ $key }; } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } - $fh = &write_stream( $options->{ "data_out" } ); + $fh = write_stream( $options->{ "data_out" } ); foreach $key ( @{ $options->{ "keys" } } ) { if ( $median_hash{ $key } ) { - $median = &Maasha::Calc::median( $median_hash{ $key } ); + $median = Maasha::Calc::median( $median_hash{ $key } ); } else { $median = "N/A"; } - &put_record( { $key . "_MEDIAN" => $median } , $fh ); + put_record( { $key . "_MEDIAN" => $median } , $fh ); } close $fh; @@ -5299,7 +5169,7 @@ sub script_max_vals my ( $record, $key, $fh, %max_hash, $max_record ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { foreach $key ( @{ $options->{ "keys" } } ) { @@ -5309,17 +5179,17 @@ sub script_max_vals } } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } - $fh = &write_stream( $options->{ "data_out" } ); + $fh = write_stream( $options->{ "data_out" } ); foreach $key ( @{ $options->{ "keys" } } ) { $max_record->{ $key . "_MAX" } = $max_hash{ $key }; } - &put_record( $max_record, $fh ); + put_record( $max_record, $fh ); close $fh; } @@ -5340,7 +5210,7 @@ sub script_min_vals my ( $record, $key, $fh, %min_hash, $min_record ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { foreach $key ( @{ $options->{ "keys" } } ) { @@ -5354,17 +5224,17 @@ sub script_min_vals } } - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; } - $fh = &write_stream( $options->{ "data_out" } ); + $fh = write_stream( $options->{ "data_out" } ); foreach $key ( @{ $options->{ "keys" } } ) { $min_record->{ $key . "_MIN" } = $min_hash{ $key }; } - &put_record( $min_record, $fh ); + put_record( $min_record, $fh ); close $fh; } @@ -5406,34 +5276,34 @@ sub script_upload_to_ucsc { $options->{ "visibility" } = "full"; - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; $record->{ "CHR" } = $record->{ "S_ID" } if not defined $record->{ "CHR" }; $record->{ "CHR_BEG" } = $record->{ "S_BEG" } if not defined $record->{ "CHR_BEG" }; $record->{ "CHR_END" } = $record->{ "S_END" } if not defined $record->{ "CHR_END" }; - $fh_hash{ $record->{ "CHR" } } = &Maasha::Common::write_open( "$BP_TMP/$record->{ 'CHR' }" ) if not exists $fh_hash{ $record->{ "CHR" } }; + $fh_hash{ $record->{ "CHR" } } = Maasha::Common::write_open( "$BP_TMP/$record->{ 'CHR' }" ) if not exists $fh_hash{ $record->{ "CHR" } }; $fh_out = $fh_hash{ $record->{ "CHR" } }; - &Maasha::UCSC::bed_put_entry( $record, $fh_out, 5 ); + Maasha::UCSC::bed_put_entry( $record, $fh_out, 5 ); } map { close $_ } keys %fh_hash; - $fh_out = &Maasha::Common::write_open( $file ); + $fh_out = Maasha::Common::write_open( $file ); foreach $chr ( sort keys %fh_hash ) { - &Maasha::Common::run( "bedSort", "$BP_TMP/$chr $BP_TMP/$chr" ); + Maasha::Common::run( "bedSort", "$BP_TMP/$chr $BP_TMP/$chr" ); - $fh_in = &Maasha::Common::read_open( "$BP_TMP/$chr" ); + $fh_in = Maasha::Common::read_open( "$BP_TMP/$chr" ); undef $block; - while ( $entry = &Maasha::UCSC::bed_get_entry( $fh_in, 5 ) ) + while ( $entry = Maasha::UCSC::bed_get_entry( $fh_in, 5 ) ) { $chr = $entry->{ 'CHR' }; $beg = $entry->{ 'CHR_BEG' }; @@ -5450,7 +5320,7 @@ sub script_upload_to_ucsc { if ( $beg > $max ) { - &Maasha::UCSC::fixedstep_put_entry( $chr, $beg_block, $block, $fh_out ); + Maasha::UCSC::fixedstep_put_entry( $chr, $beg_block, $block, $fh_out ); undef $block; } else @@ -5459,7 +5329,7 @@ sub script_upload_to_ucsc $block->[ $i ] += $clones; } - $max = &Maasha::Calc::max( $max, $end ); + $max = Maasha::Calc::max( $max, $end ); } } @@ -5476,7 +5346,7 @@ sub script_upload_to_ucsc close $fh_in; - &Maasha::UCSC::fixedstep_put_entry( $chr, $beg_block, $block, $fh_out ); + Maasha::UCSC::fixedstep_put_entry( $chr, $beg_block, $block, $fh_out ); unlink "$BP_TMP/$chr"; } @@ -5488,12 +5358,12 @@ sub script_upload_to_ucsc $wib_dir = "$ENV{ 'BP_DATA' }/genomes/$options->{ 'database' }/wib"; - &Maasha::Common::dir_create_if_not_exists( $wib_dir ); + Maasha::Common::dir_create_if_not_exists( $wib_dir ); - # &Maasha::Common::run( "wigEncode", "$file $wig_file $wib_file > /dev/null 2>&1" ); + # Maasha::Common::run( "wigEncode", "$file $wig_file $wib_file > /dev/null 2>&1" ); `cd $BP_TMP && wigEncode $file $wig_file $wib_file > /dev/null 2>&1`; - &Maasha::Common::run( "mv", "$BP_TMP/$wib_file $wib_dir" ); + Maasha::Common::run( "mv", "$BP_TMP/$wib_file $wib_dir" ); unlink $file; @@ -5503,16 +5373,16 @@ sub script_upload_to_ucsc } else { - $fh_out = &Maasha::Common::write_open( $file ); + $fh_out = Maasha::Common::write_open( $file ); - while ( $record = &get_record( $in ) ) + while ( $record = get_record( $in ) ) { - &put_record( $record, $out ) if not $options->{ "no_stream" }; + put_record( $record, $out ) if not $options->{ "no_stream" }; if ( $record->{ "REC_TYPE" } eq "PSL" ) { - &Maasha::UCSC::psl_put_header( $fh_out ) if $first; - &Maasha::UCSC::psl_put_entry( $record, $fh_out ); + Maasha::UCSC::psl_put_header( $fh_out ) if $first; + Maasha::UCSC::psl_put_entry( $record, $fh_out ); $first = 0; @@ -5538,14 +5408,14 @@ sub script_upload_to_ucsc } elsif ( $record->{ "REC_TYPE" } eq "BED" ) { - &Maasha::UCSC::bed_put_entry( $record, $fh_out, $record->{ "BED_COLS" } ); + Maasha::UCSC::bed_put_entry( $record, $fh_out, $record->{ "BED_COLS" } ); $format = "BED" if not $format; $columns = $record->{ "BED_COLS" } if not $columns; } elsif ( $record->{ "REC_TYPE" } eq "PATSCAN" and $record->{ "CHR" } ) { - &Maasha::UCSC::bed_put_entry( $record, $fh_out, 6 ); + Maasha::UCSC::bed_put_entry( $record, $fh_out, 6 ); $format = "BED" if not $format; $columns = 6 if not $columns; @@ -5560,7 +5430,7 @@ sub script_upload_to_ucsc $format = "BED" if not $format; $columns = 6 if not $columns; - &Maasha::UCSC::bed_put_entry( $record, $fh_out ); + Maasha::UCSC::bed_put_entry( $record, $fh_out ); } elsif ( $record->{ "REC_TYPE" } eq "VMATCH" and $record->{ "S_ID" } =~ /^chr/i ) { @@ -5573,7 +5443,7 @@ sub script_upload_to_ucsc $format = "BED" if not $format; $columns = 6 if not $columns; - &Maasha::UCSC::bed_put_entry( $record, $fh_out, 6 ); + Maasha::UCSC::bed_put_entry( $record, $fh_out, 6 ); } if ( $i == $options->{ "chunk_size" } ) @@ -5581,9 +5451,9 @@ sub script_upload_to_ucsc close $fh_out; if ( $format eq "BED" ) { - &Maasha::UCSC::bed_upload_to_ucsc( $BP_TMP, $file, $options, $append ); + Maasha::UCSC::bed_upload_to_ucsc( $BP_TMP, $file, $options, $append ); } elsif ( $format eq "PSL" ) { - &Maasha::UCSC::psl_upload_to_ucsc( $file, $options, $append ); + Maasha::UCSC::psl_upload_to_ucsc( $file, $options, $append ); } unlink $file; @@ -5592,7 +5462,7 @@ sub script_upload_to_ucsc $append = 1; - $fh_out = &Maasha::Common::write_open( $file ); + $fh_out = Maasha::Common::write_open( $file ); } $i++; @@ -5607,7 +5477,7 @@ sub script_upload_to_ucsc { $type = "bed $columns"; - &Maasha::UCSC::bed_upload_to_ucsc( $BP_TMP, $file, $options, $append ); + Maasha::UCSC::bed_upload_to_ucsc( $BP_TMP, $file, $options, $append ); } elsif ( $format eq "BED_SS" ) { @@ -5615,24 +5485,24 @@ sub script_upload_to_ucsc $type = "sec_struct"; - &Maasha::UCSC::bed_upload_to_ucsc( $BP_TMP, $file, $options, $append ); + Maasha::UCSC::bed_upload_to_ucsc( $BP_TMP, $file, $options, $append ); } elsif ( $format eq "PSL" ) { $type = "psl"; - &Maasha::UCSC::psl_upload_to_ucsc( $file, $options, $append ); + Maasha::UCSC::psl_upload_to_ucsc( $file, $options, $append ); } elsif ( $format eq "WIGGLE" ) { $type = "wig 0"; - &Maasha::UCSC::wiggle_upload_to_ucsc( $BP_TMP, $wib_dir, $file, $options ); + Maasha::UCSC::wiggle_upload_to_ucsc( $BP_TMP, $wib_dir, $file, $options ); } unlink $file; - &Maasha::UCSC::update_my_tracks( $options, $type ); + Maasha::UCSC::update_my_tracks( $options, $type ); } } @@ -5654,11 +5524,11 @@ sub read_stream my ( $fh ); if ( not -t STDIN ) { - $fh = &Maasha::Common::read_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 ); + $fh = Maasha::Common::read_open( $path ); } # $fh->autoflush(1) if $fh; # Disable file buffer for debugging. @@ -5682,9 +5552,9 @@ sub write_stream my ( $fh ); if ( $path ) { - $fh = &Maasha::Common::write_open( $path, $gzip ); + $fh = Maasha::Common::write_open( $path, $gzip ); } else { - $fh = &Maasha::Common::write_stdout(); + $fh = Maasha::Common::write_stdout(); } return $fh; @@ -5820,7 +5690,7 @@ sub sig_handler # This is a really bad solution, potentially, anyone can include this module and set # the BP_TMP to point at any dir and thus take out the machine !!! - &Maasha::Common::dir_remove( $BP_TMP ); + Maasha::Common::dir_remove( $BP_TMP ); } exit( 0 ); @@ -5832,7 +5702,7 @@ END # This is a really bad solution, potentially, anyone can include this module and set # the BP_TMP to point at any dir and thus take out the machine !!! - &Maasha::Common::dir_remove( $BP_TMP ); + Maasha::Common::dir_remove( $BP_TMP ); } @@ -5859,19 +5729,19 @@ sub script_read_soft my ( $data_in, $file, $num, $records, $record ); - while ( $record = &get_record( $in ) ) { - &put_record( $record, $out ); + while ( $record = get_record( $in ) ) { + put_record( $record, $out ); } $num = 1; foreach $file ( @{ $options->{ "files" } } ) { - $records = &Maasha::NCBI::soft_parse( $file ); + $records = Maasha::NCBI::soft_parse( $file ); foreach $record ( @{ $records } ) { - &put_record( $record, $out ); + put_record( $record, $out ); goto NUM if $options->{ "num" } and $num == $options->{ "num" }; diff --git a/code_perl/Maasha/Blast.pm b/code_perl/Maasha/Blast.pm index 5b8647b..b89ce8c 100644 --- a/code_perl/Maasha/Blast.pm +++ b/code_perl/Maasha/Blast.pm @@ -108,12 +108,12 @@ sub xml_parse_blast if ( $doctype eq '' ) { print STDERR qq(Parsing blastcl3 results ...\n); - $results = &xml_parse_blast_blastcl3( $fh ); + $results = xml_parse_blast_blastcl3( $fh ); } elsif ( $doctype eq '' ) { print STDERR qq(Parsing NCBI blast results ...\n); - $results = &xml_parse_blast_ncbi( $fh ); + $results = xml_parse_blast_ncbi( $fh ); } else { @@ -133,7 +133,7 @@ sub xml_parse_blast_ncbi my ( $blast_record, $line, @blast_query, @blast_subject, $query, $subject, @results ); - while ( $blast_record = &xml_get_blast_record( $fh ) and scalar @{ $blast_record } > 0 ) + while ( $blast_record = xml_get_blast_record( $fh ) and scalar @{ $blast_record } > 0 ) { foreach $line ( @{ $blast_record } ) { @@ -147,8 +147,8 @@ sub xml_parse_blast_ncbi if ( $line =~ /<\/Iteration_hits>/ ) { - $query = &xml_parse_blast_query( \@blast_query ); - $subject = &xml_parse_blast_subject( \@blast_subject ); + $query = xml_parse_blast_query( \@blast_query ); + $subject = xml_parse_blast_subject( \@blast_subject ); push @results, { "QUERY" => $query, @@ -175,7 +175,7 @@ sub xml_parse_blast_blastcl3 my ( $blast_record, $line, @blast_query, @blast_subject, $query, $subject, @results ); - while ( $blast_record = &xml_get_blast_record( $fh ) and scalar @{ $blast_record } > 0 ) + while ( $blast_record = xml_get_blast_record( $fh ) and scalar @{ $blast_record } > 0 ) { foreach $line ( @{ $blast_record } ) { @@ -189,8 +189,8 @@ sub xml_parse_blast_blastcl3 if ( $line =~ /<\/Iteration_hits>/ ) { - $query = &xml_parse_blast_query( \@blast_query ); - $subject = &xml_parse_blast_subject( \@blast_subject ); + $query = xml_parse_blast_query( \@blast_query ); + $subject = xml_parse_blast_subject( \@blast_subject ); push @results, { "QUERY" => $query, @@ -277,8 +277,8 @@ sub xml_parse_blast_subject if ( $line =~ /<\/Hit_hsps>/ ) { - $hit = &xml_parse_blast_hit( \@blast_hit ); - $hsps = &xml_parse_blast_hsps( \@blast_hsps ); + $hit = xml_parse_blast_hit( \@blast_hit ); + $hsps = xml_parse_blast_hsps( \@blast_hsps ); $hit->{ "HSPS" } = $hsps; diff --git a/code_perl/Maasha/Calc.pm b/code_perl/Maasha/Calc.pm index 7906b52..34959a0 100644 --- a/code_perl/Maasha/Calc.pm +++ b/code_perl/Maasha/Calc.pm @@ -175,7 +175,7 @@ sub median $num = scalar @{ $numbers }; if ( $num % 2 == 0 ) { - $median = &mean( [ $numbers->[ $num / 2 ], $numbers->[ $num / 2 + 1 ] ] ); + $median = mean( [ $numbers->[ $num / 2 ], $numbers->[ $num / 2 + 1 ] ] ); } else { $median = $numbers->[ int( $num / 2 ) ]; } diff --git a/code_perl/Maasha/Common.pm b/code_perl/Maasha/Common.pm index a6d63e1..4da7483 100644 --- a/code_perl/Maasha/Common.pm +++ b/code_perl/Maasha/Common.pm @@ -62,9 +62,9 @@ sub error chomp $msg; - $script = &get_scriptname(); + $script = get_scriptname(); - $error = &Carp::longmess(); + $error = Carp::longmess(); @lines = split "\n", $error; @@ -148,9 +148,9 @@ sub read_open $type = `file $path` if $path; if ( $type =~ /gzip compressed/ ) { - $fh = new IO::File "zcat $path|" or &Maasha::Common::error( qq(Could not read-open file "$path": $!) ); + $fh = new IO::File "zcat $path|" or Maasha::Common::error( qq(Could not read-open file "$path": $!) ); } else { - $fh = new IO::File $path, "r" or &Maasha::Common::error( qq(Could not read-open file "$path": $!) ); + $fh = new IO::File $path, "r" or Maasha::Common::error( qq(Could not read-open file "$path": $!) ); } return $fh; @@ -172,9 +172,9 @@ sub write_open my ( $fh ); if ( $gzip ) { - $fh = new IO::File "|gzip -f>$path" or &Maasha::Common::error( qq(Could not write-open file "$path": $!) ); + $fh = new IO::File "|gzip -f>$path" or Maasha::Common::error( qq(Could not write-open file "$path": $!) ); } else { - $fh = new IO::File $path, "w" or &Maasha::Common::error( qq(Could not write-open file "$path": $!) ); + $fh = new IO::File $path, "w" or Maasha::Common::error( qq(Could not write-open file "$path": $!) ); } return $fh; @@ -194,7 +194,7 @@ sub append_open my ( $fh ); - $fh = new IO::File $path, "a" or &Maasha::Common::error( qq(Could not append-open file "$path": $!) ); + $fh = new IO::File $path, "a" or Maasha::Common::error( qq(Could not append-open file "$path": $!) ); return $fh; } @@ -208,7 +208,7 @@ sub pipe_open my ( $fh ); - $fh = new IO::File "-" or &Maasha::Common::error( qq(Could not open pipe: $!) ); + $fh = new IO::File "-" or Maasha::Common::error( qq(Could not open pipe: $!) ); return $fh; } @@ -222,7 +222,7 @@ sub read_stdin my ( $fh ); - $fh = new IO::File "<&STDIN" or &Maasha::Common::error( qq(Could not read from STDIN: $!) ); + $fh = new IO::File "<&STDIN" or Maasha::Common::error( qq(Could not read from STDIN: $!) ); return $fh; } @@ -236,7 +236,7 @@ sub write_stdout my ( $fh ); - $fh = new IO::File ">&STDOUT" or &Maasha::Common::error( qq(Could not write to STDOUT: $!) ); + $fh = new IO::File ">&STDOUT" or Maasha::Common::error( qq(Could not write to STDOUT: $!) ); return $fh; } @@ -252,7 +252,7 @@ sub file_store $data, # data structure ) = @_; - &Storable::store( $data, $path ) or &Maasha::Common::error( qq(Could not write-open file "$path": $!) ); + Storable::store( $data, $path ) or Maasha::Common::error( qq(Could not write-open file "$path": $!) ); } @@ -268,7 +268,7 @@ sub file_retrieve my ( $data ); - $data = &Storable::retrieve( $path ) or &Maasha::Common::error( qq(Could not read-open file "$path": $!) ); + $data = Storable::retrieve( $path ) or Maasha::Common::error( qq(Could not read-open file "$path": $!) ); return wantarray ? %{ $data } : $data; } @@ -286,9 +286,9 @@ sub dir_create # Returns nothing. if ( -d $path ) { - &Maasha::Common::error( qq(Directory already exists "$path": $!) ); + Maasha::Common::error( qq(Directory already exists "$path": $!) ); } else { - mkdir $path or &Maasha::Common::error( qq(Could not create directory "$path": $!) ); + mkdir $path or Maasha::Common::error( qq(Could not create directory "$path": $!) ); } } @@ -305,7 +305,7 @@ sub dir_create_if_not_exists # Returns nothing. if ( not -d $path ) { - mkdir $path or &Maasha::Common::error( qq(Could not create directory "$path": $!) ); + mkdir $path or Maasha::Common::error( qq(Could not create directory "$path": $!) ); } } @@ -319,7 +319,7 @@ sub dir_remove my ( $path, # directory ) = @_; - &Maasha::Common::run( "rm", "-rf $path" ) if -d $path; + Maasha::Common::run( "rm", "-rf $path" ) if -d $path; } @@ -336,9 +336,9 @@ sub ls_dirs my ( $dh, @dirs ); - $dh = &open_dir( $path ); + $dh = open_dir( $path ); - @dirs = &read_dir( $dh ); + @dirs = read_dir( $dh ); @dirs = grep { -d "$path/$_" } @dirs; map { $_ = "$path/$_" } @dirs; @@ -362,9 +362,9 @@ sub ls_files my ( $dh, @files ); - $dh = &open_dir( $path ); + $dh = open_dir( $path ); - @files = &read_dir( $dh ); + @files = read_dir( $dh ); @files = grep { -f "$path/$_" } @files; map { $_ = "$path/$_" } @files; @@ -390,7 +390,7 @@ sub open_dir my $dh; - $dh = IO::Dir->new( $path ) or &Maasha::Common::error( qq(Could not open dir "$path": $!) ); + $dh = IO::Dir->new( $path ) or Maasha::Common::error( qq(Could not open dir "$path": $!) ); return $dh; } @@ -446,7 +446,7 @@ sub read_args } elsif ( -f $arg ) { push @files, $arg; } else { - &Maasha::Common::error( qq(Bad syntax in argument->"$arg") ); + Maasha::Common::error( qq(Bad syntax in argument->"$arg") ); } } @@ -460,7 +460,7 @@ sub read_args $ok_hash{ "DIRS" } = 1; $ok_hash{ "FILES" } = 1; - map { &Maasha::Common::error( qq(Unknown argument->"$_") ) if not exists $ok_hash{ $_ } } keys %hash; + map { Maasha::Common::error( qq(Unknown argument->"$_") ) if not exists $ok_hash{ $_ } } keys %hash; } return wantarray ? %hash : \%hash; @@ -490,16 +490,16 @@ sub get_tmpdir my ( $user, $sid, $path ); - &Maasha::Common::error( qq(no BP_TMP set in %ENV) ) if not -d $ENV{ 'BP_TMP' }; + Maasha::Common::error( qq(no BP_TMP set in %ENV) ) if not -d $ENV{ 'BP_TMP' }; $user = $ENV{ 'USER' }; $user =~ s/\.//g; - $sid = &Maasha::Common::get_sessionid(); + $sid = Maasha::Common::get_sessionid(); $path = "$ENV{ 'BP_TMP' }/$user\_$sid"; - &Maasha::Common::dir_create( $path ); + Maasha::Common::dir_create( $path ); return $path; } @@ -551,7 +551,7 @@ sub file_read my ( $string ); - &Maasha::Common::error( qq(Negative length: $len) ) if $len < 0; + Maasha::Common::error( qq(Negative length: $len) ) if $len < 0; sysseek $fh, $beg, 0; sysread $fh, $string, $len; @@ -592,11 +592,11 @@ sub run my ( $command_line, $result ); - $command_line = &Maasha::Config::get_exe( $exe ); + $command_line = Maasha::Config::get_exe( $exe ); $command_line .= " " . $args if $args; $command_line = "nice -n19 " . $command_line if $nice; - system( $command_line ) == 0 or &Maasha::Common::error( qq(Could not execute "$command_line": $?) ); + system( $command_line ) == 0 or Maasha::Common::error( qq(Could not execute "$command_line": $?) ); } @@ -616,7 +616,7 @@ sub run_and_return my ( $command_line, @result ); - $command_line = &Maasha::Config::get_exe( $exe ); + $command_line = Maasha::Config::get_exe( $exe ); $command_line .= " " . $args if $args; $command_line = "nice -n19 " . $command_line if $nice; diff --git a/code_perl/Maasha/Config.pm b/code_perl/Maasha/Config.pm index b713973..03bf0ec 100644 --- a/code_perl/Maasha/Config.pm +++ b/code_perl/Maasha/Config.pm @@ -74,7 +74,7 @@ sub get_exe return "$dir/$exe" if -x "$dir/$exe" and not -d "$dir/$exe"; } - &Maasha::Common::error( qq(Could not find executable \'$exe\') ); + Maasha::Common::error( qq(Could not find executable \'$exe\') ); } @@ -93,7 +93,7 @@ sub genome_fasta my $genome_file = "$BP_DATA/genomes/$genome/$genome.fna"; if ( not -f $genome_file ) { - &Maasha::Common::error( qq(Genome file "$genome_file" for genome "$genome" not found) ); + Maasha::Common::error( qq(Genome file "$genome_file" for genome "$genome" not found) ); } return $genome_file; @@ -115,7 +115,7 @@ sub genome_fasta_index my $index = "$BP_DATA/genomes/$genome/$genome.fna.index"; if ( not -f $index ) { - &Maasha::Common::error( qq(Index file "$index" for genome -> $genome not found) ); + Maasha::Common::error( qq(Index file "$index" for genome -> $genome not found) ); } return $index; @@ -154,7 +154,7 @@ sub genome_blat_ooc my $ooc_file = "$BP_DATA/genomes/$genome/blat/$tile_size.ooc"; - &Maasha::Common::error( qq(ooc file "$ooc_file" not found for genome -> $genome) ) if not -f $ooc_file; + Maasha::Common::error( qq(ooc file "$ooc_file" not found for genome -> $genome) ) if not -f $ooc_file; return $ooc_file; } @@ -173,7 +173,7 @@ sub genome_vmatch my ( @chrs ); - @chrs = &chromosomes( $genome ); + @chrs = chromosomes( $genome ); map { $_ = "$BP_DATA/genomes/$genome/vmatch/$_" } @chrs; @@ -230,7 +230,7 @@ sub genomes my ( %genome_hash, $fh, $line, @genomes, $org ); - $fh = &Maasha::Common::read_open( "$BP_DIR/conf/genomes.conf" ); + $fh = Maasha::Common::read_open( "$BP_DIR/conf/genomes.conf" ); while ( $line = <$fh> ) { @@ -265,7 +265,7 @@ sub chromosomes my ( $fh_in, $line, $org, $chr, %genome_hash, @chrs ); - $fh_in = &Maasha::Common::read_open( "$BP_DIR/bp_conf/genomes.conf" ); + $fh_in = Maasha::Common::read_open( "$BP_DIR/bp_conf/genomes.conf" ); while ( $line = <$fh_in> ) { @@ -283,7 +283,7 @@ sub chromosomes if ( exists $genome_hash{ $genome } ) { @chrs = @{ $genome_hash{ $genome } }; } else { - &Maasha::Common::error( qq(Genome -> $genome not found in genome hash) ); + Maasha::Common::error( qq(Genome -> $genome not found in genome hash) ); } return wantarray ? @chrs : \@chrs; @@ -320,7 +320,7 @@ sub maf_track tetNig1 => 'multiz7way', ); - &Maasha::Common::error( qw(multiz track not found) ) if not exists $hash{ $genome }; + Maasha::Common::error( qw(multiz track not found) ) if not exists $hash{ $genome }; return $hash{ $genome }; } diff --git a/code_perl/Maasha/EMBL.pm b/code_perl/Maasha/EMBL.pm index 2e1cc53..0cd6267 100644 --- a/code_perl/Maasha/EMBL.pm +++ b/code_perl/Maasha/EMBL.pm @@ -142,7 +142,7 @@ sub parse_embl_entry if ( exists $hash{ "FT" } ) { $seq =~ tr/ //d; - $ft = &parse_feature_table( $hash{ "FT" }, $seq, $args ); + $ft = parse_feature_table( $hash{ "FT" }, $seq, $args ); $hash{ "FT" } = $ft; } @@ -194,9 +194,9 @@ sub parse_feature_table $p = 1; - if ( not &balance_params( $locator ) ) + if ( not balance_params( $locator ) ) { - while ( not &balance_params( $locator ) ) + while ( not balance_params( $locator ) ) { $locator .= $lines[ $i + $p ]; $p++; @@ -207,7 +207,7 @@ sub parse_feature_table # ---- getting subsequence - $subseq = &parse_locator( $locator, $seq ); + $subseq = parse_locator( $locator, $seq ); push @{ $qual_hash{ "_seq" } }, $subseq; @@ -232,9 +232,9 @@ sub parse_feature_table $q = 1; - if ( not &balance_quotes( $qual_val ) ) + if ( not balance_quotes( $qual_val ) ) { - while ( not &balance_quotes( $qual_val ) ) + while ( not balance_quotes( $qual_val ) ) { $qual_val .= " " . $lines[ $i + $p + $q ]; $q++; @@ -298,23 +298,23 @@ sub parse_locator @intervals = split ",", $locator; - if ( not &balance_params( $intervals[ 0 ] ) ) # locator includes a join/comp/order of several ranges + if ( not balance_params( $intervals[ 0 ] ) ) # locator includes a join/comp/order of several ranges { if ( $locator =~ /^join\((.*)\)$/ ) { $join = 1; - $subseq = &parse_locator( $1, $seq, $subseq, $join, $comp, $order ); + $subseq = parse_locator( $1, $seq, $subseq, $join, $comp, $order ); } elsif ( $locator =~ /^complement\((.*)\)$/ ) { $comp = 1; - $subseq = &parse_locator( $1, $seq, $subseq, $join, $comp, $order ); + $subseq = parse_locator( $1, $seq, $subseq, $join, $comp, $order ); } elsif ( $locator =~ /^order\((.*)\)$/ ) { $order = 1; - $subseq = &parse_locator( $1, $seq, $subseq, $join, $comp, $order ); + $subseq = parse_locator( $1, $seq, $subseq, $join, $comp, $order ); } } else @@ -324,18 +324,18 @@ sub parse_locator if ( $interval =~ /^join\((.*)\)$/ ) { $join = 1; - $subseq = &parse_locator( $1, $seq, $subseq, $join, $comp, $order ); + $subseq = parse_locator( $1, $seq, $subseq, $join, $comp, $order ); } elsif ( $interval =~ /^complement\((.*)\)$/ ) { $comp = 1; - $subseq = &parse_locator( $1, $seq, $subseq, $join, $comp, $order ); + $subseq = parse_locator( $1, $seq, $subseq, $join, $comp, $order ); } elsif ( $interval =~ /^order\((.*)\)$/ ) { $order = 1; - $subseq = &parse_locator( $1, $seq, $subseq, $join, $comp, $order ); + $subseq = parse_locator( $1, $seq, $subseq, $join, $comp, $order ); } elsif ( $interval =~ /^[<>]?(\d+)[^\d]+(\d+)$/ ) { @@ -344,7 +344,7 @@ sub parse_locator $newseq = substr $seq, $beg - 1, $end - $beg + 1; - $newseq = &Maasha::Seq::dna_revcomp( $newseq ) if $comp; + $newseq = Maasha::Seq::dna_revcomp( $newseq ) if $comp; if ( $order ) { $subseq .= " " . $newseq; @@ -358,7 +358,7 @@ sub parse_locator $newseq = substr $seq, $beg - 1, 1 ; - $newseq = &Maasha::Seq::dna_revcomp( $newseq ) if $comp; + $newseq = Maasha::Seq::dna_revcomp( $newseq ) if $comp; if ( $order ) { $subseq .= " " . $newseq; diff --git a/code_perl/Maasha/Fasta.pm b/code_perl/Maasha/Fasta.pm index 95a2fa8..3df2ddc 100644 --- a/code_perl/Maasha/Fasta.pm +++ b/code_perl/Maasha/Fasta.pm @@ -60,7 +60,7 @@ sub fasta_format_ok my ( $fh, $line, $count ); - $fh = &Maasha::Common::read_open( $path ); + $fh = Maasha::Common::read_open( $path ); $count = 0; @@ -93,9 +93,9 @@ sub get_entries my ( $fh, $entry, @entries ); - $fh = &Maasha::Common::read_open( $path ); + $fh = Maasha::Common::read_open( $path ); - while ( $entry = &get_entry( $fh ) ) + while ( $entry = get_entry( $fh ) ) { push @entries, $entry; @@ -123,9 +123,9 @@ sub put_entries my ( $fh ); - $fh = &Maasha::Common::write_open( $path ) if $path; + $fh = Maasha::Common::write_open( $path ) if $path; - map { &put_entry( $_, $fh, $wrap ) } @{ $entries }; + map { put_entry( $_, $fh, $wrap ) } @{ $entries }; close $fh if defined; } @@ -144,7 +144,7 @@ sub wrap # Returns nothing. - &Maasha::Seq::wrap( \$entry->[ SEQ ], $wrap ); + Maasha::Seq::wrap( \$entry->[ SEQ ], $wrap ); } @@ -203,11 +203,11 @@ sub put_entry # Returns nothing. - &Maasha::Common::error( qq(FASTA entry has no header) ) if not defined $entry->[ HEAD ]; - &Maasha::Common::error( qq(FASTA entry has no sequence) ) if not defined $entry->[ SEQ ]; + Maasha::Common::error( qq(FASTA entry has no header) ) if not defined $entry->[ HEAD ]; + Maasha::Common::error( qq(FASTA entry has no sequence) ) if not defined $entry->[ SEQ ]; if ( $wrap ) { - &Maasha::Fasta::wrap( $entry, $wrap ); + Maasha::Fasta::wrap( $entry, $wrap ); } if ( defined $fh ) { @@ -290,9 +290,9 @@ sub fasta_get_headers my ( $fh, $entry, @list ); - $fh = &Maasha::Common::read_open( $path ); + $fh = Maasha::Common::read_open( $path ); - while ( $entry = &get_entry( $fh ) ) { + while ( $entry = get_entry( $fh ) ) { push @list, $entry->[ HEAD ]; } @@ -314,11 +314,11 @@ sub fasta_reformat my ( $fh_in, $fh_out, $entry ); - $fh_in = &Maasha::Common::read_open( $path ); - $fh_out = &Maasha::Common::write_open( "$path.temp" ); + $fh_in = Maasha::Common::read_open( $path ); + $fh_out = Maasha::Common::write_open( "$path.temp" ); - while ( $entry = &get_entry( $fh_in ) ) { - &put_entry( $entry, $fh_out ); + while ( $entry = get_entry( $fh_in ) ) { + put_entry( $entry, $fh_out ); } close $fh_in; @@ -343,16 +343,16 @@ sub index_create my ( $file_size, $fh, $entry, $beg, $len, %hash, @index ); - $file_size = &Maasha::Common::file_size( $path ); + $file_size = Maasha::Common::file_size( $path ); push @index, "FILE_SIZE=$file_size"; - $fh = &Maasha::Common::read_open( $path ); + $fh = Maasha::Common::read_open( $path ); $beg = 0; $len = 0; - while ( $entry = &get_entry( $fh ) ) + while ( $entry = get_entry( $fh ) ) { warn qq(WARNING: header->$entry->[ HEAD ] alread exists in index) if exists $hash{ $entry->[ HEAD ] }; @@ -443,7 +443,7 @@ sub index_store # returns nothing - &Maasha::Common::file_store( $path, $index ); + Maasha::Common::file_store( $path, $index ); } @@ -460,7 +460,7 @@ sub index_retrieve my $index; - $index = &Maasha::Common::file_retrieve( $path ); + $index = Maasha::Common::file_retrieve( $path ); return wantarray ? @{ $index } : $index; } diff --git a/code_perl/Maasha/GFF.pm b/code_perl/Maasha/GFF.pm index 8d8a20b..154dad8 100644 --- a/code_perl/Maasha/GFF.pm +++ b/code_perl/Maasha/GFF.pm @@ -109,9 +109,9 @@ sub get_entries my ( $fh, $entry, @entries ); - $fh = &Maasha::Common::read_open( $path ); + $fh = Maasha::Common::read_open( $path ); - while ( $entry = &get_entry( $fh ) ) { + while ( $entry = get_entry( $fh ) ) { push @entries, $entry; } diff --git a/code_perl/Maasha/Gwiki.pm b/code_perl/Maasha/Gwiki.pm index 042eed6..b0e5c97 100644 --- a/code_perl/Maasha/Gwiki.pm +++ b/code_perl/Maasha/Gwiki.pm @@ -98,7 +98,7 @@ sub gwiki2ascii $line =~ s/\*(\w+)\*/&text_bold($1)/ge if $line =~ /(^| )\*\w+\*( |$)/; $line =~ s/_(\w+)_/&text_underline($1)/ge if $line =~ /(^| )_\w+_( |$)/; - push @lines, $_ foreach &Maasha::Common::wrap_line( $line, 80 ); + push @lines, $_ foreach Maasha::Common::wrap_line( $line, 80 ); } } elsif ( $block->[ 0 ]->{ 'FORMAT' } eq "whitespace" ) @@ -129,7 +129,7 @@ sub gwiki_read my ( $fh, @lines, $i, $c, $section, $paragraph, @block, @output ); - $fh = &Maasha::Common::read_open( $file ); + $fh = Maasha::Common::read_open( $file ); @lines = <$fh>; diff --git a/code_perl/Maasha/Match.pm b/code_perl/Maasha/Match.pm index 8f52d8d..5a37650 100644 --- a/code_perl/Maasha/Match.pm +++ b/code_perl/Maasha/Match.pm @@ -69,7 +69,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/; @@ -82,12 +82,12 @@ sub match_mummer map { $_->[ 0 ] =~ tr/ /_/ } @{ $entries1 }; map { $_->[ 0 ] =~ tr/ /_/ } @{ $entries2 }; - &Maasha::Fasta::put_entries( $entries1, $file_in1 ); - &Maasha::Fasta::put_entries( $entries2, $file_in2 ); + Maasha::Fasta::put_entries( $entries1, $file_in1 ); + Maasha::Fasta::put_entries( $entries2, $file_in2 ); - &Maasha::Common::run( "mummer", "$arg $file_in1 $file_in2 > $file_out 2>/dev/null" ); + Maasha::Common::run( "mummer", "$arg $file_in1 $file_in2 > $file_out 2>/dev/null" ); - $fh = &Maasha::Common::read_open( $file_out ); + $fh = Maasha::Common::read_open( $file_out ); while ( $line = <$fh> ) { @@ -147,7 +147,7 @@ sub match_vmatch $query_file = "$tmp_dir/query.seq"; $result_file = "$tmp_dir/vmatch.out"; - $fh_out = &Maasha::Common::write_open( $query_file ); + $fh_out = Maasha::Common::write_open( $query_file ); foreach $record ( @{ $records } ) { @@ -157,7 +157,7 @@ sub match_vmatch push @seq_names, $record->{ "SEQ_NAME" }; - &Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh_out, 80 ); + Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh_out, 80 ); } } @@ -174,22 +174,22 @@ sub match_vmatch for ( $i = 0; $i < @{ $index_files }; $i++ ) { - &Maasha::Common::run( "vmatch", "$vmatch_args $index_files->[ $i ] > $result_file.$i" ); + Maasha::Common::run( "vmatch", "$vmatch_args $index_files->[ $i ] > $result_file.$i" ); push @result_files, "$result_file.$i"; } unlink $query_file; - $count_list = &vmatch_count_hits( \@result_files ) if ( $options->{ "count" } ); + $count_list = vmatch_count_hits( \@result_files ) if ( $options->{ "count" } ); - $fh_out = &Maasha::Common::write_open( $result_file ); + $fh_out = Maasha::Common::write_open( $result_file ); for ( $i = 0; $i < @{ $index_files }; $i++ ) { $index_files->[ $i ] =~ s/.+\/(.+)\.fna$/$1/ if $options->{ 'genome' }; - $fh_in = &Maasha::Common::read_open( "$result_file.$i" ); + $fh_in = Maasha::Common::read_open( "$result_file.$i" ); while ( $line = <$fh_in> ) { @@ -236,7 +236,7 @@ sub vmatch_count_hits foreach $file ( @{ $files } ) { - $fh_in = &Maasha::Common::read_open( $file ); + $fh_in = Maasha::Common::read_open( $file ); while ( $line = <$fh_in> ) { @@ -273,7 +273,7 @@ sub vmatch_count_hits_old my ( $fh_in, $fh_out, $line, @fields, @count_list ); - $fh_in = &Maasha::Common::read_open( $path ); + $fh_in = Maasha::Common::read_open( $path ); while ( $line = <$fh_in> ) { @@ -288,8 +288,8 @@ sub vmatch_count_hits_old close $fh_in; - $fh_in = &Maasha::Common::read_open( $path ); - $fh_out = &Maasha::Common::write_open( "$tmp_dir/vmatch.count" ); + $fh_in = Maasha::Common::read_open( $path ); + $fh_out = Maasha::Common::write_open( "$tmp_dir/vmatch.count" ); while ( $line = <$fh_in> ) { @@ -335,10 +335,10 @@ sub vmatch_count_hits_old if ( $max_count ) { %count_hash = (); } else { - %count_hash = &Maasha::Berkeley_DB::db_init( "$tmp_dir/hash.bdb" ); + %count_hash = Maasha::Berkeley_DB::db_init( "$tmp_dir/hash.bdb" ); } - $fh_in = &Maasha::Common::read_open( $path ); + $fh_in = Maasha::Common::read_open( $path ); while ( $line = <$fh_in> ) { @@ -353,8 +353,8 @@ sub vmatch_count_hits_old close $fh_in; - $fh_in = &Maasha::Common::read_open( $path ); - $fh_out = &Maasha::Common::write_open( "$tmp_dir/vmatch.count" ); + $fh_in = Maasha::Common::read_open( $path ); + $fh_out = Maasha::Common::write_open( "$tmp_dir/vmatch.count" ); while ( $line = <$fh_in> ) { diff --git a/code_perl/Maasha/Matrix.pm b/code_perl/Maasha/Matrix.pm index 82a08f6..941ec82 100644 --- a/code_perl/Maasha/Matrix.pm +++ b/code_perl/Maasha/Matrix.pm @@ -81,7 +81,7 @@ sub matrix_check my ( $dims, $row, $check ); - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); $check = $dims->[ COLS ]; @@ -104,24 +104,24 @@ sub matrix_summary my ( $dims, $i, $col, $list, $type, $sort, $uniq, $min, $max, $mean ); - die qq(ERROR: cannot summarize uneven matrix\n) if not &matrix_check( $matrix ); + die qq(ERROR: cannot summarize uneven matrix\n) if not matrix_check( $matrix ); - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); print join( "\t", "TYPE", "LEN", "UNIQ", "SORT", "MIN", "MAX", "MEAN" ), "\n"; for ( $i = 0; $i < $dims->[ COLS ]; $i++ ) { - $col = &cols_get( $matrix, $i, $i ); - $list = &matrix_flip( $col )->[ 0 ]; + $col = cols_get( $matrix, $i, $i ); + $list = matrix_flip( $col )->[ 0 ]; - if ( &list_check_numeric( $list ) ) { + if ( list_check_numeric( $list ) ) { $type = "num"; } else { $type = "alph"; } - if ( &list_check_sort( $list, $type ) ) { + if ( list_check_sort( $list, $type ) ) { $sort = "yes"; } else { $sort = "no"; @@ -136,10 +136,10 @@ sub matrix_summary } else { - ( $min, $max ) = &Maasha::Calc::minmax( $list ); + ( $min, $max ) = Maasha::Calc::minmax( $list ); } - $mean = sprintf( "%.2f", &Maasha::Calc::mean( $list ) ); + $mean = sprintf( "%.2f", Maasha::Calc::mean( $list ) ); } else { @@ -148,7 +148,7 @@ sub matrix_summary $mean = "N/A"; } - $uniq = &list_uniq( $list ); + $uniq = list_uniq( $list ); print join( "\t", $type, $dims->[ ROWS ], $uniq, $sort, $min, $max, $mean ), "\n"; } @@ -168,9 +168,9 @@ sub matrix_flip my ( $i, $c, $dims, $AoA ); - die qq(ERROR: cannot flip uneven matrix\n) if not &matrix_check( $matrix ); + die qq(ERROR: cannot flip uneven matrix\n) if not matrix_check( $matrix ); - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); for ( $i = 0; $i < $dims->[ ROWS ]; $i++ ) { @@ -203,16 +203,16 @@ sub matrix_rotate_right $shift ||= 1; - die qq(ERROR: cannot right rotate uneven matrix\n) if not &matrix_check( $matrix ); + die qq(ERROR: cannot right rotate uneven matrix\n) if not matrix_check( $matrix ); - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); for ( $i = 0; $i < $shift; $i++ ) { - $col = &cols_get( $matrix, $dims->[ COLS ] - 1, $dims->[ COLS ] - 1 ); - $AoA = &cols_get( $matrix, 0, $dims->[ COLS ] - 2 ); + $col = cols_get( $matrix, $dims->[ COLS ] - 1, $dims->[ COLS ] - 1 ); + $AoA = cols_get( $matrix, 0, $dims->[ COLS ] - 2 ); - &cols_unshift( $AoA, $col ); + cols_unshift( $AoA, $col ); $matrix = $AoA; } @@ -240,16 +240,16 @@ sub matrix_rotate_left $shift ||= 1; - die qq(ERROR: cannot right rotate uneven matrix\n) if not &matrix_check( $matrix ); + die qq(ERROR: cannot right rotate uneven matrix\n) if not matrix_check( $matrix ); - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); for ( $i = 0; $i < $shift; $i++ ) { - $col = &cols_get( $matrix, 0, 0 ); - $AoA = &cols_get( $matrix, 1, $dims->[ COLS ] - 1 ); + $col = cols_get( $matrix, 0, 0 ); + $AoA = cols_get( $matrix, 1, $dims->[ COLS ] - 1 ); - &cols_push( $AoA, $col ); + cols_push( $AoA, $col ); $matrix = $AoA; } @@ -276,14 +276,14 @@ sub matrix_rotate_up $shift ||= 1; - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); for ( $i = 0; $i < $shift; $i++ ) { - $row = &rows_get( $matrix, 0, 0 ); - $AoA = &rows_get( $matrix, 1, $dims->[ ROWS ] - 1 ); + $row = rows_get( $matrix, 0, 0 ); + $AoA = rows_get( $matrix, 1, $dims->[ ROWS ] - 1 ); - &rows_push( $AoA, dclone $row ); + rows_push( $AoA, dclone $row ); $matrix = $AoA; } @@ -310,14 +310,14 @@ sub matrix_rotate_down $shift ||= 1; - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); for ( $i = 0; $i < $shift; $i++ ) { - $row = &rows_get( $matrix, $dims->[ ROWS ] - 1, $dims->[ ROWS ] - 1 ); - $AoA = &rows_get( $matrix, 0, $dims->[ ROWS ] - 2 ); + $row = rows_get( $matrix, $dims->[ ROWS ] - 1, $dims->[ ROWS ] - 1 ); + $AoA = rows_get( $matrix, 0, $dims->[ ROWS ] - 2 ); - &rows_unshift( $AoA, $row ); + rows_unshift( $AoA, $row ); $matrix = $AoA; } @@ -343,8 +343,8 @@ sub submatrix my ( $submatrix, $subsubmatrix ); - $submatrix = &rows_get( $matrix, $row_beg, $row_end ); - $subsubmatrix = &cols_get( $submatrix, $col_beg, $col_end ); + $submatrix = rows_get( $matrix, $row_beg, $row_end ); + $subsubmatrix = cols_get( $submatrix, $col_beg, $col_end ); return wantarray ? @{ $subsubmatrix } : $subsubmatrix; } @@ -364,9 +364,9 @@ sub row_get my ( $dims, $i, @list ); - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); - &Maasha::Common::error( qq(Row->$row outside of matrix->$dims->[ ROWS ]) ) if $row > $dims->[ ROWS ]; + Maasha::Common::error( qq(Row->$row outside of matrix->$dims->[ ROWS ]) ) if $row > $dims->[ ROWS ]; @list = @{ $matrix->[ $row ] }; @@ -427,9 +427,9 @@ sub col_get my ( $dims, $i, @list ); - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); - &Maasha::Common::error( qq(Column->$col outside of matrix->$dims->[ COLS ]) ) if $col > $dims->[ COLS ]; + Maasha::Common::error( qq(Column->$col outside of matrix->$dims->[ COLS ]) ) if $col > $dims->[ COLS ]; for ( $i = 0; $i < $dims->[ ROWS ]; $i++ ) { push @list, $matrix->[ $i ]->[ $col ]; @@ -454,7 +454,7 @@ sub cols_get my ( $dims, @cols, $row, @AoA ); - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); $col_beg ||= 0; @@ -496,12 +496,12 @@ sub col_sum my ( $list, $sum ); - $list = &cols_get( $matrix, $col, $col ); - $list = &matrix_flip( $list )->[ 0 ]; + $list = cols_get( $matrix, $col, $col ); + $list = matrix_flip( $list )->[ 0 ]; die qq(ERROR: cannot sum non-nummerical column\n); - $sum = &Maasha::Calc::sum( $list ); + $sum = Maasha::Calc::sum( $list ); return $sum; } @@ -557,8 +557,8 @@ sub cols_push my ( $dims_matrix, $dims_cols, $i ); - $dims_matrix = &matrix_dims( $matrix ); - $dims_cols = &matrix_dims( $cols ); + $dims_matrix = matrix_dims( $matrix ); + $dims_cols = matrix_dims( $cols ); die qq(ERROR: Cannot merge columns with different row count\n) if $dims_matrix->[ ROWS ] != $dims_cols->[ ROWS ]; @@ -585,8 +585,8 @@ sub cols_unshift my ( $dims_matrix, $dims_cols, $i ); - $dims_matrix = &matrix_dims( $matrix ); - $dims_cols = &matrix_dims( $cols ); + $dims_matrix = matrix_dims( $matrix ); + $dims_cols = matrix_dims( $cols ); die qq(ERROR: Cannot merge columns with different row count\n) if $dims_matrix->[ ROWS ] != $dims_cols->[ ROWS ]; @@ -620,11 +620,11 @@ sub rows_rotate_left for ( $i = $beg; $i <= $end; $i++ ) { - $row = &rows_get( $matrix, $i, $i ); + $row = rows_get( $matrix, $i, $i ); for ( $c = 0; $c < $shift; $c++ ) { - $row = &list_rotate_left( @{ $row } ); + $row = list_rotate_left( @{ $row } ); $matrix->[ $i ] = $row; } } @@ -653,18 +653,18 @@ sub rows_rotate_right $shift ||= 1; - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); die qq(ERROR: end < beg: $end < $beg\n) if $end < $beg; die qq(ERROR: row outside matrix\n) if $end >= $dims->[ ROWS ]; for ( $i = $beg; $i <= $end; $i++ ) { - $row = &rows_get( $matrix, $i, $i ); + $row = rows_get( $matrix, $i, $i ); for ( $c = 0; $c < $shift; $c++ ) { - $row = &list_rotate_right( @{ $row } ); + $row = list_rotate_right( @{ $row } ); $matrix->[ $i ] = $row; } } @@ -693,31 +693,31 @@ sub cols_rotate_up $shift ||= 1; - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); - $cols_pre = &cols_get( $matrix, 0, $beg - 1 ) if $beg > 0; - $cols_post = &cols_get( $matrix, $end + 1, $dims->[ COLS ] - 1 ) if $end < $dims->[ COLS ] - 1; + $cols_pre = cols_get( $matrix, 0, $beg - 1 ) if $beg > 0; + $cols_post = cols_get( $matrix, $end + 1, $dims->[ COLS ] - 1 ) if $end < $dims->[ COLS ] - 1; for ( $i = $beg; $i <= $end; $i++ ) { - $col_select = &cols_get( $matrix, $i, $i ); + $col_select = cols_get( $matrix, $i, $i ); - $list = &matrix_flip( $col_select )->[ 0 ]; + $list = matrix_flip( $col_select )->[ 0 ]; for ( $c = 0; $c < $shift; $c++ ) { - $list = &list_rotate_left( $list ); + $list = list_rotate_left( $list ); } - $col_select = &matrix_flip( [ $list ] ); + $col_select = matrix_flip( [ $list ] ); if ( $cols_pre ) { - &cols_push( $cols_pre, $col_select ); + cols_push( $cols_pre, $col_select ); } else { $cols_pre = $col_select; } } - &cols_push( $cols_pre, $cols_post ) if $cols_post; + cols_push( $cols_pre, $cols_post ) if $cols_post; $matrix = $cols_pre; @@ -745,31 +745,31 @@ sub cols_rotate_down $shift ||= 1; - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); - $cols_pre = &cols_get( $matrix, 0, $beg - 1 ) if $beg > 0; - $cols_post = &cols_get( $matrix, $end + 1, $dims->[ COLS ] - 1 ) if $end < $dims->[ COLS ] - 1; + $cols_pre = cols_get( $matrix, 0, $beg - 1 ) if $beg > 0; + $cols_post = cols_get( $matrix, $end + 1, $dims->[ COLS ] - 1 ) if $end < $dims->[ COLS ] - 1; for ( $i = $beg; $i <= $end; $i++ ) { - $col_select = &cols_get( $matrix, $i, $i ); + $col_select = cols_get( $matrix, $i, $i ); - $list = &matrix_flip( $col_select )->[ 0 ]; + $list = matrix_flip( $col_select )->[ 0 ]; for ( $c = 0; $c < $shift; $c++ ) { - $list = &list_rotate_right( $list ); + $list = list_rotate_right( $list ); } - $col_select = &matrix_flip( [ $list ] ); + $col_select = matrix_flip( [ $list ] ); if ( $cols_pre ) { - &cols_push( $cols_pre, $col_select ); + cols_push( $cols_pre, $col_select ); } else { $cols_pre = $col_select; } } - &cols_push( $cols_pre, $cols_post ) if $cols_post; + cols_push( $cols_pre, $cols_post ) if $cols_post; $matrix = $cols_pre; @@ -863,7 +863,7 @@ sub list_check_sort if ( not $type ) { - if ( &list_check_numeric( $list ) ) { + if ( list_check_numeric( $list ) ) { $type = "n"; } else { $type = "a"; @@ -936,10 +936,10 @@ sub tabulate my ( $dims, $list, $i, $max, $len, %hash, $elem, @list ); - $dims = &matrix_dims( $matrix ); + $dims = matrix_dims( $matrix ); - $list = &cols_get( $matrix, $col, $col ); - $list = &matrix_flip( $list )->[ 0 ]; + $list = cols_get( $matrix, $col, $col ); + $list = matrix_flip( $list )->[ 0 ]; $max = 0; @@ -954,7 +954,7 @@ sub tabulate @list = keys %hash; - if ( &list_check_numeric( $list ) ) { + if ( list_check_numeric( $list ) ) { @list = sort { $a <=> $b } @list; } else { @list = sort { $a cmp $b } @list; @@ -1084,7 +1084,7 @@ sub matrix_read $delimiter ||= "\t"; - $fh = &Maasha::Common::read_open( $path ); + $fh = Maasha::Common::read_open( $path ); while ( $line = <$fh> ) { @@ -1118,7 +1118,7 @@ sub matrix_write my ( $fh, $row ); - $fh = &Maasha::Common::write_open( $path ) if $path; + $fh = Maasha::Common::write_open( $path ) if $path; $delimiter ||= "\t"; @@ -1145,7 +1145,7 @@ sub matrix_store $matrix, # data structure ) = @_; - &Maasha::Common::file_store( $path, $matrix ); + Maasha::Common::file_store( $path, $matrix ); } @@ -1158,7 +1158,7 @@ sub matrix_retrive my ( $path, # full path to file ) = @_; - my $matrix = &Maasha::Common::file_retrieve( $path ); + my $matrix = Maasha::Common::file_retrieve( $path ); return wantarray ? @{ $matrix } : $matrix; } diff --git a/code_perl/Maasha/NCBI.pm b/code_perl/Maasha/NCBI.pm index 3c8f581..689fd7d 100644 --- a/code_perl/Maasha/NCBI.pm +++ b/code_perl/Maasha/NCBI.pm @@ -121,7 +121,7 @@ sub soft_parse my ( $fh, @lines, $i, $c, $num, %key_hash, @fields, %id_hash, $id, $seq, $count, $record, @records, $platform_id, $sample_id, $sample_title ); - $fh = &Maasha::Common::read_open( $path ); + $fh = Maasha::Common::read_open( $path ); @lines = <$fh>; @@ -228,7 +228,7 @@ sub soft_index_file my ( $fh, $line, $i, $c, @index, $first ); - $fh = &Maasha::Common::read_open( $file ); + $fh = Maasha::Common::read_open( $file ); $first = 1; diff --git a/code_perl/Maasha/Patscan.pm b/code_perl/Maasha/Patscan.pm index 7aeb3c3..2fed120 100644 --- a/code_perl/Maasha/Patscan.pm +++ b/code_perl/Maasha/Patscan.pm @@ -54,7 +54,7 @@ sub read_patterns my ( $fh, $line, @patterns ); - $fh = &Maasha::Common::read_open( $path ); + $fh = Maasha::Common::read_open( $path ); while ( $line = <$fh> ) { diff --git a/code_perl/Maasha/Plot.pm b/code_perl/Maasha/Plot.pm index 225433d..f7072bd 100644 --- a/code_perl/Maasha/Plot.pm +++ b/code_perl/Maasha/Plot.pm @@ -71,7 +71,7 @@ sub lineplot_simple $tmp_file = "$tmp_dir/lineplot_simple.tab"; - $fh_out = &Maasha::Common::write_open( $tmp_file ); + $fh_out = Maasha::Common::write_open( $tmp_file ); map { print $fh_out join( "\t", @{ $_ } ), "\n" } @{ $data }; @@ -337,8 +337,8 @@ sub dotplot_matches $forward_file = "$tmp_dir/match_f.tab"; $backward_file = "$tmp_dir/match_r.tab"; - $fh_forward = &Maasha::Common::write_open( $forward_file ); - $fh_backward = &Maasha::Common::write_open( $backward_file ); + $fh_forward = Maasha::Common::write_open( $forward_file ); + $fh_backward = Maasha::Common::write_open( $backward_file ); $q_max = 0; $s_max = 0; @@ -448,11 +448,11 @@ sub karyogram # $karyo_file = "/home/m.hansen/maasha/perl_scripts/biopieces/karyo_data/mouse_cytobands.txt"; } - $karyo = &parse_karyo_data( $karyo_file ); + $karyo = parse_karyo_data( $karyo_file ); - $svg = &init_svg; + $svg = init_svg; - &chromosome_layout( $svg, $karyo, $data ); + chromosome_layout( $svg, $karyo, $data ); return $svg->xmlify; } @@ -491,7 +491,7 @@ sub parse_karyo_data # stalk => "gray66", ); - $fh = &Maasha::Common::read_open( $file ); + $fh = Maasha::Common::read_open( $file ); while ( $line = <$fh> ) { @@ -503,7 +503,7 @@ sub parse_karyo_data ( $chr, $beg, $end, $name, $color ) = split "\t", $line; # if ( $color =~ /^gpos(\d+)/ ) { -# $color = &color_intensity( $1 ); +# $color = color_intensity( $1 ); # } elsif ( exists $color_hash{ $color } ) { $color = $color_hash{ $color }; # } else { @@ -615,12 +615,12 @@ sub chromosome_layout { $chr = $list[ $i ]; $chr_len = $karyo_list->{ $chr }->[ -1 ]->[ 2 ]; - $chr_cent = &find_cent( $karyo_list->{ $list[ $i ] } ); + $chr_cent = find_cent( $karyo_list->{ $list[ $i ] } ); $y = HEIGHT / 2 - $chr_len; $x = ( WIDTH / ( @list + 2 ) ) * ( $i + 1 ); - &draw_chr( $layout_obj, $x, $y, $chr_len, $chr_width, $chr_cent, $chr, $karyo_list, $feat_list ); + draw_chr( $layout_obj, $x, $y, $chr_len, $chr_width, $chr_cent, $chr, $karyo_list, $feat_list ); $i++; } @@ -678,7 +678,7 @@ sub draw_chr ); if ( exists $feat_list->{ $chr } ) { - &draw_chr_feat( $chr_obj, $x, $y, $chr_width, $feat_list->{ $chr } ); + draw_chr_feat( $chr_obj, $x, $y, $chr_width, $feat_list->{ $chr } ); } $clip_obj = $chr_obj->clipPath( @@ -708,7 +708,7 @@ sub draw_chr ); if ( exists $karyo_list->{ $chr } ) { - &draw_karyo_data( $gr_obj, $x, $y, $chr_width, $karyo_list->{ $chr } ); + draw_karyo_data( $gr_obj, $x, $y, $chr_width, $karyo_list->{ $chr } ); } $gr_obj->rectangle( @@ -731,7 +731,7 @@ sub draw_chr ry => 10, ); - &draw_chr_num( $chr_obj, $x, $y, $chr_len, $chr_width, $chr ); + draw_chr_num( $chr_obj, $x, $y, $chr_len, $chr_width, $chr ); } @@ -869,7 +869,7 @@ sub seq_logo my ( $type, $bit_max, $logo_data, $svg ); - $type = &Maasha::Seq::seq_guess_type( $entries->[ 0 ]->[ 1 ] ); + $type = Maasha::Seq::seq_guess_type( $entries->[ 0 ]->[ 1 ] ); if ( $type =~ /^p/i ) { $bit_max = 4; @@ -877,12 +877,12 @@ sub seq_logo $bit_max = 2; } - $logo_data = &Maasha::Seq::seqlogo_calc( $bit_max, $entries ); + $logo_data = Maasha::Seq::seqlogo_calc( $bit_max, $entries ); - $svg = &Maasha::Plot::svg_init(); + $svg = Maasha::Plot::svg_init(); - &svg_draw_logo( $svg, $logo_data, $bit_max, $type ); - &svg_draw_logo_scale( $svg, $bit_max ); + svg_draw_logo( $svg, $logo_data, $bit_max, $type ); + svg_draw_logo_scale( $svg, $bit_max ); return $svg->xmlify; } @@ -945,9 +945,9 @@ sub svg_draw_logo if ( $nocolor ) { $color = "black"; } elsif ( $type eq "dna" or $type eq "rna" ) { - $color = &Maasha::Seq::color_nuc( $char ); + $color = Maasha::Seq::color_nuc( $char ); } else { - $color = &Maasha::Seq::color_pep( $char ); + $color = Maasha::Seq::color_pep( $char ); } $block->text( @@ -956,7 +956,7 @@ sub svg_draw_logo y => 0, style => { 'font-weight' => 'bold', - fill => &Maasha::Seq::color_palette( $color ), + fill => Maasha::Seq::color_palette( $color ), } )->cdata( $char ); diff --git a/code_perl/Maasha/SQL.pm b/code_perl/Maasha/SQL.pm index c7feeaa..5ce3927 100644 --- a/code_perl/Maasha/SQL.pm +++ b/code_perl/Maasha/SQL.pm @@ -75,7 +75,7 @@ sub database_exists my ( @databases ); - @databases = &list_databases( $user, $pass ); + @databases = list_databases( $user, $pass ); if ( grep /^$database$/i, @databases ) { return 1; @@ -99,7 +99,7 @@ sub list_databases my ( @databases ); - @databases = &Maasha::Common::run_and_return( "mysqlshow", "--user=$user --password=$pass" ); + @databases = Maasha::Common::run_and_return( "mysqlshow", "--user=$user --password=$pass" ); splice @databases, 0, 3; @@ -123,7 +123,7 @@ sub request { $errstr = $DBI::errstr; - &disconnect( $dbh ); + disconnect( $dbh ); die qq(ERROR: $errstr, "SQL PREPARE ERROR" ); } @@ -131,7 +131,7 @@ sub request { $errstr = $DBI::errstr; - &disconnect( $dbh ); + disconnect( $dbh ); die qq(ERROR: $errstr, "SQL EXECUTE ERROR" ); } @@ -160,7 +160,7 @@ sub query_hash { $errstr = $DBI::errstr; - &disconnect( $dbh ); + disconnect( $dbh ); die qq(ERROR: $errstr, "SQL PREPARE ERROR" ); } @@ -168,7 +168,7 @@ sub query_hash { $errstr = $DBI::errstr; - &disconnect( $dbh ); + disconnect( $dbh ); die qq(ERROR: $errstr, "SQL EXECUTE ERROR" ); } @@ -180,7 +180,7 @@ sub query_hash { $errstr = $DBI::errstr; - &disconnect( $dbh ); + disconnect( $dbh ); die qq(ERROR: $errstr, "DATABASE RETRIEVE ERROR" ); } @@ -208,7 +208,7 @@ sub query_array { $errstr = $DBI::errstr; - &disconnect( $dbh ); + disconnect( $dbh ); die qq(ERROR: $errstr, "SQL PREPARE ERROR" ); } @@ -216,7 +216,7 @@ sub query_array { $errstr = $DBI::errstr; - &disconnect( $dbh ); + disconnect( $dbh ); die qq(ERROR: $errstr, "SQL EXECUTE ERROR" ); } @@ -228,7 +228,7 @@ sub query_array { $errstr = $DBI::errstr; - &disconnect( $dbh ); + disconnect( $dbh ); die qq(ERROR: $errstr, "DATABASE RETRIEVE ERROR" ); } } @@ -259,7 +259,7 @@ sub delete_table $table, ) = @_; - &request( $dbh, "drop table $table" ); + request( $dbh, "drop table $table" ); } @@ -270,7 +270,7 @@ sub list_tables my ( @list ); - @list = &query_array( $dbh, "show tables" ); + @list = query_array( $dbh, "show tables" ); if ( @list ) { @list = map { $_->[0] } @list; @@ -288,7 +288,7 @@ sub table_exists $name, ) = @_; - if ( grep /^$name$/, &list_tables( $dbh ) ) { + if ( grep /^$name$/, list_tables( $dbh ) ) { return 1; } else { return; @@ -312,7 +312,7 @@ sub connect my ( $dbh ); - &Maasha::Common::error( qq(Database "$database" does not exist) ) if not &database_exists( $database, $user, $pass ); + Maasha::Common::error( qq(Database "$database" does not exist) ) if not database_exists( $database, $user, $pass ); $dbh = DBI->connect( "dbi:mysql:$database", @@ -329,7 +329,7 @@ sub connect if ( $dbh ) { return $dbh; } else { - &Maasha::Common::error( qq($DBI::errstr) ); + Maasha::Common::error( qq($DBI::errstr) ); } } @@ -363,7 +363,7 @@ sub update_field $count_sql = qq( SELECT $column FROM $table WHERE $column="$old_val"; ); - $count = scalar &query_array( $dbh, $count_sql ); + $count = scalar query_array( $dbh, $count_sql ); if ( $count > 1 ) { @@ -371,13 +371,13 @@ sub update_field } elsif ( $count == 0 ) { - &disconnect( $dbh ); + disconnect( $dbh ); die qq(ERROR: entry not found "$count_sql"\n); } else { $sql = qq( UPDATE $table SET $column="$new_val" WHERE $column="$old_val"; ); - &request( $dbh, $sql ); + request( $dbh, $sql ); } return; @@ -400,7 +400,7 @@ sub delete_row $sql = qq(DELETE FROM $table WHERE $field = "$pattern";); - &request( $dbh, $sql ); + request( $dbh, $sql ); return; } @@ -430,7 +430,7 @@ sub add_row $sql = "INSERT INTO $table VALUES ( " . join( ", ", @fields ) . " );"; - &request( $dbh, $sql ); + request( $dbh, $sql ); return; } @@ -457,7 +457,7 @@ sub add_column $sql = "ALTER TABLE $table ADD COLUMN ( $column $type );"; } - &request( $dbh, $sql ); + request( $dbh, $sql ); return; } @@ -478,7 +478,7 @@ sub del_column $sql = "ALTER TABLE $table DROP COLUMN $column;"; - &request( $dbh, $sql ); + request( $dbh, $sql ); return; } @@ -504,7 +504,7 @@ sub load_sql_file $sql = qq( LOAD DATA LOCAL INFILE "$path" INTO TABLE $table FIELDS TERMINATED BY '$delimiter' ); - &SQL::request( $dbh, $sql ); + SQL::request( $dbh, $sql ); } diff --git a/code_perl/Maasha/Seq.pm b/code_perl/Maasha/Seq.pm index f2b8089..9170518 100644 --- a/code_perl/Maasha/Seq.pm +++ b/code_perl/Maasha/Seq.pm @@ -450,7 +450,7 @@ sub translate if ( $frame =~ /-?[1-3]/ ) { if ( $frame < 0 ) { - $dna = &Maasha::Seq::dna_revcomp( $dna ); + $dna = Maasha::Seq::dna_revcomp( $dna ); } $frame = abs( $frame ) - 1; @@ -459,7 +459,7 @@ sub translate } else { - &Maasha::Common::error( qq(Badly formated frame "$frame") ); + Maasha::Common::error( qq(Badly formated frame "$frame") ); } $pos = 0; @@ -468,7 +468,7 @@ sub translate { last if not length $codon == 3; - $pep .= &codon2aa( $codon ); + $pep .= codon2aa( $codon ); $pos += 3; } @@ -495,7 +495,7 @@ sub fold_struct_rnafold $pid = open2( $fh_out, $fh_in, "RNAfold -noPS" ); - &Maasha::Fasta::put_entry( [ "RNAfold", $seq ], $fh_in ); + Maasha::Fasta::put_entry( [ "RNAfold", $seq ], $fh_in ); close $fh_in; @@ -537,13 +537,13 @@ sub fold_struct_contrastruct $out_file1 = "$tmp_dir/fold.out1"; $out_file2 = "$tmp_dir/fold.out2"; - &Maasha::Fasta::put_entries( [ [ "fold", $seq ] ], $tmp_file ); + Maasha::Fasta::put_entries( [ [ "fold", $seq ] ], $tmp_file ); - &Maasha::Common::run( "contrafold", "predict --parens $out_file1 --bpseq $out_file2 $tmp_file" ); + Maasha::Common::run( "contrafold", "predict --parens $out_file1 --bpseq $out_file2 $tmp_file" ); unlink $tmp_file; - $fh = &Maasha::Common::read_open( $out_file1 ); + $fh = Maasha::Common::read_open( $out_file1 ); while ( $line = <$fh> ) { @@ -556,7 +556,7 @@ sub fold_struct_contrastruct unlink $out_file1; - $fh = &Maasha::Common::read_open( $out_file2 ); + $fh = Maasha::Common::read_open( $out_file2 ); while ( $line = <$fh> ) { @@ -575,7 +575,7 @@ sub fold_struct_contrastruct { last if $AoA[ $i ]->[ 0 ] > $AoA[ $i ]->[ 2 ]; - $temp += &base_pair_melting_temp( $AoA[ $i ]->[ 1 ] . $AoA[ $AoA[ $i ]->[ 2 ] - 1 ]->[ 1 ] ); + $temp += base_pair_melting_temp( $AoA[ $i ]->[ 1 ] . $AoA[ $AoA[ $i ]->[ 2 ] - 1 ]->[ 1 ] ); } } @@ -836,7 +836,7 @@ sub seq_analyze my ( %analysis, @chars, @chars_lc, $char, %char_hash, $gc, $at, $lc, $max, $res_sum, @indels, %indel_hash ); - $analysis{ "SEQ_TYPE" } = uc &Maasha::Seq::seq_guess_type( $seq ); + $analysis{ "SEQ_TYPE" } = uc Maasha::Seq::seq_guess_type( $seq ); $analysis{ "SEQ_LEN" } = length $seq; @indels = qw( - ~ . _ ); @@ -965,11 +965,11 @@ sub seqlogo_calc delete $char_hash{ "~" }; delete $char_hash{ "." }; - $bit_height = &seqlogo_calc_bit_height( \%char_hash, $char_tot ); + $bit_height = seqlogo_calc_bit_height( \%char_hash, $char_tot ); $bit_diff = $bit_max - $bit_height; - $char_heights = &seqlogo_calc_char_heights( \%char_hash, $char_tot, $bit_diff ); + $char_heights = seqlogo_calc_char_heights( \%char_hash, $char_tot, $bit_diff ); push @logo, $char_heights; } diff --git a/code_perl/Maasha/Test.pm b/code_perl/Maasha/Test.pm index c5a319f..2a0fe25 100644 --- a/code_perl/Maasha/Test.pm +++ b/code_perl/Maasha/Test.pm @@ -20,5 +20,5 @@ sub hello_world } END { - &hello_world; + hello_world; } diff --git a/code_perl/Maasha/TwoBit.pm b/code_perl/Maasha/TwoBit.pm index 1d839bc..1e93c23 100644 --- a/code_perl/Maasha/TwoBit.pm +++ b/code_perl/Maasha/TwoBit.pm @@ -305,22 +305,22 @@ sub twobit_get_TOC sysseek $fh, 0, 0; - $signature = &unpack_32bit( $fh ); - $version = &unpack_32bit( $fh ); - $seq_count = &unpack_32bit( $fh ); - $reserved = &unpack_32bit( $fh ); + $signature = unpack_32bit( $fh ); + $version = unpack_32bit( $fh ); + $seq_count = unpack_32bit( $fh ); + $reserved = unpack_32bit( $fh ); - &Maasha::Common::error( qq(2bit file signature didn't match - inverse bit order?) ) if $signature != 0x1A412743; + Maasha::Common::error( qq(2bit file signature didn't match - inverse bit order?) ) if $signature != 0x1A412743; for ( $i = 0; $i < $seq_count; $i++ ) { - $seq_name_size = &unpack_8bit( $fh ); + $seq_name_size = unpack_8bit( $fh ); sysread $fh, $string, $seq_name_size; $seq_name = unpack( "A$seq_name_size", $string ); - $offset = &unpack_32bit( $fh ); + $offset = unpack_32bit( $fh ); push @AoA, [ $seq_name, $offset ]; } @@ -356,24 +356,24 @@ sub twobit_get_seq sysseek $fh, $offset, 0; - $seq_len = &unpack_32bit( $fh ); + $seq_len = unpack_32bit( $fh ); $sub_len = $seq_len if $sub_len > $seq_len; - $n_count = &unpack_32bit( $fh ); + $n_count = unpack_32bit( $fh ); - map { push @n_begs, &unpack_32bit( $fh ) } 1 .. $n_count; - map { push @n_sizes, &unpack_32bit( $fh ) } 1 .. $n_count; + map { push @n_begs, unpack_32bit( $fh ) } 1 .. $n_count; + map { push @n_sizes, unpack_32bit( $fh ) } 1 .. $n_count; - $m_count = &unpack_32bit( $fh ); + $m_count = unpack_32bit( $fh ); - map { push @m_begs, &unpack_32bit( $fh ) } 1 .. $m_count; - map { push @m_sizes, &unpack_32bit( $fh ) } 1 .. $m_count; + map { push @m_begs, unpack_32bit( $fh ) } 1 .. $m_count; + map { push @m_sizes, unpack_32bit( $fh ) } 1 .. $m_count; - $reserved = &unpack_32bit( $fh ); + $reserved = unpack_32bit( $fh ); $offset += 4 + 4 + $n_count * 8 + 4 + $m_count * 8 + 4; - $seq = &unpack_dna( $fh, $offset, $sub_beg, $sub_len ); + $seq = unpack_dna( $fh, $offset, $sub_beg, $sub_len ); for ( $n = 0; $n < $n_count; $n++ ) { @@ -514,12 +514,12 @@ sub fasta2twobit $seq_offset = 0; # offset for reading sequence from FASTA file $offset = 16; # offset starting after header line which is 16 bytes - while ( $entry = &Maasha::Fasta::get_entry( $fh_in ) ) + while ( $entry = Maasha::Fasta::get_entry( $fh_in ) ) { $seq_len = length $entry->[ SEQ ]; $seq_name_len = length $entry->[ SEQ_NAME ]; - $mask_index = &mask_locate( $entry->[ SEQ ], $mask ); + $mask_index = mask_locate( $entry->[ SEQ ], $mask ); $pack_len = ( $seq_len + ( 4 - ( $seq_len ) % 4 ) ) / 4; @@ -604,7 +604,7 @@ sub fasta2twobit $seq = uc $seq; $seq =~ tr/RYWSMKHDVBN/TTTTTTTTTTT/; - $bin .= &pack_dna( $seq ); + $bin .= pack_dna( $seq ); print $fh_out $bin; } diff --git a/code_perl/Maasha/UCSC.pm b/code_perl/Maasha/UCSC.pm index 5170725..8e02dde 100644 --- a/code_perl/Maasha/UCSC.pm +++ b/code_perl/Maasha/UCSC.pm @@ -138,7 +138,7 @@ sub bed_get_entry } else { - &Maasha::Common::error( qq(Bad BED format in line->$line<-) ); + Maasha::Common::error( qq(Bad BED format in line->$line<-) ); } $entry{ "REC_TYPE" } = "BED"; @@ -164,9 +164,9 @@ sub bed_get_entries my ( $fh, $entry, @list ); - $fh = &Maasha::Common::read_open( $path ); + $fh = Maasha::Common::read_open( $path ); - while ( $entry = &bed_get_entry( $fh ) ) { + while ( $entry = bed_get_entry( $fh ) ) { push @list, $entry; } @@ -272,7 +272,7 @@ sub bed_put_entries # Returns nothing. - map { &bed_put_entry( $_, $fh ) } @{ $entries }; + map { bed_put_entry( $_, $fh ) } @{ $entries }; } @@ -360,9 +360,9 @@ sub bed_sort my ( $fh_in, $key, $fh_out, %fh_hash, $part_file, $entry, $entries ); - $fh_in = &Maasha::Common::read_open( $file ); + $fh_in = Maasha::Common::read_open( $file ); - while ( $entry = &bed_get_entry( $fh_in ) ) + while ( $entry = bed_get_entry( $fh_in ) ) { if ( $strand ) { $key = join "_", $entry->{ "CHR" }, $entry->{ "STRAND" }; @@ -370,24 +370,24 @@ sub bed_sort $key = $entry->{ "CHR" }; } - $fh_hash{ $key } = &Maasha::Common::write_open( "$tmp_dir/$key.sort" ) if not exists $fh_hash{ $key }; + $fh_hash{ $key } = Maasha::Common::write_open( "$tmp_dir/$key.sort" ) if not exists $fh_hash{ $key }; - &bed_put_entry( $entry, $fh_hash{ $key } ); + bed_put_entry( $entry, $fh_hash{ $key } ); } close $fh_in; map { close $_ } keys %fh_hash; - $fh_out = &Maasha::Common::write_open( "$tmp_dir/temp.sort" ); + $fh_out = Maasha::Common::write_open( "$tmp_dir/temp.sort" ); foreach $part_file ( sort keys %fh_hash ) { - $entries = &bed_get_entries( "$tmp_dir/$part_file.sort" ); + $entries = bed_get_entries( "$tmp_dir/$part_file.sort" ); @{ $entries } = sort { $a->{ "CHR_BEG" } <=> $b->{ "CHR_BEG" } } @{ $entries }; - map { &bed_put_entry( $_, $fh_out ) } @{ $entries }; + map { bed_put_entry( $_, $fh_out ) } @{ $entries }; unlink "$tmp_dir/$part_file.sort"; } @@ -415,8 +415,8 @@ sub bed_merge_entries for ( $i = 0; $i < @{ $entries }; $i++ ) { - &Maasha::Common::error( qq(Attempted merge of BED entries from different chromosomes) ) if $entries->[ 0 ]->{ "CHR" } ne $entries->[ $i ]->{ "CHR" }; - &Maasha::Common::error( qq(Attempted merge of BED entries from different strands) ) if $entries->[ 0 ]->{ "STRAND" } ne $entries->[ $i ]->{ "STRAND" }; + Maasha::Common::error( qq(Attempted merge of BED entries from different chromosomes) ) if $entries->[ 0 ]->{ "CHR" } ne $entries->[ $i ]->{ "CHR" }; + Maasha::Common::error( qq(Attempted merge of BED entries from different strands) ) if $entries->[ 0 ]->{ "STRAND" } ne $entries->[ $i ]->{ "STRAND" }; push @q_ids, $entries->[ $i ]->{ "Q_ID" } || sprintf( "ID%06d", $i ); @@ -558,11 +558,11 @@ sub bed_upload_to_ucsc { $table = $options->{ "table" }; - &Maasha::Common::error( "Attempt to load secondary structure track without 'rnaSecStr' in table name" ) if not $table =~ /rnaSecStr/; + Maasha::Common::error( "Attempt to load secondary structure track without 'rnaSecStr' in table name" ) if not $table =~ /rnaSecStr/; $sql_file = "$tmp_dir/upload_RNA_SS.sql"; - $fh_out = &Maasha::Common::write_open( $sql_file ); + $fh_out = Maasha::Common::write_open( $sql_file ); print $fh_out qq( CREATE TABLE $table ( @@ -585,13 +585,13 @@ CREATE TABLE $table ( close $fh_out; - &Maasha::Common::run( "hgLoadBed", "-notItemRgb -sqlTable=$sql_file $options->{ 'database' } $options->{ 'table' } -tmpDir=$tmp_dir $file > /dev/null 2>&1" ); + Maasha::Common::run( "hgLoadBed", "-notItemRgb -sqlTable=$sql_file $options->{ 'database' } $options->{ 'table' } -tmpDir=$tmp_dir $file > /dev/null 2>&1" ); unlink $sql_file; } else { - &Maasha::Common::run( "hgLoadBed", "$args > /dev/null 2>&1" ); + Maasha::Common::run( "hgLoadBed", "$args > /dev/null 2>&1" ); } } @@ -612,7 +612,7 @@ sub psl_get_entries my ( $fh, @lines, @fields, $i, %record, @records ); - $fh = &Maasha::Common::read_open( $path ); + $fh = Maasha::Common::read_open( $path ); @lines = <$fh>; @@ -624,7 +624,7 @@ sub psl_get_entries { @fields = split "\t", $lines[ $i ]; - &Maasha::Common::error( qq(Bad PSL format in file "$path") ) if not @fields == 21; + Maasha::Common::error( qq(Bad PSL format in file "$path") ) if not @fields == 21; undef %record; @@ -745,7 +745,7 @@ sub psl_upload_to_ucsc $args = join " ", $options->{ "database" }, "-table=$options->{ 'table' }", "-clientLoad", $file; } - &Maasha::Common::run( "hgLoadPsl", "$args > /dev/null 2>&1" ); + Maasha::Common::run( "hgLoadPsl", "$args > /dev/null 2>&1" ); } @@ -770,8 +770,8 @@ sub update_my_tracks # ---- create a backup ---- - $fh_in = &Maasha::Common::read_open( $file ); - $fh_out = &Maasha::Common::write_open( "$file~" ); + $fh_in = Maasha::Common::read_open( $file ); + $fh_out = Maasha::Common::write_open( "$file~" ); while ( $line = <$fh_in> ) { print $fh_out $line; @@ -782,9 +782,9 @@ sub update_my_tracks # ---- append track ---- - $time = &Maasha::Common::time_stamp(); + $time = Maasha::Common::time_stamp(); - $fh_out = &Maasha::Common::append_open( $file ); + $fh_out = Maasha::Common::append_open( $file ); if ( $type eq "sec_struct" ) { @@ -830,7 +830,7 @@ sub update_my_tracks close $fh_out; - &Maasha::Common::run( "ucscMakeTracks.pl", "-b > /dev/null 2>&1" ); + Maasha::Common::run( "ucscMakeTracks.pl", "-b > /dev/null 2>&1" ); } @@ -1019,11 +1019,11 @@ sub phastcons_index_create my ( $fh, $pos, $index_beg, $index_len, $entry, $locator, $chr, $step, $beg, $end, $len, %index, $i ); - $fh = &Maasha::Common::read_open( $path ); + $fh = Maasha::Common::read_open( $path ); $pos = 0; - while ( $entry = &Maasha::UCSC::phastcons_get_entry( $fh ) ) + while ( $entry = Maasha::UCSC::phastcons_get_entry( $fh ) ) { $locator = shift @{ $entry }; @@ -1035,7 +1035,7 @@ sub phastcons_index_create } else { - &Maasha::Common::error( qq(Could not parse PhastCons locator: $locator) ); + Maasha::Common::error( qq(Could not parse PhastCons locator: $locator) ); } $pos += length( $locator ) + 11; @@ -1078,7 +1078,7 @@ sub phastcons_index_store # returns nothing - &Maasha::Common::file_store( $path, $index ); + Maasha::Common::file_store( $path, $index ); } @@ -1095,7 +1095,7 @@ sub phastcons_index_retrieve my $index; - $index = &Maasha::Common::file_retrieve( $path ); + $index = Maasha::Common::file_retrieve( $path ); return wantarray ? %{ $index } : $index; } @@ -1130,10 +1130,10 @@ sub phastcons_index_lookup if ( exists $index->{ $chr } ) { - $index_beg = &Maasha::Matrix::interval_search( $index->{ $chr }, 0, 1, $chr_beg ); + $index_beg = Maasha::Matrix::interval_search( $index->{ $chr }, 0, 1, $chr_beg ); if ( $index_beg < 0 ) { - &Maasha::Common::error( qq(Index search failed - begin index position doesn't exists: $chr_beg) ); + Maasha::Common::error( qq(Index search failed - begin index position doesn't exists: $chr_beg) ); } if ( $chr_end < $index->{ $chr }->[ $index_beg ]->[ 1 ] ) @@ -1142,10 +1142,10 @@ sub phastcons_index_lookup } else { - $index_end = &Maasha::Matrix::interval_search( $index->{ $chr }, 0, 1, $chr_end ); + $index_end = Maasha::Matrix::interval_search( $index->{ $chr }, 0, 1, $chr_end ); if ( $index_end < 0 ) { - &Maasha::Common::error( qq(Index search failed - end index position doesn't exists: $chr_end) ); + Maasha::Common::error( qq(Index search failed - end index position doesn't exists: $chr_end) ); } } @@ -1153,12 +1153,12 @@ sub phastcons_index_lookup if ( $index_beg == $index_end ) { - $beg = &Maasha::Calc::max( $chr_beg, $index->{ $chr }->[ $index_beg ]->[ CHR_BEG ] ); - $end = &Maasha::Calc::min( $chr_end, $index->{ $chr }->[ $index_end ]->[ CHR_END ] ); + $beg = Maasha::Calc::max( $chr_beg, $index->{ $chr }->[ $index_beg ]->[ CHR_BEG ] ); + $end = Maasha::Calc::min( $chr_end, $index->{ $chr }->[ $index_end ]->[ CHR_END ] ); if ( $beg <= $index->{ $chr }->[ $index_beg ]->[ CHR_END ] and $end >= $index->{ $chr }->[ $index_beg ]->[ CHR_BEG ] ) { - @vals = split "\n", &Maasha::Common::file_read( + @vals = split "\n", Maasha::Common::file_read( $fh, $index->{ $chr }->[ $index_beg ]->[ INDEX_BEG ] + 6 * ( $beg - $index->{ $chr }->[ $index_beg ]->[ CHR_BEG ] ), 6 * ( $end - $beg + 1 ), @@ -1171,7 +1171,7 @@ sub phastcons_index_lookup } else { - $beg = &Maasha::Calc::max( $chr_beg, $index->{ $chr }->[ $index_beg ]->[ CHR_BEG ] ); + $beg = Maasha::Calc::max( $chr_beg, $index->{ $chr }->[ $index_beg ]->[ CHR_BEG ] ); # print Dumper( $beg, $index->{ $chr }->[ $index_beg ] ); # print Dumper( "next", $index->{ $chr }->[ $index_beg ]->[ NEXT_CHR_BEG ] ); @@ -1182,7 +1182,7 @@ sub phastcons_index_lookup if ( $beg <= $index->{ $chr }->[ $index_beg ]->[ CHR_END ] ) { - @vals = split "\n", &Maasha::Common::file_read( + @vals = split "\n", Maasha::Common::file_read( $fh, $index->{ $chr }->[ $index_beg ]->[ INDEX_BEG ] + 6 * ( $beg - $index->{ $chr }->[ $index_beg ]->[ CHR_BEG ] ), 6 * ( $index->{ $chr }->[ $index_beg ]->[ CHR_END ] - $beg + 1 ), @@ -1193,11 +1193,11 @@ sub phastcons_index_lookup } } - $end = &Maasha::Calc::min( $chr_end, $index->{ $chr }->[ $index_end ]->[ CHR_END ] ); + $end = Maasha::Calc::min( $chr_end, $index->{ $chr }->[ $index_end ]->[ CHR_END ] ); if ( $end <= $index->{ $chr }->[ $index_end ]->[ CHR_END ] ) { - @vals = split "\n", &Maasha::Common::file_read( + @vals = split "\n", Maasha::Common::file_read( $fh, $index->{ $chr }->[ $index_end ]->[ INDEX_BEG ], 6 * ( $end - $index->{ $chr }->[ $index_end ]->[ CHR_BEG ] + 1 ), @@ -1210,7 +1210,7 @@ sub phastcons_index_lookup for ( $i = $index_beg + 1; $i <= $index_end - 1; $i++ ) { - @vals = split "\n", &Maasha::Common::file_read( + @vals = split "\n", Maasha::Common::file_read( $fh, $index->{ $chr }->[ $i ]->[ INDEX_BEG ], 6 * ( $index->{ $chr }->[ $i ]->[ CHR_END ] - $index->{ $chr }->[ $i ]->[ CHR_BEG ] + 1 ), @@ -1224,7 +1224,7 @@ sub phastcons_index_lookup } else { - &Maasha::Common::error( qq(Chromosome "$chr" was not found in index) ); + Maasha::Common::error( qq(Chromosome "$chr" was not found in index) ); } return wantarray ? @{ $scores } : $scores; @@ -1263,8 +1263,8 @@ sub phastcons_normalize { $diff = scalar @{ $list } - $mean; - &phastcons_list_inflate( $list, abs( $diff ) ) if $diff < 0; - &phastcons_list_deflate( $list, $diff ) if $diff > 0; + phastcons_list_inflate( $list, abs( $diff ) ) if $diff < 0; + phastcons_list_deflate( $list, $diff ) if $diff > 0; } return wantarray ? @{ $AoA } : $AoA; @@ -1349,9 +1349,9 @@ sub phastcons_mean my ( @list ); - $AoA = &Maasha::Matrix::matrix_flip( $AoA ); + $AoA = Maasha::Matrix::matrix_flip( $AoA ); - map { push @list, &Maasha::Calc::mean( $_ ) } @{ $AoA }; + map { push @list, Maasha::Calc::mean( $_ ) } @{ $AoA }; return wantarray ? @list : \@list; } @@ -1371,9 +1371,9 @@ sub phastcons_median my ( @list ); - $AoA = &Maasha::Matrix::matrix_flip( $AoA ); + $AoA = Maasha::Matrix::matrix_flip( $AoA ); - map { push @list, &Maasha::Calc::median( $_ ) } @{ $AoA }; + map { push @list, Maasha::Calc::median( $_ ) } @{ $AoA }; return wantarray ? @list : \@list; } @@ -1404,9 +1404,9 @@ sub maf_extract $tmp_file = "$tmp_dir/maf_extract.maf"; - &Maasha::Common::run( "mafFrag", "$database $table $chr $beg $end $strand $tmp_file" ); + Maasha::Common::run( "mafFrag", "$database $table $chr $beg $end $strand $tmp_file" ); - $align = &maf_parse( $tmp_file ); + $align = maf_parse( $tmp_file ); unlink $tmp_file; @@ -1426,7 +1426,7 @@ sub maf_parse my ( $fh, $line, @fields, @align ); - $fh = &Maasha::Common::read_open( $path ); + $fh = Maasha::Common::read_open( $path ); while ( $line = <$fh> ) { @@ -1504,7 +1504,7 @@ sub wiggle_upload_to_ucsc # $args = join " ", "-tmpDir=$tmp_dir", "-pathPrefix=$wib_dir", $options->{ "database" }, $options->{ 'table' }, $wig_file; -# &Maasha::Common::run( "hgLoadWiggle", "$args > /dev/null 2>&1" ); +# Maasha::Common::run( "hgLoadWiggle", "$args > /dev/null 2>&1" ); `cd $tmp_dir && hgLoadWiggle -tmpDir=$tmp_dir -pathPrefix=$wib_dir $options->{ 'database' } $options->{ 'table' } $wig_file > /dev/null 2>&1`; } @@ -1524,7 +1524,7 @@ sub ucsc_get_user my ( $fh, $line, $user ); - $fh = &Maasha::Common::read_open( "$ENV{ 'HOME' }/.hg.conf" ); + $fh = Maasha::Common::read_open( "$ENV{ 'HOME' }/.hg.conf" ); while ( $line = <$fh> ) { @@ -1555,7 +1555,7 @@ sub ucsc_get_password my ( $fh, $line, $password ); - $fh = &Maasha::Common::read_open( "$ENV{ 'HOME' }/.hg.conf" ); + $fh = Maasha::Common::read_open( "$ENV{ 'HOME' }/.hg.conf" ); while ( $line = <$fh> ) { -- 2.39.2