Commit 3ff492de by Mikael Boden

### release 2016.1

parents
binomial.py 0 → 100644
 from math import log, exp import sys MAXIT = 100 EPS = 3.0e-7 FPMIN = 1.0e-300 gamma_c = [76.18009172947146, -86.50532032941677, 24.01409824083091, -1.23173957245, 0.1208650973866179e-2, -0.5395239384953e-5] def log_binomial_ncdf(N, k, p): """ Log of one minus the cumulative distribution function of the binomial dist. The binomial density gives the probability of k successes in N independent trials each with probability p of success. """ if (k==0): return 0 else: return log_betai(k, N-k+1, p) def betai (a, b, x): """ Incomplete beta function """ if (x<0 or x>1): die("Bad x=`" + str(x) + "' in routine betai") if (x==0 or x==1): bt = 0 else: bt = exp(gammaln(a+b)-gammaln(a)-gammaln(b)+a*log(x)+b*log(1-x)) thresh = (a+1)/(a+b+2.0) if (x1): die("Bad x=`" + str(x) + "' in routine betai") if (x==0 or x==1): log_bt = -1e300 # log(0) else: log_bt = gammaln(a+b)-gammaln(a)-gammaln(b)+a*log(x)+b*log(1.0-x) thresh = (a+1.0)/(a+b+2.0) if (x MAXIT): print >> sys.stderr, ("a or b too big or MAXIT too small " "in betacf") return h def gammaln(x): """ Compute log gamma function """ xx = x s = 1.000000000190015 for i in range(0, 6): xx += 1 s += gamma_c[i]/xx res = ((x+0.5) * log(x+5.5)) - (x+5.5) + log(2.5066282746310005*s/x) if (res >= 0): return res else: return 0 # avoid roundoff error def die(string): print >> sys.stderr, string
genome.py 0 → 100644
This diff is collapsed.
gibbs.py 0 → 100644
This diff is collapsed.
godata.py 0 → 100644
This diff is collapsed.
guide.py 0 → 100644
This diff is collapsed.
ml.py 0 → 100644
This diff is collapsed.
phylo.py 0 → 100644
This diff is collapsed.
prob.py 0 → 100644
This diff is collapsed.
rcdict.py 0 → 100644
 import sym class RCDict(dict): """ Class that extends a standard dictionary to accept only fixed-length DNA symbol strings as keys. Additionally, it maps the reverse complement to the same value. """ def __init__(self, alpha = sym.DNA_Alphabet): """ Initialise a reverse-complement dictionary to accept strings of a given alphabet (DNA by default) """ self.alpha = alpha self.length = None def __setitem__(self, key, value): """ Set the value for a key. Checks to see that if (a) previous keys have been used that the length is the same, and (b) the key consists only of valid symbols. """ if self.length == None: self.length = len(key) elif len(key) != self.length: raise RuntimeError("Invalid key: " + str(key)) for i in range(len(key)): if not key[i] in sym.DNA_Alphabet: raise RuntimeError("Invalid symbol in key: " + str(key[i])) super(RCDict, self).__setitem__(self.canonical(key), value) def canonical(self, key): """ Figures out the canonical key (original or its reverse complement). Note that is you use other than DNA you may need to modify this code. """ if self.length == None: return key alpha = self.alpha rcindx = [0 for _ in range(self.length)] fwindx = [alpha.index(sym) for sym in key] undecided = True for forw in range(self.length): backw = self.length - forw - 1 rcindx[forw] = 3 - fwindx[backw] # formula for converting A <-> T, C <-> G if undecided and rcindx[forw] > fwindx[forw]: # RC is "higher" than original return key undecided = rcindx[forw] == fwindx[forw] return ''.join([alpha.symbols[indx] for indx in rcindx]) def __getitem__(self, key): """ Retrieve the value associated with a specified key. """ return super(RCDict, self).__getitem__(self.canonical(key)) def getSum(self, IUPAC_key): """ Retrieve the sum of all the entries that match the specified IUPAC key. """ # TODO pass
sam.py 0 → 100644
This diff is collapsed.
seqdata.py 0 → 100644
This diff is collapsed.
sequence.py 0 → 100644
This diff is collapsed.
spred.py 0 → 100644
sstruct.py 0 → 100644
This diff is collapsed.
stats.py 0 → 100644
This diff is collapsed.
sym.py 0 → 100644
This diff is collapsed.
webservice.py 0 → 100644
This diff is collapsed.
wordcount.py 0 → 100644
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!