Skip to content

Commit

Permalink
In checking mode, if the first database has no amplicons, then fix th…
Browse files Browse the repository at this point in the history
…e bug
  • Loading branch information
Tao Zhu committed Nov 24, 2020
1 parent 50490d8 commit cda6c1a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion primerserver2/cmd/primertool.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def run(args):
tsv_fh = open(f'{args.query.name}.tsv', mode='w')
else:
tsv_fh = args.tsv
print(output.tsv(primers, dbs), file=tsv_fh)
print(output.tsv(primers, dbs, args.run_mode), file=tsv_fh)
if args.check_multiplex is True:
print(output.dimer_list(dimers), file=tsv_fh)
output_fh.close()
Expand Down
19 changes: 11 additions & 8 deletions primerserver2/core/output.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import json
import sys
import os
import argparse

def tsv(primers_dict, dbs):
def tsv(primers_dict, dbs, mode):
print_line = []
header_line = '\t'.join(['#Site_ID', 'Primer_Rank', 'Primer_Seq_Left', 'Primer_Seq_Right', 'Primer_Seq_Oligo', 'Target_Amplicon_Size', \
'Primer_Pair_Penalty_Score', 'Primer_Rank_in_Primer3_output', 'Tm_left', 'Tm_Right', 'Tm_Oligo', \
Expand All @@ -24,15 +25,15 @@ def tsv(primers_dict, dbs):
print_line.append('###')
continue

if 'PRIMER_PAIR_NUM_RETURNED_FINAL' in primers:
if mode != 'check':
primer_num = primers['PRIMER_PAIR_NUM_RETURNED_FINAL']
else:
primer_num = primers['PRIMER_PAIR_NUM_RETURNED']
for amplicon_rank in range(0, primer_num):
print_data = []
print_data.append(id)
print_data.append(str(amplicon_rank))
if 'PRIMER_PAIR_NUM_RETURNED_FINAL' in primers:
if mode != 'check':
raw_rank = primers[f'PRIMER_PAIR_AMPLICON_NUM_RANK_{amplicon_rank}']
else:
raw_rank = amplicon_rank
Expand Down Expand Up @@ -72,9 +73,9 @@ def tsv(primers_dict, dbs):
else:
print_data.extend(('NA', 'NA'))
else:
print_data.extend(('NA', 'NA', 'NA'))
print_data.extend(('0', 'NA', 'NA'))
else:
print_data.extend(('NA', 'NA', 'NA'))
print_data.extend(('0', 'NA', 'NA'))


print_line.append('\t'.join(print_data))
Expand All @@ -101,6 +102,8 @@ def dimer_list(dimers):


if __name__ == "__main__":
primers = json.load(open('tests/_internal_/sort_primers2.json'))
dbs = ["Ghir.JGI.genomic", "Gbar.IGDB.genomic"]
print(tsv(primers, dbs))
parser = argparse.ArgumentParser(description='For internal testing only', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('primers_json', help='primers.json file')
args = parser.parse_args()
primers_data = json.load(open(args.primers_json))
print(tsv(primers_data['primers'], primers_data['meta']['dbs'], primers_data['meta']['mode']))
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.0b14'
return '2.0.0b15'

0 comments on commit cda6c1a

Please sign in to comment.