Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

P6 2017 biopython2

(Bio)python in the wild

  • Login to see the comments

  • Be the first to like this

P6 2017 biopython2

  1. 1. FBW 28-11-2017 Wim Van Criekinge
  2. 2. Google Calendar
  3. 3. Control Structures if condition: statements [elif condition: statements] ... else: statements while condition: statements for var in sequence: statements break continue
  4. 4. Lists • Flexible arrays, not Lisp-like linked lists • a = [99, "bottles of beer", ["on", "the", "wall"]] • Same operators as for strings • a+b, a*3, a[0], a[-1], a[1:], len(a) • Item and slice assignment • a[0] = 98 • a[1:2] = ["bottles", "of", "beer"] -> [98, "bottles", "of", "beer", ["on", "the", "wall"]] • del a[-1] # -> [98, "bottles", "of", "beer"]
  5. 5. Dictionaries • Hash tables, "associative arrays" • d = {"duck": "eend", "water": "water"} • Lookup: • d["duck"] -> "eend" • d["back"] # raises KeyError exception • Delete, insert, overwrite: • del d["water"] # {"duck": "eend", "back": "rug"} • d["back"] = "rug" # {"duck": "eend", "back": "rug"} • d["duck"] = "duik" # {"duck": "duik", "back": "rug"}
  6. 6. Regex.py text = 'abbaaabbbbaaaaa' pattern = 'ab' for match in re.finditer(pattern, text): s = match.start() e = match.end() print ('Found "%s" at %d:%d' % (text[s:e], s, e)) m = re.search("^([A-Z]) ",line) if m: from_letter = m.groups()[0]
  7. 7. Install Biopython pip is the preferred installer program. Starting with Python 3.4, it is included by default with the Python binary installers. pip3.5 install Biopython #pip3.5 install yahoo_finance from yahoo_finance import Share yahoo = Share('AAPL') print (yahoo.get_open())
  8. 8. Prelude • Erdos • Gaussian - towards random DNAwalks • Fetch random Protein • AAindex parser
  9. 9. Erdos.py
  10. 10. Gaussian.py
  11. 11. Prelude • Erdos • Gaussian - towards random DNAwalks • Fetch random Protein • AAindex parser
  12. 12. To be adapted for proteins …
  13. 13. Exceptions • Exceptions are events that can modify the flow or control through a program. • They are automatically triggered on errors. • try/except : catch and recover from raised by you or Python exceptions • try/finally: perform cleanup actions whether exceptions occur or not • raise: trigger an exception manually in your code • assert: conditionally trigger an exception in your code
  14. 14. Exception Roles • Error handling – Wherever Python detects an error it raises exceptions – Default behavior: stops program. – Otherwise, code try to catch and recover from the exception (try handler) • Event notification – Can signal a valid condition (for example, in search) • Special-case handling – Handles unusual situations • Termination actions – Guarantees the required closing-time operators (try/finally) • Unusual control-flows – A sort of high-level “goto”
  15. 15. Example
  16. 16. Prelude • Erdos • Gaussian - towards random DNAwalks • Fetch random Protein • AAindex parser
  17. 17. BioPython • Make a histogram of the MW (in kDa) of all proteins in Swiss-Prot • Find the most basic and most acidic protein in Swiss-Prot? • Biological relevance of the results ? From AAIndex H ZIMJ680104 D Isoelectric point (Zimmerman et al., 1968) R LIT:2004109b PMID:5700434 A Zimmerman, J.M., Eliezer, N. and Simha, R. T The characterization of amino acid sequences in proteins by statistical methods J J. Theor. Biol. 21, 170-201 (1968) C KLEP840101 0.941 FAUJ880111 0.813 FINA910103 0.805 I A/L R/K N/M D/F C/P Q/S E/T G/W H/Y I/V 6.00 10.76 5.41 2.77 5.05 5.65 3.22 5.97 7.59 6.02 5.98 9.74 5.74 5.48 6.30 5.68 5.66 5.89 5.66 5.96
  18. 18. Find_Most_Basic_Protein.py
  19. 19. Find_Most_Basic_Protein.py
  20. 20. Extra Questions • How many human proteins in Swiss Prot ? • What is the longest human protein ? The shortest ? • Calculate for all human proteins their MW and pI, display as two histograms (2D scatter ?) • How many human proteins have “cancer” in their description? • Which genes has the highest number of SNPs/somatic mutations (COSMIC) • How many human DNA-repair enzymes are represented in Swiss Prot (using description / GO)? • List proteins that only contain alpha-helices based on the Chou-Fasman algorithm • List proteins based on the number of predicted transmembrane regions (Kyte-Doollittle)
  21. 21. Biopython AAindex ? Dictionary Hydrophobicity = {A:6.00,L:5.98,R:10.76,K:9.74,N:5.41,M:5.74,D:2.77,F:5.48, C:5.05,P:6.30,Q:5.65,S:5.68,E:3.22,T:5.66,G:5.97,W:5.89, H:7.59,Y:5.66,I:6.02,V:5.96} from Bio import SeqIO c=0 handle = open(r'/Users/wvcrieki/Downloads/uniprot_sprot.dat') for seq_rec in SeqIO.parse(handle, "swiss"): print (seq_rec.id) print (repr(seq_rec.seq)) print (len(seq_rec)) c+=1 if c>5: break
  22. 22. Extra Questions (2) • How many human proteins in Swiss Prot ? • What is the longest human protein ? The shortest ? • Calculate for all human proteins their MW and pI, display as two histograms (2D scatter ?) • How many human proteins have “cancer” in their description? • Which genes has the highest number of SNPs/somatic mutations (COSMIC) • How many human DNA-repair enzymes are represented in Swiss Prot (using description / GO)? • List proteins that only contain alpha-helices based on the Chou-Fasman algorithm • List proteins based on the number of predicted transmembrane regions (Kyte-Doollittle)
  23. 23. Primary sequence reveals important clues about a protein DnaG E. coli ...EPNRLLVVEGYMDVVAL... DnaG S. typ ...EPQRLLVVEGYMDVVAL... DnaG B. subt ...KQERAVLFEGFADVYTA... gp4 T3 ...GGKKIVVTEGEIDMLTV... gp4 T7 ...GGKKIVVTEGEIDALTV... : *: :: * * : : small hydrophobic large hydrophobic polar positive charge negative charge • Evolution conserves amino acids that are important to protein structure and function across species. Sequence comparison of multiple “homologs” of a particular protein reveals highly conserved regions that are important for function. • Clusters of conserved residues are called “motifs” -- motifs carry out a particular function or form a particular structure that is important for the conserved protein. motif
  24. 24.  The hydropathy index of an amino acid is a number representing the hydrophobic or hydrophilic properties of its side-chain.  It was proposed by Jack Kyte and Russell Doolittle in 1982.  The larger the number is, the more hydrophobic the amino acid. The most hydrophobic amino acids are isoleucine (4.5) and valine (4.2). The most hydrophilic ones are arginine (-4.5) and lysine (-3.9).  This is very important in protein structure; hydrophobic amino acids tend to be internal in the protein 3D structure, while hydrophilic amino acids are more commonly found towards the protein surface. Hydropathy index of amino acids
  25. 25. (http://gcat.davidson.edu/DGPB/kd/kyte-doolittle.htm)Kyte Doolittle Hydropathy Plot
  26. 26. Possible transmembrane fragment
  27. 27. Window size – 9, strong negative peaks indicate possible surface regions Surface region of a protein
  28. 28. Prediction of transmembrane helices in proteins (TMHMM)
  29. 29. 5-hydroxytryptamine receptor 2A (Mus musculus)
  30. 30. 5-hydroxytryptamine receptor 2 (Grapical output)

×