targetfile <- commandArgs(trailingOnly=TRUE)[1]
replacement.table <- commandArgs(trailingOnly=TRUE)[2]
gene.names <- commandArgs(trailingOnly=TRUE)[3]
outdir <- commandArgs(trailingOnly=TRUE)[4]

likelihoods <- read.table(targetfile)
colnames(likelihoods) <- trimws(as.character(read.table(replacement.table, sep=';')[,2]))
rownames(likelihoods) <- c(readLines(gene.names), 'root')

write.table(likelihoods, outdir, quote=FALSE)
