Python programming - Theoretical Biophysics, Molecular Simulation ...

adventurescoldSoftware and s/w Development

Nov 7, 2013 (3 years and 9 months ago)

99 views

Do-it-yourselfprogramming
KonradHinsen
hinsen@cnrs-orleans.fr
CentredeBiophysiqueMol
´
eculaire,CNRSOrl
´
eans
and
SynchrotronSoleil,SaintAubin
Programmingp.1/15
Biomolecularsimulations
Standardtasks:

RunanMDsimulation

Calculateatomicuctuations

Visualizetrajectory
⇒standardprograms
Nonstandardtasks:

Automatizeamultistepoperation

Extractdatafromale

Fileformatconversion

Implementnewalgorithms

do-it-yourselfprogramming
Programmingp.2/15
Visualization
Programmingp.3/15
Visualization
Programmingp.4/15
Trajectoryanalysis
0200400600800
Surrounding protein density [amu/nm3]
0
10
20
30
Friction constant [1000 amu/ps]
measured friction constants
linear fit
Programmingp.5/15
Methoddevelopment
Programmingp.6/15
Programmingoptions
Shellscripts:

quicktowrite

workonany(Unix)system

verylimitedpossibilities

difculttoread

veryslowexecution
Suitablefor:automatizationofsimpleoperations
Programmingp.7/15
Programmingoptions
Low-levellanguages
(C,C++,Fortran,...):

fastexecution

gooddevelopmenttools

requiresignicantexperience

longdevelopmenttimes

canbedifculttoread
Suitablefor:time-criticalalgorithms
Programmingp.8/15
Programmingoptions
High-levellanguages
(Perl,
Python
,Ruby,...):

completeprogramminglanguages

easytolearn

fastdevelopment

easytoread

interfacetolow-levellanguages

slowexecution
Suitablefor:everythingthatisnottime-critical
Programmingp.9/15
Programmingoptions
Empiricalrule:
90%ofaprogramisnottimecritical
Therefore:

Everyoneshouldknowanduseahigh-level
language.

Developersofnumericalmethodsmustalsoknow
alow-levellanguage.
Programmingp.10/15
Python
Features:

Cleansyntax

Object-oriented
(→problem-orienteddatastructures)

Goodlow-levellanguageinterface
(C,C++,Fortran)

Freeandportableimplementation

Wellestablishedasascriptinglanguagefor
computationalscience
Programmingp.11/15
Python
Examples:

Sumupnumbersinthethirdcolumnofatextle
sum=0.
forlineinfile('my_data'):
sum=sum+float(line.split()[2])
printsum
Programmingp.12/15
Python

Calculatetheradiusofgyrationofaprotein
fromMMTK.ProteinsimportProtein
importnumpy
protein=Protein('protein.pdb')
center=protein.centerOfMass()
r_sq=0.
foratominprotein.atomList():
mass=atom.mass()
distance=atom.position()-center
r_sq=r_sq+mass*distance*distance
r_sq=r_sq/protein.mass()
printnumpy.sqrt(r_sq)
Programmingp.13/15
MolecularModellingToolkit
MolecularsimulationlibraryforPython

Standardoperations:MolecularDynamics,
energyminimmization,normalmodes,molecular
surfaces,...

Lower-levelbasicoperationsforimplementing
yourownmethods

Interfacestovisualizationsoftware

CanbecombinedwithotherPythonlibraries

OpenSource
http://dirac.cnrs-orleans.fr/MMTK
Programmingp.14/15
Practical
MolecularsimulationwithMMTK

IntroductiontoMMTK

Normalmodesofawatermolecule

Normalmodesofaproteinfragment

MolecularDynamicsofaproteinfragment

Trajectoryanalysis
Programmingp.15/15