-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBarcoder.py
More file actions
24 lines (21 loc) · 1.21 KB
/
Copy pathBarcoder.py
File metadata and controls
24 lines (21 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import argparse
import random
def generate_barcode(length, gc_min, gc_max):
"""
Generates a random DNA barcode of the specified length with GC content between gc_min and gc_max.
"""
bases = ['A', 'C', 'G', 'T']
gc_count = int(length * random.uniform(gc_min, gc_max))
barcode = [random.choice(['G', 'C']) if i < gc_count else random.choice(['A', 'T']) for i in range(length)]
random.shuffle(barcode)
return ''.join(barcode)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate random DNA barcodes with specified GC content range.')
parser.add_argument('-l', '--length', type=int, required=True, help='Length of the barcode.')
parser.add_argument('-min', '--gc_min', type=float, required=True, help='Minimum desired GC content as a decimal fraction.')
parser.add_argument('-max', '--gc_max', type=float, required=True, help='Maximum desired GC content as a decimal fraction.')
parser.add_argument('-n', '--num_barcodes', type=int, default=1, help='Number of barcodes to generate (default: 1)')
args = parser.parse_args()
for i in range(args.num_barcodes):
barcode = generate_barcode(args.length, args.gc_min, args.gc_max)
print(barcode)