| Filename | /home/jgardin/data/profiling_data/hiseq_07-29/Sample_gap_FT/nmer_mapping_quant.pl |
| Statements | Executed 74725779 statements in 63.3s |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 775783 | 5 | 1 | 268ms | 268ms | main::CORE:readline (opcode) |
| 798209 | 2 | 1 | 162ms | 162ms | main::CORE:match (opcode) |
| 8192 | 1 | 1 | 16.1ms | 16.1ms | main::CORE:print (opcode) |
| 1 | 1 | 1 | 6.68ms | 13.0ms | main::BEGIN@3 |
| 1 | 1 | 1 | 6.31ms | 6.31ms | main::combin |
| 1 | 1 | 1 | 1.41ms | 1.44ms | main::BEGIN@2 |
| 1 | 1 | 1 | 234µs | 254µs | main::BEGIN@2.1 |
| 1 | 1 | 1 | 219µs | 466µs | main::BEGIN@4 |
| 6 | 4 | 1 | 146µs | 146µs | main::CORE:open (opcode) |
| 6 | 4 | 1 | 107µs | 107µs | main::CORE:close (opcode) |
| 13 | 1 | 1 | 12µs | 12µs | mro::method_changed_in (xsub) |
| 13 | 1 | 1 | 8µs | 8µs | utf8::is_utf8 (xsub) |
| 13 | 1 | 1 | 5µs | 5µs | Internals::SvREADONLY (xsub) |
| 0 | 0 | 0 | 0s | 0s | main::RUNTIME |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | #!/usr/bin/perl | ||||
| 2 | 4 | 1.55ms | 4 | 1.70ms | use warnings; use strict; # spent 1.44ms making 1 call to main::BEGIN@2
# spent 254µs making 1 call to main::BEGIN@2.1
# spent 7µs making 1 call to warnings::import
# spent 2µs making 1 call to strict::import |
| 3 | 2 | 80µs | 2 | 14.2ms | # spent 13.0ms (6.68+6.28) within main::BEGIN@3 which was called:
# once (6.68ms+6.28ms) by main::RUNTIME at line 3 # spent 13.0ms making 1 call to main::BEGIN@3
# spent 1.26ms making 1 call to Getopt::Long::import |
| 4 | 2 | 784µs | 2 | 504µs | # spent 466µs (219+247) within main::BEGIN@4 which was called:
# once (219µs+247µs) by main::RUNTIME at line 4 # spent 466µs making 1 call to main::BEGIN@4
# spent 38µs making 1 call to Exporter::import |
| 5 | 1 | 500ns | my $k=6; | ||
| 6 | 1 | 100ns | my $window=31; | ||
| 7 | 1 | 900ns | my $bins=2*$window+$k; | ||
| 8 | 1 | 100ns | my %ktc; | ||
| 9 | 1 | 100ns | my $sequence_fname; | ||
| 10 | 1 | 100ns | my $wiggle_fname; | ||
| 11 | 1 | 200ns | my $permute=0; | ||
| 12 | 1 | 100ns | my $normalize_fname; | ||
| 13 | 1 | 500ns | my $out='default_out'; | ||
| 14 | 1 | 3µs | 1 | 5µs | GetOptions ( # spent 5µs making 1 call to Getopt::Long::GetOptions |
| 15 | "o=s" => \$out, | ||||
| 16 | "s=s" => \$sequence_fname, | ||||
| 17 | "wig=s" => \$wiggle_fname, | ||||
| 18 | "n=s" => \$normalize_fname, | ||||
| 19 | "p=i" => \$permute); | ||||
| 20 | |||||
| 21 | ############initialize %ktc | ||||
| 22 | 1 | 500ns | $out=$out.'counts.tab'; | ||
| 23 | 1 | 1µs | my $letters=[ qw(A C G T N) ]; | ||
| 24 | 1 | 1.02ms | 1 | 6.31ms | my @words=&combin($letters,$k ); # spent 6.31ms making 1 call to main::combin |
| 25 | 1 | 5µs | foreach(@words){ | ||
| 26 | 15625 | 56.3ms | @{$ktc{$_}}= ((0)x$bins) ; | ||
| 27 | } | ||||
| 28 | ########## | ||||
| 29 | ##########Load normalization file data | ||||
| 30 | 1 | 42µs | 1 | 29µs | open(NORM,"<$normalize_fname")||die "Cannot open normalization file\n"; # spent 29µs making 1 call to main::CORE:open |
| 31 | 1 | 400ns | my %normalize; | ||
| 32 | 1 | 18µs | 1 | 13µs | while (<NORM>){ # spent 13µs making 1 call to main::CORE:readline |
| 33 | 8066 | 4.62ms | my @a=split(/\t/,$_); | ||
| 34 | 8066 | 20.3ms | 8066 | 2.49ms | $normalize{$a[0]}=$a[1]; # spent 2.49ms making 8066 calls to main::CORE:readline, avg 309ns/call |
| 35 | } | ||||
| 36 | 1 | 14µs | 1 | 10µs | close NORM; # spent 10µs making 1 call to main::CORE:close |
| 37 | ##########Load position counts | ||||
| 38 | 1 | 200ns | my %counts; | ||
| 39 | 1 | 9µs | 1 | 6µs | open (CTS,'<',$wiggle_fname)||die "Cannot open wiggle file\n"; # spent 6µs making 1 call to main::CORE:open |
| 40 | 1 | 400ns | my $cur_chr=''; | ||
| 41 | 1 | 200ns | my $pos=''; | ||
| 42 | 1 | 300ns | my $counts=''; | ||
| 43 | 1 | 8µs | 1 | 6µs | while (<CTS>){ # spent 6µs making 1 call to main::CORE:readline |
| 44 | 766959 | 2.81s | 1533918 | 389ms | if($_=~/variableStep chrom=(.*?)$/){ # spent 242ms making 766959 calls to main::CORE:readline, avg 316ns/call
# spent 147ms making 766959 calls to main::CORE:match, avg 191ns/call |
| 45 | 16 | 39µs | $cur_chr=$1; | ||
| 46 | 16 | 24µs | $counts{$cur_chr}={}; | ||
| 47 | } | ||||
| 48 | else{ | ||||
| 49 | 766943 | 591ms | ($pos,$counts)=split(/\t/,$_); | ||
| 50 | 766943 | 646ms | $counts{$cur_chr}{$pos}=$counts; | ||
| 51 | } | ||||
| 52 | } | ||||
| 53 | 1 | 12µs | 1 | 6µs | close CTS; # spent 6µs making 1 call to main::CORE:close |
| 54 | ####### | ||||
| 55 | #########Map counts to orfs | ||||
| 56 | 1 | 500ns | my $test=0; | ||
| 57 | 1 | 456ms | if(!($permute)){ | ||
| 58 | open(SEQ,'<',$sequence_fname)||die "Cannot open sequence file\n"; | ||||
| 59 | while (my @line=split (/\t/,<SEQ>)){ | ||||
| 60 | my $ct=0; | ||||
| 61 | my $start=$line[1]; | ||||
| 62 | if ($start < $line[2]){##Watson Strand | ||||
| 63 | until ($start > $line[2]-$window){ | ||||
| 64 | for(my $i=0;$i<$bins;++$i){ | ||||
| 65 | if(defined $normalize{$line[3]} && $normalize{$line[3]} > 0 && $counts{$line[0]}{$start-$window+$i}){ | ||||
| 66 | ${$ktc{substr($line[4],$ct,$k)}}[$i]+=$counts{$line[0]}{$start-$window+$i}/$normalize{$line[3]}; | ||||
| 67 | } | ||||
| 68 | else{ | ||||
| 69 | ++$test; | ||||
| 70 | } | ||||
| 71 | } | ||||
| 72 | |||||
| 73 | ++$start; | ||||
| 74 | ++$ct; | ||||
| 75 | } | ||||
| 76 | } | ||||
| 77 | else{##Crick Strand | ||||
| 78 | until($start < $line[2]+$window){ | ||||
| 79 | for(my $i=0;$i<$bins;++$i){ | ||||
| 80 | if(defined $normalize{$line[3]} && $normalize{$line[3]} > 0 && $counts{$line[0]}{$start-$window+$i}){ | ||||
| 81 | ${$ktc{substr($line[4],$ct,$k)}}[$i]+=$counts{$line[0]}{$start-$window+$i}/$normalize{$line[3]}; | ||||
| 82 | } | ||||
| 83 | else{ | ||||
| 84 | ++$test; | ||||
| 85 | } | ||||
| 86 | } | ||||
| 87 | --$start; | ||||
| 88 | ++$ct; | ||||
| 89 | } | ||||
| 90 | } | ||||
| 91 | } | ||||
| 92 | foreach my $key(keys %ktc){ | ||||
| 93 | if($key=~/N/){ | ||||
| 94 | next; | ||||
| 95 | } | ||||
| 96 | print $key,"\t", "@{$ktc{$key}}\n"; | ||||
| 97 | } | ||||
| 98 | } | ||||
| 99 | else{ | ||||
| 100 | 1 | 7µs | for(my $r=0;$r<$permute;++$r){#for all permutation iterations | ||
| 101 | 2 | 19µs | foreach my $key(keys %counts){#for each chromosome | ||
| 102 | 32 | 443ms | 32 | 19.7ms | my @values = shuffle(values %{$counts{$key}});#make a array of values # spent 19.7ms making 32 calls to List::Util::shuffle, avg 616µs/call |
| 103 | 32 | 1.24s | $counts{$key}{$_} = shift @values for keys %{$counts{$key}};#permute the values to a read position in the chromosome | ||
| 104 | } | ||||
| 105 | 2 | 6µs | foreach(@words){ | ||
| 106 | 31250 | 197ms | @{$ktc{$_}}= ((0)x$bins) ; | ||
| 107 | } | ||||
| 108 | 2 | 68µs | 2 | 46µs | open(SEQ,'<',$sequence_fname)||die "Cannot open sequence file\n";#open the sequence file # spent 46µs making 2 calls to main::CORE:open, avg 23µs/call |
| 109 | 2 | 45.9ms | 756 | 23.0ms | while (my @line=split (/\t/,<SEQ>)){#for each sequence record the nmer information # spent 23.0ms making 756 calls to main::CORE:readline, avg 30µs/call |
| 110 | 754 | 237µs | my $ct=0; | ||
| 111 | 754 | 249µs | my $start=$line[1]; | ||
| 112 | 754 | 1.42ms | if ($start < $line[2]){##Watson Strand | ||
| 113 | 754 | 394µs | until ($start > $line[2]-$window){ | ||
| 114 | 1112444 | 49.7s | for(my $i=0;$i<$bins;++$i){ | ||
| 115 | if(defined $normalize{$line[3]} && $normalize{$line[3]} > 0 && $counts{$line[0]}{$start-$window+$i}){ | ||||
| 116 | ${$ktc{substr($line[4],$ct,$k)}}[$i]+=$counts{$line[0]}{$start-$window+$i}/$normalize{$line[3]}; | ||||
| 117 | } | ||||
| 118 | else{ | ||||
| 119 | 68958886 | 6.27s | ++$test; | ||
| 120 | } | ||||
| 121 | } | ||||
| 122 | 1112444 | 66.2ms | ++$start; | ||
| 123 | 1112444 | 330ms | ++$ct; | ||
| 124 | } | ||||
| 125 | } | ||||
| 126 | else{##Crick Strand | ||||
| 127 | until($start < $line[2]+$window){ | ||||
| 128 | for(my $i=0;$i<$bins;++$i){ | ||||
| 129 | if(defined $normalize{$line[3]} && $normalize{$line[3]} > 0 && $counts{$line[0]}{$start-$window+$i}){ | ||||
| 130 | ${$ktc{substr($line[4],$ct,$k)}}[$i]+=$counts{$line[0]}{$start-$window+$i}/$normalize{$line[3]}; | ||||
| 131 | } | ||||
| 132 | else{ | ||||
| 133 | ++$test; | ||||
| 134 | } | ||||
| 135 | } | ||||
| 136 | --$start; | ||||
| 137 | ++$ct; | ||||
| 138 | } | ||||
| 139 | } | ||||
| 140 | } | ||||
| 141 | 2 | 25µs | 2 | 15µs | close SEQ; # spent 15µs making 2 calls to main::CORE:close, avg 7µs/call |
| 142 | 2 | 76µs | 2 | 65µs | open(OUT,">>$out")||die "Cannot open $out\n"; # spent 65µs making 2 calls to main::CORE:open, avg 32µs/call |
| 143 | 2 | 10.8ms | foreach my $key(keys %ktc){ | ||
| 144 | 31250 | 75.0ms | 31250 | 15.8ms | if($key=~/N/){#skip if the nmer contains an N # spent 15.8ms making 31250 calls to main::CORE:match, avg 504ns/call |
| 145 | # $ktc{$key}=((0)x$bins);#reset the hash | ||||
| 146 | 23058 | 3.82ms | next; | ||
| 147 | } | ||||
| 148 | 8192 | 358ms | 8192 | 16.1ms | print OUT $key,"\t","@{$ktc{$key}}\n";#print result # spent 16.1ms making 8192 calls to main::CORE:print, avg 2µs/call |
| 149 | # $ktc{$key}=((0)x$bins);#reset hash | ||||
| 150 | } | ||||
| 151 | 2 | 103µs | 2 | 76µs | close OUT; # spent 76µs making 2 calls to main::CORE:close, avg 38µs/call |
| 152 | } | ||||
| 153 | } | ||||
| 154 | |||||
| 155 | |||||
| 156 | # spent 6.31ms within main::combin which was called:
# once (6.31ms+0s) by main::RUNTIME at line 24 | ||||
| 157 | 1 | 500ns | my ($data, $q) = @_; | ||
| 158 | |||||
| 159 | 1 | 200ns | return if $q < 1; | ||
| 160 | |||||
| 161 | 1 | 200ns | my $results = $data; | ||
| 162 | |||||
| 163 | 1 | 400ns | while (--$q) { | ||
| 164 | 5 | 400ns | my @new; | ||
| 165 | 5 | 2µs | for my $letter (@$data) { | ||
| 166 | 25 | 4.50ms | push @new, map { $letter . $_ } @$results; | ||
| 167 | } # end for $letter in @$data | ||||
| 168 | |||||
| 169 | 5 | 92µs | $results = \@new; | ||
| 170 | } # end while --$q is not 0 | ||||
| 171 | |||||
| 172 | 1 | 1.73ms | return @$results; | ||
| 173 | } # end ordered_combinations | ||||
# spent 5µs within Internals::SvREADONLY which was called 13 times, avg 392ns/call:
# 13 times (5µs+0s) by constant::import at line 132 of constant.pm, avg 392ns/call | |||||
sub main::CORE:close; # opcode | |||||
sub main::CORE:match; # opcode | |||||
sub main::CORE:open; # opcode | |||||
# spent 16.1ms within main::CORE:print which was called 8192 times, avg 2µs/call:
# 8192 times (16.1ms+0s) by main::RUNTIME at line 148, avg 2µs/call | |||||
# spent 268ms within main::CORE:readline which was called 775783 times, avg 345ns/call:
# 766959 times (242ms+0s) by main::RUNTIME at line 44, avg 316ns/call
# 8066 times (2.49ms+0s) by main::RUNTIME at line 34, avg 309ns/call
# 756 times (23.0ms+0s) by main::RUNTIME at line 109, avg 30µs/call
# once (13µs+0s) by main::RUNTIME at line 32
# once (6µs+0s) by main::RUNTIME at line 43 | |||||
# spent 12µs within mro::method_changed_in which was called 13 times, avg 885ns/call:
# 13 times (12µs+0s) by constant::import at line 147 of constant.pm, avg 885ns/call | |||||
# spent 8µs within utf8::is_utf8 which was called 13 times, avg 615ns/call:
# 13 times (8µs+0s) by constant::import at line 123 of constant.pm, avg 615ns/call |