#!/usr/bin/perl -w use strict; use warnings; my $data = <>; my $tol = 2; my @chr; my @start; my @end; my @count; my @strand; while ( $data = (<>) ) { my ( $chr, $start, $end, $info, $cnt, $strand, $start2, $end2, $color, $cnt2, $length , $zero ) = split( "\t", $data ); push( @chr, $chr); push (@start, $start); push (@end, $end); push (@strand, $strand); } my $cl1length = @start; my $cl2length = @end; print "TSSD_ID \t Start \t End \t Count\t Strand \n" ; foreach ( my $i =0 ; $i < $cl1length ; $i = $i++) { for ( my $i = 1 ; $i < $cl1length ; $i++ ) { my $ID = 1; my $count = 0; for (my $j = 0 ; $j < $cl2length ; $j++) { if ( $tol < ( $start[$i] - $start[$i+1] ) ) { $ID++; } if ($start[$i]-$start[$j] == 0) { $count++;}} print "ID_$ID \t $chr[$i] \t $start[$i] \t $end[$i] $count \t $strand[$i] \n"; }}