Exemplo n.º 1
0
def printOutput(coreGraph, graphGenes):
    if not os.path.exists('networkOutput'):
        os.mkdir('networkOutput')
    #write graph in a .txt file
    time = dt.datetime.now()
    printTime = time.strftime("%Y%m%d%H%M%S")
    os.mkdir('networkOutput/' + printTime)
    print('Creating directory: \'networkOutput/' + printTime + '\'',
          flush=True)

    #Pearson correlation
    print('Calculating Pearson Correlation...', flush=True)
    #only on complete graph because all edges in core are in the complete graph
    pearsonComplete = ut.pearsonCorrelation(graphGenes, 'vv_exprdata_2.csv')

    #RETURN CORE
    nameFileCore = 'networkOutput/' + printTime + '/Core_Graph'
    coreGraph = sorted(coreGraph, key=ut.ord)
    ut.printCSV(nameFileCore, coreGraph)

    #RETURN GRAPH
    nameFileCompleteGraph = 'networkOutput/' + printTime + '/Complete_Graph'
    graphGenes = sorted(graphGenes, key=ut.ord)
    ut.printCSV(nameFileCompleteGraph, graphGenes)

    #DRAW GRAPH
    graphic.drawGraph(coreGraph, nameFileCore + '_Circular', pearsonComplete,
                      autoSaveImg, [], 1 - min_frel, False)
    graphic.drawGraph(coreGraph, nameFileCore, pearsonComplete, autoSaveImg,
                      [], 1 - min_frel, True)
    graphic.drawGraph(graphGenes, nameFileCompleteGraph + '_Circular',
                      pearsonComplete, autoSaveImg, list_Genes, 1 - min_frel,
                      False)
    graphic.drawGraph(graphGenes, nameFileCompleteGraph, pearsonComplete,
                      autoSaveImg, list_Genes, 1 - min_frel, True)
def printOutput(coreGraph, graphGenes):
    if not os.path.exists('networkOutput'):
        os.mkdir('networkOutput')
    #write graph in a .txt file
    time = dt.datetime.now()
    printTime = time.strftime("%Y%m%d%H%M%S")
    os.mkdir('networkOutput/' + printTime)
    print('Creating directory: \'networkOutput/' + printTime + '\'',
          flush=True)

    #Pearson correlation
    print('Calculating Pearson Correlation...', flush=True)
    #only on complete graph because all edges in core are in the complete graph
    pearsonComplete = ut.pearsonCorrelation(graphGenes, 'vv_exprdata_2.csv')

    #UPDATE NAME GENE
    f = open('import_doc/NewAnnotVitisnet3.csv', 'r')
    text = f.readlines()
    listLineName = []
    i = 1
    while i < len(text):
        listLineName.append(text[i].split(','))
        i += 1
    listBioNameUpdate = {}
    for l in listLineName:
        if l[3] != '':
            if l[3] not in listBioNameUpdate.values():
                listBioNameUpdate[l[0].upper()] = l[3]
            else:
                listBioNameUpdate[l[0].upper()] = l[3] + '_' + l[0].upper()
        elif l[2] != '':
            if l[2] not in listBioNameUpdate.values():
                listBioNameUpdate[l[0].upper()] = l[2]
            else:
                listBioNameUpdate[l[0].upper()] = l[2] + '_' + l[0].upper()
        else:
            listBioNameUpdate[l[0].upper()] = l[0].upper()
    f.close()

    i = 0
    while i < len(graphGenes):
        # tmp = graphGenes[i]
        # try:
        #     graphGenes[i] = (listBioNameUpdate[tmp[0]], listBioNameUpdate[tmp[1]], tmp[2])
        # except:
        #     try:
        #         graphGenes[i] = (tmp[0], listBioNameUpdate[tmp[1]], tmp[2])
        #     except:
        #         graphGenes[i] = (listBioNameUpdate[tmp[0]], tmp[1], tmp[2])
        tmp = pearsonComplete[i]
        try:
            pearsonComplete[i] = (listBioNameUpdate[tmp[0]],
                                  listBioNameUpdate[tmp[1]], tmp[2])
        except:
            try:
                pearsonComplete[i] = (tmp[0], listBioNameUpdate[tmp[1]],
                                      tmp[2])
            except:
                pearsonComplete[i] = (listBioNameUpdate[tmp[0]], tmp[1],
                                      tmp[2])
        i += 1

    #RETURN CORE
    nameFileCore = 'networkOutput/' + printTime + '/Core_Graph'
    coreGraph = sorted(coreGraph, key=ut.ord)
    ut.printCSV(nameFileCore, coreGraph)
    #update name of genes
    i = 0
    while i < len(coreGraph):
        tmp = coreGraph[i]
        try:
            coreGraph[i] = (listBioNameUpdate[tmp[0]],
                            listBioNameUpdate[tmp[1]], tmp[2])
        except:
            try:
                coreGraph[i] = (tmp[0], listBioNameUpdate[tmp[1]], tmp[2])
            except:
                coreGraph[i] = (listBioNameUpdate[tmp[0]], tmp[1], tmp[2])
        i += 1
    coreGraph = sorted(coreGraph, key=ut.ord)
    #draw graph in a image
    graphic.drawGraph('V', coreGraph, nameFileCore + '_Circular',
                      pearsonComplete, autoSaveImg, [], 1 - min_frel, False,
                      False, True)
    graphic.drawGraph('V', coreGraph, nameFileCore, pearsonComplete,
                      autoSaveImg, [], 1 - min_frel, False, True, True)

    #RETURN GRAPH
    nameFileCompleteGraph = 'networkOutput/' + printTime + '/Complete_Graph'
    graphGenes = sorted(graphGenes, key=ut.ord)
    ut.printCSV(nameFileCompleteGraph, graphGenes)
    #update name
    i = 0
    while i < len(graphGenes):
        tmp = graphGenes[i]
        try:
            graphGenes[i] = (listBioNameUpdate[tmp[0]],
                             listBioNameUpdate[tmp[1]], tmp[2])
        except:
            try:
                graphGenes[i] = (tmp[0], listBioNameUpdate[tmp[1]], tmp[2])
            except:
                graphGenes[i] = (listBioNameUpdate[tmp[0]], tmp[1], tmp[2])
        i += 1
    graphGenes = sorted(graphGenes, key=ut.ord)
    #draw graph in a image
    for k in list_Genes:
        list_Genes[list_Genes.index(k)] = listBioNameUpdate[k]
    graphic.drawGraph('V', graphGenes, nameFileCompleteGraph + '_Circular',
                      pearsonComplete, autoSaveImg, list_Genes, 1 - min_frel,
                      False, False, True)
    graphic.drawGraph('V', graphGenes, nameFileCompleteGraph, pearsonComplete,
                      autoSaveImg, list_Genes, 1 - min_frel, False, True, True)
Exemplo n.º 3
0
def printOutput(coreGraph, graphGenes, graphGenesOld):
    if not os.path.exists('networkOutput'):
        os.mkdir('networkOutput')
    #write graph in a .txt file
    time = dt.datetime.now()
    printTime = time.strftime("%Y%m%d%H%M%S")
    os.mkdir('networkOutput/' + printTime)
    print('Creating directory: \'networkOutput/' + printTime + '\'',
          flush=True)

    #Pearson correlation
    print('Calculating Pearson Correlation...', flush=True)
    #only on complete graph because all edges in core are in the complete graph
    if comprimeNode:
        fIsoEdges = open('networkOutput/' + printTime + '/isoformInEdge.txt',
                         'w')
        fIsoEdgesCSV = open(
            'networkOutput/' + printTime + '/isoformInEdge.csv', 'w')
        listEdgesOriginalGraph = [(a, b) for (a, b, c) in graphGenesOld]
        prePearson = {}
        for e in graphGenes:
            numberIsoformPerEdges = 0
            fIsoEdges.write('EDGE: ' + str(e[0]) + ' - ' + str(e[1]) +
                            '. Componed by:\n')
            fIsoEdgesCSV.write(str(e[0][1:]) + ',' + str(e[1][1:]))
            listIndex1 = indexDictGene(e[0], listBioNameUpdate.values())
            listIndex2 = indexDictGene(e[1], listBioNameUpdate.values())
            for k in [(a, b) for a in listIndex1 for b in listIndex2]:
                if k in listEdgesOriginalGraph:
                    fIsoEdges.write('> ' + str(listBioNameUpdate[k[0]]) +
                                    ' - ' + str(listBioNameUpdate[k[1]]) +
                                    '\n')
                    fIsoEdgesCSV.write(',' + str(listBioNameUpdate[k[0]]) +
                                       '-' + str(listBioNameUpdate[k[1]]))
                    numberIsoformPerEdges += 1
                    prePearson[k] = 1
            fIsoEdges.write('NUMBER OF EDGES: ' + str(numberIsoformPerEdges) +
                            '\n\n')
            fIsoEdgesCSV.write('\n')
        fIsoEdges.close()
        fIsoEdgesCSV.close()
        pearsonComplete = ut.pearsonCorrelation(
            list(prePearson.keys()), 'hgnc_cc_zero_filtered_mat.csv')
        i = 0
        while i < len(pearsonComplete):
            tmp = pearsonComplete[i]
            pearsonComplete[i] = ((re.search(
                r'@\w*', listBioNameUpdate[tmp[0]])).group(), (re.search(
                    r'@\w*', listBioNameUpdate[tmp[1]])).group(), tmp[2])
            i += 1
        pearsonComplete = ut.manageDuplicates(pearsonComplete)
    else:
        pearsonComplete = []  #TCGA
        if typeDB:
            pearsonComplete = ut.pearsonCorrelation(
                graphGenes, 'hgnc_cc_zero_filtered_mat.csv')  #FANTOM
        #update name of genes
        i = 0
        while i < len(coreGraph):
            tmp = coreGraph[i]
            if tmp[0] in listBioNameUpdate.keys(
            ) and tmp[1] in listBioNameUpdate.keys():
                coreGraph[i] = (listBioNameUpdate[tmp[0]],
                                listBioNameUpdate[tmp[1]], tmp[2])
            i += 1
        i = 0
        while i < len(graphGenes):
            tmp = graphGenes[i]
            if tmp[0] in listBioNameUpdate.keys(
            ) and tmp[1] in listBioNameUpdate.keys():
                graphGenes[i] = (listBioNameUpdate[tmp[0]],
                                 listBioNameUpdate[tmp[1]], tmp[2])
            if typeDB:
                tmp = pearsonComplete[i]  #FANTOM
                if tmp[0] in listBioNameUpdate.keys(
                ) and tmp[1] in listBioNameUpdate.keys():
                    pearsonComplete[i] = (listBioNameUpdate[tmp[0]],
                                          listBioNameUpdate[tmp[1]], tmp[2]
                                          )  #FANTOM
            else:
                if tmp[0] in listBioNameUpdate.keys(
                ) and tmp[1] in listBioNameUpdate.keys():
                    pearsonComplete[i] = (listBioNameUpdate[tmp[0]],
                                          listBioNameUpdate[tmp[1]], 1)  #TCGA
                else:  #TCGA
                    pearsonComplete.append((tmp[0], tmp[1], 1))  #TCGA
            i += 1

    print('Calculating Pearson Correlation complete', flush=True)

    #RETURN CORE
    nameFileCore = 'networkOutput/' + printTime + '/Core_Graph'
    coreGraph = sorted(coreGraph, key=ut.ord)
    ut.printCSV(nameFileCore, coreGraph)
    #draw graph in a image
    graphic.drawGraph('H', coreGraph, nameFileCore + '_Circular',
                      pearsonComplete, autoSaveImg, [], 1 - min_frel,
                      comprimeNode, False, typeDB)
    graphic.drawGraph('H', coreGraph, nameFileCore, pearsonComplete,
                      autoSaveImg, [], 1 - min_frel, comprimeNode, True,
                      typeDB)

    #RETURN GRAPH
    nameFileCompleteGraph = 'networkOutput/' + printTime + '/Complete_Graph'
    graphGenes = sorted(graphGenes, key=ut.ord)
    ut.printCSV(nameFileCompleteGraph, graphGenes)
    #draw graph in a image
    graphic.drawGraph('H', graphGenes, nameFileCompleteGraph + '_Circular',
                      pearsonComplete, autoSaveImg, list_Genes, 1 - min_frel,
                      comprimeNode, False, typeDB)
    graphic.drawGraph('H', graphGenes, nameFileCompleteGraph, pearsonComplete,
                      autoSaveImg, list_Genes, 1 - min_frel, comprimeNode,
                      True, typeDB)
def main():
    if len(sys.argv) >= 2:
        if sys.argv[1] == '--help':
            utex.printInfo()
        elif sys.argv[1] == '-vitis' and (sys.argv[2] == '-shared'
                                          or sys.argv[2] == '-rank'
                                          or sys.argv[2] == '-frel'
                                          or sys.argv[2] == '-pattern'):
            #read parameters
            cmd = readParameters(sys.argv)
            analyzeAllGene = False
            for f in cmd[1]:
                if f[0] == '-f':
                    global min_frel
                    min_frel = float(f[1])
                elif f[0] == '-a':
                    global autoSaveImg
                    autoSaveImg = True
                elif f[0] == '-c':
                    global completeGraph
                    completeGraph = True
                elif f[0] == '-e':
                    global printDiagram
                    printDiagram = True
                elif f[0] == '-u':
                    analyzeAllGene = True
            #read each file .csv, read first line, check if is our gene
            #If YES -> go further, If NO -> check next file
            #When we have read all expansion of all gene, manage lists
            #find common genes in the lists readed
            listCommonGenes = []
            edgesGraph = []
            listCouple = []
            if analyzeAllGene:
                #read files Vitis
                listFiles = utex.readFilesGenes(cmd[0][:], listCouple, cmd[1])
                listCouple = [[u[0] for u in listFiles]]
            else:
                listCouple = utex.readFiles(cmd[0][0])
                #read files Vitis
                listFiles = utex.readFilesGenes(cmd[0][1:], listCouple, cmd[1])

            #find common genes
            listCommonGenes = utex.findCommonGenes(listCouple, listFiles)
            if typeAnalyze == 0 or typeAnalyze == 1 or typeAnalyze == 3:  #frel or rank or pattern
                edgesGraph = utex.buildEdgesFrelRankPattern(
                    listCouple, listFiles)
            elif typeAnalyze == 2:  #shared
                edgesGraph = listCommonGenes[0]

            #print CSV with genes share between every gene of LGN
            createDir()
            utex.printCSV(edgesGraph, listCommonGenes[1], nameDir, typeAnalyze)
            #Draw the Venn diagram, Histogram
            if printDiagram:
                utex.printNumberVenn(listCommonGenes, nameDir)
                graphic.printVenn(listCommonGenes[1], listCouple, nameDir)
                if analyzeAllGene:
                    textFiles = utex.readFilesGenes(cmd[0][:], listCouple,
                                                    [('-f', min_frel)])
                else:
                    textFiles = utex.readFilesGenes(cmd[0][1:], listCouple,
                                                    [('-f', min_frel)])
                graphic.printHistogram(edgesGraph, textFiles, nameDir)

            pearsonComplete = []
            for l in edgesGraph:
                #Write genes to download and add the edges
                if completeGraph:
                    #write in a .txt the genes to download
                    listFileToRead = utex.nameAssociateGene(l)
                    if len(listFileToRead) > 0:
                        strToPrint = "To draw edges between associated genes please download lists in file \'" + nameDir + str(
                            edgesGraph.index(l)) + "/listToDownload.txt"
                        f = open(
                            nameDir + str(edgesGraph.index(l)) +
                            '/listToDownload.txt', 'w')
                        for g in listFileToRead:
                            f.write(str(g) + ', ')
                        f.close()
                        print(strToPrint, flush=True)
                        #wait until they gave the path
                        print('Please write the path of file zip:', flush=True)
                        path = input('>>')
                        print('FILE ZIP: ' + path, flush=True)
                        #read file and find edges between them
                        matrixGenes = vit.buildMatrixGenesVitis(
                            [('-f', min_frel)], [path])
                        print('Finding edges between genes...')
                        graphGenes = ut.manageDuplicates(
                            ut.buildGraph(matrixGenes))
                        print('Process complete')
                        #save new edges in the list
                        #create dir for each couple of genes
                        nameDirGenes = nameDir + str(edgesGraph.index(l)) + '/'
                        #Write file .csv
                        f = open(nameDirGenes + 'edges_graph' + '.csv', 'a')
                        f.write('Edges between discovered genes\n')
                        f.write('GeneA,rank,frel,GeneB\n')
                        i = 0
                        while i < len(graphGenes):
                            try:
                                rank = matrixGenes[[u[0] for u in matrixGenes
                                                    ].index(graphGenes[i][0])]
                                rank = rank[[v[1] for v in rank[1:]
                                             ].index(graphGenes[i][1])]
                            except:
                                rank = matrixGenes[[u[0] for u in matrixGenes
                                                    ].index(graphGenes[i][1])]
                                rank = rank[[v[1] for v in rank[1:]
                                             ].index(graphGenes[i][0])]
                            #f.write(str(listBioNameUpdate[graphGenes[i][0]])+','+str(rank[0])+','+str(listBioNameUpdate[graphGenes[i][1]])+','+str(graphGenes[i][2])+'\n')
                            f.write(
                                str(graphGenes[i][0]) + ',' + str(rank[0]) +
                                ',' + str(graphGenes[i][2]) + ',' +
                                str(graphGenes[i][1]) + '\n')
                            l.append((graphGenes[i][0], rank[0],
                                      graphGenes[i][1], graphGenes[i][2]))
                            i += 1
                        f.close()

                #Calculating pearson correlation for each edge
                print('Calculating Pearson correlation...')
                listForPearson = [(a, c, d) for (a, b, c, d) in l[1:]]
                pearsonComplete.append(
                    ut.pearsonCorrelation(listForPearson, 'vv_exprdata_2.csv'))
                print('Pearson Correlation done')
            #Draw graph
            graphic.printCommonGraph(edgesGraph, pearsonComplete, 1 - min_frel,
                                     nameDir, autoSaveImg)
        else:
            print('ERROR: wrong format')
            utex.printInfo()
Exemplo n.º 5
0
def main():
    if len(sys.argv) >= 2:
        if sys.argv[1] == '--help':
            utex.printInfo()
        elif (sys.argv[1] == '-fantom' or sys.argv[1] == '-TCGA' or sys.argv[1] == '-vitis') and (sys.argv[2] == '-shared' or sys.argv[2] == '-rank' or sys.argv[2] == '-frel'):
            #read parameters
            cmd = readParameters(sys.argv)
            for f in cmd[1]:
                if f[0] == '-f':
                    global min_frel
                    min_frel = float(f[1])
                elif f[0] == '-a':
                    global autoSaveImg
                    autoSaveImg = True
                elif f[0] == '-c':
                    global completeGraph
                    completeGraph = True
                elif f[0] == '-e':
                    global printDiagram
                    printDiagram = True
            #read each file .csv, read first line, check if is our gene
            #If YES -> go further, If NO -> check next file
            #When we have read all expansion of all gene, manage lists
            #TODO: Fix better. Take VIT as LGN in input
            try:
                listCouple = [[listBioNameUpdate[elem.strip().upper()] for elem in u] for u in utex.readFiles(cmd[0][0])]
            except:
                listCouple = utex.readFiles(cmd[0][0])
            #find common genes in the lists readed
            listCommonGenes = []
            isoformInEdge = []
            edgesGraph = []
            if TCGAdb or vitis:
                #read files if are TCGA or Vitis
                listFiles = [utex.manageBR(u) for u in utex.readFilesGenes(cmd[0][1:], listCouple, cmd[1], vitis, TCGAdb, listBioNameUpdate)]
                if vitis:
                    #upload name if is Vitis
                    for l in listFiles:
                        l[0] = listBioNameUpdate[l[0]]
                        i = 1
                        while i < len(l):
                            try:
                                l[i] = (l[i][0], listBioNameUpdate[l[i][1]], l[i][2])
                            except:
                                pass
                            i += 1
                #find common genes
                listCommonGenes = utex.findCommonGenes(listCouple, listFiles)
                if typeAnalyze == 0 or typeAnalyze == 1: #frel or rank
                    edgesGraph = utex.buildEdgesFrelRank(listCouple, listFiles)
                elif typeAnalyze == 2: #shared
                    edgesGraph = listCommonGenes[0]
            else:
                #read files if is Fantom
                listFiles = utex.readFilesGenes(cmd[0][1:-1], listCouple, cmd[1], vitis, TCGAdb, listBioNameUpdate)
                #upload name
                for l in listFiles:
                    l[0] = listBioNameUpdate[l[0]]
                    i = 1
                    while i < len(l):
                        l[i] = (l[i][0], listBioNameUpdate[l[i][1]], l[i][2])
                        i += 1
                #read which isoforms compone the edges
                isoformInEdge = utex.readFiles(cmd[0][-1])
                #find common genes
                listCommonGenes = utex.findCommonGenesFantom(listCouple, listFiles, isoformInEdge)
                if typeAnalyze == 0 or typeAnalyze == 1: #frel or rank
                    edgesGraph = utex.buildEdgesFrelRankIsoform(listCouple, listFiles, isoformInEdge)
                elif typeAnalyze == 2:
                    edgesGraph = listCommonGenes[0]

            #print CSV with genes share between every gene of LGN
            createDir()
            utex.printCSV(edgesGraph, listCommonGenes[1], nameDir, listBioNameUpdate)
            #Draw the Venn diagram, Histogram
            if printDiagram:
                utex.printNumberVenn(listCommonGenes, nameDir)
                graphic.printVenn(listCommonGenes[1], listCouple, nameDir)
                if TCGAdb or vitis:
                    textFiles = [utex.manageBR(u) for u in utex.readFilesGenes(cmd[0][1:], listCouple, [('-f',0.1)], vitis, TCGAdb, listBioNameUpdate)]
                    if vitis:
                        #upload name if is Vitis
                        for l in textFiles:
                            l[0] = listBioNameUpdate[l[0]]
                            i = 1
                            while i < len(l):
                                try:
                                    l[i] = (l[i][0], listBioNameUpdate[l[i][1]], l[i][2])
                                except:
                                    pass
                                i += 1
                else:
                    textFiles = utex.readFilesGenes(cmd[0][1:-1], listCouple, [('-f',0.1)], vitis, TCGAdb, listBioNameUpdate)
                    #upload name
                    for l in textFiles:
                        l[0] = listBioNameUpdate[l[0]]
                        i = 1
                        while i < len(l):
                            l[i] = (l[i][0], listBioNameUpdate[l[i][1]], l[i][2])
                            i += 1
                graphic.printHistogram(edgesGraph, textFiles, nameDir, TCGAdb or vitis, isoformInEdge)

            pearsonComplete = []
            for l in edgesGraph:
                #Write genes to download and add the edges
                if completeGraph:
                    #write in a .txt the genes to download
                    listFileToRead = utex.nameAssociateGene(l, listBioNameUpdate, TCGAdb)
                    if len(listFileToRead) > 0:
                        strToPrint = "To draw edges between associated genes please download lists in file \'"+nameDir+str(edgesGraph.index(l))+"/listToDownload.txt"
                        f = open(nameDir+str(edgesGraph.index(l))+'/listToDownload.txt', 'w')
                        for g in listFileToRead:
                            f.write(str(g) + ', ')
                        f.close()
                        print(strToPrint, flush=True)
                        #wait until they gave the path
                        print('Please write the path of file zip:', flush=True)
                        path = input('>>')
                        print('FILE ZIP: '+path, flush=True)
                        if vitis:
                            #read file and find edges between them
                            matrixGenes = vit.buildMatrixGenesVitis([('-f', min_frel)], [path])
                            print('Finding edges between genes...')
                            graphGenes = ut.manageDuplicates(ut.buildGraph(matrixGenes))
                            print('Process complete')
                            #save new edges in the list
                            nameF = utex.buildNamefile(l)
                            #create dir for each couple of genes
                            nameDirGenes = nameDir+str(edgesGraph.index(l))+'/'
                            #Write file .csv
                            nameF = nameF.replace("<", "_")
                            nameF = nameF.replace(">", "_")
                            f = open(nameDirGenes+'edges_graph'+'.csv', 'a')
                            f.write('Edges between discovered genes\n')
                            f.write('GeneA,rank,frel,GeneB\n')
                            i = 0
                            while i < len(graphGenes):
                                try:
                                    rank = matrixGenes[[u[0] for u in matrixGenes].index(graphGenes[i][0])]
                                    rank = rank[[v[1] for v in rank[1:]].index(graphGenes[i][1])]
                                except:
                                    rank = matrixGenes[[u[0] for u in matrixGenes].index(graphGenes[i][1])]
                                    rank = rank[[v[1] for v in rank[1:]].index(graphGenes[i][0])]
                                #f.write(str(listBioNameUpdate[graphGenes[i][0]])+','+str(rank[0])+','+str(listBioNameUpdate[graphGenes[i][1]])+','+str(graphGenes[i][2])+'\n')
                                f.write(str(graphGenes[i][0])+','+str(rank[0])+','+str(graphGenes[i][2])+','+str(graphGenes[i][1])+'\n')
                                l.append((listBioNameUpdate[graphGenes[i][0]], rank[0], listBioNameUpdate[graphGenes[i][1]], graphGenes[i][2]))
                                i += 1
                            f.close()
                        else:
                            pass
                            #TODO: find a way to download the lists of human

                #Calculating pearson correlation for each edge
                print('Calculating Pearson correlation '+str(utex.buildNamefile(l))+'...')
                if vitis: #TODO: manage Pearson Correlation if expansion with GT-001
                    #listForPearson = [((list(listBioNameUpdate.keys())[list(listBioNameUpdate.values()).index(a)]),(list(listBioNameUpdate.keys())[list(listBioNameUpdate.values()).index(c)]),d) for (a,b,c,d) in l[1:]]
                    #TODEL_GT-001
                    dictConvert = {}
                    for elem in l[1:]:
                        if elem[0] != 'GT-001':
                            dictConvert[(list(listBioNameUpdate.keys())[list(listBioNameUpdate.values()).index(elem[0])])] = elem[0]
                        if elem[2] != 'GT-001':
                            dictConvert[(list(listBioNameUpdate.keys())[list(listBioNameUpdate.values()).index(elem[2])])] = elem[2]
                    listForPearson = [((list(listBioNameUpdate.keys())[list(listBioNameUpdate.values()).index(a)]),(list(listBioNameUpdate.keys())[list(listBioNameUpdate.values()).index(c)]),d) for (a,b,c,d) in l[1:] if a != 'GT-001' and c != 'GT-001']
                    tmp = utex.manageBR(ut.pearsonCorrelation(listForPearson, 'vv_exprdata_2.csv'))
                    #pearson = [(listBioNameUpdate[u],listBioNameUpdate[v],p) for (u,v,p) in tmp]
                    #TODEL_GT-001
                    #pearson = [(listBioNameUpdate[u],listBioNameUpdate[v],p) for (u,v,p) in tmp]+[((list(listBioNameUpdate.keys())[list(listBioNameUpdate.values()).index(a)]),(list(listBioNameUpdate.keys())[list(listBioNameUpdate.values()).index(c)]),1) for (a,b,c,d) in l[1:] if a == 'GT-001' or c == 'GT-001']
                    pearson = [(dictConvert[[w for w in u.split('<BR>') if w in dictConvert.keys()][0]],dictConvert[[w for w in v.split('<BR>') if w in dictConvert.keys()][0]],p) for (u,v,p) in tmp]+[((list(listBioNameUpdate.keys())[list(listBioNameUpdate.values()).index(a)]),(list(listBioNameUpdate.keys())[list(listBioNameUpdate.values()).index(c)]),1) for (a,b,c,d) in l[1:] if a == 'GT-001' or c == 'GT-001']
                    pearsonComplete.append(pearson)
                else:
                    listForPearson = [(a,c,d) for (a,b,c,d) in l[1:]]
                    pearsonComplete.append(listForPearson)
                    #TODO: calculate pearson correlation for human
                print('Pearson Correlation done')

            #Draw graph
            graphic.printCommonGraph(edgesGraph, pearsonComplete, 1-min_frel, nameDir, autoSaveImg, listBioNameUpdate)
        else:
            print('ERROR: wrong format')
            utex.printInfo()