Hi I'm very new to python and I'm still struggling with this problem. For the problem, I already created a function called reverse_complement, which computes the reverse complement of the input DNA sequence given.
Problem 3 (Virtual PCR):
You will write a program that performs "Virtual PCR" using pairs of PCR primers and a template sequence, much in the manner of UCSC's In-Silico PCR tool (http://genome.ucsc.edu/cgi-bin/hgPcr?command=start).
Your program (call it your_last_name_virtual_pcr.py) will load and assemble the pBR322 plasmid DNA sequence contained in hw_input\pBR322.txt - this will serve as your large target sequence. Your program will also load pairs of PCR primer sequences contained in hw_input\pBR322_PCR_products.txt. Note that each line consists of a forward primer sequence and a reverse primer sequence separated by a comma. You will use the unaltered forward primer sequence and the reverse-complemented reverse primer sequence to find the start and end positions of the predicted PCR product and then extract its sequence. Remember to import your reverse_complement function that you created in Problem 2 and use it to alter the reverse primer sequences.
Create an output file named hw_output\pBR322_PCR_products.txt and on each line write the forward primer, the reverse-complemented reverse primer and the predicted PCR product. Separate the fields with commas.
pBR322 primers.txt- I read it in as one long string
"TCGGGCTCGCCACTTCGGGCTCA,GAGTTGCATGATAAAGAAGACAGTCA
ATGGCCCGCTTTATCAGAAGCCAGACA,GTCAGTGAGCGAGGAAGCGGAAGAGCGC
AATCAGTGAGGCACCTATCTCAGCGATC,ACTCTAGCTTCCCGGCAACAATTAATAGA
CGGTGTGAAATACCGCACAGATGC,GAGCGAGGAAGCGGAAGAGCGCCTGATG"
My pseudo code I've written is:
1. Read the input file/import the function
2. Create a for loop in order to obtain the complement sequence
3. Then I 'cleaned' the list by turning it into a list of lists so now it looks like this
[['TCGGGCTCGCCACTTCGGGCTCA', 'GAGTTGCATGATAAAGAAGACAGTCA'], ['ATGGCCCGCTTTATCAGAAGCCAGACA', 'GTCAGTGAGCGAGGAAGCGGAAGAGCGC'], ['AATCAGTGAGGCACCTATCTCAGCGATC', 'ACTCTAGCTTCCCGGCAACAATTAATAGA'], ['CGGTGTGAAATACCGCACAGATGC', 'GAGCGAGGAAGCGGAAGAGCGCCTGATG']]
4. Now I have to use my reverse_complement function to change the reverse sequences (every other sequence starting from the second sequence) into reverse_complement reverse sequences but I'm having trouble doing this
fwd_and_rsvcomp_rsv_primers = []
for pair in cleaned_primer_list:
if pair[0]:
t = pair[0]
fwd_and_rsvcomp_rsv_primers.append(t)
else:
s = pair[1]
fwd_and_rsvcomp_rsv_primers.append(s)
My output values on python shell gave me this (first string-foward sequence in each of the lists):
['TCGGGCTCGCCACTTCGGGCTCA', 'ATGGCCCGCTTTATCAGAAGCCAGACA', 'AATCAGTGAGGCACCTATCTCAGCGATC', 'CGGTGTGAAATACCGCACAGATGC']
Next I have to use the forward and reverse complemented reverse sequences and use to find the start and end positions of the predicted PCR product and then extract its sequence. But I'm stuck at the step where I have to use the reverse complement function though. I have no idea how to solve the next step. Can anyone help?