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 "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 ) }
flank|f=s
);
}
- elsif ( $script eq "split_seq" )
- {
- @options = qw(
- word_size|w=s
- uniq|u
- );
- }
- elsif ( $script eq "split_bed" )
- {
- @options = qw(
- window_size|w=s
- step_size|s=s
- );
- }
elsif ( $script eq "tile_seq" )
{
@options = qw(
}
-sub script_split_seq
-{
- # Martin A. Hansen, August 2007.
-
- # Split a sequence in stream into words.
-
- my ( $in, # handle to in stream
- $out, # handle to out stream
- $options, # options hash
- ) = @_;
-
- # Returns nothing.
-
- my ( $record, $new_record, $i, $subseq, %lookup );
-
- $options->{ "word_size" } ||= 7;
-
- while ( $record = Maasha::Biopieces::get_record( $in ) )
- {
- if ( $record->{ "SEQ_NAME" } and $record->{ "SEQ" } )
- {
- for ( $i = 0; $i < length( $record->{ "SEQ" } ) - $options->{ "word_size" } + 1; $i++ )
- {
- $subseq = substr $record->{ "SEQ" }, $i, $options->{ "word_size" };
-
- if ( $options->{ "uniq" } and not $lookup{ $subseq } )
- {
- $new_record->{ "SEQ_NAME" } = $record->{ "SEQ_NAME" } . "[" . ( $i + 1 ) . "-" . ( $i + $options->{ "word_size" } ) . "]";
- $new_record->{ "SEQ" } = $subseq;
-
- Maasha::Biopieces::put_record( $new_record, $out );
-
- $lookup{ $subseq } = 1;
- }
- else
- {
- $new_record->{ "SEQ_NAME" } = $record->{ "SEQ_NAME" } . "[" . ( $i + 1 ) . "-" . ( $i + $options->{ "word_size" } ) . "]";
- $new_record->{ "SEQ" } = $subseq;
-
- Maasha::Biopieces::put_record( $new_record, $out );
- }
- }
- }
- else
- {
- Maasha::Biopieces::put_record( $record, $out );
- }
- }
-}
-
-
-sub script_split_bed
-{
- # Martin A. Hansen, June 2008.
-
- # Split a BED record into overlapping windows.
-
- my ( $in, # handle to in stream
- $out, # handle to out stream
- $options, # options hash
- ) = @_;
-
- # Returns nothing.
-
- my ( $record, $new_record, $i );
-
- $options->{ "window_size" } ||= 20;
- $options->{ "step_size" } ||= 1;
-
- while ( $record = Maasha::Biopieces::get_record( $in ) )
- {
- if ( $record->{ "CHR" } and $record->{ "CHR_BEG" } and $record->{ "CHR_END" } )
- {
- $record->{ "BED_LEN" } = $record->{ "CHR_END" } - $record->{ "CHR_BEG" } + 1;
-
- for ( $i = 0; $i < $record->{ "BED_LEN" } - $options->{ "window_size" }; $i += $options->{ "step_size" } )
- {
- $new_record->{ "REC_TYPE" } = "BED";
- $new_record->{ "CHR" } = $record->{ "CHR" };
- $new_record->{ "CHR_BEG" } = $record->{ "CHR_BEG" } + $i;
- $new_record->{ "CHR_END" } = $record->{ "CHR_BEG" } + $i + $options->{ "window_size" };
- $new_record->{ "BED_LEN" } = $options->{ "window_size" };
- $new_record->{ "Q_ID" } = $record->{ "Q_ID" } . "_$i";
- $new_record->{ "SCORE" } = $record->{ "SCORE" };
- $new_record->{ "STRAND" } = $record->{ "STRAND" };
-
- Maasha::Biopieces::put_record( $new_record, $out );
- }
- }
- else
- {
- Maasha::Biopieces::put_record( $record, $out );
- }
- }
-}
-
-
sub script_tile_seq
{
# Martin A. Hansen, February 2008.