Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Roman Sarrazin-Gendron
RNABayesPairing2
Commits
74dafdd6
Commit
74dafdd6
authored
Nov 22, 2021
by
Hua-Ting Yao
Browse files
Update jar3d.py
parent
67c03c69
Changes
2
Hide whitespace changes
Inline
Side-by-side
bayespairing/src/jar3d.py
View file @
74dafdd6
...
...
@@ -5,6 +5,7 @@ import statistics
import
sys
import
ast
from
Bio
import
SeqIO
import
json
#mod_seqs,full_seqs,indexes = pickle.load(open("../models/RECOMB_sequences.pickle","rb"))
tr
=
{
"A"
:
0
,
"C"
:
1
,
"G"
:
2
,
"U"
:
3
}
...
...
@@ -30,13 +31,14 @@ def gen_seq(weights,size):
def
direct_score
(
modules
,
file
,
dataset
=
"RECOMB"
,
is_list
=
False
,
retrain
=
False
,
THRESHOLD
=
3.5
,
pretrained
=
False
):
mod_data
=
json
.
load
(
open
(
"../models/"
+
dataset
+
".json"
))
if
pretrained
:
BNs
=
pickle
.
load
(
open
(
"../models/"
+
dataset
+
"_models.pickle"
,
"rb"
))
else
:
BNs
=
{}
for
module
in
modules
:
BN
=
makeBN
.
call_makeBN
(
module
,
dataset
,
"NONE"
,
False
,
""
,
retrain
=
retrain
)
#BN = makeBN.call_makeBN(module, dataset,"NONE",False,"", retrain=retrain)
BN
=
makeBN
.
call_makeBN
(
module
,
dataset
,
mod_data
[
str
(
module
)],
False
,
""
,
retrain
=
retrain
)
BNs
[
module
]
=
BN
print
(
"TRAINED BAYES NETS"
,
BNs
)
if
is_list
:
...
...
@@ -90,4 +92,4 @@ if __name__ == "__main__":
a
=
direct_score
(
mod
,
file
,
dataset
,
pretrained
=
True
)
else
:
a
=
direct_score
(
mod
,
file
,
dataset
,
pretrained
=
False
)
print
(
a
[
1
])
\ No newline at end of file
print
(
a
[
1
])
bayespairing/src/make_BN_from_carnaval.py
View file @
74dafdd6
...
...
@@ -409,6 +409,31 @@ def call_makeBN(mod, dataset, module_data, Lambda=1, Theta=1,retrain=False):
'''
# Temporary placeholder function for CV for building a Bayesian Network
def
make_BN
(
module
,
dataset
,
graphs
,
motif_sequences
,
Lambda
=
0.35
,
Theta
=
1
):
# Test sequences should be tuple of seq and positions, seems like it is outdated/not used
test_seqs
=
[]
# Build the BN with the motif sequences
g
=
graphs
[
module
][
0
]
aln
=
{}
for
n
in
sorted
(
list
(
g
.
nodes
())):
aln
[
n
]
=
n
alignment
=
get_alignment
(
g
,
aln
,
motif_sequences
)
motif
=
make_graph_from_carnaval
(
g
,
alignment
)
pwm
=
BN_builder
.
build_pwm
(
sorted
(
list
(
motif
.
nodes
())),
alignment
)
BN
=
BN_builder
.
build_BN
(
motif
,
pwm
,
alignment
)
# PDBs array is also empty, outdated?
BN
.
from_alignment_dataset
(
dataset
,
module
,
[
g
],
alignment
,
test_seqs
,
[],
Lambda
,
Theta
)
return
BN
if
__name__
==
"__main__"
:
...
...
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