Пример #1
0
def runCheckPCR(input_filename, Outflank=0):
	'''
	Runs the program to check in-silico PCR stats for an input file modeled after cip_test; 
	Outflank parameter specifies an area upstream and downstream from gene's coding region that will also be downloaded. 
	The purpose of this feature is if you want primers that bind to non-coding regions to flank the entire gene 
	NOTE: outflank is different from the target_region, which is the mutation of interest	
	Program does not design primers, it just compiles their detailed chracteristics to assist in picking. 
	For primer design, run the PickPCR module, which will return a file that looks like cip_test_pr3
	'''
	#input_filename = cip_test_lit
	IntermInputCompile(input_filename, Outflank)
	interm_input_filename = '_Interm_Output'+input_filename + '.txt'
	infile = open (interm_input_filename,"rU")
	Header = ["Label",
	"Forward Primer", "FP Bind", "FP Hang", "FP Tmelting", "FP Int Stab 3", "FP Int Stab 5", "FP GC content", "FP GC Diff",
	"Reverse Primer", "RP Bind", "RP Hang", "RP Tmelting", "RP Int Stab 3", "RP Int Stab 5", "RP GC content", "RP GC Diff",
	"Template", "Template filename" ,"PCR Product", "Product length", "Product lcoation", "Product Tmelting", "Product GC", "Product TaOpt", "Product AUCGC", "Product Ratio GC", "Product NormAUCGC", "Product AUCTM", "Product Ratio TM", "Product NormAUCTM",
	"Primer Dimer Max Stability", "Primer Dimers", "Primer Tmelting diff", "Template AA sequence", "Product AA sequence"]
	outfile=open('_PCR_result_' +input_filename+'.txt', 'w')
	outfile.write(MakeString(Header)+'\n')
	for line in infile:
		Label, Template, AASequence, FP, RP, PosSense, PosAnitsense, TemplFile = line.split('\t')
		X = VirtualPCR.PcrMachine(FP, RP, Template.upper())
		# make an instance of PCR_Product
		P = VirtualPCR.PCR_Product(X.MakePCR())
		if P.sequence == 'No Product':
			Data = [Label, FP, RP, '-> **** FAIL. No Product. Nice try.****']
		else:
			P.CalcTaOpt(X.FP.Tm, X.RP.Tm)
			P.AUCGC()
			P.AUCTM()
			Dimer =	VirtualPCR.primerDimer(X.FP.Seq, X.RP.Seq)
			Dimer.sort(lambda x,y: cmp(-x.Stability, -y.Stability))	
			if len(Dimer)>=1:
				PrimerDimerStab = Dimer[0].Stability
				PrimerDimerSeq = Dimer[0].MatchString.replace('\n','')
			else:
				PrimerDimer = 0.0
				PrimerDimerSeq='No dimers'	
			#the sequence and positon of amplified region
			product_lookup = re.search(P.sequence, Template.upper(), flags=0)
			if product_lookup == None:
				P_location = "Not found"
				AAproduct = "Not found"
			else:
				P_location = str(product_lookup.span())
				AAproduct = AASequence[int(product_lookup.span()[0]/3)-5:int(product_lookup.span()[1]/3)+5]		
			Data = [Label,FP, X.FP.Bind, X.FP.Hang, X.FP.Tm, X.FP.IntStab3, X.FP.IntStab5, X.FP.GC,X.FP.GC/P.GC, 
				RP, X.RP.Bind, X.RP.Hang, X.RP.Tm, X.RP.IntStab3, X.RP.IntStab5, X.RP.GC,X.RP.GC/P.GC,Template, 
				TemplFile.strip('\n'), P.sequence, len(P.sequence),  P_location,  P.Tm, P.GC, P.TaOpt, P.AUCGC, P.RatioGC, 
				P.NormAUCGC, P.AUCTM, P.RatioTM, P.NormAUCTM, PrimerDimerStab, PrimerDimerSeq, abs(X.FP.Tm-X.RP.Tm), 
				AASequence, AAproduct]	
		outfile.write(MakeString(Data)+'\n')		
	outfile.close()	
	infile.close()
Пример #2
0
def runCheckPCR(input_filename, Outflank=0):
    '''
	Runs the program to check in-silico PCR stats for an input file modeled after cip_test; 
	Outflank parameter specifies an area upstream and downstream from gene's coding region that will also be downloaded. 
	The purpose of this feature is if you want primers that bind to non-coding regions to flank the entire gene 
	NOTE: outflank is different from the target_region, which is the mutation of interest	
	Program does not design primers, it just compiles their detailed chracteristics to assist in picking. 
	For primer design, run the PickPCR module, which will return a file that looks like cip_test_pr3
	'''
    #input_filename = cip_test_lit
    IntermInputCompile(input_filename, Outflank)
    interm_input_filename = '_Interm_Output' + input_filename + '.txt'
    infile = open(interm_input_filename, "rU")
    Header = [
        "Label", "Forward Primer", "FP Bind", "FP Hang", "FP Tmelting",
        "FP Int Stab 3", "FP Int Stab 5", "FP GC content", "FP GC Diff",
        "Reverse Primer", "RP Bind", "RP Hang", "RP Tmelting", "RP Int Stab 3",
        "RP Int Stab 5", "RP GC content", "RP GC Diff", "Template",
        "Template filename", "PCR Product", "Product length",
        "Product lcoation", "Product Tmelting", "Product GC", "Product TaOpt",
        "Product AUCGC", "Product Ratio GC", "Product NormAUCGC",
        "Product AUCTM", "Product Ratio TM", "Product NormAUCTM",
        "Primer Dimer Max Stability", "Primer Dimers", "Primer Tmelting diff",
        "Template AA sequence", "Product AA sequence"
    ]
    outfile = open('_PCR_result_' + input_filename + '.txt', 'w')
    outfile.write(MakeString(Header) + '\n')
    for line in infile:
        Label, Template, AASequence, FP, RP, PosSense, PosAnitsense, TemplFile = line.split(
            '\t')
        X = VirtualPCR.PcrMachine(FP, RP, Template.upper())
        # make an instance of PCR_Product
        P = VirtualPCR.PCR_Product(X.MakePCR())
        if P.sequence == 'No Product':
            Data = [Label, FP, RP, '-> **** FAIL. No Product. Nice try.****']
        else:
            P.CalcTaOpt(X.FP.Tm, X.RP.Tm)
            P.AUCGC()
            P.AUCTM()
            Dimer = VirtualPCR.primerDimer(X.FP.Seq, X.RP.Seq)
            Dimer.sort(lambda x, y: cmp(-x.Stability, -y.Stability))
            if len(Dimer) >= 1:
                PrimerDimerStab = Dimer[0].Stability
                PrimerDimerSeq = Dimer[0].MatchString.replace('\n', '')
            else:
                PrimerDimer = 0.0
                PrimerDimerSeq = 'No dimers'
            #the sequence and positon of amplified region
            product_lookup = re.search(P.sequence, Template.upper(), flags=0)
            if product_lookup == None:
                P_location = "Not found"
                AAproduct = "Not found"
            else:
                P_location = str(product_lookup.span())
                AAproduct = AASequence[int(product_lookup.span()[0] / 3) -
                                       5:int(product_lookup.span()[1] / 3) + 5]
            Data = [
                Label, FP, X.FP.Bind, X.FP.Hang, X.FP.Tm, X.FP.IntStab3,
                X.FP.IntStab5, X.FP.GC, X.FP.GC / P.GC, RP, X.RP.Bind,
                X.RP.Hang, X.RP.Tm, X.RP.IntStab3, X.RP.IntStab5, X.RP.GC,
                X.RP.GC / P.GC, Template,
                TemplFile.strip('\n'), P.sequence,
                len(P.sequence), P_location, P.Tm, P.GC, P.TaOpt, P.AUCGC,
                P.RatioGC, P.NormAUCGC, P.AUCTM, P.RatioTM, P.NormAUCTM,
                PrimerDimerStab, PrimerDimerSeq,
                abs(X.FP.Tm - X.RP.Tm), AASequence, AAproduct
            ]
        outfile.write(MakeString(Data) + '\n')
    outfile.close()
    infile.close()
Пример #3
0
file = open (InputFile,"r")

# file header
#print "Label\tForward Primer\tFP Bind\tFP Hang\tFP Tmelting\tFP Int Stab 3\tFP Int Stab 5\tFP GC content\tFP GC Diff\tReverse Primer\tRP Bind\tRP Hang\tRP Tmelting\tRP Int Stab 3\tRP Int Stab 5\tRP GC content\tTemplate\tPCR Product\tProduct Tmelting\tProduct GC\tProduct TaOpt\tProduct AUCGC\tProduct Ratio GC\tProduct NormAUCGC\tProduct AUCTM\tProduct Ratio TM\tProduct NormAUCTM\tPrimer Dimer\tPrimer Tmelting diff\tPrimer GC Diff"
Header = ["Label",
"Forward Primer", "FP Bind", "FP Hang", "FP Tmelting", "FP Int Stab 3", "FP Int Stab 5", "FP GC content", "FP GC Diff",
"Reverse Primer", "RP Bind", "RP Hang", "RP Tmelting", "RP Int Stab 3", "RP Int Stab 5", "RP GC content", "RP GC Diff",
"Template", "PCR Product", "Product Tmelting", "Product GC", "Product TaOpt", "Product AUCGC", "Product Ratio GC", "Product NormAUCGC", "Product AUCTM", "Product Ratio TM", "Product NormAUCTM",
"Primer Dimer", "Primer Tmelting diff"]

print MakeString(Header)

for mybuffer in file.xreadlines():
	Label, FP, RP, Template = mybuffer.split()

	X = VirtualPCR.PcrMachine(FP, RP, Template)
	# make an instance of PCR_Product
	P = VirtualPCR.PCR_Product(X.MakePCR())
	P.CalcTaOpt(X.FP.Tm, X.RP.Tm)
	P.AUCGC()
	P.AUCTM()
	Dimer =	VirtualPCR.primerDimer(X.FP.Seq, X.RP.Seq)
	Dimer.sort(lambda x,y: cmp(-x.Stability, -y.Stability))
	
	if len(Dimer)>=1:
		PrimerDimer = Dimer[0].Stability
	else:
		PrimerDimer = 0.0

	Data = [Label,
			FP, X.FP.Bind, X.FP.Hang, X.FP.Tm, X.FP.IntStab3, X.FP.IntStab5, X.FP.GC,X.FP.GC/P.GC,
Пример #4
0
def IntermLineCompile(template_filename, primer_sense, primer_antisense,
                      interest_regions):
    """
	Merges input of primer sequences with the gene template; returns  FP, RP, Template 	that is to be fed into the VirtualPCR; 
	"""
    template = open(template_filename)
    Outflank = re.findall('\d+', template_filename.split('_')[1])[0]
    outflank = int(Outflank)
    template.readline()
    #read entire FASTA sequence as one string (includes hang
    gene_seq_h = [seqs.replace('\n', '') for seqs in template.readlines()]
    gene_seq_h = ''.join(gene_seq_h)
    template.close()
    #gene_seq excludes the hang:
    if outflank != 0:
        gene_seq = gene_seq_h[outflank:-outflank]
        #gene_seg_f is formatted, combining the hangs as small caps
        gene_seq_f = gene_seq_h[:outflank].lower(
        ) + gene_seq + gene_seq_h[-outflank:].lower()
    else:
        gene_seq = gene_seq_h
        gene_seq_f = gene_seq
    #translate codon sequence to AA sequence w numbers
    aa_seq = VirtualPCR.SeqToAA(gene_seq)
    #visualize the target relativet o entire aa sequence; basically, scan the aa sequence, draw it as a ---, replace teh dash w the aa target name if it matches.
    if interest_regions != ['']:
        aa_viz = ['*'] * aa_seq.count('_')
        for region in interest_regions:
            for aa in aa_seq.split('_'):
                #if there is a perfect match, return them in uppercase
                if aa == region.strip():
                    aa_viz[aa_seq.split('_').index(aa)] = aa.upper()
                #if just numbers match, return in lowercase
                elif re.findall('\d+',
                                aa) == re.findall('\d+', region.strip()):
                    aa_viz[aa_seq.split('_').index(aa)] = aa
                else:
                    next
        aa_viz = ''.join(aa_viz)
    #if no target region is specified, translate entire aa sequence
    else:
        aa_viz = aa_seq
    #if outflanked, add '-' to the ends
    aa_viz = outflank / 3 * '-' + aa_viz + outflank / 3 * '-'
    #find the positions of the sense and anti-sense primers relative to template; if not found, return (No exact match)
    sense_postest = re.search(primer_sense, gene_seq, flags=0)
    if sense_postest == None:
        sense_pos = "Not in range"
    else:
        sense_pos = sense_postest.span()
    #Note: use the reverse comp for the antisense check
    antisense_postest = re.search(VirtualPCR.CompRev(primer_antisense),
                                  gene_seq,
                                  flags=0)
    if antisense_postest == None:
        antisense_pos = "Not in range"
    else:
        antisense_pos = antisense_postest.span()
    #open the input file, read in the primer sequences
    InputLineData = [
        gene_seq_f, aa_viz, primer_sense, primer_antisense, sense_pos,
        antisense_pos
    ]
    InputLineDataStr = MakeString(InputLineData)
    return (InputLineDataStr)