[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Omaha.pm] perl
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