start end ID 36701 40200 1 37901 39700 2 36701 39700 3 #### #!/usr/local/bin/perl use strict; use warnings; use Set::IntervalTree; use Data::Dumper; #get the scaffold file name from user input (@ARGV) and stores in $file #opens the scaffold file so that it can be used to fill the empty interval tree my $file = shift; open my $fh, '<', $file or die "Cannot open $file: $!"; #create an empty interval tree my $tree = Set::IntervalTree -> new(); #loop to the file, read each line and add objects to the empty interval tree #there will be as many objects in the interval tree as there are hits for the specific file my %overlap_table; while (my $line=<$fh>){ #while there are lines my @low = split("\t", $line); #get the value from the 1st column (start position = low BT) print "$low[0]\n"; $overlap_table{$low[0]}++; my @high = split("\t", $line); #get the value from the 2nd column (end position = high BT) print "$high[1]\n"; $overlap_table{$high[1]}++; my @ID = split ("", $line); #ID information is the "value" print "$ID[2]\n"; $overlap_table{$ID[2]}++; } close($fh); print Dumper \%overlap_table;