-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrev_compl_V1_uppercase.py
27 lines (23 loc) · 1.09 KB
/
rev_compl_V1_uppercase.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
########################################################
# Please cite the script by referencing to github #
# repository #
########################################################
from Bio import SeqIO
from Bio.SeqRecord import SeqRecord
import argparse
import re
parser = argparse.ArgumentParser(description="This script generates reverse complementary sqeuence\n.")
parser.add_argument("-fa", "--fasta", help = "A fasta sequence is provided here.", action = "store")
parser.add_argument("-up", "--uppercase", help = "Convert sequence to uppercase.", action = "store_true")
args = parser.parse_args()
def make_rc_record(record):
# """Returns a new SeqRecord with the reverse complement sequence."""
record = SeqRecord(seq = record.seq.reverse_complement(), id = "rc_" + record.id, description = "reverse complement")
if args.uppercase:
print(args.uppercase)
record = record.upper()
return record
print(args.fasta)
records = map(make_rc_record, SeqIO.parse(args.fasta, "fasta"))
SeqIO.write(records, "rev_comp_" + args.fasta, "fasta")