output_index <- ""
resultsList <- list()
i <- 0
methodN <- c()

dofabia <- TRUE
dobeagle <- TRUE
doplink <- TRUE
dogermline <- TRUE
dodash <- TRUE
dorelate <- FALSE
domcmc <- FALSE



resultsAll <- c()

rowNN <- c()

Headermax <- c("IBDtrueP","IBDfalseN","IBDfalseP","IBDtrueN","IBDsensitivity","IBDspecifity","IBDFDR","IBDFPR","IBDaccuracy","IBDF1","IBDMatthews",
"IBDtruePSample","IBDfalseNSample","IBDfalsePSample","IBDtrueNSample","IBDsensitivitySample","IBDspecifitySample","IBDFDRSample","IBDFPRSample","IBDaccuracySample","IBDF1Sample","IBDMatthewsSample",
"IBDtruePSnps","IBDfalseNSnps","IBDfalsePSnps","IBDtrueNSnps","IBDsensitivitySnps","IBDspecifitySnps","IBDFDRSnps","IBDFPRSnps","IBDaccuracySnps","IBDF1Snps","IBDMatthewsSnps")

           
if (dofabia) {
fabiaresM <- read.table(file= paste("fabiares",output_index,".txt",sep=""),skip=1)

fabiaHeader <- c("runNumber","restarts","numberIBDs",
"truePSample","falseNSample","falsePSample","trueNSample","sensitivitySample","specifitySample","FDRSample","FPRSample","accuracySample","F1Sample","MatthewsSample",
"truePSnps","falseNSnps","falsePSnps","trueNSnps","sensitivitySnps","specifitySnps","FDRSnps","FPRSnps","accuracySnps","F1Snps","MatthewsSnps",
"trueP","falseN","falseP","trueN","sensitivity","specifity","FDR","FPR","accuracy","F1","Matthews")
colnames(fabiaresM) <- fabiaHeader

fabiaMeans <- colMeans(fabiaresM)

resultsAll <-  rbind(resultsAll,fabiaMeans[(-1:-3)])

rowNN <- c(rowNN,"FABIA")



}


beagleHeader <- c("runNumber",
"truePSample","falseNSample","falsePSample","trueNSample","sensitivitySample","specifitySample","FDRSample","FPRSample","accuracySample","F1Sample","MatthewsSample",
"truePSnps","falseNSnps","falsePSnps","trueNSnps","sensitivitySnps","specifitySnps","FDRSnps","FPRSnps","accuracySnps","F1Snps","MatthewsSnps",
"trueP","falseN","falseP","trueN","sensitivity","specifity","FDR","FPR","accuracy","F1","Matthews")


if (dobeagle) {

beagleres1M <- read.table(file=paste("beagleres1",output_index,".txt",sep=""),skip=1)

  
colnames(beagleres1M) <- beagleHeader

beagleres2M <- read.table(file=paste("beagleres2",output_index,".txt",sep=""),skip=1)

colnames(beagleres2M) <- beagleHeader

beagle1Means <- colMeans(beagleres1M)

beagle2Means <- colMeans(beagleres2M)

resultsAll <-  rbind(resultsAll,beagle1Means[-1],beagle2Means[-1])

rowNN <- c(rowNN,"BEAGLE 1","BEAGLE 2")
}



if (doplink) {
plinkresM <- read.table(file=paste("plinkres",output_index,".txt",sep=""),skip=1)

plinkHeader <- beagleHeader

colnames(plinkresM) <- plinkHeader

plinkMeans <- colMeans(plinkresM)

resultsAll <-  rbind(resultsAll,plinkMeans[-1])

rowNN <- c(rowNN,"PLINK")

}

if (dogermline) {

germlineres1M <- read.table(file=paste("germlineres1",output_index,".txt",sep=""),skip=1)

germlineHeader <- beagleHeader

colnames(germlineres1M) <- germlineHeader

germlineres2M <- read.table(file=paste("germlineres2",output_index,".txt",sep=""),skip=1)

colnames(germlineres2M) <- germlineHeader
germline1Means <- colMeans(germlineres1M)

germline2Means <- colMeans(germlineres2M)

resultsAll <-  rbind(resultsAll,germline1Means[-1],germline2Means[-1])

rowNN <- c(rowNN,"GERMLINE 1","GERMLINE 2")
}


if (dodash) {
dashresM <- read.table(file= paste("dashres",output_index,".txt",sep=""),skip=1)

dashHeader <- c("runNumber","numberClusters",
"truePSample","falseNSample","falsePSample","trueNSample","sensitivitySample","specifitySample","FDRSample","FPRSample","accuracySample","F1Sample","MatthewsSample",
"truePSnps","falseNSnps","falsePSnps","trueNSnps","sensitivitySnps","specifitySnps","FDRSnps","FPRSnps","accuracySnps","F1Snps","MatthewsSnps",
"trueP","falseN","falseP","trueN","sensitivity","specifity","FDR","FPR","accuracy","F1","Matthews")               

colnames(dashresM) <- dashHeader

dashMeans <- colMeans(dashresM)

resultsAll <-  rbind(resultsAll,dashMeans[(-1:-2)])
rowNN <- c(rowNN,"DASH")


}

#relateresM <- read.table(file="relateres.txt",skip=1)

#mcmcresM <- read.table(file="mcmcres.txt",skip=1)

rownames(resultsAll) <- rowNN




write.table(resultsAll,file= paste("resultsAll",output_index,".txt",sep=""),sep="\t")