Mercurial > repos > xuebing > splicesite_max_entropy
changeset 7:3fd430270c0c
Uploaded
author | xuebing |
---|---|
date | Sun, 01 Apr 2012 01:59:22 -0400 |
parents | 85af77643e89 |
children | ec97befe722b |
files | splicesitescore/score3.pl~ splicesitescore/score5.pl splicesitescore/score5.pl~ |
diffstat | 3 files changed, 106 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/splicesitescore/score3.pl~ Sun Apr 01 01:50:07 2012 -0400 +++ b/splicesitescore/score3.pl~ Sun Apr 01 01:59:22 2012 -0400 @@ -51,7 +51,7 @@ } sub makemaxentscores{ - my $dir = "/Users/xuebing/galaxy-dist/tools/mytools/splicesitescore/splicemodels/"; + my $dir = "splicemodels/"; my @list = ('me2x3acc1','me2x3acc2','me2x3acc3','me2x3acc4', 'me2x3acc5','me2x3acc6','me2x3acc7','me2x3acc8','me2x3acc9'); my @metables; @@ -72,7 +72,7 @@ return @metables; } sub makewmmscores{ - my $dir = "/bionet/geneyeo_essentials/MaxEntropy/webserver/splicemodels/"; + my $dir = "splicemodels/"; my @list = ('me1s0acc1','me1s0acc2','me1s0acc3','me1s0acc4', 'me1s0acc5','me1s0acc6','me1s0acc7','me1s0acc8','me1s0acc9'); my @metables; @@ -93,7 +93,7 @@ return @metables; } sub makemmscores{ - my $dir = "/bionet/geneyeo_essentials/MaxEntropy/webserver/splicemodels/"; + my $dir = "splicemodels/"; my @list = ('me2s0acc1','me2s0acc2','me2s0acc3','me2s0acc4', 'me2s0acc5','me2s0acc6','me2s0acc7','me2s0acc8','me2s0acc9'); my @metables;
--- a/splicesitescore/score5.pl Sun Apr 01 01:50:07 2012 -0400 +++ b/splicesitescore/score5.pl Sun Apr 01 01:59:22 2012 -0400 @@ -4,7 +4,7 @@ my $inputfile = $ARGV[0]; my $usemaxent = 1; -my $modelpath = "/Users/xuebing/galaxy-dist/tools/mytools/splicesitescore/"; +my $modelpath = "splicesitescore/"; my %me2x5 = &makescorematrix($modelpath.'me2x5'); my %seq = &makesequencematrix($modelpath.'splicemodels/splice5sequences');
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/splicesitescore/score5.pl~ Sun Apr 01 01:59:22 2012 -0400 @@ -0,0 +1,102 @@ +use strict; + + +my $inputfile = $ARGV[0]; +my $usemaxent = 1; + +my $modelpath = "/Users/xuebing/galaxy-dist/tools/mytools/splicesitescore/"; +my %me2x5 = &makescorematrix($modelpath.'me2x5'); +my %seq = &makesequencematrix($modelpath.'splicemodels/splice5sequences'); + +my %bgd; +$bgd{'A'} = 0.27; +$bgd{'C'} = 0.23; +$bgd{'G'} = 0.23; +$bgd{'T'} = 0.27; + + + +open (FILE,"<$inputfile") || die "can't open!\n"; + +while(<FILE>) { + chomp; + if (/^\s*$/) { #discard blank lines; + next; + } + elsif (/^>/) { #discard comment lines; + print $_."\t"; + next; + } + elsif (/[NQWERYUIOPLKJHFDSZXVBM]/) { + next; + } + else { + $_ =~ s/\cM//g; #gets rid of carriage return + my $str = $_; + print $str."\t"; + $str = uc($str); + if ($usemaxent) { + print sprintf("%.2f",&log2(&scoreconsensus($str)*$me2x5{$seq{&getrest($str)}}))."\n"; + } + } +} + + +sub makesequencematrix{ + my $file = shift; + my %matrix;my $n=0; + open(SCOREF, $file) || die "Can't open $file!\n"; + while(<SCOREF>) { + chomp; + $_=~ s/\s//; + $matrix{$_} = $n; + $n++; + } + close(SCOREF); + return %matrix; +} +sub makescorematrix{ + my $file = shift; + my %matrix;my $n=0; + open(SCOREF, $file) || die "Can't open $file!\n"; + while(<SCOREF>) { + chomp; + $_=~ s/\s//; + $matrix{$n} = $_; + $n++; + } + close(SCOREF); + return %matrix; +} + +sub getrest{ + my $seq = shift; + my @seqa = split(//,uc($seq)); + return $seqa[0].$seqa[1].$seqa[2].$seqa[5].$seqa[6].$seqa[7].$seqa[8]; +} +sub scoreconsensus{ + my $seq = shift; + my @seqa = split(//,uc($seq)); + my %bgd; + $bgd{'A'} = 0.27; + $bgd{'C'} = 0.23; + $bgd{'G'} = 0.23; + $bgd{'T'} = 0.27; + my %cons1; + $cons1{'A'} = 0.004; + $cons1{'C'} = 0.0032; + $cons1{'G'} = 0.9896; + $cons1{'T'} = 0.0032; + my %cons2; + $cons2{'A'} = 0.0034; + $cons2{'C'} = 0.0039; + $cons2{'G'} = 0.0042; + $cons2{'T'} = 0.9884; + my $addscore = $cons1{$seqa[3]}*$cons2{$seqa[4]}/($bgd{$seqa[3]}*$bgd{$seqa[4]}); + return $addscore; +} + +sub log2{ + my ($val) = @_; + return log($val)/log(2); +}