Skip to content

Commit

Permalink
Merge pull request #12 from simpsonlab/fix_primer_prefix
Browse files Browse the repository at this point in the history
Add support for primer name prefix
  • Loading branch information
rdeborja authored Jul 7, 2021
2 parents c0eaffa + 74d56ba commit 14698f0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion bin/primers_to_amplicons.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
help='filename to write BED to')
parser.add_argument('--bed_type', default='unique_amplicons',
help='type of BED to produce (e.g. full, no_primers, unique-amplicons')
parser.add_argument('--primer_prefix', default='nCoV-2019',
help='the primer name prefix used in the BED file (default: nCoV-2019)')
if len(sys.argv) <= 1:
parser.print_help(sys.stderr)
sys.exit('Invalid number of arguments')
Expand All @@ -23,7 +25,8 @@
primer_pairs = pr.create_primer_pairs(primers=primers)
amplicon_ranges = pr.create_amplicons(primer_pairs=primer_pairs,
offset=args.offset,
type=args.bed_type)
type=args.bed_type,
prefix=args.primer_prefix)

with open(args.output, 'w') as file_o:
for line in amplicon_ranges:
Expand Down
8 changes: 4 additions & 4 deletions ncov/parser/primers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def create_primer_pairs(primers, left='_LEFT.*', right='_RIGHT.*'):
return primer_pairs


def create_amplicons(primer_pairs, offset=0, type='unique_amplicons'):
def create_amplicons(primer_pairs, offset=0, type='unique_amplicons', prefix='nCoV-2019'):
'''
Create an array of BED regions as either full including primers, with no
primers included, or as unique amplicons without overlaps.
Expand All @@ -92,9 +92,9 @@ def create_amplicons(primer_pairs, offset=0, type='unique_amplicons'):
amplicons = list()
for index in range(0, len(primer_pairs)):
amplicon_id = index + 1
primer_name = f'nCoV-2019_{amplicon_id}'
previous_primer_name = f'nCoV-2019_{amplicon_id-1}'
next_primer_name = f'nCoV-2019_{amplicon_id + 1}'
primer_name = f'{prefix}_{amplicon_id}'
previous_primer_name = f'{prefix}_{amplicon_id-1}'
next_primer_name = f'{prefix}_{amplicon_id + 1}'
if type == 'full':
start = int(primer_pairs[primer_name]['left_start'])
end = int(primer_pairs[primer_name]['right_end'])
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="ncov_parser",
version="0.6.8",
version="0.6.9",
author="Richard J. de Borja",
author_email="[email protected]",
description="A nCoV package for parsing analysis files",
Expand Down

0 comments on commit 14698f0

Please sign in to comment.