def get_strands_tube_three(self): tubes = [] count = 1 # 记录试管数目 for i in range(self.len_gene): for j in range(i, self.len_gene): for k in range(j, self.len_gene): strands = { Strand(self.gene_list[i], name="t{0}:L{1}".format(count, i)): self.c_gene, Strand(self.gene_list[j], name="t{0}:M{1}".format(count, j)): self.c_gene, Strand(self.gene_list[k], name="t{0}:R{1}".format(count, k)): self.c_gene } tubes.append( Tube( strands=strands, complexes=SetSpec(max_size=3), # max_size,使用变量代替? name='t{0}'.format( count))) # complexes defaults to [A, B] count += 1 return tubes
def analysis_all(self): count = self.len_g1 + self.len_g2 strands = self.get_strands() my_model = Model(material='dna', celsius=self.temp) t1 = Tube(strands=strands, complexes=SetSpec(max_size=count), name='t1') # complexes defaults to [A, B] tube_results = tube_analysis(tubes=[t1], model=my_model)
def get_strand_tube_all(self): # 获取试管中只有两条基因片段的所有情况 strands = {} for i in range(1, len(self.oligo) - 1): strands[Strand(self.oligo[i][1], name=self.oligo[i][0])] = self.oligo_conc strands[Strand(self.oligo[0][1], name=self.oligo[0][0])] = self.primer_conc strands[Strand(self.oligo[-1][1], name=self.oligo[-1][0])] = self.primer_conc my_model = Model(material='dna', celsius=self.temp) t = Tube(strands=strands, complexes=SetSpec(max_size=2), name='t') # complexes defaults to [A, B] tube_results = tube_analysis(tubes=[t], model=my_model) all_conc = {} for my_complex, conc in tube_results.tubes[ t].complex_concentrations.items(): all_conc[my_complex.name] = conc # 反应后每个试管中DNA的浓度 all_conc = sorted(all_conc.items(), key=lambda d: d[1], reverse=True) # 排序 error = {} for key, val in all_conc: if key.count('+') == 1 and val > self.first_check: tem_split = key[1:-1].split('+') # # 先去除括号,在根据+分割字符串 t1 = tem_split[0][1:] t2 = tem_split[1][1:] # print(t1, t2) # print(t1.isdigit(), t2.isdigit()) if not t1.isdigit() or not t2.isdigit(): # 处理含有primer的片段,都是错配的 # primer+pirmer, primer+x , x+primer error['{0}, {1}'.format(tem_split[0], tem_split[1])] = val elif tem_split[0][0] == tem_split[1][0]: # 错配 # Rx+Rx ; Fx+Fx error['{0}, {1}'.format(tem_split[0], tem_split[1])] = val elif tem_split[0][0] == 'F' and int(t1) - int(t2) not in [ 0, 1 ]: error['{0}, {1}'.format(tem_split[0], tem_split[1])] = val elif tem_split[0][0] == 'R' and int(t1) - int(t2) not in [ 0, -1 ]: error['{0}, {1}'.format(tem_split[0], tem_split[1])] = val # 判断条件有待改进 elif val < self.first_check: # break print(error) return error
def verification_two(self, list1): # 验证错配的是否有问题 set1 = set() strands = {} for i in range(len(list1)): for j in range(len(list1[i])): if j == 0: set1.add(list1[i][j]) strands[Strand( self.gene_list[list1[i][j] - 1], name="E:{1}:{0}".format(list1[i][j], i))] = self.c_gene * 2 # 改正浓度 elif Strand(self.gene_list[list1[i][j] - 1], name=str(list1[i][j])) in strands.keys(): strands[Strand(self.gene_list[list1[i][j] - 1], name=str(list1[i][j]))] = self.c_gene * 2 else: strands[Strand(self.gene_list[list1[i][j] - 1], name=str(list1[i][j]))] = self.c_gene tube = Tube(strands=strands, complexes=SetSpec(max_size=len(list1)), name="test") my_model = Model(material='dna', celsius=self.temp) tube_results = tube_analysis(tubes=[tube], model=my_model) all_conc = {} # print(tube_results) # print("____________-") for my_complex, conc in tube_results.tubes[ tube].complex_concentrations.items(): all_conc[my_complex.name] = conc name = my_complex.name[1:-1] # if name.count("E") == 2: # if name.count("E") == len(list1) and conc > self.second_check: # name_list = name.split("+") set_t = set() for i in range(len(list1)): set_t.add(name_list[i][2]) if len(set_t) == len(list1) and set_t == set1: # 只关注错配的那几条 # print(name, conc) return False # print(name, conc) new_conc = sorted(all_conc.items(), key=lambda d: d[1], reverse=True)
def get_strands_tube_tow(self): # 获取试管中只有两条基因片段的所有情况 tubes = [] count = 1 for i in range(self.len_gene): for j in range(i, self.len_gene): strands = { Strand(self.gene_list[i], name="t{0}:L{1}".format(count, i)): self.c_gene, Strand(self.gene_list[j], name="t{0}:R{1}".format(count, j)): self.c_gene } tubes.append( Tube(strands=strands, complexes=SetSpec(max_size=2), name='t{0}'.format(count))) count += 1 return tubes