Feb-10-2020, 06:16 PM
(This post was last modified: Feb-10-2020, 07:31 PM by Yoriz. Edited 4 times in total.)

Does anyone help me fix bugs here?

It works well when I type a.seqtosymbols() first and then a.periods().

But what I want to do is to call a.periods() separately without the seqtosymbols() first.

Many thanks,

My link: https://bpaste.net/raw/OUNQ

Please post all code, output and errors (in its entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.

It works well when I type a.seqtosymbols() first and then a.periods().

But what I want to do is to call a.periods() separately without the seqtosymbols() first.

Many thanks,

My link: https://bpaste.net/raw/OUNQ

import numpy from numpy import array, exp, pi, arange, float64 class ipdft(object): def __init__(self, seq, dints,period = None): self.seq = seq self.length = len(seq) self.dints = dints def seqtosymbols(self): self.result = numpy.zeros(self.length, numpy.uint8) #create arrays array([1, 0], dtype=uint8) for i in range(0,self.length-1): if self.seq[i:i+2] in self.dints: self.result[i] = 1 return self.result def ipdft_inner(self, X, W, ulim, N): for p in range(ulim): w = 1 for n in range(N): if n != 0: w *= W[p] X[p] = X[p] + self.result[n] * w return X def period(self, llim = None, ulim = None): self.llim = 2 self.ulim = self.length - 1 self.periods = array(range(self.llim, self.ulim + 1)) self.W = exp(-1j*2*pi/arange(1, self.ulim + 1)) self.X = array([0 + 0j]*self.length) self.X = self.ipdft_inner(self.X, self.W, self.ulim, self.length) power = abs(self.X[self.llim-1:self.ulim]) #if self.period is not None: #return power[self.period-2] #return array(power), self.period return self.periods a = ipdft("ATGTATTGCTAAAAATAGCAATAAATAGCATAATTAAGCTTATTTATTTT","GC")

**wrote Feb-10-2020, 07:31 PM:***Yoriz*Please post all code, output and errors (in its entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.