#!/usr/bin/perl # repeatscan.perl # cat $outblat | perl -n repeatscan.perl ## some of these are good looking genes (but maybe repeatetive protein struct...) ## tandy should probably just flag repeats not filter them. my $MINREP=50; my (%xrepeats, %grepeats); while(<>){ chomp; my @v=split"\t"; my($qid,$ref,$pctid,$alen,$tb,$te,$eval,$bits)=@v[0,1,2,3,8,9,10,11]; # if($eval > $MINEVAL) { next; } # should filter MINEVAL or esp. MINALIGN $xrepeats{$qid}++; my($geneid,$exnum,$xloc)= split_exonid($qid, 1); $grepeats{$geneid}{$exnum}++; } END{ my @xids= sort{$xrepeats{$b} <=> $xrepeats{$a}} keys %xrepeats; foreach my $qid (@xids) { my $nrep= $xrepeats{$qid}; next if ($nrep < $MINREP); my($geneid,$exnum,$xloc)= split_exonid($qid, 1); my @ex= sort keys %{$grepeats{$geneid}}; my $minrep= $nrep; foreach my $ex (@ex) { my $xrep= $grepeats{$geneid}{$ex}; $minrep= $xrep if($xrep < $minrep); } next if($minrep < $MINREP); my $nx= @ex; print "#Rep: $geneid nexon=$nx; nrep=$nrep; minrep=$minrep; \n"; } } sub split_exonid { local $_= shift; my $dropnum= shift; $dropnum ||= 0; my ($exnum, $exloc, $exeq)=(0,"",-1); s/^[\+\*\@\%\#\&]*//; # drop marks at ^front; or s/^\W+//; s/\=([\d\-]+)$// and $exeq=$1; # added; testing s/\:([\d\-]+)$// and $exloc=$1; if($dropnum && s/\.(\d+)$//) { $exnum= $1; }; return (wantarray) ? ($_,$exnum,$exloc,$exeq) : $_; }