Commit 4a92031c authored by Simon Gosset's avatar Simon Gosset
Browse files

ajout de prot dans thesaurus

parent 81cd1ae5
......@@ -946,7 +946,7 @@ finish <- function(network, network2, r.s.i, r.u.l, UpDate, selected.database4,
# Mise a jour des bases de donnees a partir des corrections effectuees sur le reseau (automatiques et manuelles)
if (UpDate == 'yes') {
update_db(selected.database4, resume, os, Os, organism.path,cor.manuel)
update_db(selected.database4, resume, os, Os, organism.path,cor.manuel,Th)
}
### Les bases de donnees sont corrigees en fonction des modifications apportees sur le reseau ###
......@@ -961,14 +961,18 @@ finish <- function(network, network2, r.s.i, r.u.l, UpDate, selected.database4,
}
update_db <- function(db, resume, os, Os, organism.path,cor.manuel = NULL) {
update_db <- function(db, resume, os, Os, organism.path,cor.manuel = NULL, Th) {
# Recuperation des bases et de la liste des modifications a approter
database <- as.matrix(db)
resume2 <- as.matrix(resume)
thesaurus <- read.delim(file = Th, header = T, sep = "\t")
modif_thesaurus = FALSE
# S'il y a eu des modifications dans le reseau on fait les memes dans les bases
if (dim(resume2)[1] > 0 || dim(cor.manuel)[1] > 0) {
if (dim(resume2)[1] > 0 || !is.null(cor.manuel)) {
cat('\n>Update')
cat('\n')
......@@ -981,11 +985,26 @@ update_db <- function(db, resume, os, Os, organism.path,cor.manuel = NULL) {
if (dim(cor.manuel)[1] > 0) {
if (!is.null(cor.manuel)) {
for (j in 1:dim(cor.manuel)[1]) {
ind_thesaurus = unique(grep(unlist(cor.manuel[j,2]), thesaurus[,1]))
if(length(ind_thesaurus) == 0) {
row = cbind(unlist(cor.manuel[j,2]),NA,unlist(cor.manuel[j,6]), NA,unlist(cor.manuel[j,4]), NA,NA,"0","FALSE","FALSE")
colnames(row) = colnames(thesaurus)
thesaurus = rbind(thesaurus, row)
modif_thesaurus = TRUE
}
indA = unique(grep(cor.manuel[j,1], database[,1]))
indB = unique(grep(cor.manuel[j,1], database[,2]))
......@@ -1038,6 +1057,15 @@ update_db <- function(db, resume, os, Os, organism.path,cor.manuel = NULL) {
}
}
# Creation d'un repertoire pour les bases mises a jour
if(modif_thesaurus == TRUE) {
new_path = gsub(x=Th, pattern = ".txt", replacement = "_updated.txt")
write.table(thesaurus, file = new_path, append = F, row.names = F, quote = F, col.names = T, sep = "\t")
}
tax <- os
setwd(organism.path)
if (file.exists('Updated_databases') == F) dir.create('Updated_databases')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment