-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompensatory-splicing.pl
More file actions
executable file
·89 lines (74 loc) · 2.1 KB
/
compensatory-splicing.pl
File metadata and controls
executable file
·89 lines (74 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/perl
use strict;
use ProgramName;
use EssexParser;
use EssexICE;
my $name=ProgramName::get();
die "$name <indiv-ID> <infile.essex>\n" unless @ARGV==2;
my ($indiv,$infile)=@ARGV;
chomp $infile;
$infile=~/(\d).essex$/ || die $infile;
my $hap=$1;
my $parser=new EssexParser($infile);
while(1) {
my $elem=$parser->nextElem();
last unless $elem;
my $report=new EssexICE($elem);
next unless $report->getStatusString() eq "splicing-changes";
#next if $report->mappedNMD(50);
next if $elem->findDescendent("premature-stop");
my $substrate=$report->getSubstrate();
my $transcriptID=$report->getTranscriptID();
my $geneID=$report->getGeneID();
my $cigar=$report->getCigar();
my $transcript=$report->getMappedTranscript();
my $brokenSites=$report->getBrokenSpliceSites();
my $indels=parseCigar($cigar);
my $numExons=$transcript->numExons();
for(my $i=0 ; $i<$numExons ; ++$i) {
my $exonID=$i+1;
my $exon=$transcript->getIthExon($i);
if(exonSkipped($exon,$brokenSites)) {
my $netIndel=0;
foreach my $indel (@$indels) {
if($exon->containsCoordinate($indel->{altPos})) {
if($indel->{type} eq "I") { $netIndel+=$indel->{len} }
else { $netIndel-=$indel->{len} }
}
}
if($netIndel%3!=0) {
print "$indiv\thap$hap\t$geneID\t$transcriptID\texon$exonID\t$netIndel\n";
}
}
}
undef $indels;
}
sub exonSkipped
{
my ($exon,$brokenSites)=@_;
foreach my $site (@$brokenSites) {
my ($pos,$type)=@$site;
#print "$pos $type\t"; print $exon->getBegin() . "-" . $exon->getEnd() ."\n";
if($type eq "GT" && $exon->getEnd()==$pos ||
$type eq "AG" && $exon->getBegin()==$pos+2) {
return 1;
}
}
return 0;
}
sub parseCigar
{
my ($cigar)=@_;
my $array=[];
open(CIGAR,"/home/bmajoros/cia/collapse-cigar.pl $cigar|") || die;
<CIGAR>;
while(<CIGAR>) {
chomp; my @fields=split; next unless @fields>=5;
my ($refPos,$altPos,$len,$bp,$type)=@fields;
$type=($type eq "insertion" ? "I" : "D");
my $rec={refPos=>$refPos,altPos=>$altPos,len=>$len,type=>$type};
push @$array,$rec;
}
close(CIGAR);
return $array;
}