Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VEBER Philippe
codepi
Commits
8cb49aff
Commit
8cb49aff
authored
Jul 16, 2019
by
Philippe Veber
Browse files
Simulator: produce histogram of fitness values
parent
d7815fa4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
5 deletions
+27
-5
lib/pipeline2.ml
lib/pipeline2.ml
+1
-0
lib/simulator.ml
lib/simulator.ml
+25
-4
lib/simulator.mli
lib/simulator.mli
+1
-1
No files found.
lib/pipeline2.ml
View file @
8cb49aff
...
...
@@ -128,6 +128,7 @@ let rec nucleotide_alignment = function
let
tree
=
tree
sim
in
let
fitness_profiles
=
Workflow
.
input
profiles
in
Simulator
.
simulator
~
branch_factor
~
n_ha
~
n_h0
~
ne_s
~
gBGC
~
tree
~
seed
~
fitness_profiles
()
|>
fst
let
amino_acid_alignment
d
=
Bppsuite
.
fna2faa
(
nucleotide_alignment
d
)
...
...
lib/simulator.ml
View file @
8cb49aff
...
...
@@ -68,11 +68,32 @@ let%pworkflow simulator ?branch_factor ?seed ~n_h0 ~n_ha ~ne_s:(ne_s0, ne_s1) ~g
let
species_name
=
Phylogenetics
.
Tree
.
leaves
tree
|>
List
.
map
~
f
:
(
fun
{
name
}
->
Option
.
value_exn
name
)
in
Out_channel
.
with_file
[
%
dest
]
~
f
:
(
fun
oc
->
List
.
iter2_exn
species_name
ali
~
f
:
(
fun
description
sequence
->
fprintf
oc
">%s
\n
%s
\n
"
description
(
sequence
:>
string
)
let
save_alignment
fn
=
Out_channel
.
with_file
fn
~
f
:
(
fun
oc
->
List
.
iter2_exn
species_name
ali
~
f
:
(
fun
description
sequence
->
fprintf
oc
">%s
\n
%s
\n
"
description
(
sequence
:>
string
)
)
)
in
let
save_fitness_histogram
dest
=
let
data
=
Array
.
fold
(
Array
.
append
h0_params
ha_params
)
~
init
:
[]
~
f
:
(
fun
acc
(
p
,
q
)
->
(
p
.
scaled_fitness
:>
float
array
)
::
(
q
.
scaled_fitness
:>
float
array
)
::
acc
)
)
|>
Array
.
concat
in
OCamlR_grDevices
.
pdf
dest
;
ignore
(
OCamlR_graphics
.
hist
data
)
;
OCamlR_grDevices
.
dev_off
()
in
Core
.
Unix
.
mkdir_p
[
%
dest
]
;
save_alignment
(
Filename
.
concat
[
%
dest
]
"simulation.fa"
)
;
save_fitness_histogram
(
Filename
.
concat
[
%
dest
]
"fitness_histogram.pdf"
)
let
simulator
?
branch_factor
?
seed
~
n_h0
~
n_ha
~
ne_s
~
gBGC
~
tree
~
fitness_profiles
()
=
let
dir
=
simulator
?
branch_factor
?
seed
~
n_h0
~
n_ha
~
ne_s
~
gBGC
~
tree
~
fitness_profiles
()
in
Bistro
.
Workflow
.
select
dir
[
"simulation.fa"
]
,
Bistro
.
Workflow
.
select
dir
[
"fitness_histogram.pdf"
]
let
%
pworkflow
pair_tree
~
branch_length1
~
branch_length2
~
npairs
=
let
open
Phylogenetics
in
...
...
lib/simulator.mli
View file @
8cb49aff
...
...
@@ -11,7 +11,7 @@ val simulator :
tree
:
nhx
pworkflow
->
fitness_profiles
:#
text_file
pworkflow
->
unit
->
nucleotide_fasta
pworkflow
nucleotide_fasta
pworkflow
*
pdf
pworkflow
val
pair_tree
:
branch_length1
:
float
->
...
...
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