Ejemplo n.º 1
0
def predict(path, weightPath1, weightPath2, method):
    
    predictionPath = "predictions.txt"
    
    predictions = []    
    limit = 500
    
    # load
    weight1 = np.load(weightPath1)
    weight2 = np.load(weightPath2)
    
    method = method.lower()
    if(method == 'fasta'):
        proteins = fileUtils.readFasta(path)
        
        for proteinId in range(len(proteins)):  
            
            sequences = sequenceUtils.openReadingFrames(proteins[proteinId])        
            
            for pos in range(len(sequences)):
                
                 # lav sekvens om til binær
                inputLayer = sequenceUtils.createInputLayer(sequences[pos])
                
                # forward
                outputLayer = forward(inputLayer, weight1, weight2)[1]
                outputLayer = logTransform.invTransform(outputLayer)                
                
                if(outputLayer <= limit):
                    # plus one, since both are zero indexed
                    predictions.append([proteinId + 1, pos + 1])
    
    
                
    np.savetxt(predictionPath, np.array(predictions), fmt = '%d', delimiter = '\t')
    print("There is {} predicted epitopes.".format(len(predictions)))   
Ejemplo n.º 2
0
machine0 = []
# all affinity predictions
machine1 = []
# predicted epitopes
machine = [[], [], []]
weight1 = np.load("weight1.npy")
weight2 = np.load("weight2.npy")


# predict

allSequences = [[], [], [], [], [], [], [], [], []]

for proteinId in range(len(hivProteins)):  
    
    allSequences[proteinId] = sequenceUtils.openReadingFrames(hivProteins[proteinId])        
    
    for pos in range(len(allSequences[proteinId])):
        
        ## machine
        # save sequence
        machine0.append(allSequences[proteinId][pos])        
        
        # lav sekvens om til binær
        inputLayer = sequenceUtils.createInputLayer(allSequences[proteinId][pos])
        
        # forward
        outputLayer = forward(inputLayer, weight1, weight2)[1]
        outputLayer = logTransform.invTransform(outputLayer)                

        # save prediction