8 use List
::Util qw
/ min max /;
10 # hash the lines by Target
14 unless( /^(\S+)\tITAG_transcripts_\S+.+Target=(\S+)/ ) {
20 my @f = split /\t/, $_, 9;
21 push @
{ $lines{"$1:$2"} }, \
@f;
24 #warn dump( [values %lines] );
30 my @groups = ($curr_group);
32 my ($fs,$fe) = @
{$l}[3,4];
34 my ($ts,$te) = $l->[8] =~ /Target=\S+ (\d+) (\d+)/ or die;
40 ?
abs( $pte - $ts ) > 3
41 : abs( $pts - $te ) > 3
43 || $fs - $pfe > 30_000
47 push @groups, $curr_group;
49 push @
$curr_group, $l;
58 #warn dump( \@groups );
60 # make feature groups out of them
61 for my $g ( @groups ) {
63 my $superfeature = dclone
($g->[0]);
64 $superfeature->[5] = '.';
65 my ( $sf_id ) = $superfeature->[8] =~ /ID=([^;]+)/
66 or die "cannot parse line $superfeature";
67 my @tcoords = map { $_->[8] =~ /Target=\S+ (\d+) (\d+)/ } @
$g;
68 @
{$superfeature}[3,4] = ( min
( map $_->[3], @
$g ), max
( map $_->[4], @
$g ) );
69 $superfeature->[8] =~ s/Target=(\S+) \d+ \d+/"Target=$1 ".min(@tcoords).' '.max(@tcoords)/e
73 $_->[8] =~ s/ID=[^;]+;/Parent=$sf_id;/;
74 $_->[2] = 'match_part';
76 print(join "\t", @
$_) for $superfeature, @
$g;
79 print join "\t", @
$_ for @
$g;