Debian Codegraph @

sim4dbutils/cleanPolishes-experiments/intronstats.pl

raw
1 #!/usr/local/bin/perl
2
3 $| = 1;
4
5 use strict;
6
7 use FindBin;
8 use lib "/home/walenzbp/projects/scripts";
9 use libBri;
10
11 my $tot = 0;
12 my $sma = 0;
13 my $big = 0;
14
15 my $smafirst = 0;
16 my $smalast = 0;
17 my $bigfirst = 0;
18 my $biglast = 0;
19
20 my $smaoneintronF = 0;
21 my $smaoneintronL = 0;
22 my $smaoneintronB = 0;
23 my $bigoneintron = 0;
24
25 my $interiorintron = 0;
26
27 my $ff=0;
28 my $fc=0;
29 my $lf=0;
30 my $lc=0;
31
32 my @bigA;
33 my @smaA;
34
35 open(SMA, "> sma-exon-after-big-intron");
36 open(BIG, "> big-exon-after-big-intron");
37 open(SMAO, "> sma-exon-after-big-oneintron");
38 open(BIGO, "> big-exon-after-big-oneintron");
39
40 while (!eof(STDIN)) {
41 $tot++;
42
43 my %p = &libBri::readPolish(*STDIN);
44 my $exonsLen = scalar(@{$p{'exons'}});
45 my $firstintron = 1;
46
47 if ($exonsLen > 1) {
48 my @exons = @{$p{'exons'}};
49
50 my $lastC = shift @exons;
51 loop:
52 my $thisC = shift @exons;
53 my $gap = $thisC->{'GENOMICstart'} - $lastC->{'GENOMICend'};
54
55 if ($gap > 499999) {
56
57 if (($firstintron) && (scalar(@exons) == 0)) {
58 # Exactly one intron
59 #
60 if ((($lastC->{'cDNAend'} - $lastC->{'cDNAstart'}) < 50) &&
61 (($thisC->{'cDNAend'} - $thisC->{'cDNAstart'}) < 50)) {
62 $sma++;
63 $smaoneintronB++;
64 print SMAO $p{'raw'};
65 } elsif (($lastC->{'cDNAend'} - $lastC->{'cDNAstart'}) < 50) {
66 $sma++;
67 $smaoneintronF++;
68 print SMAO $p{'raw'};
69 } elsif (($thisC->{'cDNAend'} - $thisC->{'cDNAstart'}) < 50) {
70 $sma++;
71 $smaoneintronL++;
72 print SMAO $p{'raw'};
73 } else {
74 $big++;
75 $bigoneintron++;
76 print BIGO $p{'raw'};
77 }
78
79 } elsif ($firstintron) {
80 # First intron
81 #
82 if (($lastC->{'cDNAend'} - $lastC->{'cDNAstart'}) < 50) {
83 $sma++;
84 $smafirst++;
85 print SMA $p{'raw'};
86 if ($p{'matchOrientation'} eq "forward") {
87 $ff++;
88 } else {
89 $fc++;
90 }
91 } else {
92 $big++;
93 $bigfirst++;
94 print BIG $p{'raw'};
95 }
96 } elsif (scalar(@exons) == 0) {
97 # Last intron
98 #
99 if (($thisC->{'cDNAend'} - $thisC->{'cDNAstart'}) < 50) {
100 $sma++;
101 $smalast++;
102 print SMA $p{'raw'};
103 if ($p{'matchOrientation'} eq "forward") {
104 $lf++;
105 } else {
106 $lc++;
107 }
108 } else {
109 $big++;
110 $biglast++;
111 print BIG $p{'raw'};
112 }
113 } else {
114 # Interior intron
115 #
116 $interiorintron++;
117 }
118
119 print "int: $interiorintron sma: $sma(First:$smafirst,Last:$smalast,";
120 print "oneF:$smaoneintronF,oneL:$smaoneintronL,oneB:$smaoneintronB) -- big ";
121 print "$big(First:$bigfirst,Last:$biglast,One:$bigoneintron) -- tot $tot -- ";
122 print "ff=$ff,fc=$fc lf=$lf,lc=$lc\n";
123 }
124
125 $firstintron = 0;
126
127 $lastC = $thisC;
128
129 goto loop if (scalar(@exons) > 0);
130 }
131
132 }
133
134 close(SMA);
135 close(BIG);
136 close(SMAO);
137 close(BIGO);