Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use constant { RIGHT=>1, LEFT=>0, NAME=>2 };
- my(@repeats,@genes, @t47);
- loadFile(\@genes,"genes-g38-201505-nodoppel-chr1.csv",0,1,3);
- loadFile(\@repeats,"repeats-g38-201505-nodoppel-chr1.csv",1,2,3);
- loadFile(\@t47,"47k-80-80-ignore-random-noreverse-chr1.csv",0,1,2);
- my $tl=@t47;
- my $gl=@genes;
- my $rl=@repeats;
- my ($gi, $ri)=(0,0);
- $|=1;
- for(my $ti=0;$ti<$tl;$ti++) {
- $gi++ while($genes[$gi][RIGHT] <= $t47[$ti][LEFT] && $gi<$gl);
- $ri-- while($repeats[$ri][RIGHT] > $t47[$ti][RIGHT] && $ri>0);
- $ri++ while($repeats[$ri][RIGHT] <= $t47[$ti][RIGHT] && $ri<$rl);
- next if($t47[$ti][LEFT] <= $genes[$gi][LEFT] ||
- $t47[$ti][RIGHT] <= $repeats[$ri][LEFT] ||
- $t47[$ti][LEFT] >= $genes[$gi][RIGHT] ||
- $t47[$ti][RIGHT] >= $repeats[$ri][RIGHT]
- );
- print join(',',@{$t47[$ti]},$genes[$gi][NAME],$repeats[$ri][NAME]),"\n";
- }
- sub loadFile {
- my $o=shift;
- my $name=shift;
- open(my $fl,"<",$name) or die("Can't open file $name\n");
- while(<$fl>) {
- chomp;
- my @r=(split(/,/))[@_];
- push @{$o}, \@r;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement