bpStat1 <- vector("list", length=length(y2hSysGW))
for(i in 1:length(y2hSysGW)){
    bpStat1[[i]] <- genBPGraph(y2h[i], nonWeighted=TRUE, homodimer=FALSE)
}
names(bpStat1) <- names(y2hSysGW)

aggInteraction <- sapply(bpStat1, sum)

bpStat2 <- vector("list", length=length(y2hSysGW))
for(i in 1:length(y2hSysGW)){
    bpStat2[[i]] <- genBPGraph(y2h[i], sym=TRUE, nonWeighted=TRUE, homodimer=FALSE)
}
names(bpStat2) <- names(y2hSysGW)

symInteraction <- sapply(bpStat2, sum)

bpStat3 <- vector("list", length=length(y2hSysGW))
for(i in 1:length(y2hSysGW)){
    bpStat3[[i]] <- genBPGraph(y2h[i], inNuc=TRUE, nonWeighted=TRUE, homodimer=FALSE)
}
names(bpStat3) <- names(y2hSysGW)

nucInteraction <- sapply(bpStat3, sum)

bpStat4 <- vector("list", length=length(y2hSysGW))
for(i in 1:length(y2hSysGW)){
    bpStat4[[i]] <- genBPGraph(y2h[i], sym=TRUE, inNuc=TRUE, nonWeighted=TRUE, homodimer=FALSE)
}
names(bpStat4) <- names(y2hSysGW)

symNucInteraction <- sapply(bpStat4, sum)

cbind(cbind(cbind(aggInteraction, symInteraction), nucInteraction), symNucInteraction)

symInteraction <- symInteraction/aggInteraction
nucInteraction <- nucInteraction/aggInteraction
symNucInteraction <- symNucInteraction/aggInteraction

cbind(cbind(cbind(aggInteraction, symInteraction), nucInteraction), symNucInteraction)

###########

bpStat11 <- vector("list", length=length(y2hSysGW))
for(i in 1:length(y2hSysGW)){
    bpStat11[[i]] <- genBPGraph(y2hSysGW[i], nonWeighted=TRUE, homodimer=FALSE)
}
names(bpStat11) <- names(y2hSysGW)

aggInteraction11 <- sapply(bpStat11, sum)

bpStat22 <- vector("list", length=length(y2hSysGW))
for(i in 1:length(y2hSysGW)){
    bpStat22[[i]] <- genBPGraph(y2hSysGW[i], sym=TRUE, nonWeighted=TRUE, homodimer=FALSE)
}
names(bpStat22) <- names(y2hSysGW)

symInteraction22 <- sapply(bpStat22, sum)

bpStat33 <- vector("list", length=length(y2hSysGW))
for(i in 1:length(y2hSysGW)){
    bpStat33[[i]] <- genBPGraph(y2hSysGW[i], inNuc=TRUE, nonWeighted=TRUE, homodimer=FALSE)
}
names(bpStat33) <- names(y2hSysGW)

nucInteraction33 <- sapply(bpStat33, sum)

bpStat44 <- vector("list", length=length(y2hSysGW))
for(i in 1:length(y2hSysGW)){
    bpStat44[[i]] <- genBPGraph(y2hSysGW[i], sym=TRUE, inNuc=TRUE, nonWeighted=TRUE, homodimer=FALSE)
}
names(bpStat44) <- names(y2hSysGW)

symNucInteraction44 <- sapply(bpStat44, sum)

cbind(cbind(cbind(aggInteraction11, symInteraction22), nucInteraction33), symNucInteraction44)

symInteraction22 <- symInteraction22/aggInteraction11
nucInteraction33 <- nucInteraction33/aggInteraction11
symNucInteraction44 <- symNucInteraction44/aggInteraction11

cbind(cbind(cbind(aggInteraction11, symInteraction22), nucInteraction33), symNucInteraction44)








%%%%%%%%%%%%%%%%%%%%%%

preyBait <- function(matL){

    denom <- lapply(matL,rowSums)
    hits <- lapply(matL, function(x){preyL <- list()
                                     
                                     if(nrow(x)>0){
                                         prot <- colnames(x)
                                         for(i in 1:nrow(x)){
                                             if(length(prot[which(x[i,]==1)]) != 0){
                                                 preyL[[i]] <- prot[which(x[i,]==1)]
                                             }
                                             else{preyL[[i]] <- character(0)}

                                         }
                                     }
                                     names(preyL) <- rownames(x)
                                     preyL})
    hits2 <- hits
    
    if(length(hits)>0){
        for(i in 1:length(hits)){
            if(length(hits[[i]])>0){
                for(j in 1:length(hits[[i]])){
                    if(length(hits[[i]][[j]])>0){
                        for(k in 1:length(hits[[i]][[j]])){
                            if(matL[[i]][hits[[i]][[j]][k], names(hits[[i]])[j]] == 1){hits2[[i]][[j]][k] = 1}
                            else{hits2[[i]][[j]][k] = 0}
                        }
                        #print(hits2[[i]][[j]])
                        mode(hits2[[i]][[j]])="numeric"
                        #print(hits2[[i]][[j]])
                        #print("------------------")
                    }
                }
            }
        }
    }
    
    ratio <- denom

    if(length(hits2)>0){
        for(i in 1:length(hits2)){
            if(length(hits2[[i]])>0){
                for(j in 1:length(hits2[[i]])){
                    if(length(hits2[[i]][[j]])>0){
                        ratio[[i]][[j]] <- sum(hits2[[i]][[j]])/(denom[[i]][[j]])
                    }
                }
            }
        }
    }
    
    ratio

}