Python如何统计核酸序列中频率为1或2的双核苷酸?
- 内容介绍
- 文章标签
- 相关推荐
本文共计208个文字,预计阅读时间需要1分钟。
概念+双核苹果酸由任意2个碱基组成+测试1+DNA序列为AATGATGAACGAC
概念
双核苷酸由任意2个碱基组成
测试1
dna="AATGATGAACGAC"#一一列举
dinucleotides=['AA','AT','AG','AC',
'TA','TT','TG','TC',
'GA','GT','GG','GC',
'CA','CT','CG','CT']
all_counts={}
fordinucleotideindinucleotides:
count=dna.count(dinucleotide)
ifcount>0:
all_counts[dinucleotide]=count
print(all_counts)
fordinucleotideinall_counts.keys():
ifall_counts.get(dinucleotide,0)==2:
print(dinucleotide)
测试2
dna="AATGATGAACGAC"bases=['A','T','G','C']
all_counts={}
#循环生成
forbase1inbases:
forbase2inbases:
dinucleotide=base1+base2
count=dna.count(dinucleotide)
ifcount>0:
all_counts[dinucleotide]=count
print(all_counts)
fordinucleotideinall_counts.keys():
ifall_counts.get(dinucleotide,0)==2:
print(dinucleotide)
结果
AA
AT
AC
TG
作者:Bioinfarmer
若要及时了解动态信息,请关注同名微信公众号:Bioinfarmer。
本文共计208个文字,预计阅读时间需要1分钟。
概念+双核苹果酸由任意2个碱基组成+测试1+DNA序列为AATGATGAACGAC
概念
双核苷酸由任意2个碱基组成
测试1
dna="AATGATGAACGAC"#一一列举
dinucleotides=['AA','AT','AG','AC',
'TA','TT','TG','TC',
'GA','GT','GG','GC',
'CA','CT','CG','CT']
all_counts={}
fordinucleotideindinucleotides:
count=dna.count(dinucleotide)
ifcount>0:
all_counts[dinucleotide]=count
print(all_counts)
fordinucleotideinall_counts.keys():
ifall_counts.get(dinucleotide,0)==2:
print(dinucleotide)
测试2
dna="AATGATGAACGAC"bases=['A','T','G','C']
all_counts={}
#循环生成
forbase1inbases:
forbase2inbases:
dinucleotide=base1+base2
count=dna.count(dinucleotide)
ifcount>0:
all_counts[dinucleotide]=count
print(all_counts)
fordinucleotideinall_counts.keys():
ifall_counts.get(dinucleotide,0)==2:
print(dinucleotide)
结果
AA
AT
AC
TG
作者:Bioinfarmer
若要及时了解动态信息,请关注同名微信公众号:Bioinfarmer。

