introduc on to programming using python
play

Introduc)on to Programming using Python Programming Course - PowerPoint PPT Presentation

Introduc)on to Programming using Python Programming Course for Biologists WC-16 David Knox and Phil Richmond Dic)onary Data Type Similar to Word


  1. Introduc)on ¡to ¡Programming ¡ using ¡Python ¡ Programming ¡Course ¡for ¡Biologists ¡ WC-­‑16 ¡ David ¡Knox ¡and ¡Phil ¡Richmond ¡

  2. Dic)onary ¡Data ¡Type ¡ • Similar ¡to ¡Word ¡Dic)onary ¡ – Lookup ¡by ¡Word ¡ – Find ¡defini)on(s) ¡

  3. Dic)onary ¡is ¡a ¡Table ¡ Key ¡ Value ¡

  4. Dic)onary ¡is ¡a ¡Table ¡ Key ¡ Value ¡ 'EcoRI’ 'gaattc' 'BamHI’ 'ggatcc' 'HindIII’ 'aagctt' … …

  5. dict() ¡ • Create ¡new ¡dic)onary ¡ ¡ enzymeRestrictions = dict() • Add ¡item ¡to ¡the ¡dic)onary ¡ enzymeRestrictions[“EcoR1”] = ‘gaattc’ • Get ¡value ¡for ¡item ¡ seq = enzymeRestrictions[“EcoR1”] • Check ¡for ¡item ¡in ¡dict ¡ enzymeRestrictions.has_key(‘HindIII’) • Replace ¡Item ¡ enzymeRestrictions[“EcoR1”] = ‘GAATTC’

  6. Dic)onary ¡is ¡a ¡Table ¡ Key ¡ Value ¡ ’TATA’ 5 ’GATA’ 6 ’CATA’ 1 … …

  7. Dic)onary ¡is ¡a ¡Table ¡ Key ¡ Value ¡ [‘GAL10’,‘GENE’, 105387 ‘+’,’TSS’, ‘DOUBIOUS’] 105935 [‘LTR’, …] [ ‘GAL1’, ‘GENE’, 106702 …] … …

  8. Compare ¡Data ¡Types ¡and ¡Methods ¡

  9. Dic)onary ¡Methods ¡ • Ini)aliza)on ¡of ¡dic)onary ¡ ¡ d = {‘key1’:’v1’, ‘key2’:’v2’, …} • Get ¡list ¡of ¡the ¡keys ¡in ¡a ¡dic)onary ¡ ¡ d.keys() - order ¡of ¡the ¡keys ¡is ¡unknown ¡ • Get ¡a ¡list ¡of ¡the ¡values ¡in ¡a ¡dic)onary ¡ d.values() • Itera)on ¡through ¡the ¡dic)onary ¡ for key,value in d: print key,”:”,value

  10. Summary ¡WC-­‑16 ¡ • Dic)onary ¡Data ¡Type ¡ • Contains ¡Keys ¡and ¡Values ¡ • Lookup ¡Table ¡ ¡ • Look ¡by ¡key ¡ • Key ¡is ¡unique ¡ • Value ¡can ¡be ¡any ¡object ¡ ¡ (including ¡a ¡dic)onary) ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend