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_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 ) }
frames|f=s
);
}
- elsif ( $script eq "extract_seq" )
- {
- @options = qw(
- beg|b=s
- end|e=s
- len|l=s
- );
- }
elsif ( $script eq "get_genome_align" )
{
@options = qw(
}
-sub script_extract_seq
-{
- # Martin A. Hansen, August 2007.
-
- # Extract subsequences from sequences in record.
-
- my ( $in, # handle to in stream
- $out, # handle to out stream
- $options, # options hash
- ) = @_;
-
- # Returns nothing.
-
- my ( $beg, $end, $len, $record );
-
- if ( not defined $options->{ "beg" } or $options->{ "beg" } < 0 ) {
- $beg = 0;
- } else {
- $beg = $options->{ "beg" } - 1; # correcting for start offset
- }
-
- if ( defined $options->{ "end" } and $options->{ "end" } - 1 < $beg ) {
- $end = $beg - 1;
- } elsif ( defined $options->{ "end" } ) {
- $end = $options->{ "end" } - 1; # correcting for start offset
- }
-
- $len = $options->{ "len" };
-
-# print "beg->$beg, end->$end, len->$len\n";
-
- while ( $record = Maasha::Biopieces::get_record( $in ) )
- {
- if ( $record->{ "SEQ" } )
- {
- if ( defined $beg and defined $end )
- {
- if ( $end - $beg + 1 > length $record->{ "SEQ" } ) {
- $record->{ "SEQ" } = substr $record->{ "SEQ" }, $beg;
- } else {
- $record->{ "SEQ" } = substr $record->{ "SEQ" }, $beg, $end - $beg + 1;
- }
- }
- elsif ( defined $beg and defined $len )
- {
- if ( $len > length $record->{ "SEQ" } ) {
- $record->{ "SEQ" } = substr $record->{ "SEQ" }, $beg;
- } else {
- $record->{ "SEQ" } = substr $record->{ "SEQ" }, $beg, $len;
- }
- }
- elsif ( defined $beg )
- {
- $record->{ "SEQ" } = substr $record->{ "SEQ" }, $beg;
- }
- }
-
- $record->{ "SEQ_LEN" } = length $record->{ "SEQ" };
-
- Maasha::Biopieces::put_record( $record, $out );
- }
-}
-
-
sub script_get_genome_align
{
# Martin A. Hansen, April 2008.