forked from Ashish438/Python-for-Bioinformatics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcount_ATGC.py
More file actions
31 lines (25 loc) · 791 Bytes
/
Copy pathcount_ATGC.py
File metadata and controls
31 lines (25 loc) · 791 Bytes
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
# counting ATGC in all fasta sequences in a multiple fasta file
fr = open("path of your multiple fasta file","r")
header = ""
seq = ""
for line in fr:
if ">" in line:
header = line
if seq != "":
print(seq)
print("No. of A: ",seq.count("A"))
print("No. of T: ",seq.count("T"))
print("No. of G: ",seq.count("G"))
print("No. of C: ",seq.count("C"))
seq = ""
print(header)
else:
line = line.rstrip("\n")
seq = seq+line
print(seq)
print("No. of A: ",seq.count("A"))
print("No. of T: ",seq.count("T"))
print("No. of G: ",seq.count("G"))
print("No. of C: ",seq.count("C"))
##please leave a message if you want a text version of this code or if you face any issues while using the code
##your personal queries are also invited