如何用Python评估序列的GC含量水平?
- 内容介绍
- 文章标签
- 相关推荐
本文共计249个文字,预计阅读时间需要1分钟。
题目:如何定义一条序列,例如GC含量超过65%则认为为高?
编程:from __future__ import division
题目:
随便给定一条序列,如果GC含量超过65%,则认为高。
编程:
from__future__importdivision#整数除法defis_gc_rich(dna):
length=len(dna)
G_count=dna.upper().count('G')
C_count=dna.upper().count('C')
GC_content=(G_count+C_count)/length
ifGC_content>0.65:
print('GCcontentishigh')
else:
print("GCcontentisnormal")
测试
dna="agcTacGAcatgcacgtgcac"is_gc_rich(dna)
解析
Python提供了__future__模块,把下一个新版本的特性导入到当前版本,于是我们就可以在当前版本中测试一些新版本的特性。
主要解决python2版本中和python3不同的一些问题,如print、整数除法、with用法、absolute_import等。上例中即引入了整数除法。
Ref:www.liaoxuefeng.com/wiki/897692888725344/923030465280480
作者:Bioinfarmer
若要及时了解动态信息,请关注同名微信公众号:Bioinfarmer。
本文共计249个文字,预计阅读时间需要1分钟。
题目:如何定义一条序列,例如GC含量超过65%则认为为高?
编程:from __future__ import division
题目:
随便给定一条序列,如果GC含量超过65%,则认为高。
编程:
from__future__importdivision#整数除法defis_gc_rich(dna):
length=len(dna)
G_count=dna.upper().count('G')
C_count=dna.upper().count('C')
GC_content=(G_count+C_count)/length
ifGC_content>0.65:
print('GCcontentishigh')
else:
print("GCcontentisnormal")
测试
dna="agcTacGAcatgcacgtgcac"is_gc_rich(dna)
解析
Python提供了__future__模块,把下一个新版本的特性导入到当前版本,于是我们就可以在当前版本中测试一些新版本的特性。
主要解决python2版本中和python3不同的一些问题,如print、整数除法、with用法、absolute_import等。上例中即引入了整数除法。
Ref:www.liaoxuefeng.com/wiki/897692888725344/923030465280480
作者:Bioinfarmer
若要及时了解动态信息,请关注同名微信公众号:Bioinfarmer。

