[Rcolony-commits] r67 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 5 15:28:17 CET 2011


Author: jonesor
Date: 2011-01-05 15:28:17 +0100 (Wed, 05 Jan 2011)
New Revision: 67

Modified:
   pkg/R/build.colony.input.R
Log:
Bug fix (spotted by Jean-Sebastien Moore)

Modified: pkg/R/build.colony.input.R
===================================================================
--- pkg/R/build.colony.input.R	2010-09-25 17:08:14 UTC (rev 66)
+++ pkg/R/build.colony.input.R	2011-01-05 14:28:17 UTC (rev 67)
@@ -350,6 +350,7 @@
 #######################################################
 #Import candidate FATHERS file
 #######################################################
+if(colonyfile$n.father!=0){
 while(length(colonyfile$fathersPATH)==0){
 cat("Provide the path to the candidate FATHERS file.\n\n\n")
 flush.console()
@@ -372,6 +373,11 @@
 flush.console();
 warning(paste("The number of defined FATHERS ","(", colonyfile$n.father,") does not equal the number of FATHERS provided in the file selected (", dim(colonyfile$fathers)[1],").\n\n",sep=""),immediate.=TRUE)}
 }
+}else{
+colonyfile$fathersPATH<-NA
+colonyfile$delim.for.fathers<-""
+colonyfile$fathers<-matrix(nrow=1,ncol=1)
+}
 
 #######################################################
 #MOTHERS - probability of inclusion in candidate set
@@ -404,6 +410,7 @@
 #######################################################
 #Import candidate MOTHERS
 #######################################################
+if(colonyfile$n.mother!=0){
 while(length(colonyfile$mothersPATH)==0){
 cat("Provide the path to the candidate MOTHERS file.\n\n\n")
 flush.console()
@@ -425,17 +432,26 @@
 flush.console();
 warning(paste("The number of defined MOTHERS ","(", colonyfile$n.mother,") does not equal the number of MOTHERS provided in the file selected (", dim(colonyfile$mothers)[1],").\n\n",sep=""),immediate.=TRUE)}
 }
+}else{
+colonyfile$mothersPATH<-NA
+colonyfile$delim.for.mothers<-""
+colonyfile$mothers<-matrix(nrow=1,ncol=1)
+}
 
 write(paste(colonyfile$fatherprob,colonyfile$motherprob,"!Probabilities that the father and mother of an offspring included in candidates"),name,append=TRUE)
 write(paste(colonyfile$n.father,colonyfile$n.mother,"!Numbers of candidate males and females"),name,append=TRUE)
 write("",name,append=TRUE)
 
+if(colonyfile$n.father!=0){
 colonyfile$fathers[,1+dim(colonyfile$fathers)[2]]<-c("!Candidate M ID and genotypes",rep("",dim(colonyfile$fathers)[1]-1))
 write.table(colonyfile$fathers,name,append=TRUE,quote=FALSE,row.names=FALSE,col.names=FALSE)
+}
 write("",name,append=TRUE)
 
+if(colonyfile$n.mother!=0){
 colonyfile$mothers[,1+dim(colonyfile$mothers)[2]]<-c("!Candidate F ID and genotypes",rep("",dim(colonyfile$mothers)[1]-1))
 write.table(colonyfile$mothers,name,append=TRUE,quote=FALSE,row.names=FALSE,col.names=FALSE)
+}
 write("",name,append=TRUE)
 
 #######################################################
@@ -494,7 +510,6 @@
 	colonyfile$paternal.sibships[i,1]<-sum(as.vector(is.na(colonyfile$paternal.sibships[i,])==FALSE))-1
 	}}
 
-#Is this still OK?
 #Check the data
 
 #1) DO THE NUMBER OF SIBSHIPS/PATERNITIES MATCH UP WITH THE DATA PROVIDED?
@@ -1023,18 +1038,22 @@
 write.table(temp1,"OffspringGenotype.txt",row.names=FALSE,quote=FALSE,col.names=TRUE)
 
 #MaleGenotype.txt
+if(colonyfile$n.father!=0){
 temp1<-as.data.frame(colonyfile$fathers)
 temp1<-temp1[,1:dim(temp1)[2]-1]
 n<-(dim(temp1)[2])-1
 names(temp1)<-c("Male",paste(paste("Marker",rep(1:(n/2),each=2),sep=""),rep(1:2,(n/2)),sep="-"))
 write.table(temp1,"MaleGenotype.txt",row.names=FALSE,quote=FALSE,col.names=TRUE)
+}
 
+if(colonyfile$n.mother!=0){
 #FemaleGenotype.txt
 temp1<-as.data.frame(colonyfile$mothers)
 temp1<-temp1[,1:dim(temp1)[2]-1]
 n<-(dim(temp1)[2])-1
 names(temp1)<-c("Female",paste(paste("Marker",rep(1:(n/2),each=2),sep=""),rep(1:2,(n/2)),sep="-"))
 write.table(temp1,"FemaleGenotype.txt",row.names=FALSE,quote=FALSE,col.names=TRUE)
+}
 
 #KnownPaternalDyads.txt
 if(length(colonyfile$paternal.dyads)>0){
@@ -1088,4 +1107,4 @@
 
 #This could be useful at some point.
 return(colonyfile)
-}    
\ No newline at end of file
+}    



More information about the Rcolony-commits mailing list