def templet_generation_and_prediction(finger_sequence, finger_name,len_minimum, len_maximum, operation_tm, C_Na,C_Mg,C_Strand): if template_trigger_gengerate(finger_sequence,finger_name,len_maximum,len_minimum)==1: #gengerate trigger, template successfully and stored in ~tri.txt, ~tem.txt dic_therm=unafold_pred('~tem.txt',"~tri.txt",operation_tm, C_Na,C_Mg,C_Strand) dic_jf={} dic_tri={} dic_temp={} dic_trigen={} for cur_record_o in SeqIO.parse(open('~tem.txt'), "fasta") : dic_temp[str(cur_record_o.id)]=str(cur_record_o.seq) for cur_record_o in SeqIO.parse(open('~tri.txt'), "fasta") : dic_tri[str(cur_record_o.id)]=str(cur_record_o.seq) for cur_record_o in SeqIO.parse(open('~tri_gen.txt'), "fasta") : dic_trigen[str(cur_record_o.id)]=str(cur_record_o.seq) for cur_record_o in SeqIO.parse(open('~tem.txt'), "fasta") : cur_seq=str(cur_record_o.seq).upper() #all capitalized dic_jf[cur_record_o.id]=SeqDep.method_2_prediction(cur_seq) for key,value in sorted(dic_therm. iteritems(), key=lambda(k,v):(v,k)): valuelist=key.split('_') part='_'.join(valuelist[0:5]) part2=part+'_' triname=part2+'tri_' triname=triname+valuelist[6] trigenname=part2+'tri_gen' if (float(dic_therm[key][0])>configure_finger.min_tri_temp_tm and float(dic_therm[key][0])<configure_finger.max_tri_temp_tm and float(dic_therm[key][1])<configure_finger.max_temp_tm and int(dic_therm[key][2])<configure_finger.max_temp_bonds): #if(float(dic_therm[key][0])>configure_finger.min_tri_temp_tm and float(dic_therm[key][0])<configure_finger.max_tri_temp_tm and float(dic_therm[key][1])<configure_finger.max_temp_tm): todo.Tritemp(finger_id=valuelist[1],type=valuelist[2], start= valuelist[3], trigger =dic_tri[triname] , trig_gen=dic_trigen[trigenname],temp=dic_temp[key],tri_length=len(dic_tri[triname]) ,temp_bayes_class=dic_jf[key][1][0],temp_pwm_class=dic_jf[key][0][0] ,temp_p90_score=dic_jf[key][0][1],temp_diff_score= dic_jf[key][0][2],tri_temp_tm=dic_therm[key][0] ,temp_tm=dic_therm[key][1] ,bonds=dic_therm[key][2] ) elixir.session.commit
def templet_generation_and_prediction(finger_sequence, finger_name,len_minimum, len_maximum, operation_tm, C_Na,C_Mg,C_Strand): rank=finger_name.split("_")[1] type=finger_name.split("_")[2] location=finger_name.split("_")[3] length=len(finger_sequence) trigger=[] template=[] maximum=int(len_maximum) minimum=int(len_minimum) nc=['A','T','G','C'] xxxx=[''] if (type=='HTH'): tri_gen=finger_sequence[length-9-8:length-9] tri_gen_len=len(tri_gen) for i in range(minimum,maximum+1): if (length-9-i>=9): up_trigger=finger_sequence[length-9-i:length-9] bottom_trigger=revcomp(finger_sequence[9:i+9]) for j in range(4): for h in range(4): for k in range(4): for m in range(4): xxxx=nc[j]+nc[h]+nc[k]+nc[m] up_emplate=up_trigger+'GAGTC'+xxxx+up_trigger bottom_template=bottom_trigger+'GAGTC'+xxxx+bottom_trigger #print "<tr><td>",up_trigger,"</td><td>",revcomp(up_template),"<td><tr>" up_set=cal_tm_bond(up_trigger,revcomp(up_template),1000,0,50) up_pred=SeqDep.method_2_prediction(str(up_template).upper()) bottom_set=cal_tm_bond(up_trigger,revcomp(up_template),C_Na*1000,C_Mg*1000,C_Strand*1000000000) bottom_pred=SeqDep.method_2_prediction(str(up_template).upper()) print up_trigger, revcomp(up_template), up_set[0], configure_finger.min_tri_temp_tm, float(up_set[0]), configure_finger.max_tri_temp_tm, float(up_set[1]), configure_finger.max_temp_tm , int(up_set[2]), configure_finger.max_temp_bonds if (float(up_set[0])>configure_finger.min_tri_temp_tm and float(up_set[0])<configure_finger.max_tri_temp_tm and float(up_set[1])<configure_finger.max_temp_tm and int(up_set[2])<configure_finger.max_temp_bonds): todo.Tritemp(finger_id=rank,type=type, start= location, trigger =up_trigger , trig_gen=tri_gen,temp=up_template,tri_length=tri_gen_len ,temp_bayes_class=up_pred[1],temp_pwm_class=up_pred[0][0] ,temp_p90_score=up_pred[0][1],temp_diff_score= up_pred[0][2],tri_temp_tm=up_set[0] ,temp_tm=up_set[1] ,bonds=up_set[2] ) elixir.session.commit if (float(bottom_set[0])>configure_finger.min_tri_temp_tm and float(bottom_set[0])<configure_finger.max_tri_temp_tm and float(bottom_set[1])<configure_finger.max_temp_tm and int(bottom_set[2])<configure_finger.max_temp_bonds): todo.Tritemp(finger_id=rank,type=type, start= location, trigger =bottom_trigger , trig_gen=tri_gen,temp=bottom_template, tri_length=tri_gen_len ,temp_bayes_class=bottom_pred[1],temp_pwm_class=bottom_pred[0][0] ,temp_p90_score=bottom_pred[0][1],temp_diff_score= bottom_pred[0][2],tri_temp_tm=bottom_set[0] ,temp_tm=bottom_set[1] ,bonds=bottom_set[2] ) elixir.session.commit if (type=='HTT'): tri_gen=finger_sequence[length-9-8:length-4] len_tri_gen=len(tri_gen) #print "HTT enter" for i in range(minimum,maximum+1): if (length-9-i>=9): up_trigger=finger_sequence[length-9-i:length-9] xxxx=finger_sequence[length-4:length] up_template=up_trigger+'GAGTC'+xxxx+up_trigger up_set=cal_tm_bond(up_trigger,revcomp(up_template),C_Na*1000,C_Mg*1000,C_Strand*1000000000) up_pred=SeqDep.method_2_prediction(str(up_template).upper()) if (float(up_set[0])>configure_finger.min_tri_temp_tm and float(up_set[0])<configure_finger.max_tri_temp_tm and float(up_set[1])<configure_finger.max_temp_tm and int(up_set[2])<configure_finger.max_temp_bonds): todo.Tritemp(finger_id=rank,type=type, start= location, trigger =up_trigger , trig_gen=tri_gen,temp=bottom_template,tri_length=tri_gen_len ,temp_bayes_class=up_pred[0],temp_pwm_class=up_pred[1] ,temp_p90_score=up_pred[0][1],temp_diff_score= up_pred[0][2],tri_temp_tm=up_set[0] ,temp_tm=up_set[1] ,bonds=up_set[2] ) elixir.session.commit if (type=='TTH'): for i in range(minimum,maximum+1): if (length-9-i>=9): bottom_trigger=revcomp(finger_sequence[9:i+9]) xxxx=revcomp(finger_sequence[0:4]) bottom_template=bottom_trigger+'GAGTC'+xxxx+bottom_trigger bottom_set=cal_tm_bond(bottom_trigger,revcomp(bottom_template),C_Na*1000,C_Mg*1000,C_Strand*1000000000) bottom_pred=SeqDep.method_2_prediction(str(bottom_template).upper()) if (float(bottom_set[0])>configure_finger.min_tri_temp_tm and float(bottom_set[0])<configure_finger.max_tri_temp_tm and float(bottom_set[1])<configure_finger.max_temp_tm and int(bottom_set[2])<configure_finger.max_temp_bonds): todo.Tritemp(finger_id=rank,type=type, start= location, trigger =bottom_trigger , trig_gen=tri_gen,temp=bottom_template, tri_length=tri_gen_len ,temp_bayes_class=bottom_pred[1],temp_pwm_class=bottom_pred[0][0] ,temp_p90_score=bottom_pred[0][1],temp_diff_score= bottom_pred[0][2],tri_temp_tm=bottom_set[0] ,temp_tm=bottom_set[1] ,bonds=bottom_set[2] ) elixir.session.commit