def __call__(self, mismatches): """Consolidates ModuleInstances in KFinder.ModuleInstances into Modules. - mismatches accounts for the difference between two ModuleInstances in terms of purine vs pyrimidine or strong vs weak bonding. """ # New list to hold consolidated modules consolidated_list = [] # Bind module_dict and module_order locally module_dict = self.KFinder.ModuleDict module_order = self.KFinder.ModuleOrder # Check that dict is not empty if module_dict: # Iterate through modules in order for pattern in module_order: # Create a Bitvector representation of pattern pat_array = fromstring(pattern, "c") added = False # Iterate through consolidated_list for curr_module, curr_array in consolidated_list: # If pat_vec and curr_vec are in the allowed mismatch cutoff if sum(pat_array != curr_array) <= mismatches: # Add module information to curr_module curr_module.update(module_dict[pattern]) added = True break if not added: # Add new module to consolidated list consolidated_list.append([module_dict[pattern], pat_array]) # self.Modules should have only the list of modules self.Modules = [i[0] for i in consolidated_list]
def get_two_stock_data(): """ load stock time and price data for two stocks The return values (d1,p1,d2,p2) are the trade time (in days) and prices for stocks 1 and 2 (intc and aapl) """ ticker1, ticker2 = 'INTC', 'AAPL' M1 = fromstring( file('data/%s.dat' % ticker1, 'rb').read(), 'd') M1 = M1.resize( (M1.shape[0]/2,2) ) M2 = fromstring( file('data/%s.dat' % ticker2, 'rb').read(), 'd') M2 = M2.resize( (M2.shape[0]/2,2) ) d1, p1 = M1[:,0], M1[:,1] d2, p2 = M2[:,0], M2[:,1] return (d1,p1,d2,p2)
def read_nicolet(tmin, tmax): """Load Nicolet BMSI data.""" if tmin < 0: tmin = 0 fh = file(filename, 'rb') indmin = Fs * tmin numsamples = os.path.getsize(filename) / (channels * 2) indmax = min(numsamples, Fs * tmax) byte0 = int(indmin * channels * 2) numbytes = int((indmax - indmin) * channels * 2) fh.seek(byte0) data = fromstring(fh.read(numbytes), Int16).astype(Float) data.shape = -1, channels t = (1 / Fs) * arange(indmin, indmax) return t, data
def read_nicolet(tmin, tmax): """Load Nicolet BMSI data.""" if tmin<0: tmin=0 fh = file(filename, 'rb') indmin = Fs*tmin numsamples = os.path.getsize(filename)/(channels*2) indmax = min(numsamples, Fs*tmax) byte0 = int(indmin*channels*2) numbytes = int( (indmax-indmin)*channels*2 ) fh.seek(byte0) data = fromstring(fh.read(numbytes), Int16).astype(Float) data.shape = -1, channels t = (1/Fs)*arange(indmin, indmax) return t, data