def format_oligos(oligos, options): '''for output''' oligo_list = [] for oligo in oligos: id = oligo['id'] seq = oligo['seq'].upper() size = oligo['size'] GC = chilli.cal_GC_content(seq, size) Tm = TmDeltaG.calTm(seq, Seq.complement(seq), mono_conc=options.mono_conc, diva_conc=options.diva_conc, dntp_conc=options.dntp_conc, oligo_conc=options.oligo_conc) GC = '%.1f' % GC Tm = '%.1f' % Tm oligo_list.append((id, seq, size, GC, Tm)) return oligo_list
def primer_analysis(product, options, oligos, session_dir, fcdict, db): '''Analysis the candidate forward and reverse primer and check whether they can amplify an amplicon''' mid_seq_id_list = [] tmp_list = [] amp_list = [] filter_product = [] # Forward primer for i in xrange(len(product)): # Reverse primer #print i amp = product[i] hid = amp['hid'] pid = amp['pid'] mid = amp['mid'] f_len = amp['plen'] r_len = amp['mlen'] pseq = amp['pseq'] mseq = amp['mseq'] size = amp['size'] f_3_pos = amp['f3_pos'] r_3_pos = amp['r3_pos'] p_qseq = amp['p_qseq'] p_aseq = amp['p_aseq'] p_sseq = amp['p_sseq'] p_tail = amp['p_tail'] m_qseq = amp['m_qseq'] m_aseq = amp['m_aseq'] m_sseq = amp['m_sseq'] m_tail = amp['m_tail'] p_Tm = amp['p_Tm'] p_DeltaG = amp['p_DeltaG'] m_Tm = amp['m_Tm'] m_DeltaG = amp['m_DeltaG'] #print 2*i, 2*i + 1 p_3_DeltaG = TmDeltaG.calDeltaG(p_qseq[-5:], Seq.complement(p_sseq[-5:]), mono_conc=options.mono_conc, diva_conc=options.diva_conc, dntp_conc=options.dntp_conc) m_3_DeltaG = TmDeltaG.calDeltaG(m_qseq[:5], Seq.complement(m_sseq[:5]), mono_conc=options.mono_conc, diva_conc=options.diva_conc, dntp_conc=options.dntp_conc) # Filter DeltaG if p_3_DeltaG < float(options.dg_start) or p_3_DeltaG > float(options.dg_stop): continue if m_3_DeltaG < float(options.dg_start) or m_3_DeltaG > float(options.dg_stop): continue ppc = cal_PPC(len(p_qseq), f_len, len(m_qseq), r_len) # Filter by PPC if ppc < options.ppc: continue mid_seq_id = '%s:%s-%s' % (hid, f_3_pos, r_3_pos) mid_seq_id_list.append(mid_seq_id) ave_Tm = (p_Tm + m_Tm) / 2 # For sort to_be_added = (ave_Tm, ppc, p_3_DeltaG, m_3_DeltaG) tmp_list.append(to_be_added) filter_product.append(amp) mid_seq_list = get_mid_seq(mid_seq_id_list, options, session_dir, db) for i in xrange(len(mid_seq_list)): mid_seq = mid_seq_list[i] (ave_Tm, ppc, p_3_DeltaG, m_3_DeltaG) = tmp_list[i] amp = filter_product[i] pid = amp['pid'] mid = amp['mid'] hid = int(amp['hid']) real_hid = fcdict[str(hid)]['id'] hdesc = fcdict[str(hid)]['desc'] amp_graphic = draw_graphical_alignment_primer(amp, oligos, options, mid_seq) size = amp['size'] amp['p_3_DeltaG'] = p_3_DeltaG amp['m_3_DeltaG'] = m_3_DeltaG amp['real_hid'] = real_hid amp['hdesc'] = hdesc amp['mid_seq'] = mid_seq amp['amp_graphic'] = amp_graphic amp_list.append([ave_Tm, ppc, size, amp]) return amp_list
def get_align_seq(seq_list, options, product): '''Alignment seq''' filter_product = [] for i in xrange(len(product)): amp = product[i] pseq = amp['pseq'] mseq = amp['mseq'] pts = seq_list[2 * i] # Forward primer target sequence mts = seq_list[2 * i + 1] # Reverse primer target sequence # ts for target sequence #p_aseq = Watson_Click_alignment(pseq, pts, 'forward') p_aseq = Thermodynamics_alignment(pseq, pts, 'forward') p_aseq_len = len(p_aseq) p_qseq = pseq[-p_aseq_len:].upper() p_sseq = pts[-p_aseq_len:].upper() p_tail = pseq[:-p_aseq_len] p_thermo = TmDeltaG.Cal(p_qseq, Seq.complement(p_sseq), mono_conc=options.mono_conc, diva_conc=options.diva_conc, dntp_conc=options.dntp_conc) p_DeltaG = p_thermo.DeltaG p_Tm = p_thermo.Tm if p_Tm < float(options.tm_start) or p_Tm > float(options.tm_stop): continue #m_aseq = Watson_Click_alignment(mseq, mts, 'reverse') m_aseq = Thermodynamics_alignment(mseq, mts, 'reverse') m_aseq_len = len(m_aseq) m_qseq = mseq[:m_aseq_len].upper() m_sseq = mts[:m_aseq_len].upper() r_len = amp['mlen'] if m_aseq_len == r_len: m_tail = '' else: m_tail = mseq[m_aseq_len:] m_thermo = TmDeltaG.Cal(m_qseq, Seq.complement(m_sseq), mono_conc=options.mono_conc, diva_conc=options.diva_conc, dntp_conc=options.dntp_conc) m_DeltaG = m_thermo.DeltaG m_Tm = m_thermo.Tm if m_Tm < float(options.tm_start) or m_Tm > float(options.tm_stop): continue amp['p_qseq'] = p_qseq amp['p_aseq'] = p_aseq amp['p_sseq'] = p_sseq amp['p_tail'] = p_tail amp['m_qseq'] = m_qseq amp['m_aseq'] = m_aseq amp['m_sseq'] = m_sseq amp['m_tail'] = m_tail amp['p_Tm'] = p_Tm amp['p_DeltaG'] = p_DeltaG amp['m_Tm'] = m_Tm amp['m_DeltaG'] = m_DeltaG filter_product.append(amp) return filter_product
def primer_analysis(product, options, oligos, session_dir, fcdict, db): '''Analysis the candidate forward and reverse primer and check whether they can amplify an amplicon''' mid_seq_id_list = [] tmp_list = [] amp_list = [] filter_product = [] # Forward primer for i in xrange(len(product)): # Reverse primer #print i amp = product[i] hid = amp['hid'] pid = amp['pid'] mid = amp['mid'] f_len = amp['plen'] r_len = amp['mlen'] pseq = amp['pseq'] mseq = amp['mseq'] size = amp['size'] f_3_pos = amp['f3_pos'] r_3_pos = amp['r3_pos'] p_qseq = amp['p_qseq'] p_aseq = amp['p_aseq'] p_sseq = amp['p_sseq'] p_tail = amp['p_tail'] m_qseq = amp['m_qseq'] m_aseq = amp['m_aseq'] m_sseq = amp['m_sseq'] m_tail = amp['m_tail'] p_Tm = amp['p_Tm'] p_DeltaG = amp['p_DeltaG'] m_Tm = amp['m_Tm'] m_DeltaG = amp['m_DeltaG'] #print 2*i, 2*i + 1 p_3_DeltaG = TmDeltaG.calDeltaG(p_qseq[-5:], Seq.complement(p_sseq[-5:]), mono_conc=options.mono_conc, diva_conc=options.diva_conc, dntp_conc=options.dntp_conc) m_3_DeltaG = TmDeltaG.calDeltaG(m_qseq[:5], Seq.complement(m_sseq[:5]), mono_conc=options.mono_conc, diva_conc=options.diva_conc, dntp_conc=options.dntp_conc) # Filter DeltaG if p_3_DeltaG < float(options.dg_start) or p_3_DeltaG > float( options.dg_stop): continue if m_3_DeltaG < float(options.dg_start) or m_3_DeltaG > float( options.dg_stop): continue ppc = cal_PPC(len(p_qseq), f_len, len(m_qseq), r_len) # Filter by PPC if ppc < options.ppc: continue mid_seq_id = '%s:%s-%s' % (hid, f_3_pos, r_3_pos) mid_seq_id_list.append(mid_seq_id) ave_Tm = (p_Tm + m_Tm) / 2 # For sort to_be_added = (ave_Tm, ppc, p_3_DeltaG, m_3_DeltaG) tmp_list.append(to_be_added) filter_product.append(amp) mid_seq_list = get_mid_seq(mid_seq_id_list, options, session_dir, db) for i in xrange(len(mid_seq_list)): mid_seq = mid_seq_list[i] (ave_Tm, ppc, p_3_DeltaG, m_3_DeltaG) = tmp_list[i] amp = filter_product[i] pid = amp['pid'] mid = amp['mid'] hid = int(amp['hid']) real_hid = fcdict[str(hid)]['id'] hdesc = fcdict[str(hid)]['desc'] amp_graphic = draw_graphical_alignment_primer(amp, oligos, options, mid_seq) size = amp['size'] amp['p_3_DeltaG'] = p_3_DeltaG amp['m_3_DeltaG'] = m_3_DeltaG amp['real_hid'] = real_hid amp['hdesc'] = hdesc amp['mid_seq'] = mid_seq amp['amp_graphic'] = amp_graphic amp_list.append([ave_Tm, ppc, size, amp]) return amp_list