Skip to content

Commit

Permalink
Support gzipped FASTA FAI + normal blastdb
Browse files Browse the repository at this point in the history
  • Loading branch information
billzt committed Jan 14, 2021
1 parent cda6c1a commit 3992945
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion primerserver2/cmd/primertool.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def check_templates(args):
code = os.system(f'samtools faidx {template} 2>/dev/null')
if code != 0:
raise Exception(f'File {template} cannot be indexed by samtools faidx. Perhaps it is not in FASTA format')
if os.path.isfile(template+'.nhr') is False and os.path.isfile(template+'.nal') is False:
if os.path.isfile(re.sub('[.]gz$', '', template)+'.nhr') is False and os.path.isfile(re.sub('\.gz$', '', template)+'.nal') is False:
code = os.system(f'makeblastdb -dbtype nucl -in {template} 2>/dev/null')
if code != 0:
raise Exception(f'File {template} cannot be indexed by makeblastdb.')
Expand Down
7 changes: 4 additions & 3 deletions primerserver2/core/run_blast.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ def run_blast(p3_inputs):
query_primer_seq_dict[f'{id}.{rank}.L'] = seq_L
query_primer_seq_dict[f'{id}.{rank}.R'] = seq_R

if os.path.isfile(db+'.nhr')==False and os.path.isfile(db+'.nal')==False:
raise Exception(f'The database file is not complete: file {db}.nhr or {db}.nal is not found')
cmd = f'blastn -task blastn-short -db {db} -evalue 30000 -word_size 7 ' \
blast_db = re.sub('[.]gz$', '', db)
if os.path.isfile(blast_db+'.nhr')==False and os.path.isfile(blast_db+'.nal')==False:
raise Exception(f'The database file is not complete: file {blast_db}.nhr or {blast_db}.nal is not found')
cmd = f'blastn -task blastn-short -db {blast_db} -evalue 30000 -word_size 7 ' \
+ '-perc_identity 60 -dust no -reward 1 -penalty -1 -max_hsps 500 -ungapped ' \
+ ' -outfmt "6 qseqid qlen qstart qend sseqid slen sstart send sstrand"'
blast_out = subprocess.run(cmd, input=blast_query, stdout=subprocess.PIPE, shell=True, encoding='ascii').stdout
Expand Down
2 changes: 1 addition & 1 deletion primerserver2/core/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def get():
return '2.0.0b15'
return '2.0.0b16'

0 comments on commit 3992945

Please sign in to comment.