From be204f3b0d9d30364db3a5b125877e0180db08b9 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Thu, 28 May 2009 09:43:48 +0000 Subject: [PATCH] migrated patscan_seq git-svn-id: http://biopieces.googlecode.com/svn/trunk@435 74ccb610-7750-0410-82ae-013aeee3265d --- code_perl/Maasha/BioRun.pm | 115 ------------------------------------- 1 file changed, 115 deletions(-) diff --git a/code_perl/Maasha/BioRun.pm b/code_perl/Maasha/BioRun.pm index 1f2ffeb..33884c4 100644 --- a/code_perl/Maasha/BioRun.pm +++ b/code_perl/Maasha/BioRun.pm @@ -136,7 +136,6 @@ sub run_script 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 "tile_seq" ) { script_tile_seq( $in, $out, $options ) } - elsif ( $script eq "patscan_seq" ) { script_patscan_seq( $in, $out, $options ) } elsif ( $script eq "soap_seq" ) { script_soap_seq( $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 ) } @@ -332,17 +331,6 @@ sub get_options supress_indels|s ); } - elsif ( $script eq "patscan_seq" ) - { - @options = qw( - patterns|p=s - patterns_in|P=s - comp|c - max_hits|h=s - max_misses|m=s - genome|g=s - ); - } elsif ( $script eq "soap_seq" ) { @options = qw( @@ -1747,109 +1735,6 @@ sub script_tile_seq } -sub script_patscan_seq -{ - # Martin A. Hansen, August 2007. - - # Locates patterns in sequences using scan_for_matches. - - my ( $in, # handle to in stream - $out, # handle to out stream - $options, # options hash - ) = @_; - - # Returns nothing. - - 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" } ); - } elsif ( -f $options->{ "patterns_in" } ) { - $patterns = Maasha::Patscan::read_patterns( $options->{ "patterns_in" } ); - } - - $genome_file = "$ENV{ 'BP_DATA' }/genomes/$options->{ 'genome' }/fasta/$options->{ 'genome' }.fna" if $options->{ 'genome' }; - - push @args, "-c" if $options->{ "comp" }; - push @args, "-m $options->{ 'max_hits' }" if $options->{ 'max_hits' }; - push @args, "-n $options->{ 'max_misses' }" if $options->{ 'max_hits' }; - - $seq_file = "$BP_TMP/patscan.seq"; - $pat_file = "$BP_TMP/patscan.pat"; - $out_file = "$BP_TMP/patscan.out"; - - $fh_out = Maasha::Common::write_open( $seq_file ); - - $i = 0; - - while ( $record = Maasha::Biopieces::get_record( $in ) ) - { - if ( $record->{ "SEQ" } and $record->{ "SEQ_NAME" } ) - { - $type = Maasha::Seq::seq_guess_type( $record->{ "SEQ" } ) if not $type; - - Maasha::Fasta::put_entry( [ $i, $record->{ "SEQ" } ], $fh_out ); - - $head_hash{ $i } = $record->{ "SEQ_NAME" }; - - $i++; - } - } - - close $fh_out; - - $arg = join " ", @args; - $arg .= " -p" if $type eq "protein"; - - foreach $pattern ( @{ $patterns } ) - { - $fh_out = Maasha::Common::write_open( $pat_file ); - - print $fh_out "$pattern\n"; - - close $fh_out; - - 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" ); - } else { - `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 ); - - while ( $entry = Maasha::Fasta::get_entry( $fh_in ) ) - { - $result = Maasha::Patscan::parse_scan_result( $entry, $pattern ); - - if ( $options->{ 'genome' } ) - { - $result->{ "CHR" } = $result->{ "S_ID" }; - $result->{ "CHR_BEG" } = $result->{ "S_BEG" }; - $result->{ "CHR_END" } = $result->{ "S_END" }; - - delete $result->{ "S_ID" }; - delete $result->{ "S_BEG" }; - delete $result->{ "S_END" }; - } - else - { - $result->{ "S_ID" } = $head_hash{ $result->{ "S_ID" } }; - } - - Maasha::Biopieces::put_record( $result, $out ); - } - - close $fh_in; - } - - unlink $pat_file; - unlink $seq_file; - unlink $out_file; -} - - sub script_soap_seq { # Martin A. Hansen, July 2008. -- 2.39.5