C10000035 12 C 4 ....^>. HHFCC C10000035 13 C 6 .....^>. HHFFCC C10000035 14 C 6 ...... JHFFCC C10000035 15 C 6 ...... IHFFFC C10000035 16 A 4 .GG...^>G JGHFFFC C10000035 17 C 7 ....... JGHFFFC C10000035 18 C 8 .......^]. JIHHFFC@ C10000035 19 A 8 ........ IJHHFFFC C10000035 20 C 9 ..T...T.^]. JIHGHFF@C C10000035 21 G 10 A........^]. AJJHHHFDCC C10000040 30 C 5 ....^>. HHFCC C10000040 31 C 6 .....^>. HHFFCC C10000040 32 C 6 ...... JHFFCC C10000040 33 C 6 ...... IHFFFC C10000040 34 C 4 ...... IHFFFC C10000040 35 C 4 ...... IHFFFC C10000040 36 C 4 ...... IHFFFC C10000040 37 C 6 ...... IHFFFC C10000040 38 C 6 ...... IHFFFC #### C10000035,13,15,3 C10000035,17,21,5 C10000040,30,33,4 C10000040,37,38,2 #### #!/usr/bin/perl use strict; use warnings; #usage: perl script.pl my $pileup =$ARGV[0]; # get filename from command line argument open (IN, $pileup) or die ("Could not open file.\n"); #test for file my @chroms; #initialize chroms array my @positions; #initialize positions array my $count = 0; #initialize count while ( my $line = ){ #while line read from input file #split line into array from tab-delimited fields my @line = split("\t",$line); #check if element [3] (coverage depth) less than 5 if($line[3]<5){ #if above condition met, move to next line next; } else{ do{ #if above conditions not met, push element [0] #(chromosome name) into chroms array push @chroms, $line[0]; #push element [1] (position on chromosome) into #positions array push @positions, $line[1]; #increment count by one $count++; } #do the above until element added to chrom array does #not match previous elements OR #until position is not in sequence OR #element [3] of line (coverage depth) is less than 5 until ($chroms[0] ne $chroms[$count-1] || $positions[0] != $positions[$count-1]-length(@positions) || $line[3]<5); next; } } #print initial chromosome name, first position, last position, #length of span of consecutive positions print $chroms[0],"\t", $positions[0],"\t", $positions[$count-2],"\t", $positions[$count-2]-$positions[0]+1,"\n"; #### C10000035 13 37 25