in reply to Re^2: Stuck in my final step of code using array of arrays
in thread Stuck in my final step of code using array of arrays
HIT:PF12951 SEQ_START:120 SEQ_END:350 HIT:PF03797 SEQ_START:822 SEQ_END:1073 HIT:PF15789 SEQ_START:1515 SEQ_END:1547 HIT:PF00267 SEQ_START:1200 SEQ_END:1350
use strict; use warnings; my %special = (PF03797 => 1); { local $/ = "//\n"; while (<DATA>) { my ($id) = /^ID:(\w+)/; my @data; while (/HIT:(\w+).*?SEQ_START:(\d+).*?(\d+)/g) { push @data, [ $1, $2, $3 ]; } @data = sort { $a->[2] <=> $b->[2] } @data; for my $i (0 .. $#data) { my $start; my $end; #print $data[$i][0]."\n"; if ($special{$data[$i][0]}) { print $data[$i][2]."\n"; if($start=$i) { $start = $data[$i - 1][2] - 1; } else { $start = $data[$i][1] - 1; } if($end=$i) { $end = $data[$i][2] - 1; } else { $end = $data[$i + 1][1] - 1; } print join "\t" => $id, $data[$i][0], $start, $end; } } } } print "\n"; __DATA__ ID:A0AWZ5 HIT:PF12951 SEQ_START:120 SEQ_END:350 HIT:PF03797 SEQ_START:822 SEQ_END:1073 HIT:PF15789 SEQ_START:1515 SEQ_END:1547 HIT:PF00267 SEQ_START:1200 SEQ_END:1350 //
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Stuck in my final step of code using array of arrays
by Cristoforo (Curate) on Mar 04, 2014 at 02:53 UTC | |
Re^4: Stuck in my final step of code using array of arrays
by kcott (Archbishop) on Mar 04, 2014 at 04:06 UTC | |
by Anonymous Monk on Mar 04, 2014 at 10:20 UTC |