<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import sys
import os
import networkx as nx
import GeneDirectedPathFinder2 as g

def Read_In_File(disease, graph):
    filename=disease
    
    if filename.find('.txt')==-1:
	
	filename+='.txt'  
	
    filename="../data/"+filename
    
    listOfGenes=g.Read_Genes(filename)
    
    tempListOfGenes=[]
    for gene in listOfGenes:
	
	if gene in graph.nodes():
	    
	    tempListOfGenes.append(gene.strip("\r"))
	
	else:
	    
	    print gene.upper(), "is not in the gene network"
	       
    return tempListOfGenes

def Create_Test_List_Manually(graph):
    
    tempListOfGenes=[]
    
    print("\nEnter each gene known to connect to your disease. \nEnter \"done\" to start the search.\n")
    
    isDone = False
    
    while isDone == False:
    
        x = raw_input("Input gene: ")
        
        if x=="done":
            
            if len(tempListOfGenes) &lt;= 1:
                
                print("\nYou did not input enough genes to map. Please enter at least two genes.\n")
            
            else:
                isDone=True
	    
        else:
            if x != 'done':
		
		if x.upper() in graph.nodes():
		    
		    tempListOfGenes.append(x)
		    
		else:
		    
		    print x.upper(), "is not in the gene network"
	    
    print("\n")
    
    tempListOfGenes.sort()
    
    return tempListOfGenes


def Create_Test_List(graph):
    
    tempListOfGenes= []
    worked=False
    howToRead=raw_input("How would you like to input your list? (file/manual): ")

    if howToRead == 'file' or howToRead == 'f' or howToRead=='File':
        disease=raw_input("Enter the name of the file you would like to read: ")
        tempListOfGenes = Read_In_File(disease, graph)
	worked=True
	
    if howToRead == 'manual' or howToRead == 'm' or howToRead == 'Manual':
        
        tempListOfGenes=Create_Test_List_Manually(graph)
	worked=True
    
    if worked==False:
    
        print "That was not an option. Please enter either file or manual.\n"
        Create_Test_List()
    
    return map(lambda x: x.upper(), tempListOfGenes)</pre></body></html>