本文整理匯總了Python中Bio.Emboss.Primer3類的典型用法代碼示例。如果您正苦於以下問題:Python Primer3類的具體用法?Python Primer3怎麽用?Python Primer3使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Primer3類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_simple_parse
def test_simple_parse(self):
"""Make sure that we can parse all primer3 files.
"""
for file in self.test_files:
h = open(file, "r")
Primer3.read(h)
h.close()
示例2: test_simple_parse
def test_simple_parse(self):
"""Make sure that we can use all single target primer3 files."""
for file in self.test_files:
# First using read...
h = open(file, "r")
Primer3.read(h)
h.close()
# Now using parse...
h = open(file, "r")
self.assertEqual(1, len(list(Primer3.parse(h))))
h.close()
示例3: test_indepth_regular_parse
def test_indepth_regular_parse(self):
"""Make sure we get the data from normal primer3 files okay.
"""
regular_file = self.test_files[0]
h = open(regular_file, "r")
primer_info = Primer3.read(h)
h.close()
self.assertEqual(len(primer_info.primers), 5)
self.assertEqual(primer_info.comments,
"# PRIMER3 RESULTS FOR AC074298\n")
self.assertEqual(primer_info.primers[1].forward_seq,
"CCGGTTTCTCTGGTTGAAAA")
self.assertEqual(primer_info.primers[2].reverse_seq,
"TCACATTCCCAAATGTAGATCG")
self.assertEqual(primer_info.primers[0].size, 218)
self.assertEqual(len(primer_info.primers[0]), 218)
self.assertEqual(primer_info.primers[3].forward_start, 112)
self.assertEqual(primer_info.primers[3].forward_length, 20)
self.assertEqual(primer_info.primers[3].forward_tm, 59.57)
self.assertEqual(primer_info.primers[3].forward_gc, 45.00)
self.assertEqual(primer_info.primers[4].reverse_start, 304)
self.assertEqual(primer_info.primers[4].reverse_length, 22)
self.assertEqual(primer_info.primers[4].reverse_tm, 59.61)
self.assertEqual(primer_info.primers[4].reverse_gc, 40.91)
示例4: test_indepth_regular_parse
def test_indepth_regular_parse(self):
"""Make sure we get the data from normal primer3 files okay.
"""
regular_file = self.test_files[0]
h = open(regular_file, "r")
primer_info = Primer3.read(h)
h.close()
assert len(primer_info.primers) == 5, \
"Wrong number of primers: %s" % len(primer_info.primers)
assert primer_info.primers[1].forward_seq \
== "CCGGTTTCTCTGGTTGAAAA"
assert primer_info.primers[2].reverse_seq == \
"TCACATTCCCAAATGTAGATCG"
assert primer_info.primers[0].size == 218
assert primer_info.primers[3].forward_start == 112
assert primer_info.primers[3].forward_length == 20
assert primer_info.primers[3].forward_tm == 59.57
assert primer_info.primers[3].forward_gc == 45.00
assert primer_info.primers[4].reverse_start == 304
assert primer_info.primers[4].reverse_length == 22
assert primer_info.primers[4].reverse_tm == 59.61
assert primer_info.primers[4].reverse_gc == 40.91
示例5: parse_primer3
def parse_primer3(keys):
''' '''
flagged=[]
dic={}
regexp = re.compile('[RrYyKkMmSsWwNn]')
for key in keys:
filename='primer3_results/'+key+'_primer3.txt'
open_handle=open(filename,'r')
dic[key]=Primer3.read(open_handle)
open_handle.close()
if dic[key].primers==[]:
flagged.append(key)
del dic[key]
#Added: Also remove if there are polymorphic/divergent sites w/in primer:
else:
try:
if regexp.search(str(dic[key].primers[0].forward_seq)) is not None:
flagged.append(key)
del dic[key]
elif regexp.search(str(dic[key].primers[0].reverse_seq)) is not None:
flagged.append(key)
del dic[key]
except:
print dic[key].primers[0]
exit(1)
for x in flagged:
keys.remove(x)
return keys, dic
示例6: test_mutli_record_fwd
def test_mutli_record_fwd(self):
"""Test parsing multiple primer sets (NirK forward)"""
h = open(os.path.join("Emboss", "NirK.primer3"))
targets = list(Primer3.parse(h))
h.close()
self.assertEqual(len(targets), 16)
for target in targets:
self.assertEqual(len(target.primers), 5)
self.assertEqual(targets[0].primers[0].forward_seq, "GCAAACTGAAAAGCGGACTC")
self.assertEqual(targets[0].primers[1].forward_seq, "GGGACGTACTTTCGCACAAT")
self.assertEqual(targets[0].primers[2].forward_seq, "GTCTTATGCGTGGTGGAGGT")
self.assertEqual(targets[0].primers[3].forward_seq, "GTACATCAACATCCGCAACG")
self.assertEqual(targets[0].primers[4].forward_seq, "CGTACATCAACATCCGCAAC")
self.assertEqual(targets[1].primers[0].forward_seq, "GGAAGTGCTTCTCGTTTTCG")
self.assertEqual(targets[1].primers[1].forward_seq, "TACAGAGCGTCACGGATGAG")
self.assertEqual(targets[1].primers[2].forward_seq, "TTGTCATCGTGCTCTTCGTC")
self.assertEqual(targets[1].primers[3].forward_seq, "GACTCCAACCTCAGCTTTCG")
self.assertEqual(targets[1].primers[4].forward_seq, "GGCACGAAGAAGGACAGAAG")
self.assertEqual(targets[15].primers[0].forward_seq, "TGCTTGAAAATGACGCACTC")
self.assertEqual(targets[15].primers[1].forward_seq, "CTCGCTGGCTAGGTCATAGG")
self.assertEqual(targets[15].primers[2].forward_seq, "TATCGCACCAAACACGGTAA")
self.assertEqual(targets[15].primers[3].forward_seq, "CGATTACCCTCACCGTCACT")
self.assertEqual(targets[15].primers[4].forward_seq, "TATCGCAACCACTGAGCAAG")
示例7: primer
def primer(self, direction='forward'):
tmp_file = '/tmp/' + self.gi + '-' + \
self.strand + str(self.start) + str(self.end)
primer3_input_file = tmp_file
primer3_output_file = tmp_file + '-output'
record = SeqRecord(Seq(self.sequence), id='', description='')
with open(primer3_input_file, 'w') as f:
SeqIO.write(record, f, 'fasta')
primercl = Primer3Commandline(sequence=primer3_input_file, auto=True,
hybridprobe=True)
primercl.osizeopt = 20
primercl.psizeopt = 200
primercl.outfile = primer3_output_file
stdout, stderr = primercl()
unpack = lambda r: [[p.forward_seq, p.reverse_seq] for p in r.primers]
with open(primer3_output_file, 'r') as f:
record = Primer3.parse(f).next()
all_primers = [[p.forward_seq, p.reverse_seq] for p in record.primers]
if direction == 'forward':
return all_primers[0][0]
elif direction == 'reverse':
return all_primers[0][1]
else:
return None
示例8: test_in_depth_single_parse
def test_in_depth_single_parse(self):
"""Make sure we get info right from a single primer find.
"""
file = self.test_files[1]
h = open(file, "r")
primer_info = Primer3.read(h)
h.close()
assert len(primer_info.primers) == 5
assert primer_info.primers[1].reverse_seq == ""
assert primer_info.primers[3].forward_seq == "TGTGATTGCTTGAGCTGGAC"
assert primer_info.primers[3].forward_start == 253
示例9: test_in_depth_single_parse
def test_in_depth_single_parse(self):
"""Make sure we get info right from a single primer find.
"""
file = self.test_files[1]
h = open(file, "r")
primer_info = Primer3.read(h)
h.close()
self.assertEqual(len(primer_info.primers), 5)
self.assertEqual(primer_info.comments,
"# PRIMER3 RESULTS FOR 26964-28647#\n")
self.assertEqual(primer_info.primers[1].reverse_seq, "")
self.assertEqual(primer_info.primers[3].forward_seq, "TGTGATTGCTTGAGCTGGAC")
self.assertEqual(primer_info.primers[3].forward_start, 253)
示例10: test_internal_oligo_single_parse
def test_internal_oligo_single_parse(self):
''' Make sure we can parse an internal oligo file correctly '''
# these files are generated when designing hybridization probes.
file = self.test_files[4]
h = open(file, "r")
primer_info = Primer3.read(h)
h.close()
assert len(primer_info.primers) == 5
assert primer_info.primers[0].internal_length == 22
assert primer_info.primers[1].internal_seq == 'TTGCGCTTTAGTTTGAATTGAA'
assert primer_info.primers[2].internal_tm == 58.62
assert primer_info.primers[3].internal_start == 16
assert primer_info.primers[4].internal_gc == 35.00
示例11: test_internal_oligo_single_parse
def test_internal_oligo_single_parse(self):
""" Make sure we can parse an internal oligo file correctly """
# these files are generated when designing hybridization probes.
file = self.test_files[4]
h = open(file, "r")
primer_info = Primer3.read(h)
h.close()
self.assertEqual(len(primer_info.primers), 5)
self.assertEqual(primer_info.comments, "# EPRIMER3 RESULTS FOR YNL138W-A\n")
self.assertEqual(primer_info.primers[0].internal_length, 22)
self.assertEqual(primer_info.primers[1].internal_seq, "TTGCGCTTTAGTTTGAATTGAA")
self.assertEqual(primer_info.primers[2].internal_tm, 58.62)
self.assertEqual(primer_info.primers[3].internal_start, 16)
self.assertEqual(primer_info.primers[4].internal_gc, 35.00)
示例12: GetPrimersFromFasta
def GetPrimersFromFasta(inputFile):
"""
Reads in the sequences and melting temperatures of an eprimer32 fasta file
Args:
inputFile: where to look for the file
Returns:
list of <PrimerPair> objects, which have the information we need
"""
primerList = []
with open(inputFile) as fileHandle:
record = Primer3.parse(fileHandle)
# XXX check is len>0
primers = record.next().primers
numPrimers = len(primers)
size=(numPrimers*2,1)
seqs= []
temps = []
for i,p in enumerate(primers):
primerList.append(PrimerPair(p.forward_seq,p.reverse_tm,
p.forward_seq,p.reverse_tm))
return primerList
示例13: open
#specify maximum different of tm
primer_cl.set_parameter("-maxdifftm",max_tm_diff )
#other useful parameters
primer_cl.set_parameter("-ogcpercent", opt_GC_percent)
primer_cl.set_parameter("-opolyxmax", maxpolyx)
primer_cl.set_parameter("-osize", optimum_length)
primer_cl.set_parameter("-otm", optimum_tm)
primer_cl.set_parameter("-gcclamp", gc_clamp)
#set product size range
primer_cl.set_parameter("-prange", productsizerange)
#using python subprocess method to run emboss command line programe with the parameters given
fnull = open(os.devnull, 'w')
result=subprocess.check_call(str(primer_cl),shell=True ,stdout = fnull, stderr = fnull)
#read temporary outputfile
handle = open(tempproutfile)
record = Primer3.read(handle)
if len(record.primers) > 0:
primer = record.primers[:5] # We want 5 primer results per target
for index, p in enumerate(primer):
# Start postition of feature i.e. where the SNP is, to know where to insert mt_base for mt_amplicon
startposition = [f for f in targetRec.features if f.id==target_ID][0].location.start.position
# The SNP wt/mu base
wtbase = [f for f in targetRec.features if f.id==target_ID][0].qualifiers.get('Reference_seq')
mubase = [f for f in targetRec.features if f.id==target_ID][0].qualifiers.get('Variant_seq')
wt_base = ''.join(c for c in wtbase if c not in '[]') # Removes the [''] from wtbase
mu_base = ''.join(c for c in mubase if c not in '[]') # Removes the [''] from mubase
# Wild-type amplicon
# NOTE: Due to the script's 1 and 0 indexing inconsistencies, the amplicon starts 1 bp later than the primer forward start, hence the "forward_start-1" required
# ADDENDUM: record.primers[0].reverse_start indicates the primer start FROM LEFT TO RIGHT (3' -> 5') hence reverse_start is actually the END position of the reverse primer if reading from 5' -> 3' and therefore not a good basis for determining exactly where to splice for amplicon, hence the following changes:
wt_amplicon = targetRec.seq[record.primers[index].forward_start-1:record.primers[index].forward_start-1+record.primers[index].size]
示例14:
def parse_primer3(self):
self.p3 = P3.read(self.setup_primer3()).primers