python中计算点突变的数目

发布时间 2023-08-28 10:39:36作者: 小鲨鱼2018

 

001、直接比较计算

[root@PC1 test01]# ls
a.fa  b.fa  test.py
[root@PC1 test01]# cat a.fa     ## 测试dna序列
GAGCCTACTAACGGGAT
[root@PC1 test01]# cat b.fa     ## 测试dna序列
CATCGTAATGACGGCCT
[root@PC1 test01]# cat test.py  ## 计算程序
#!/usr/bin/env python
# -*- coding: utf-8 -*-

in_file1 = open("a.fa", "r")
in_file2 = open("b.fa", "r")
file1 = in_file1.read().strip()
file2 = in_file2.read().strip()
in_file1.close()
in_file2.close()

count = 0
for i in range(len(file1)):
        if file1[i] != file2[i]:
                count += 1
print(count)
[root@PC1 test01]# python3 test.py   ## 计算结果
7

 

002、