DICTIONARIES (CONT.)
Transcript of DICTIONARIES (CONT.)
CSE111Bio:ProgramDesignILecture24:Phylogenetictrees
RobertSloan(CS)&RachelPoretsky(Bio)UniversityofIllinois,Chicago
November21,2017
https://imgs.xkcd.com/comics/tree.png
TuesdayafterThanksgiving
• About5minutesofclasswillbespentonCSdepartmentClimatesurvey
• AdministeredinCS111,141,andCS251eachfallbyCSstudentaffairsstaff
• Easytodoonyourphone,butbringlaptopifyoupreferthat
def translate():d = {"hello":"hola", "goodbye":"adios", "good":"bueno", "spam":"spam"}for word in d:
print(word, "is: ", d[word])d["more"] = "mas"
translate() A. hello is: holagoodbye is: adiosgood is: buenospam is: spam
B.good is: buenohello is: holagoodbye is: adiosspam is: spam
C. E. A or D or otherhello is: holagoodbye is: adiosgood is: buenospam is: spammore is: mas
D.spam is: spamgood is: buenogoodbye is: adioshello is: hola
def translate():d = {"hello":"hola", "goodbye":"adios", "good":"bueno", "spam":"spam"}for word in d:
print(word, "is: ", d[word])d["more"] = "mas"
translate()good is: buenohello is: holagoodbye is: adiosspam is: spam
Theorderisweird!
TryThis…
>>> score(“spam”, scrabble_dict)8
def score(myString, dict):
Youcanusewhileorforloopshere…
scrabble_dict = {"a":1, "b":3, "c":3, "d":2, …}
TryThis…
scrabble_dict = {"a":1, "b":3, "c":3, "d":2, …}
def score(my_string, dict):total = 0for letter in my_string:
total += scrabble_dict[letter]return total
Usefulmethod(fromZybook)
• d.get(key)isalternatesyntaxford[key]– Okay,fine,butwhere'stheadvantage?
• d[key-not-in-d]à KeyError• d.get(key,default)à d[key]ifkeyand defaultotherwise
– E.g.,d.get(key,"N/A")
Dictionary,ohhowdoIlovethee?
• ListsinPythonarewonderful,andamazing• Theonethingthatmightbebetterisdictionaries• All-purposeforkey-valuelinkages
– Ifyou'reGoogleandwanttoremembereverypagethathasthephrase"TreeofLife"onit?
• Dictionarywithstringkeys,andlistofstrings(URLS)values
– Doinganysortoftranslation,rangingfromEnglishtoSpanishtomRNAtoAminoacids?
– Etc.?
• AlllifeonEarthevolvedfromacommonancestor.
• Biologistsmaphoworganismsarerelatedbyconstructingphylogenetictrees.
• Recentgeneticanalysisandotheradvancementshavefoundthatsomeearliertaxonomicclassificationsdonotreflectactualevolutionaryrelationships,andtherefore,changesandupdatesmustbemadeasnewdiscoveriestakeplace.
• Onedramaticandrecentexamplewasthebreakingapartofprokaryoticspecies,whichuntilthe1970swereallclassifiedasbacteria.
• TheirdivisionintoArchaea andBacteriacameaboutaftertherecognitionthattheirlargegeneticdifferenceswarrantedtheirseparationintotwoofthreefundamentalbranchesoflife.
Figure12.4
Aphylogenetictreeisrootedandshowshowdifferentorganisms,inthiscasethespeciesandsubspeciesoflivingapes,evolvedfromacommonancestor.
Branchpoint
Sistertaxa
Figure12.5
• Thisphylogenetictreeisrootedbyanorganismthatlackedavertebralcolumn.Ateachbranchpoint,organismswithdifferentcharactersareplacedindifferentgroups.
Figure12.6
Organismsthatsharesimilarphysicalfeaturesandgeneticsequencestendtobemorecloselyrelatedthanthosethatdonot.Featuresthatoverlapbothmorphologicallyandgeneticallyarereferredtoashomologousstructures;thesimilaritiesstemfromcommonevolutionarypaths.
Figure12.7
Someorganismsmaybeverycloselyrelated,eventhoughaminorgeneticchangecausedamajormorphologicaldifferencetomakethemlookquitedifferent.
Figure12.8
Unrelatedorganismsmaybedistantlyrelatedyetappearverymuchalike,usuallybecausecommonadaptationstosimilarenvironmentalconditionsevolvedinboth.
timeà
PhylogenyofSpecies:Atree-likerepresentationofevolutionaryrelationshipsamongspecies)
Commonlyusedinbasicevolutionaryresearch,conservation,andmedicine.
timeà
Isthefrogmorecloselyrelatedtothefishorthehuman?
a. Fishb. Humanc. Equallyrelatedtobothd. Thereisnotenoughinformationtodecide
timeà
Isthefrogmorecloselyrelatedtothefishorthehuman?
a. Fishb. Humanc. Equallyrelatedtobothd. Thereisnotenoughinformationtodecide
Which taxon on the tree below is most closely related to taxon D?
a. Ab. Bc. Cd. All of the above are
equally closelyrelated to D
Which taxon on the tree below is most closely related to taxon C?
a. Ab. Bc. Dd. B and D are
equally closely related to C
e. All of the above areequally closelyrelated to C
Which taxon on the tree below is most closely related to taxon A?
a. Bb. Cc. Dd. All of the above are
equally closely related to A
MostStudiedGeneSequences
• Rubisco (fromchloroplast,rbcL)• Ribosomesubunits(fromnucleus,18S&26S)• ATPsynthase(fromchloroplast,atpB)
MolecularsystematicsTheuseofDNAandRNAsequencestoinferevolutionaryrelationships
• Manymoremolecularcharactersavailableforanalysisthanmorphologicalones.
• Identityiseasiertodefine:ATCGvs.whetheraflowercolorispinkorwhite.
Forexample,twoplantsmayhavea“C”ataparticularlocationonagene
• Onepossibilityisthattheyhaveevolvedtogetherandarecloselyrelated
• Anotherpossibilityisthatonestartedatwiththe“C”atthatlocationanditdidn’tchange,whiletheotherplantwent“C->G->A->T->C”andlookslikeit’sthesameevolutionbecauseallyouseeisthestartandfinish“C”
ModernPhylogenetics
• DNAsequencedataarenowoverwhelminglythetoolofchoiceforgeneratingphylogenetichypotheses.
• Muchofthisdataisontheweb.
• NationalCenterforBiotechnologyInformationhttp://www.ncbi.nlm.nih.gov/
Figure12.9
• Lizards,rabbits,andhumansalldescendfromacommonancestorinwhichtheamnioticeggevolved.Thus,lizards,rabbits,andhumansallbelongtotheclade Amniota.Vertebrataisalargercladethatalsoincludesfishandlamprey.
RelevancetoCS?Choosingtherightrelationships:
• Constructingaphylogenetictree,orcladogram,fromthecharacterdataisamonumentaltaskthatisusuallyleftuptoacomputer.
• Thecomputerdrawsatreesuchthatallofthecladessharethesamelistofderivedcharacters
http://evolution.genetics.washington.edu/phylip/newicktree.html
TheNewick Standardforrepresentingtreesincomputer-readableformmakesuseofthecorrespondencebetweentreesandnestedparentheses,noticedin1857bythefamousEnglishmathematicianArthurCayley.Ifwehavethisrootedtree:
theninthetreefileisrepresentedby:(B,(A,C,E),D)
((raccoon:19.19959,bear:6.80041):0.84600,((sea_lion:11.99700,seal:12.00300):7.52973,((monkey:100.85930,cat:47.14069):20.59201,weasel:18.87953):2.09460):3.87382,dog:25.46154)
"HomosapiensisamemberofthegroupHomo,whichisamemberofthegroupHomininae”
Childtoparent
"Primatescontainstwogroups:Haplorrhini andStrepsirrhini”
Parenttochild
"HomosapiensisamemberofthegroupHomo,whichisamemberofthegroupHomininae”
Childtoparent
tax_dict = {'Homo sapiens' : 'Homo','Homo' : 'Homininae'
}
def get_ancestors(taxon):first_parent = tax_dict.get(taxon)second_parent = tax_dict.get(first_parent)third_parent = tax_dict.get(second_parent)return[first_parent, second_parent, third_parent]
def get_ancestors(taxon):result = [taxon]while taxon != 'Primates':
result.append(tax_dict.get(taxon))taxon = tax_dict.get(taxon)
return result
Noticehoweachtimeroundtheloopwesetthevalueofthetaxonvariabletobethenameoftheparenttaxon,whichthenbecomesthechildinthenextiterationofthewhileloop.
"Primatescontainstwogroups:Haplorrhini andStrepsirrhini”
Parenttochild
tax_dict = {'Strepsirrhini' : 'Lorisidae','Strepsirrhini' : 'Lemuriformes','Strepsirrhini' : 'Lorisiformes'
}
Whyisthisnogood?