# plt.plot(trace[e], color='black') # plt.show() # converted_bp = convert_to_bp(1370, record.annotations['abif_raw'][e], dye) # print(converted_bp) # converted_index = convert_to_index(240.27, record.annotations['abif_raw'][e]) # print(converted_index) alelle = 288 height = [] index_of_peaks = [] data1 = list(record.annotations['abif_raw'][a]) for c in range(find_lower(record.annotations['abif_raw'][e], dye), find_upper(record.annotations['abif_raw'][e], dye)): converted_bp = convert_to_bp(c, record.annotations['abif_raw'][e], dye) in_range = converted_bp >= alelle - 1 and converted_bp <= alelle + 1 if in_range: index_of_peaks.append(c) height.append(data1[c]) elif converted_bp > alelle: break print(height) print(index_of_peaks) print(max(height)) print(convert_to_bp(1175, record.annotations['abif_raw'][e], dye)) # Make negative values in array zero # data_105 = list(record.annotations['abif_raw'][e]) # i = len(record.annotations['abif_raw'][e])
# converted_bp = convert_to_bp(1370, record.annotations['abif_raw'][e], dye) # print(converted_bp) # converted_index = convert_to_index(240.27, record.annotations['abif_raw'][e], dye) # print(converted_index) alelle = 250 index = 3472 # alelle = 272 # index = 3696 height = [] index_of_peaks = [] data1 = list(record.annotations['abif_raw'][a]) converted_index = convert_to_bp(index, record.annotations['abif_raw'][e], dye) print(converted_index) print(find_lower(record.annotations['abif_raw'][e], dye)) print(find_upper(record.annotations['abif_raw'][e], dye)) # for c in range(find_lower(record.annotations['abif_raw'][e], dye), find_upper(record.annotations['abif_raw'][e], dye)): # converted_bp = convert_to_bp(c, record.annotations['abif_raw'][e], dye) # in_range = converted_bp >= alelle - 1.5 and converted_bp <= alelle + 1.5 # if in_range: # index_of_peaks.append(c) # height.append(data1[c]) # elif converted_bp > alelle + 1.5: # break # print(height)
filename = filename.replace('_CON', '') elif filename[4] == 'T': filename = filename.replace('_TIG', '') abif_file = 'A_' + filename + '.fsa' record = SeqIO.read(abif_file, 'abi') print('\nopening fsa file ({}/{}): {}'.format(i, len(file), abif_file)) index_min = find_lower(record.annotations['abif_raw'][e], dye) index_max = find_upper(record.annotations['abif_raw'][e], dye) data = record.annotations['abif_raw'][a] height = [] index_of_peaks = [] for x in range(index_min, index_max): # print("#",end='') converted_bp = convert_to_bp(x, record.annotations['abif_raw'][e], dye) in_range = converted_bp >= alelle1 - 1.5 and converted_bp <= alelle1 + 1.5 if in_range: index_of_peaks.append(x) height.append(data[x]) elif converted_bp > alelle1 + 1.5: break alelle1_index = index_of_peaks[height.index(max(height))] if alelle1 != alelle2: height = [] index_of_peaks = [] for x in range(index_min, index_max): # print("#",end='') converted_bp = convert_to_bp(x,
# elif converted_bp > alelle2: # break # new_values2.append(max(height)) # new_values4.append(index_of_peaks[height.index(max(height))]) index_min = find_lower(record.annotations['abif_raw'][e], dye) index_max = find_upper(record.annotations['abif_raw'][e], dye) data = record.annotations['abif_raw'][a] height = [] index_of_peaks = [] for x in range(index_min, index_max): # print("#",end='') converted_bp = convert_to_bp(x, record.annotations['abif_raw'][e], dye) in_range = converted_bp >= alelle1 - 1.5 and converted_bp <= alelle1 + 1.5 if in_range: index_of_peaks.append(x) height.append(data[x]) elif converted_bp > alelle1+1.5: break alelle1_index = index_of_peaks[height.index(max(height))] # <<<<<<< HEAD # ind = index_of_peaks[height.index(max(height))] # new_values1.append(max(height)) # new_values3.append(ind) # new_v_area1.append(np.trapz(data1[ind-80:ind+40]))
lower_end_of_window = detected_peaks[i] - 80 upper_end_of_window = detected_peaks[i] + 20 if lower_end_of_window < index_35 or upper_end_of_window > index_500: continue peaks.append(detected_peaks[i]) area_of_peaks.append( np.trapz(data[lower_end_of_window:upper_end_of_window])) no_of_peaks.append( len( fp.findpeaks(data[lower_end_of_window:upper_end_of_window], spacing=5, limit=15))) length.append( round( convert_to_bp(detected_peaks[i], record.annotations['abif_raw']['DATA105'], dye))) height.append(data[detected_peaks[i]]) for i in range(len(peaks) - 1): label.append( model.predict( [[area_of_peaks[i], no_of_peaks[i], length[i], height[i]]])) # print(peaks) # print(len(peaks)) # print(label) for x in range(len(label) - 1): if label[x] == 1: print(length[x]) # print(label)