-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckRegions.pl
executable file
·65 lines (58 loc) · 1.41 KB
/
checkRegions.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl
# Script: checkRegions.pl
# Description:
# Author: Steven Ahrendt
# email: sahrendt0@gmail.com
# Date: 08.19.2015
##################################
use warnings;
use strict;
use Getopt::Long;
use lib '/rhome/sahrendt/Scripts';
#####-----Global Variables-----#####
my $input;
my ($help,$verb);
my $sim = 0; # similarity threshold: number of bases difference
# between start and/or stop
GetOptions ('i|input=s' => \$input,
'sim=i' => \$sim,
'h|help' => \$help,
'v|verbose' => \$verb);
my $usage = "Usage: checkRegions.pl -i input\n\n";
die $usage if $help;
die "No input.\n$usage" if (!$input);
#####-----Main-----#####
open(my $in,"<",$input) or die "Can't open $input: $!\n";
my @file = <$in>;
close($in);
chomp @file;
my @unique; # unique regions
for(my $i=0;$i<(scalar @file)-1; $i++)
{
my $j = $i+1; # next index
my $line = $file[$i];
my ($start1,$end1,$scf1,$src1) = split(/\t/,$line);
my ($start2,$end2,$scf2,$src2) = split(/\t/,$file[$j]);
if(!isSame($start1,$start2) && !isSame($end1,$end2))
{
#print "$start1 $start2 :: $end1 $end2\t";
#print isSame($start1,$start2),"\t",isSame($end1,$end2),"\t";
print $line,"\n";
}
else
{
$i++;
}
}
warn "Done.\n";
exit(0);
#####-----Subroutines-----#####
sub isSame {
my ($a,$b) = @_;
my $isSame = 0;
if(abs($a-$b) <= $sim)
{
$isSame = 1;
}
return $isSame;
}