Skip to content

Instantly share code, notes, and snippets.

@coleoguy
Created August 25, 2013 17:11
Show Gist options
  • Save coleoguy/6335059 to your computer and use it in GitHub Desktop.
Save coleoguy/6335059 to your computer and use it in GitHub Desktop.
data <- as.numeric(read.table("rosalind_iprb.txt"))
k<-data[1]
m<-data[2]
n<-data[3]
t<-sum(data)
# Sire is AA Dam is anything
t.prob <- k/(t)
# Sire is Aa Dam is AA, Aa, aa
t.prob <- t.prob + (((m/(t)) * (k/(t-1))) + #Aa x AA
((m/(t)) * ((m-1)/(t-1)) * .75) + #Aa x Aa
(m/(t)) * (n/(t-1) * .5)) #Aa x aa
# Sire is aa Dam is AA, Aa
t.prob <- t.prob + (((n/(t)) * (k/(t-1)) * 1) + #aa x AA
((n/(t)) * (m/(t-1)) *.5)) #aa x Aa
cat(t.prob)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment