准备(windows为例):安装python、pycharm

输入文件: fasta格式,包括两条序列;

输出文件包括位置及两个差异位点

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# -*- coding = utf-8 -*-
# @Time : 2021/5/28 23:22
# @Author : wutz
# @File : call_divergent_sites.py
# @Software : PyCharm
fasfile = open("input.fas")
outfile = open("divergent-sites.txt","w")
lines = fasfile.readlines()
a = lines[1].strip()
b = lines[3].strip()
len = len(a)
i = 0
while i < len:
if a[i] != b[i] and a[i] != "-" and b[i] != "-" and a[i] != "?" and b[i] != "?":
print(a[i],i + 1,b[i], file=outfile)
i+=1