-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4d.site.py
executable file
·39 lines (31 loc) · 1.07 KB
/
4d.site.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
28
29
30
31
32
33
34
35
36
37
#! /usr/bin/env python3
import argparse
parse = argparse.ArgumentParser()
parse.add_argument("-i", "--input", help = "input file")
args = parse.parse_args()
_4d_codon = ["GCT", "GCC", "GCA", "GCG",
"CGT", "CGC", "CGA", "CGG",
"GGT", "GGC", "GGA", "GGG",
"CTT", "CTC", "CTA", "CTG",
"CCT", "CCC", "CCA", "CCG",
"TCT", "TCC", "TCA", "TCG",
"ACT", "ACC", "ACA", "ACG",
"GTT", "GTC", "GTA", "GTG"]
with open (args.input, "r") as file:
for line in file:
line = line.strip()
if ">" in line:
print(line)
else:
if len(line) % 3 == 0:
_4d_site = []
for i in range(0,len(line),3):
codon = line[i:i+3]
if codon in _4d_codon:
_4d_site.append(codon[-1])
else:
_4d_site.append("-")
print("".join(_4d_site))
else:
print("your sequence isnot the multiple of three")
exit