Commit bdcb8913 authored by Pauline Pommeret's avatar Pauline Pommeret
Browse files

[trx] sliding_pb

parent dfbd7258
......@@ -43,7 +43,7 @@ def pair_score(string, TRX):
return TRX[max(potential)]
def match(sequence, TRX, shift):
def match(sequence, TRX):
"""
Translates a raw ``sequence`` into a list of values of ``TRX``.
......@@ -63,5 +63,23 @@ def match(sequence, TRX, shift):
return sequence_TRX
def sliding_pb(sequence_TRX, shift=72):
"""
Uses ``sequence_TRX`` (dictionary where keys are position in sequence and
values are TRX values associated with the nucleotides) and computes the
mean value on ``shift`` (int) sliding bp.
Default ``shift=72``.
Returns a dictionary.
"""
# Test if sequence_TRX and shift have compatible length
if len(sequence_TRX) > shift:
sliding_TRX = {}
for position in xrange(0, len(sequence)-shift):
sliding_TRX[position] = numpy.round(numpy.mean([sequence_TRX[i] for i in xrange(position, position+shift)]), decimals=2)
return sliding_TRX
elif:
raise ShiftOutOfRange("Choosen shift is too long for query sequence.")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment