Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Senizergues-Pommeret
ITPP
Commits
bdcb8913
Commit
bdcb8913
authored
Nov 26, 2014
by
Pauline Pommeret
Browse files
[trx] sliding_pb
parent
dfbd7258
Changes
1
Show whitespace changes
Inline
Side-by-side
trx.py
View file @
bdcb8913
...
...
@@ -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."
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment