Mercurial > repos > portiahollyoak > temp
comparison scripts/summarize_excision.pl @ 0:28d1a6f8143f draft
planemo upload for repository https://github.com/portiahollyoak/Tools commit 132bb96bba8e7aed66a102ed93b7744f36d10d37-dirty
| author | portiahollyoak |
|---|---|
| date | Mon, 25 Apr 2016 13:08:56 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:28d1a6f8143f |
|---|---|
| 1 #! /usr/bin/perl | |
| 2 | |
| 3 use strict; | |
| 4 | |
| 5 my @files=<*.excision.cluster.*.refined.bp>; | |
| 6 foreach my $file (@files) { | |
| 7 my $rfsp=$file.".refsup"; | |
| 8 my $count=$file; | |
| 9 my $title=$file; | |
| 10 $count =~ s/.refined.bp//; | |
| 11 $title =~ s/excision/absence/; | |
| 12 $title =~ s/.cluster.rpmk//; | |
| 13 $title .= ".summary"; | |
| 14 | |
| 15 open (input, "<$file") or die "Can't open $file since $!\n"; | |
| 16 open (input1, "<$count") or die "Can't open $count since $!\n"; | |
| 17 open (input2, "<$rfsp") or die "Can't open $rfsp since $!\n"; | |
| 18 open (output, ">>$title") or die "Can't open $title since $!\n"; | |
| 19 my $header=<input>; | |
| 20 chomp($header); | |
| 21 print output "$header\tVariant\tReference\tFrequency\n"; | |
| 22 while (my $line=<input>) { | |
| 23 chomp($line); | |
| 24 my @a=split(/\t/, $line); | |
| 25 my $line1=<input1>; | |
| 26 my $line2=<input2>; | |
| 27 chomp($line1); | |
| 28 chomp($line2); | |
| 29 my @b=split(/\s+/, $line1); | |
| 30 my @c=split(/\t/, $line2); | |
| 31 | |
| 32 my $variant=$b[1]; | |
| 33 my @x=split(/\:/, $a[4]); | |
| 34 my @y=split(/\:/, $a[5]); | |
| 35 if ($a[4] =~ /\,/) { | |
| 36 my @m=split(/\,/, $x[1]); | |
| 37 $variant += $m[0]+$x[2]; | |
| 38 } | |
| 39 else {$variant += $x[1];} | |
| 40 if ($a[5] =~ /\,/) { | |
| 41 my @n=split(/\,/, $y[1]); | |
| 42 $variant += $n[0]+$y[2]; | |
| 43 } | |
| 44 else {$variant += $y[1];} | |
| 45 my $ratio=sprintf("%.4f", ($variant*2)/($variant*2+$c[6])); | |
| 46 | |
| 47 $line =~ s/:\d+//g; | |
| 48 print output "$line\t$variant\t$c[6]\t$ratio\n"; | |
| 49 } | |
| 50 | |
| 51 close input; | |
| 52 close input1; | |
| 53 close input2; | |
| 54 close output; | |
| 55 } |
