How to correct the position of my primers
0
0
Entering edit mode
10 months ago
Keith • 0

I have been having issue getting my primers to match the expected output. For instance the bases of the first primer starting on the left are off by 4 base pairs to the right of the correct position.

This is what I am suppose to get: ttggcagttgggaccgttta This is what I am getting cagttgggaccgtttattcg

If you look at a bit of the nuclitide sequence ctaataactgtcggt[ttgg[cagttgggaccgtttattc I market in brackets where the primer should start and where it actually starts. Here is my code:

                       import argparse, pdb
import subprocess
from pyfasta import Fasta



# Create the argument parser
parser = argparse.ArgumentParser(description="Automatic Primer Identification")
parser.add_argument("Fasta_filename", help="the name of a fasta file", type=str)
parser.add_argument("Chromosome_of_interest", help="The chromosome we want to amplify", type=str)
parser.add_argument("Position_of_amplification", help="Position we want amplified", type=int)
#parser.add_argument("--product_length", type=int, default=700, help="Product length (default: 700)")
args = parser.parse_args()



# Open the fasta file and read in the sequence
F = Fasta(args.Fasta_filename)
# Identify the sequence 500 bp upstream and downstream of the requested position
req_seq = F[args.Chromosome_of_interest][args.Position_of_amplification - 500:args.Position_of_amplification + 500]
# Add braces to the DNA sequence 100 bp upstream and downstream of the requested position


# Create an input file containing the DNA sequence and specify a product length of 600 - 800 base pairs

with open('input.txt','w') as f:
    f.write("SEQUENCE_ID=test""\n")
    f.write("SEQUENCE_TEMPLATE="+req_seq+"\n")
    f.write("PRIMER_PICK_LEFT_PRIMER= 1"+"\n")
    f.write("SEQUENCE_TARGET=400,600\n")
    f.write("PRIMER_PICK_RIGHT_PRIMER=1"+"\n")
    f.write("PRIMER_PRODUCT_SIZE_RANGE="+"600-800"+"\n")
    f.write("SEQUENCE_INTERNAL_EXCLUDED_REGION="+'400'+","+'600'+"\n")
    f.write("=\n")
    f.close()


#print(F[args.Chromosome_of_interest])
# Execute the primer3_core command on the input file you created
# primer3_command = ["primer3_core", "primer.txt"]
primer3_command = 'primer3_core < primer.txt'
subprocess.check_output(primer3_command, shell=True, encoding = 'utf-8')



# Read in and parse the output to identify the sequence of the best two primers

output = subprocess.check_output(primer3_command, shell=True, encoding = 'utf-8')
primer_output = output.split('\n')
best_primers = []
for i, line in enumerate(primer_output):
    if line.startswith("PRIMER_LEFT_0_SEQUENCE="):
        best_primers.append(line.split('=')[1])
    elif line.startswith("PRIMER_RIGHT_0_SEQUENCE="):
        best_primers.append(line.split('=')[1])
    if len(best_primers) == 2:
        break

# Print the best two primers to the user
for i, primer in enumerate(best_primers):
    print(f"{primer}")

I don't know if the issue has to do with the FASTA file or the file I created to import my results into. I've been at this for awhile, please any help will be appreciated.

Python primer3 • 303 views
ADD COMMENT

Login before adding your answer.

Traffic: 1486 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6