99
1010# self import
1111import os
12- from os .path import exists
13-
14- from Bio .Blast .Applications import NcbimakeblastdbCommandline
1512
1613from primerdiffer .primer_check import my_design_primer , primer_check
17- from primerdiffer .utils import dic2dic , fasta2dic , chr_select , tuple_to_pos_str , pos_str_to_tuple
14+ from primerdiffer .utils import dic2dic , fasta2dic , chr_select , tuple_to_pos_str , pos_str_to_tuple , checkblastdb
1815
1916
2017def walk_chr_dense (genome , chro , start , end , db1 , db2 ,
21- interval = 500000 , jump = 4000 , out_prefix = "primers" ):
18+ cutoff_alignlength = 16 , cutoff_free3 = 2 , product_cutoff = 2000 ,
19+ db1_maxhit = 1 , db2_maxhit = 0 ,
20+ interval = 500000 , jump = 4000 , out_prefix = "primers" , debugmod = False ):
2221 """
2322 :param genome: genome is a dict in name:seq,
2423 :param chro:
@@ -43,7 +42,10 @@ def walk_chr_dense(genome, chro, start, end, db1, db2,
4342 offset += 1
4443 else :
4544 myprimer = my_design_primer (name = name , seq = seq )
46- primer_used = primer_check (myprimer ,db1 ,db2 , debugmod = True )
45+ primer_used = primer_check (myprimer ,db1 ,db2 ,
46+ cutoff_alignlength , cutoff_free3 , product_cutoff ,
47+ db1_maxhit , db2_maxhit ,
48+ debugmod = debugmod )
4749 if primer_used == 0 :
4850 offset += 1
4951 else :
@@ -62,27 +64,10 @@ def walk_chr_dense(genome, chro, start, end, db1, db2,
6264 return primer_dict
6365
6466
65- def makeblastdb (genomefile ):
66- cline = NcbimakeblastdbCommandline (dbtype = "nucl" ,
67- input_file = genomefile )
68- NcbimakeblastdbCommandline (cmd = 'makeblastdb' , dbtype = 'prot' , input_file = 'NC_005816.faa' )
69- print (cline )
70- cline ()
71-
72-
73- def checkblastdb (genomefile ):
74- """
75- check if the blastdb exist, if not, create one
76- """
77- dbfile = genomefile + ".nsq"
78- if exists (dbfile ):
79- return 0
80- else :
81- makeblastdb (genomefile )
82- return 1
83-
84-
85- def flow_walk_chr (wkdir , genome1 , genome2 , pos_str , interval = 4000 , jump = 400 , out_prefix = "primers" ):
67+ def flow_walk_chr (wkdir , genome1 , genome2 , pos_str ,
68+ cutoff_alignlength = 16 , cutoff_free3 = 2 , product_cutoff = 2000 ,
69+ db1_maxhit = 1 , db2_maxhit = 0 ,
70+ interval = 4000 , jump = 400 , out_prefix = "primers" ):
8671 """
8772
8873 genome1: the genome fasta file used to design primers
@@ -100,10 +85,14 @@ def flow_walk_chr(wkdir, genome1, genome2, pos_str, interval=4000, jump=400, out
10085
10186 # main
10287 g1 = dic2dic (fasta2dic (genome1 ))
103- #g2=dic2dic(fasta2dic(genome2))
10488 chro , start , end = pos_str_to_tuple (pos_str )
10589
10690 primer_dict = walk_chr_dense (genome = g1 , chro = chro , start = start , end = end ,
10791 db1 = genome1 ,db2 = genome2 ,
108- interval = interval , jump = jump , out_prefix = out_prefix )
92+ cutoff_alignlength = cutoff_alignlength ,
93+ cutoff_free3 = cutoff_free3 ,
94+ product_cutoff = product_cutoff ,
95+ db1_maxhit = db1_maxhit ,
96+ db2_maxhit = db2_maxhit ,
97+ interval = interval , jump = jump , out_prefix = out_prefix )
10998 print (primer_dict )
0 commit comments