R/assignAttributes.R

Defines functions assignAttributes

Documented in assignAttributes

assignAttributes <- function(sif = sif, inputObj = inputObj, targets = targets, 
                             writeAttr = TRUE, fileName = "nodesAttributes.txt"){
  
  species <- unique(c(sif[, 1], sif[, 3]))
  
  nodesAttributes <- matrix(data = , nrow = length(species), ncol = 2)
  colnames(nodesAttributes) <- c("Species", "nodesP")
  
  nodesAttributes[, 1] <- species
  nodesAttributes[, 2] <- ""
  
  tt <- unique(unlist(targets))
  nodesAttributes[which(nodesAttributes[, 1]%in%tt), 2] <- "D"
  
  ss <- inputObj@IDmap$S.cc
  nodesAttributes[which(nodesAttributes[, 1]%in%ss), 2] <- "P"
  
  if(writeAttr){
    
    write.table(x = nodesAttributes, file = fileName, quote = FALSE, sep = "\t", row.names = FALSE)
    
  }
  
  return(nodesAttributes)
  
}
saezlab/PHONEMeS-ILP documentation built on June 21, 2022, 5:36 p.m.