[Rcolony-commits] r13 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 22 18:13:48 CEST 2009


Author: jonesor
Date: 2009-04-22 18:13:48 +0200 (Wed, 22 Apr 2009)
New Revision: 13

Added:
   pkg/R/build.colony.input.R
Log:
Added partially completed build.colony.input function

Added: pkg/R/build.colony.input.R
===================================================================
--- pkg/R/build.colony.input.R	                        (rev 0)
+++ pkg/R/build.colony.input.R	2009-04-22 16:13:48 UTC (rev 13)
@@ -0,0 +1,116 @@
+build.colony.input<-function(wd=getwd(),name="Colony2.DAT"){
+
+colonyfile<-NULL
+
+cat("This function will construct a Colony input file.\n")
+cat(paste("It will be called",name,"and be placed in",wd,"...\n"))
+
+#  ! C, Dataset name, Length<51
+cat("Enter dataset name (must be <51 characters).\n")
+colonyfile$datasetname<-scan(n=1,what="character")
+write(paste(colonyfile$datasetname,"! C, Dataset name, Length<51"),name,append=FALSE)
+
+#  ! C, Main output file name, Length<21
+cat("Enter main output file name (must be <21 characters).\n")
+colonyfile$outfile<-scan(n=1,what="character")
+write(paste(colonyfile$outfile,"! C, Main output file name, Length<21"),name,append=TRUE)
+
+#  ! I, Number of offspring in the sample
+cat("Enter number of offspring in the sample.\n")
+colonyfile$n.offspring<-scan(n=1,what="integer")
+write(paste(colonyfile$n.offspring,"! I, Number of offspring in the sample"),name,append=TRUE)
+
+#  ! I, Number of loci
+cat("Enter number of loci.\n")
+colonyfile$n.loci<-scan(n=1,what="integer")
+write(paste(colonyfile$n.loci,"! I, Number of loci"),name,append=TRUE)
+
+#  ! I, Seed for random number generator
+cat("Enter seed for random number generator.\n")
+colonyfile$rseed<-scan(n=1,what="integer")
+write(paste(colonyfile$rseed,"! I, Seed for random number generator"),name,append=TRUE)
+
+#  ! B, 0/1=Not updating/updating allele frequency
+cat("Should allele frequency be updated?\n")
+switch(menu(c("Not updating allele frequency", "Updating allele frequency")) + 1,
+       cat("Nothing done\n"), colonyfile$updateallelefreq<-0, colonyfile$updateallelefreq<-1)
+write(paste(colonyfile$updateallelefreq,"! B, 0/1=Not updating/updating allele frequency"),name,append=TRUE)
+
+#  ! B, 0/1=Diploid species/HaploDiploid species
+cat("What kind of species is it?\n")
+switch(menu(c("Diploid species", "HaploDiploid species")) + 1,
+       cat("Nothing done\n"), colonyfile$speciestype<-0, colonyfile$speciestype<-1)
+write(paste(colonyfile$speciestype,"! B, 0/1=Diploid species/HaploDiploid species"),name,append=TRUE)
+
+#  ! B, 0/1=Polygamy/Monogamy for males & females
+cat("Are males monogamous or polygamous?\n")
+switch(menu(c("Males monogamous", "Males polygamous")) + 1,
+       cat("Nothing done\n"), colonyfile$malepolygamy<-0, colonyfile$malepolygamy<-1)
+
+cat("Are females monogamous or polygamous?\n")
+switch(menu(c("Females monogamous", "Females polygamous")) + 1,
+       cat("Nothing done\n"), colonyfile$femalepolygamy<-0, colonyfile$femalepolygamy<-1)
+write(paste(colonyfile$malepolygamy,colonyfile$femalepolygamy,"! B, 0/1=Polygamy/Monogamy for males & females"),name,append=TRUE)
+
+#  ! B,R,R : Use sibship prior, Y/N=1/0. If Yes, give mean paternal, maternal sibship size
+cat("Use sibship prior?\n")
+switch(menu(c("YES", "NO")) + 1,
+       cat("Nothing done\n"), colonyfile$sibship.prior<-1, colonyfile$sibship.prior<-0)
+
+cat("Paternal sibship size (enter \"0\" if you are not using a sibship prior).\n")
+colonyfile$sibship.prior.paternal<-scan(n=1,what="integer")
+
+cat("Maternal sibship size (enter \"0\" if you are not using a sibship prior).\n")
+colonyfile$sibship.prior.maternal<-scan(n=1,what="integer")
+write(paste(colonyfile$sibship.prior,colonyfile$sibship.prior.paternal,colonyfile$sibship.prior.maternal,"! B,R,R : Use sibship prior, Y/N=1/0. If Yes, give mean paternal, maternal sibship size"),name,append=TRUE)
+
+#  ! B, 0/1=Unknown/Known population allele frequency
+cat("Unknown/Known population allele frequency?\n")
+switch(menu(c("Unknown", "Known")) + 1,
+       cat("Nothing done\n"), colonyfile$knownAFreq<-0, colonyfile$knownAFreq<-1)
+write(paste(colonyfile$knownAFreq,"! B, 0/1=Unknown/Known population allele frequency"),name,append=TRUE)
+
+#  ! I, Number of runs
+cat("Number of runs.\n")
+colonyfile$n.runs<-scan(n=1,what="integer")
+write(paste(colonyfile$n.runs,"! I, Number of runs"),name,append=TRUE)
+
+#  ! I, Length of Run (1, 2, 3) = (Short, Medium, Long)
+cat("Length of run?\n")
+switch(menu(c("Short", "Medium","Long")) + 1,
+       cat("Nothing done\n"), colonyfile$runlength<-1, colonyfile$runlength<-2, colonyfile$runlength<-3)
+write(paste(colonyfile$runlength,"! I, Length of Run (1, 2, 3) = (Short, Medium, Long)"),name,append=TRUE)
+
+
+#  ! B, 0/1=Monitor method by Iterate#/Time in second
+cat("Monitor method by Iterate/Time in second?\n")
+switch(menu(c("Monitor by iterate", "Monitor by time in seconds")) + 1,
+       cat("Nothing done\n"), colonyfile$monitortype<-0, colonyfile$monitortype<-1)
+write(paste(colonyfile$monitortype,"! B, 0/1=Monitor method by Iterate#/Time in second"),name,append=TRUE)
+
+#  ! I, Monitor interval in Iterate#/Seconds
+cat("Monitor interval (in iterate number or seconds) depending on how you have chosen to monitor progress.\n")
+colonyfile$interval<-scan(n=1,what="integer")
+write(paste(colonyfile$interval,"! I, Monitor interval in Iterate#/Seconds"),name,append=TRUE)
+
+#  ! B, 0/1=Other platform/Windows execution
+cat("What platform is this to be executed on?\n")
+switch(menu(c("Microsoft Windows system", "Other system (e.g. Mac/Unix)")) + 1,
+       cat("Nothing done\n"), colonyfile$sys<-1, colonyfile$sys<-0)
+write(paste(colonyfile$sys,"! B, 0/1=Other platform/Windows execution"),name,append=TRUE)
+
+#  ! 1/0=Full-likelihood/pair-likelihood score method
+cat("Which likelihood method should be used?\n")
+switch(menu(c("Full likelihood", "Pairwise likelihood")) + 1,
+       cat("Nothing done\n"), colonyfile$likelihood.method<-0, colonyfile$likelihood.method<-1)
+write(paste(colonyfile$likelihood.method,"! 1/0=Full-likelihood/pair-likelihood score method"),name,append=TRUE)
+
+#  ! 1/2/3=low/medium/high precision
+cat("What level of precision should be used?\n")
+switch(menu(c("Low", "Medium","High")) + 1,
+       cat("Nothing done\n"), colonyfile$precision<-1, colonyfile$precision<-2, colonyfile$precision<-3)
+write(paste(colonyfile$precision,"! 1/2/3=low/medium/high precision"),name,append=TRUE)
+
+cat("Finished!")
+
+}    



More information about the Rcolony-commits mailing list