Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
binfpy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
opensource
binfpy
Commits
6727521b
Commit
6727521b
authored
Aug 18, 2022
by
Mikael Boden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asr_update
parent
39b93af9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletion
+21
-1
asr.py
asr.py
+21
-1
No files found.
asr.py
View file @
6727521b
...
...
@@ -23,6 +23,12 @@ class SubstModel:
Q
=
normalise
(
Q
)
self
.
Q
=
Q
def
__eq__
(
self
,
other
):
return
self
.
IRM
==
other
.
IRM
def
__hash__
(
self
):
return
hash
(
tuple
(
self
.
IRM
))
def
getTransitionMatrix
(
self
,
t
):
""" Compute the transition probability matrix for a branch length, t
NOTE: Multiplication of matrices is matrix multiplication (not element-wise multiplication) """
...
...
@@ -57,7 +63,21 @@ class SubstModel:
except
ValueError
:
raise
RuntimeError
(
f
"Either {parent} or {child} is not in the substitution model's alphabet."
)
return
self
.
getTransitionMatrix
(
t
)[
parent_idx
,
child_idx
]
# Check for cached TM for given model and t. Models are assumed equal if IRMs are identical
global
tmCache
# Stores any transition probability matrix computed for any model
try
:
if
self
in
tmCache
.
keys
():
if
not
t
in
tmCache
[
self
]
.
keys
():
tmCache
[
self
][
t
]
=
self
.
getTransitionMatrix
(
t
)
else
:
tmCache
[
self
]
=
{}
tmCache
[
self
][
t
]
=
self
.
getTransitionMatrix
(
t
)
except
NameError
:
tmCache
=
{}
tmCache
[
self
]
=
{}
tmCache
[
self
][
t
]
=
self
.
getTransitionMatrix
(
t
)
return
tmCache
[
self
][
t
][
parent_idx
,
child_idx
]
class
PhyloBNet
:
""" Discrete Bayesian network. Implementation here is specifically used for representation of discrete characters
...
...
Write
Preview
Markdown
is supported
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