3 Author: Hu Xuesong @ BIOPIC <galaxy001@gmail.com>
4 Version: 1.0.0 @ 20120330
8 #use Data::Dump qw(ddx);
10 die "Usage: $0 <reference> <out>\n" if @ARGV<2;
17 open O
,'>',$out or die "Error opening $out : $!\n";
18 print O
"# Ref: [$fa]\n#Enzyme: [$Eseq], Cut after $EcutAt\n\n#ChrID\tCut\n";
19 my ($CountAll,%Count,%Len);
21 open I
,'<',$fa or die "Error opening $fa : $!\n";
26 #print STDERR " >$seqname ...";
32 #print STDERR "\b\b\b \t",length $genome,".\n";
35 $Len{$seqname} = length $genome;
36 while ( $genome =~ m/$Eseq/g ) {
37 # push @ret, [ $-[0], $+[0] ];
38 print O
join("\t",$seqname,$-[0]+$EcutAt),"\n"; # starts from 0, so OK to use directly with $EcutAt for "cut after".
48 print O
"\n#Cut stat:\n#ChrID\tLen\tCut\tAvg_distance\n";
49 for (sort keys %Count) {
50 print O
'# ',join("\t",$_,$Len{$_},$Count{$_},$Count{$_}?
int(0.5 + $Len{$_}/(1+$Count{$_})):'.'),"\n";
51 push @notCut,$_ unless $Count{$_};
53 print O
"#Total: $CountAll\n#notCut: ",scalar @notCut,"\n";
54 print O
"#notCut:[",join(',',@notCut),"]\n" if @notCut;