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
BP6.1
Commits
9f893ead
Commit
9f893ead
authored
Jul 05, 2018
by
Roman Sarrazin-Gendron
Browse files
reworked make_BN_from_carnaval
parent
d7c28a45
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/BayesPairing.py
View file @
9f893ead
...
...
@@ -9,7 +9,7 @@ from operator import itemgetter
import
ast
import
math
import
time
import
make_BN_from_carnaval
as
make_BN
def
find_loops
(
struct
):
...
...
@@ -55,13 +55,14 @@ def parse_sequence(seq,modules,ss,dataset,left_out,sm=0.25, mc=0,k=5000):
scores
=
{}
for
mod
in
modules
:
print
(
"building Bayes Net for module : "
+
str
(
mod
))
this_graph
=
graphs
[
mod
][
0
]
# print(this_graph.nodes())
os
.
chdir
(
"../src"
)
call
=
str
(
"python make_BN_from_carnaval.py"
+
" "
+
str
(
mod
)
+
" "
+
dataset
+
" "
+
str
(
left_out
))
subprocess
.
call
(
call
,
shell
=
True
)
os
.
chdir
(
"../models"
)
#os.chdir("../src")
#call = str("python make_BN_from_carnaval.py"+" "+str(mod) +" "+ dataset +" " + str(left_out))
#subprocess.call(call,shell=True)
#os.chdir("../models")
make_BN
.
call_makeBN
(
mod
,
dataset
,
left_out
)
motif
=
pickle
.
load
(
open
(
str
(
dataset
+
"_BN_"
+
str
(
mod
)),
"rb"
)
)
this_graph
=
graphs
[
mod
][
0
]
constraints
=
testSS
.
get_constraints_from_BN
(
this_graph
)
pickle_name
=
dataset
+
"_samp"
+
str
(
mod
)
+
".cPickle"
if
left_out
!=
"NONE"
:
...
...
src/carnaval_to_rmdetect.py
View file @
9f893ead
...
...
@@ -5,8 +5,8 @@ from Bio.Align.Applications import ClustalwCommandline
from
Bio
import
AlignIO
from
Bio
import
SeqIO
aligned_modulegraphs
=
pickle
.
load
(
open
(
"../models/all_21+_rna3dmotif_106_aligned_modulegraphs.cPickle"
,
'rb'
))
PDB_positions
=
pickle
.
load
(
open
(
"../models/all_21+_rna3dmotif_106_
_
PDB_positions.cPickle"
,
'rb'
))
PDBs
=
pickle
.
load
(
open
(
"../models/all_21+_rna3dmotif_106_
_
PDB_names.cPickle"
,
'rb'
))
PDB_positions
=
pickle
.
load
(
open
(
"../models/all_21+_rna3dmotif_106_PDB_positions.cPickle"
,
'rb'
))
PDBs
=
pickle
.
load
(
open
(
"../models/all_21+_rna3dmotif_106_PDB_names.cPickle"
,
'rb'
))
graphs
=
pickle
.
load
(
open
(
"../models/all_21+_rna3dmotif_106_one_of_each_graph.cPickle"
,
'rb'
))
module
=
1
aln
=
aligned_modulegraphs
[
module
]
...
...
src/make_BN_from_carnaval.py
View file @
9f893ead
...
...
@@ -124,6 +124,65 @@ def make_graph_from_carnaval(g, aln_dict):
motif
.
add_edges_from
(
edges_3d
)
return
motif
def
call_makeBN
(
mod
,
dataset
,
left_out
):
current_ID
=
mod
excluded
=
left_out
bayesname
=
dataset
+
"_BN_"
+
str
(
current_ID
)
os
.
chdir
(
"../models"
)
if
excluded
!=
"NONE"
:
removecall
=
"rm "
+
bayesname
subprocess
.
call
(
removecall
,
shell
=
True
)
#if not os.path.isfile(bayesname), changed for cross-validation; always remake the model
if
not
os
.
path
.
isfile
(
bayesname
):
aln_list
=
pickle
.
load
(
open
(
dataset
+
"_aligned_modulegraphs.cPickle"
,
'rb'
))
g_list
=
pickle
.
load
(
open
(
dataset
+
"_one_of_each_graph.cPickle"
,
'rb'
))
pdb_names
=
pickle
.
load
(
open
(
dataset
+
"_PDB_names.cPickle"
,
'rb'
))
#extra_seqs = pickle.load(open(dataset + "_rfam.cPickle",'rb'))[current_ID]
extra_seqs
=
""
if
excluded
!=
"NONE"
:
excluded_indexes
=
[]
for
pdb
in
range
(
len
(
pdb_names
)):
if
excluded
in
pdb_names
[
pdb
]:
excluded_indexes
.
append
(
pdb
)
g
=
g_list
[
current_ID
]
for
k
in
reversed
(
excluded_indexes
):
g
.
pop
(
k
)
aln
=
aln_list
[
current_ID
]
for
i
in
aln
:
for
k
in
reversed
(
excluded_indexes
):
i
.
pop
(
k
)
alignment
=
get_alignment
(
g
,
aln
,
extra_seqs
)
else
:
g
=
g_list
[
current_ID
]
aln
=
aln_list
[
current_ID
]
alignment
=
get_alignment
(
g
,
aln
,
extra_seqs
)
#print("ALIGNMENT")
#print(alignment)
addresses
=
get_addresses
(
aln
)
#print("ADDRESSES")
#print(addresses)
seqs
=
get_seqs
(
g
,
aln
,
addresses
)
#seqs = ""
#print("SEQUENCES")
#print(seqs)
aln_dict
=
(
alignment
,
addresses
,
seqs
)
#print(aln_dict)
motif
=
make_graph_from_carnaval
(
g
,
aln_dict
)
pwm
=
BN_builder
.
build_pwm
(
motif
.
nodes
(),
aln_dict
)
#print("PWM")
#print(pwm)
bob
=
BN_builder
.
build_BN
(
motif
,
pwm
,
aln_dict
)
pickle
.
dump
(
bob
,
open
(
bayesname
,
'wb'
))
pdb_list
=
get_pdb_list
(
pdb_names
[
current_ID
])
#seqs = get_pdb_seqs(pdb_list)
pickle
.
dump
(
seqs
,
open
(
"seqs_"
+
str
(
bayesname
),
'wb'
))
else
:
print
(
"Bayes Net exist, continuing"
)
if
__name__
==
"__main__"
:
print
(
"ARGUMENTS"
)
print
(
sys
.
argv
)
...
...
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