题目:

随便给定一条序列,如果GC含量超过65%,则认为高。

编程:

from __future__ import division #整数除法

def is_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
	if GC_content > 0.65:
		print('GC content is high')
	else:
		print("GC content is normal")

测试

dna="agcTacGAcatgcacgtgcac"
is_gc_rich(dna)

解析

Python提供了__future__模块,把下一个新版本的特性导入到当前版本,于是我们就可以在当前版本中测试一些新版本的特性。

主要解决python2版本中和python3不同的一些问题,如print、整数除法、with用法、absolute_import等。上例中即引入了整数除法。

Ref:https://blog.csdn.net/zzc15806/article/details/81133045
https://www.liaoxuefeng.com/wiki/897692888725344/923030465280480

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2021-11-08
  • 2021-10-02
  • 2021-08-22
猜你喜欢
  • 2021-12-06
  • 2022-12-23
  • 2021-09-26
  • 2022-12-23
  • 2021-09-06
  • 2022-03-08
  • 2021-12-16
相关资源
相似解决方案