Ejemplo n.º 1
0
    def __constructSolvers__(self, coefFiles):
	solvers = {}

	for f in coefFiles:
		currCatName = AApairwise.__catPattern.search(f).group(1)
		currFile = open(f, "r")
            	currDat = currFile.readlines()
            	currFile.close()
		solvers[currCatName] = aaProbSolver(currDat)

	return solvers
Ejemplo n.º 2
0
    def __constructSolvers__(self, coefFiles):
        solvers = {}

        for f in coefFiles:
            currCatName = AApairwise.__catPattern.search(f).group(1)
            currFile = open(f, "r")
            currDat = currFile.readlines()
            currFile.close()
            solvers[currCatName] = aaProbSolver(currDat)

        return solvers
Ejemplo n.º 3
0
    def __init__(self, pwFile):
        #init solvers
        ## first order solver
        fFirstOrder = open(firstOrderCoefFile, "r")
        firstOrderCoefs = fFirstOrder.readlines()
        fFirstOrder.close()
        self.firstOrderSolver = aaProbSolver(firstOrderCoefs)

	## second order solvers
	### first conditioned on second
	self.firstCondSecondSolvers = self.__constructSolvers__(firstCondSecondFiles)
	### second conditioned on first
	self.secondCondFirstSolvers = self.__constructSolvers__(secondCondFirstFiles)

        self.aaDict = dict()
        self.saDict = dict()
        self.firstPosDict = dict()
        self.secondPosDict = dict()
        self.pairDict = dict()
        self.posList = []

        fInput = open(pwFile, "r")
        allLines = fInput.readlines()
        fInput.close()
        for line in allLines:
            tmpLine = line.split()
            firstAA = tmpLine[4]
            secondAA = tmpLine[5]
            firstPos = tmpLine[6]
            secondPos = tmpLine[7]
            firstSA = tmpLine[9]
            secondSA = tmpLine[13]
            #float
            invSD = 1.0/(float(secondPos) - float(firstPos))
            invTD = 1.0/float(tmpLine[3])

            # fill aaDict and saDict
            if firstPos not in self.aaDict.keys():
                self.aaDict[firstPos] = firstAA
                self.saDict[firstPos] = firstSA
            if secondPos not in self.aaDict.keys():
                self.aaDict[secondPos] = secondAA
                self.saDict[secondPos] = secondSA
            
            # fill pos Dicts
            if firstPos not in self.firstPosDict.keys():
                self.firstPosDict[firstPos] = []
                self.firstPosDict[firstPos].append(secondPos)
            else:
                if secondPos not in self.firstPosDict[firstPos]:
                    self.firstPosDict[firstPos].append(secondPos)

            if secondPos not in self.secondPosDict.keys():
                self.secondPosDict[secondPos] = []
                self.secondPosDict[secondPos].append(firstPos)
            else:
                if firstPos not in self.secondPosDict[secondPos]:
                    self.secondPosDict[secondPos].append(firstPos)

            #fill in pairDict
            currPair = (firstPos, secondPos)
            self.pairDict[currPair] = map(float, ["1", firstSA, secondSA, invSD, invTD])

        self.posList = sorted(map(int, self.aaDict.keys()))
Ejemplo n.º 4
0
    def __init__(self, pwFile):
        #init solvers
        ## first order solver
        fFirstOrder = open(firstOrderCoefFile, "r")
        firstOrderCoefs = fFirstOrder.readlines()
        fFirstOrder.close()
        self.firstOrderSolver = aaProbSolver(firstOrderCoefs)

        ## second order solvers
        ### first conditioned on second
        self.firstCondSecondSolvers = self.__constructSolvers__(
            firstCondSecondFiles)
        ### second conditioned on first
        self.secondCondFirstSolvers = self.__constructSolvers__(
            secondCondFirstFiles)

        self.aaDict = dict()
        self.saDict = dict()
        self.firstPosDict = dict()
        self.secondPosDict = dict()
        self.pairDict = dict()
        self.posList = []

        fInput = open(pwFile, "r")
        allLines = fInput.readlines()
        fInput.close()
        for line in allLines:
            tmpLine = line.split()
            firstAA = tmpLine[4]
            secondAA = tmpLine[5]
            firstPos = tmpLine[6]
            secondPos = tmpLine[7]
            firstSA = tmpLine[9]
            secondSA = tmpLine[13]
            #float
            invSD = 1.0 / (float(secondPos) - float(firstPos))
            invTD = 1.0 / float(tmpLine[3])

            # fill aaDict and saDict
            if firstPos not in self.aaDict.keys():
                self.aaDict[firstPos] = firstAA
                self.saDict[firstPos] = firstSA
            if secondPos not in self.aaDict.keys():
                self.aaDict[secondPos] = secondAA
                self.saDict[secondPos] = secondSA

            # fill pos Dicts
            if firstPos not in self.firstPosDict.keys():
                self.firstPosDict[firstPos] = []
                self.firstPosDict[firstPos].append(secondPos)
            else:
                if secondPos not in self.firstPosDict[firstPos]:
                    self.firstPosDict[firstPos].append(secondPos)

            if secondPos not in self.secondPosDict.keys():
                self.secondPosDict[secondPos] = []
                self.secondPosDict[secondPos].append(firstPos)
            else:
                if firstPos not in self.secondPosDict[secondPos]:
                    self.secondPosDict[secondPos].append(firstPos)

            #fill in pairDict
            currPair = (firstPos, secondPos)
            self.pairDict[currPair] = map(
                float, ["1", firstSA, secondSA, invSD, invTD])

        self.posList = sorted(map(int, self.aaDict.keys()))
Ejemplo n.º 5
0
import glob
import math

#'L' is the reference codon                                                                           
aaList = ['A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y']

#coef file and folders                                                                                
#on desktop
#firstOrderCoefFile = '/home/kuangyu/workspace/aaCodonProbPred/coefs/aa_sa_coef.txt'
#on mac
firstOrderCoefFile = '/Users/kwang2/Documents/workspace/aaCodonProbPred/coefs/aa_sa_coef.txt'

fFirstOrder = open(firstOrderCoefFile, "r")
firstOrderCoefs = fFirstOrder.readlines()
fFirstOrder.close()
firstOrderSolver = aaProbSolver(firstOrderCoefs)

#sanac range:
#min: 0
#max: 172.4

#generate test data points between min and max
allPoints = range(1,172,2)

fOutput=open("/Users/kwang2/Documents/workspace/aaCodonProbPred/studyHydroResult/aaProb_sa_0_172.csv","w")
for x in allPoints:
    aaProbs = []
    for aa in aaList:
        tmpX = [1, x]
        tmpProb = firstOrderSolver.getCatProb(aa, tmpX)
        aaProbs.append(tmpProb)
Ejemplo n.º 6
0
#'L' is the reference codon
aaList = [
    'A', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N', 'P', 'Q', 'R',
    'S', 'T', 'V', 'W', 'Y'
]

#coef file and folders
#on desktop
#firstOrderCoefFile = '/home/kuangyu/workspace/aaCodonProbPred/coefs/aa_sa_coef.txt'
#on mac
firstOrderCoefFile = '/Users/kwang2/Documents/workspace/aaCodonProbPred/coefs/aa_sa_coef.txt'

fFirstOrder = open(firstOrderCoefFile, "r")
firstOrderCoefs = fFirstOrder.readlines()
fFirstOrder.close()
firstOrderSolver = aaProbSolver(firstOrderCoefs)

#sanac range:
#min: 0
#max: 172.4

#generate test data points between min and max
allPoints = range(1, 172, 2)

fOutput = open(
    "/Users/kwang2/Documents/workspace/aaCodonProbPred/studyHydroResult/aaProb_sa_0_172.csv",
    "w")
for x in allPoints:
    aaProbs = []
    for aa in aaList:
        tmpX = [1, x]