import os.path
if os.path.isfile('9.out'):
print("file exists")
else:
print("file not ")
fw = open('9out','w')
统计碱基个数
m = 0
G = 0
with open('3.fasta') as f:
for line in f:
if line.startswith(">"):
name = line
else:
n = len(line)
m = m +n
g = line.count('G') + line.count('C')
G = G + g
print(G)
print(m)
print(G/m)
检测文件是否存在
import os.path if os.path.isfile('9.out'): print("file exists") else: print("file not ") fw = open('9out','w')
统计碱基个数
m = 0 G = 0 with open('3.fasta') as f: for line in f: if line.startswith(">"): name = line else: n = len(line) m = m +n g = line.count('G') + line.count('C') G = G + g print(G) print(m) print(G/m)
GC含量
str((dict[ID].count('G') + dict[ID].count('C')) / len(dict[ID])