コード例 #1
0
ファイル: main2.py プロジェクト: moonblade/smith
def main():
    count=1
    outputList=[]

    globalVariables.rawScoreMatrix = pickle.load(open(globalVariables.scoreMatrixFile,"rb"))
    globalVariables.states = pickle.load(open(globalVariables.statesFile,"rb"))
    globalVariables.timedStates = pickle.load(open(globalVariables.timedStatesFile,"rb"))
    # print(globalVariables.rawScoreMatrix)
    # print(globalVariables.states)
    # print(globalVariables.timedStates)
    with open(globalVariables.inputcsv, 'r') as csvfile:
        reader = csv.DictReader(csvfile)
        names=reader.fieldnames
        for row in reader:
            # Assuming that the sequences will be in the first two rows
            # Compute probabilities with sequence 1 and reverse of sequence 2
            seq1=row[names[0]]
            seq2=row[names[1]]
            scoreMatrix, startPos = score.initScoreMatrix(seq1,seq2)
            alinedOne, alinedTwo = score.traceback(scoreMatrix, startPos, seq1,seq2)
            alignmentString=score.alignment_string(alinedOne,alinedTwo)
            place=globalVariables.reverseEndIndex-globalVariables.reverseStartIndex-1
            stateNeeded=state.getState(alinedOne[::-1][place],alinedTwo[::-1][place])
            print(count)
            print(alinedOne)
            print(alignmentString)
            print(alinedTwo)
            print()
            outputList.append(str(count)+","+stateNeeded+","+str(globalVariables.timedStates[place][stateNeeded]['probability']))
            count+=1
    print()
    for line in outputList:
        print(line)
コード例 #2
0
ファイル: main.py プロジェクト: moonblade/smith
def doStuff(seq1,seq2):
    # Initialize the scoring matrix.
    scoreMatrix, startPos = score.initScoreMatrix(seq1,seq2)
    oneAligned, twoAligned = score.traceback(scoreMatrix, startPos, seq1,seq2)

    assert len(oneAligned) == len(twoAligned), 'aligned strings are not the same size'
    # print(oneAligned)
    # print(twoAligned)

    state.initStates()
    state.initProbabilities(oneAligned,twoAligned)
コード例 #3
0
ファイル: main.py プロジェクト: moonblade/smith
def doStuff(seq1, seq2):
    # Initialize the scoring matrix.
    scoreMatrix, startPos = score.initScoreMatrix(seq1, seq2)
    oneAligned, twoAligned = score.traceback(scoreMatrix, startPos, seq1, seq2)

    assert len(oneAligned) == len(
        twoAligned), 'aligned strings are not the same size'
    # print(oneAligned)
    # print(twoAligned)

    state.initStates()
    state.initProbabilities(oneAligned, twoAligned)
コード例 #4
0
ファイル: main2.py プロジェクト: moonblade/smith
def main():
    count = 1
    outputList = []

    globalVariables.rawScoreMatrix = pickle.load(
        open(globalVariables.scoreMatrixFile, "rb"))
    globalVariables.states = pickle.load(open(globalVariables.statesFile,
                                              "rb"))
    globalVariables.timedStates = pickle.load(
        open(globalVariables.timedStatesFile, "rb"))
    # print(globalVariables.rawScoreMatrix)
    # print(globalVariables.states)
    # print(globalVariables.timedStates)
    with open(globalVariables.inputcsv, 'r') as csvfile:
        reader = csv.DictReader(csvfile)
        names = reader.fieldnames
        for row in reader:
            # Assuming that the sequences will be in the first two rows
            # Compute probabilities with sequence 1 and reverse of sequence 2
            seq1 = row[names[0]]
            seq2 = row[names[1]]
            scoreMatrix, startPos = score.initScoreMatrix(seq1, seq2)
            alinedOne, alinedTwo = score.traceback(scoreMatrix, startPos, seq1,
                                                   seq2)
            alignmentString = score.alignment_string(alinedOne, alinedTwo)
            place = globalVariables.reverseEndIndex - globalVariables.reverseStartIndex - 1
            stateNeeded = state.getState(alinedOne[::-1][place],
                                         alinedTwo[::-1][place])
            print(count)
            print(alinedOne)
            print(alignmentString)
            print(alinedTwo)
            print()
            outputList.append(
                str(count) + "," + stateNeeded + "," +
                str(globalVariables.timedStates[place][stateNeeded]
                    ['probability']))
            count += 1
    print()
    for line in outputList:
        print(line)