file1 contig1 10037203 10038203 blah contig1 10037203 10038203 blah contig1 10037203 10038203 blah
i want to get my output as belowfile2 contig1 997329 938329 blab11 contig1 10037329 10038329 blah11 contig1 10037329 10038329 blah11
i,e., if the overlap exists first output all the overlapping ones of file1 and then of file2 i was able to read each line by line and then compare but that is not what i want. here is what i was doingcontig1 10037203 10038203 blah contig1 10037203 10038203 blah contig1 10037203 10038203 blah contig1 10037329 10038329 blah11 contig1 10037329 10038329 blah11
open FILE1,"file1" or die "can't open file 1"; open FILE2,"file2" or die "can't open file 2"; open(w1,">output"); while ((my $line1 = <FILE1>) && (my $line2 = <FILE2>)) { chomp $line1; chomp $line2; my @cond1 = split("\t" , $line1); my @cond2 = split("\t" , $line2); if(($cond1[1] >= $cond2[1]) && ($cond1[2] <= $cond2[2])) { print w1 "$line1\t$line2\n"; } } close FILE1; close FILE2; close w1;
In reply to output the overlapping regions to new file by Anonymous Monk
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |