From: martinahansen Date: Tue, 16 Sep 2008 08:43:02 +0000 (+0000) Subject: added 5prime adaptor feature to remove_adaptor X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e9259ad77961a4551d566af8c1e201de9b538b9e;p=biopieces.git added 5prime adaptor feature to remove_adaptor git-svn-id: http://biopieces.googlecode.com/svn/trunk@259 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_perl/Maasha/Biopieces.pm b/code_perl/Maasha/Biopieces.pm index ab7add7..5de534e 100644 --- a/code_perl/Maasha/Biopieces.pm +++ b/code_perl/Maasha/Biopieces.pm @@ -747,7 +747,7 @@ sub get_options @options = qw( adaptor|a=s mismatches|m=s - no_remove|n + remove|r=s offset|o=s ); } @@ -1048,6 +1048,10 @@ sub get_options { Maasha::Common::error( qq(Argument to --$opt must be octal or decimal - not "$options{ $opt }") ); } + elsif ( $opt eq "remove" and $script eq "remove_adaptor" and $options{ $opt } !~ /before|after|skip/ ) + { + Maasha::Common::error( qq(Argument to --$opt must be before, after, or skip - not "$options{ $opt }") ); + } } Maasha::Common::error( qq(no --database specified) ) if $script eq "create_blast_db" and not $options{ "database" }; @@ -4696,6 +4700,8 @@ sub script_remove_adaptor my ( $record, $adaptor, $seq, $adaptor_len, $seq_len, $offset, $max_match, $max_mismatch, $pos ); + $options->{ "remove" } ||= "after"; + $max_mismatch = $options->{ "mismatches" } || 0; $offset = $options->{ "offset" }; @@ -4719,10 +4725,18 @@ sub script_remove_adaptor $record->{ "ADAPTOR_POS" } = $pos; - if ( $pos >= 0 and not $options->{ "no_remove" } ) + if ( $pos >= 0 and $options->{ "remove" } ne "skip" ) { - $record->{ "SEQ" } = substr $record->{ "SEQ" }, 0, $pos; - $record->{ "SEQ_LEN" } = $pos; + if ( $options->{ "remove" } eq "after" ) + { + $record->{ "SEQ" } = substr $record->{ "SEQ" }, 0, $pos; + $record->{ "SEQ_LEN" } = $pos; + } + else + { + $record->{ "SEQ" } = substr $record->{ "SEQ" }, $pos + $adaptor_len; + $record->{ "SEQ_LEN" } = length $record->{ "SEQ" }; + } } put_record( $record, $out ); @@ -5583,7 +5597,7 @@ sub script_plot_histogram while ( $record = get_record( $in ) ) { - $data_hash{ $record->{ $options->{ "key" } } }++ if $record->{ $options->{ "key" } }; + $data_hash{ $record->{ $options->{ "key" } } }++ if defined $record->{ $options->{ "key" } }; put_record( $record, $out ) if not $options->{ "no_stream" }; } @@ -5623,7 +5637,7 @@ sub script_plot_lendist while ( $record = get_record( $in ) ) { - $data_hash{ $record->{ $options->{ "key" } } }++ if $record->{ $options->{ "key" } }; + $data_hash{ $record->{ $options->{ "key" } } }++ if defined $record->{ $options->{ "key" } }; put_record( $record, $out ) if not $options->{ "no_stream" }; }