[Omaha.pm] perl

Dhundy Bastola kiranbina at gmail.com
Thu Apr 19 14:41:03 PDT 2012


The little program is so much better :)

On 4/19/12 4:24 PM, "Jay Hannah" <jay at jays.net> wrote:

>On Apr 19, 2012, at 1:59 PM, Klinkebiel, David L wrote:
>> In this instance the strand does not make a difference. If you wanted
>>to make the change based on a F (forward) or R (reverse) what would the
>>perl look like. Thanks
>
>At that point the command-line version is a little confusing in my
>opinion. It looks like this:
>
>   perl -anE 'say join "\t", @F[0,1], ($F[2] eq 'F' ? $F[1] + 50 : $F[1]
>- 50)' inputfile.txt
>
>So I'd probably write a little program instead:
>
>   use strict;
>   use 5.10.0;
>   while (<>) {
>      chomp;
>      my ($chr, $pos, $strand) = split /\t/;
>      if ($strand eq 'F') {
>         say join "\t", $chr, $pos, $pos + 50;
>      } else {
>         say join "\t", $chr, $pos, $pos - 50;
>      }
>   }
>
>So I could comment it, add more logic, whatever.
>
>HTH,
>
>j
>
>
>
>
>_______________________________________________
>Omaha-pm mailing list
>Omaha-pm at pm.org
>http://mail.pm.org/mailman/listinfo/omaha-pm




More information about the Omaha-pm mailing list