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 ) }
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(
}
-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.