资源描述:
《面向计算生物学的python教程》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、面向计算生物学的Python教程马红武中科院天津工生所概览Python基础知识Python实例:文件处理和信息提取Python实例:网络信息提取Biopython:从数据库获得信息Biopython:序列处理及相似性分析NetworkX:生物网络分析NumPython&Matplotlib:Python上的Matlab及作图其它Python基础知识为什么用PythonPython安装Python基本数据结构WhyUsePython?Pythonisobject-orientedIt'sfree(opensource)It‘sportable(acrossplatform)I
2、t'spowerful(“batteryincluded”,variouspackagesfordoingalmostanything)It'smixable(Gluelanguage,linkwithCetc)It'seasytouse(interpretedlanguagebutfastperformance)It'seasytolearn(“pythonic”“codethatisasunderstandableasplainEnglish”,learnfromexamples)安装pythonhttp://www.python.org建议仍使用python2.7Wi
3、ndows下ActivepythonLinux(Ubuntu)自带python,可安装IDE软件进行编辑调试(EricpythonIDE,SPE等)Debug功能一定要掌握好!Pythonwin编辑器代码编写区交互窗口调试工具栏交互窗口使用Examples:>>>print'Helloworld'Helloworld#Relevantoutputisdisplayedonsubsequentlineswithoutthe>>>symbol>>>x=[0,1,2]#Quantitiesstoredinmemoryarenotdisplayedbydefault>>>x#可用于
4、查询正在调试的程序中的变量#Ifaquantityisstoredinmemory,typingitsnamewilldisplayit[0,1,2]>>>y=[2,3]>>>x+y[0,1,2,2,3]#不确定操作符功能时可在交互窗口中试用>>>7/23#整数返回整数,试试7.0/2,编程时需注意!>>>importscript#DONOTaddthe.pysuffix.Scriptisamodulehere#可用来查看一个模块是否安装正常OperationsonNumbersBasicalgebraicoperationsFourarithmeticoperations
5、:a+b,a-b,a*b,a/bExponentiation:a**bOtherelementaryfunctionsarenotpartofstandardPython,butincludedinpackageslikeNumPyandSciPyComparisonoperatorsGreaterthan,lessthan,etc.:ab,a<=b,a>=bIdentitytests:a==b,a!=bBitwiseoperatorsBitwiseor:a
6、bBitwiseexclusiveor:a^b#Don'tconfusethiswithexponenti
7、ationBitwiseand:a&bShiftaleftorrightbybbits:a<>b数据结构Lists(字符串可以当list处理)>>>a=[1,‘s’,[2,3],5.5]>>>a[0]#startfrom01>>>a[-1]#fromthelastone5.5>>>a[1:3][‘s’,[2,3]]>>>a[::2]>>>a.append(3)[1,‘s’,[2,3],5.5,3]>>>a.sort()>>>a.reverse()>>>len(a)Turplest1=(0,1,2,3)SetsDictionary语法结构:IfForwhileifx
8、>2andx<5:#ifcondition1istrue,executeaction1action1elif‘s’instr:#ifcondition1isnottrue,butcondition2is,executeaction2#action2else:#ifneithercondition1norcondition2istrue,executeaction3#action3完全通过缩进来确定执行那些操作,不用endif。foriinrange(1,7):Forxinl:whilex<4:定义函数Usually