Commit 30d7f3d3 authored by boussau's avatar boussau
Browse files
parents 84428e8b 2be36d97
*~
_build
_bistro
outdir*
reviewphiltrans.install
**/.merlin
example/outdir
*.pdf
*.svg
report.html
*.dot
__pycache__
.PHONY: build install build_docker push_docker test clean_test
.PHONY: build install clean build_docker push_docker clean_test test_simu test_det test_val real analyses_30Bloom analyses_263Bloom
build:
jbuilder build
......@@ -7,9 +7,9 @@ install:
jbuilder install
clean:
rm -rf _build || exit 0
rm -rf example/_bistro || exit 0
rm -rf example/outdir || exit 0
rm -rf _build
rm -rf example/_bistro
rm -rf example/outdir
build_docker:
@for dir in ./etc/docker/*; \
......@@ -62,7 +62,7 @@ analyses_263Bloom:
mv dag.dot daganalyses_263SelectedProfiles.dot
clean_test:
rm -rf example/_bistro || exit 0
rm -rf example/outdir || exit 0
rm -rf example/report.log || exit 0
rm -rf example/dot.dag || exit 0
rm -rf example/_bistro
rm -rf example/outdir
rm -rf example/report.log
rm -rf example/dot.dag
FROM r-base
MAINTAINER Carine Rey carine.rey@ens-lyon.org
RUN echo 'install.packages(c("optparse", "ggplot2", "reshape2", "cowplot", "coda"), repos="https://mirror.ibcp.fr/pub/CRAN/", dependencies=TRUE)' > /tmp/packages.R \
&& Rscript /tmp/packages.R
#! /bin/bash
set -e
IMAGE_NAME=r_basics
DOCKERFILE_DIR=.
TAG=07162018
REPO=carinerey/$IMAGE_NAME:$TAG
docker build -t $REPO -f ./Dockerfile $DOCKERFILE_DIR
if [[ $1 == "push_yes" ]]
then
docker push $REPO
fi
......@@ -33,6 +33,7 @@ let meth_string_of_result = function
type dataset_res = {
model_prefix : string ;
tree_prefix : string ;
dataset : Dataset.t ;
res_by_tools: result list ;
merged_results : text_file workflow ;
plot_merged_results : svg workflow ;
......
......@@ -5,7 +5,6 @@ open Bistro_bioinfo.Std
open File_formats
open Defs
type result = [
| `Pcoc of [`pcoc] directory workflow
| `Pcoc_gamma of [`pcoc] directory workflow
......@@ -24,6 +23,7 @@ val meth_string_of_result : result -> string
type dataset_res = {
model_prefix : string ;
tree_prefix : string ;
dataset : Dataset.t ;
res_by_tools: result list ;
merged_results : text_file workflow ;
plot_merged_results : svg workflow
......
......@@ -17,7 +17,7 @@ let string_of_model m = match m with
| H0 -> "H0"
| HaPC -> "HaPC"
| HaPCOC -> "HaPCOC"
| H0_NeSmall -> "H0_NeSmall"
| H0_NeSmall -> "H0_NeSmall"
| HaPCOC_NeSmall -> "HaPCOC_NeSmall"
| HaPC_NeSmall -> "HaPC_NeSmall"
| H0_NeBig -> "H0_NeBig"
......
......@@ -8,8 +8,6 @@ type t = {
dataset : Ready_dataset.t ;
}
let repo ~preview dataset_l =
List.map dataset_l ~f:(fun dataset ->
let model_prefix = dataset.model_prefix in
......@@ -17,8 +15,8 @@ let repo ~preview dataset_l =
let repo_ready_data = Ready_dataset.repo dataset.dataset in
let repo_raw_data = if preview then Raw_dataset.repo ~prefix:model_prefix (Ready_dataset.to_raw dataset.dataset) else [] in
List.concat [
Repo.shift "data" (Repo.shift (tree_prefix ^"_"^model_prefix) repo_raw_data);
Repo.shift "debug_data" (Repo.shift tree_prefix (Repo.shift model_prefix repo_ready_data));
Repo.shift "simulated_data" (Repo.shift (tree_prefix ^"_"^model_prefix) repo_raw_data);
Repo.shift "simulated_data_debug" (Repo.shift tree_prefix (Repo.shift model_prefix repo_ready_data));
]
)
|> List.concat
......@@ -10,11 +10,6 @@ type output_parse_input_tree =
| Tree4simu
| Tree_diffsel
type det_meth =
| Pcoc
| Pcoc_gamma
| Diffsel
......@@ -44,9 +44,9 @@ let parse_input_data indir =
)
|> List.concat
let derive_from_model ~model ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview =
let derive_from_model ~model ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview ~ns =
let model_prefix = Convergence_hypothesis.string_of_model model in
let nb_sites = if preview then 20 else 50 in
let nb_sites = if ns = 0 then (if preview then 20 else 50) else ns in
let nodes = Tree_dataset.nodes tree_dataset model in
let tree = Tree_dataset.tree tree_dataset `Simulation in
let descr = "."^model_prefix^"."^tree_prefix in
......@@ -73,7 +73,7 @@ let derive_from_model ~model ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~
let ready_dataset = { Ready_dataset.input_tree = input_tree ; tree_dataset ; fna; faa; fna_infos} in
{ Dataset.model_prefix; is_real= false; tree_prefix; dataset = ready_dataset }
let derive_from_tree ~tree_dir ~tree ~profile_f ~preview ~use_concat =
let derive_from_tree ~tree_dir ~tree ~profile_f ~preview ~use_concat ~ns =
let tree_prefix = Filename.chop_extension tree in
let input_tree = input (Filename.concat tree_dir tree) in
let tree_dataset = Tree_dataset.prepare input_tree in
......@@ -95,18 +95,18 @@ let derive_from_tree ~tree_dir ~tree ~profile_f ~preview ~use_concat =
HaPC_NeBig ;
] in
let dataset_per_hypo = List.map models ~f:(fun model ->
derive_from_model ~model ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview
derive_from_model ~model ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview ~ns
) in
let ready_dataset_H0 = (derive_from_model ~model:H0 ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview).dataset in
let ready_dataset_HaPCOC = (derive_from_model ~model:HaPCOC ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview).dataset in
let ready_dataset_H0 = (derive_from_model ~model:H0 ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview ~ns).dataset in
let ready_dataset_HaPCOC = (derive_from_model ~model:HaPCOC ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview ~ns).dataset in
let concat_H0Ha = {Dataset.model_prefix="H0+HaPCOC"; tree_prefix; is_real = false; dataset = Ready_dataset.paste ready_dataset_H0 ready_dataset_HaPCOC} in
let dataset_concat_hypos = if use_concat then [concat_H0Ha;] else [] in
List.concat [ dataset_per_hypo ; dataset_concat_hypos ]
let derive_sim ~tree_dir ~trees ~profile_fn ~preview ~use_concat =
let derive_sim ~tree_dir ~trees ~profile_fn ~preview ~use_concat ~ns =
let profile_f = input profile_fn in
List.map trees ~f:(fun tree ->
derive_from_tree ~tree_dir ~tree ~profile_f ~preview ~use_concat)
derive_from_tree ~tree_dir ~tree ~profile_f ~preview ~use_concat ~ns)
|> List.concat
......@@ -186,7 +186,7 @@ let derive_from_det_meth ~det_meth ~(dataset : Dataset.t) ~preview =
| `Topological_WAG -> `Topological_WAG (Topological.topological ~faa ~tree:tree_id ~tree_conv ~prot_model:"WAG01")
let derive_from_dataset ~dataset ~preview ~no_diffsel=
let derive_from_dataset ~dataset ~preview ~fast_mode=
let det_meths = [
[`Pcoc;
`Tdg09;
......@@ -195,15 +195,15 @@ let derive_from_dataset ~dataset ~preview ~no_diffsel=
if preview then
[]
else
[`Pcoc_gamma;`Pcoc_C60;
[`Pcoc_gamma;
`Identical_WAG;
`Topological_WAG;
]
;
if no_diffsel then
if fast_mode then
[]
else
[`Diffsel;`Diffsel_bis;] ;
[`Diffsel;`Diffsel_bis;`Pcoc_C60;] ;
]
|> List.concat in
let res_by_tools = List.map det_meths ~f:(fun det_meth ->
......@@ -217,11 +217,11 @@ let derive_from_dataset ~dataset ~preview ~no_diffsel=
let plot_merged_results = plot_merge_results ~plot_all_sites ~res_by_tools ~tsv ~faa ~tree in
let model_prefix = dataset.model_prefix in
let tree_prefix = dataset.tree_prefix in
{model_prefix; tree_prefix; res_by_tools ; merged_results ; plot_merged_results}
{model_prefix; tree_prefix; dataset; res_by_tools ; merged_results ; plot_merged_results}
let derive_det ~dataset_l ~preview ~no_diffsel =
let derive_det ~dataset_l ~preview ~fast_mode =
List.map dataset_l ~f:(fun dataset ->
derive_from_dataset ~preview ~dataset ~no_diffsel)
derive_from_dataset ~preview ~dataset ~fast_mode)
let logger =
Logger.tee [
......@@ -230,29 +230,38 @@ let logger =
Bistro_utils.Html_logger.create "report.html" ;
]
let detection_main ~outdir ~indir ?(np = 2) ?(mem = 2) ~preview ~no_diffsel () =
let detection_main ~outdir ~indir ?(np = 2) ?(mem = 2) ~preview ~fast_mode () =
let dataset_l = parse_input_data indir in
let dataset_results_l = derive_det ~dataset_l ~preview ~no_diffsel in
let dataset_results_l = derive_det ~dataset_l ~preview ~fast_mode in
let repo = repo_of_dataset_results_l ~dataset_results_l in
Repo.build ~outdir ~np ~mem:(`GB mem) ~logger repo
let simulation_main ~outdir ?(np = 2) ?(mem = 2) ~tree_dir ~profile_fn ~preview ~use_concat () =
let simulation_main ~outdir ?(ns = 0) ?(np = 2) ?(mem = 2) ~tree_dir ~profile_fn ~preview ~use_concat () =
let trees = Array.to_list @@ Sys.readdir tree_dir in
let dataset_l = derive_sim ~tree_dir ~trees ~profile_fn ~preview ~use_concat in
let dataset_l = derive_sim ~tree_dir ~trees ~profile_fn ~preview ~use_concat ~ns in
let repo = Dataset.repo dataset_l ~preview in
Repo.build ~outdir ~np ~mem:(`GB mem) ~logger repo
let validation_main ~outdir ~indir ?(np = 2) ?(mem = 2) ~preview ~no_diffsel ~tree_dir ~profile_fn ~use_concat () =
let validation_main ~outdir ~indir ?(ns = 0) ?(np = 2) ?(mem = 2) ~preview ~fast_mode ~tree_dir ~profile_fn ~use_concat () =
let trees = Array.to_list @@ Sys.readdir tree_dir in
let repo = List.map trees ~f:(fun tree ->
let trees = [tree] in
let tree_prefix = Filename.chop_extension tree in
let dataset_l =
derive_sim ~tree_dir ~trees ~profile_fn ~preview ~use_concat
derive_sim ~tree_dir ~trees ~profile_fn ~preview ~use_concat ~ns
@ parse_input_data indir in
let dataset_results_l = derive_det ~dataset_l ~preview ~no_diffsel in
let repo = [
let dataset_results_l = derive_det ~dataset_l ~preview ~fast_mode in
let post_analyses = Post_analyses.post_analyses_of_dataset_results_l ~dataset_results_l in
let repo_per_tree = [
Dataset.repo dataset_l ~preview ;
repo_of_dataset_results_l ~dataset_results_l ;
Repo.shift tree_prefix (Post_analyses.repo_of_post_analyses ~prefix:tree_prefix ~post_analyses);
] |> List.concat
in
repo_per_tree
)
|> List.concat
in
Repo.build ~outdir ~np ~mem:(`GB mem) ~logger repo
let simulation_command =
......@@ -264,6 +273,8 @@ let simulation_command =
flag "--outdir" (required string) ~doc:"PATH Output directory"
and preview =
flag "--preview-mode" no_arg ~doc:" Preview mode"
and ns =
flag "--ns" (optional int) ~doc:"INT Number of sites to simulate"
and np =
flag "--np" (optional int) ~doc:"INT Number of available processors"
and mem =
......@@ -275,7 +286,7 @@ let simulation_command =
and profile_fn =
flag "--profile-fn" (required string) ~doc:"PATH Path to profile file"
in
simulation_main ~outdir ?np ?mem ~tree_dir ~profile_fn ~preview ~use_concat
simulation_main ~outdir ?ns ?np ?mem ~tree_dir ~profile_fn ~preview ~use_concat
]
let detection_command =
......@@ -289,14 +300,14 @@ let detection_command =
flag "--indir" (required string) ~doc:"PATH Input directory"
and preview =
flag "--preview-mode" no_arg ~doc:" Preview mode"
and no_diffsel =
flag "--no-diffsel" no_arg ~doc:" No diffsel mode"
and fast_mode =
flag "--fast" no_arg ~doc:" 'Fast' mode without the most costly methods"
and np =
flag "--np" (optional int) ~doc:"INT Number of available processors"
and mem =
flag "--mem" (optional int) ~doc:"INT Available memory (in GB)"
in
detection_main ~outdir ~indir ?np ?mem ~preview ~no_diffsel
detection_main ~outdir ~indir ?np ?mem ~preview ~fast_mode
]
let validation_command =
......@@ -310,10 +321,12 @@ let validation_command =
flag "--indir" (required string) ~doc:"PATH Input directory"
and preview =
flag "--preview-mode" no_arg ~doc:" Preview mode"
and no_diffsel =
flag "--no-diffsel" no_arg ~doc:" No diffsel mode"
and fast_mode =
flag "--fast" no_arg ~doc:" 'Fast' mode without the most costly methods"
and use_concat =
flag "--use-concat" no_arg ~doc:" Use concatenation H0+Ha_pcoc"
and ns =
flag "--ns" (optional int) ~doc:"INT Number of sites to simulate"
and np =
flag "--np" (optional int) ~doc:"INT Number of available processors"
and mem =
......@@ -323,5 +336,5 @@ let validation_command =
and profile_fn =
flag "--profile-fn" (required string) ~doc:"PATH Path to profile file"
in
validation_main ~outdir ~indir ?np ?mem ~preview ~no_diffsel ~tree_dir ~profile_fn ~use_concat
validation_main ~outdir ~indir ?ns ?np ?mem ~preview ~fast_mode ~tree_dir ~profile_fn ~use_concat
]
open Core
open Bistro.Std
open Bistro.EDSL
open Bistro_bioinfo.Std
open Bistro_utils
open File_formats
open Convergence_detection
type post_analyses_dir
type t_choices = {
t_choices_complete: text_file workflow ;
t_choices_max: text_file workflow ;
t_choices_plot: text_file workflow ;
}
type simu_infos = {
simu_infos: text_file workflow option ;
model_prefix: string ;
}
type post_analyses = {
t_choices : t_choices option;
simu_infos_l : simu_infos list;
}
let is_hyp ~hyp (dataset_results :dataset_res) =
let model_prefix = dataset_results.model_prefix in
model_prefix = hyp
let make_t_choices ~h0_merged_results ~ha_merged_results : post_analyses_dir directory workflow =
let env = docker_image ~account:"carinerey" ~name:"r_basics" ~tag:"07162018" () in
let out = dest // "out" in
workflow ~descr:"post_analyses.t_choices" [
docker env (
and_list [
mkdir_p dest ;
cmd "Rscript" [
file_dump (string Scripts.calc_t_per_meth) ;
opt "--H0" dep h0_merged_results;
opt "--Ha" dep ha_merged_results;
opt "--out " ident out;
];
])
]
let make_simu_infos ?(descr="") ?(fna_infos) ~faa ~tree_sc : text_file workflow =
let env = docker_image ~account:"carinerey" ~name:"pcoc" ~tag:"07022018" () in
workflow ~descr:("post_analyses.simu_infos." ^ descr) [
cmd "python" ~env [
file_dump (string Scripts.calc_simu_infos) ;
opt "--faa" dep faa;
opt "--tree" dep tree_sc;
option ( opt "--fna_infos" dep) fna_infos;
opt "--output " ident dest;
];
]
let get_t_choices ~(dataset_results_l: dataset_res list) : t_choices option =
let h0_res = List.find dataset_results_l (is_hyp ~hyp: "H0") in
let ha_res = List.find dataset_results_l (is_hyp ~hyp: "HaPCOC") in
match (h0_res, ha_res) with
| (Some h0, Some ha) ->
let h0_merged_results = h0.merged_results in
let ha_merged_results = ha.merged_results in
let t_choices_dir = make_t_choices ~h0_merged_results ~ha_merged_results in
let t_choices_max = t_choices_dir / selector ["out.max_per_meth.tsv"] in
let t_choices_complete = t_choices_dir / selector ["out.complete.tsv"] in
let t_choices_plot = t_choices_dir / selector ["out.pdf"] in
Some {t_choices_max; t_choices_complete ; t_choices_plot}
| _ -> None
let get_simu_infos ~dataset_results =
let model_prefix = dataset_results.dataset.model_prefix in
let ready_dataset = dataset_results.dataset.dataset in
let faa = ready_dataset.faa in
let tree_sc = Tree_dataset.tree ready_dataset.tree_dataset `Detection in
let fna_infos = ready_dataset.fna_infos in
match fna_infos with
| Some w -> Some (make_simu_infos ~descr:model_prefix ~faa ~tree_sc ~fna_infos:w)
| None -> None (*make_simu_infos ~faa ~tree_sc*)
let post_analyses_of_dataset_results_l ~dataset_results_l =
let t_choices = get_t_choices ~dataset_results_l in
let simu_infos_l = List.map dataset_results_l ~f:(fun dataset_results ->
{simu_infos = (get_simu_infos ~dataset_results); model_prefix = dataset_results.model_prefix} )in
{t_choices ; simu_infos_l}
let repo_of_post_analyses ~prefix ~post_analyses =
[
(match post_analyses.t_choices with
| None -> []
| Some w ->
Repo.[
item [prefix ^ ".t_choices.max_mcc_per_meth.tsv"] w.t_choices_max ;
item [prefix ^ ".t_choices.complete.tsv"] w.t_choices_complete ;
item [prefix ^ ".t_choices.pdf"] w.t_choices_plot ;
] |> Repo.shift "t_choices"
);
List.map post_analyses.simu_infos_l ~f:(fun simu_infos ->
match simu_infos.simu_infos with
| None -> []
| Some w ->
Repo.[
item [prefix ^ "." ^ simu_infos.model_prefix ^ ".tsv"] w
] |> Repo.shift "simu_infos"
) |> List.concat
] |> List.concat
......@@ -4,7 +4,7 @@ open Bistro_utils
open Bistro.EDSL
open Bistro_bioinfo.Std
open File_formats
open Bppsuite
type t = {
input_tree: nhx workflow ;
......@@ -14,7 +14,6 @@ type t = {
faa: aminoacid_fasta workflow ;
}
let of_raw (raw_dataset : Raw_dataset.t) =
let input_tree = raw_dataset.input_tree in
let fna = raw_dataset.fna in
......@@ -26,20 +25,21 @@ let of_raw (raw_dataset : Raw_dataset.t) =
let repo rd =
Repo.[
[
item ["input_tree.nhx"] rd.input_tree ;
item ["tree.H0.node_ids" ] (Tree_dataset.nodes rd.tree_dataset H0) ;
item ["tree.Ha.node_ids" ] (Tree_dataset.nodes rd.tree_dataset HaPCOC) ;
item ["tree.only_convergent_tags.nhx" ] (Tree_dataset.tree rd.tree_dataset `Detection) ;
item ["tree.only_node_ids.nhx" ] (Tree_dataset.tree rd.tree_dataset `Simulation) ;
item ["tree.diffsel" ] (Tree_dataset.diffsel_tree rd.tree_dataset) ;
item ["tree.convergent_topology" ] (Tree_dataset.topological_tree rd.tree_dataset) ;
item ["simulated_sequences.fna"] rd.fna ;
item ["simulated_sequences.faa"] rd.faa ;
item ["input_tree.nhx"] rd.input_tree ;
item ["tree.H0.node_ids" ] (Tree_dataset.nodes rd.tree_dataset H0) ;
item ["tree.Ha.node_ids" ] (Tree_dataset.nodes rd.tree_dataset HaPCOC) ;
item ["tree.only_convergent_tags.nhx" ] (Tree_dataset.tree rd.tree_dataset `Detection) ;
item ["tree.only_node_ids.nhx" ] (Tree_dataset.tree rd.tree_dataset `Simulation) ;
item ["tree.diffsel" ] (Tree_dataset.diffsel_tree rd.tree_dataset) ;
item ["tree.convergent_topology" ] (Tree_dataset.topological_tree rd.tree_dataset) ;
item ["simulated_sequences.fna"] rd.fna ;
item ["simulated_sequences.phy"] (Bppsuite.fa2phy rd.fna) ;
item ["simulated_sequences.faa"] rd.faa ;
] ;
match rd.fna_infos with
| Some w -> [item ["simulated_sequences.fna_infos"] w]
| None -> []
;
| Some w -> [item ["simulated_sequences.fna_infos"] w]
| None -> []
;
]
|> List.concat
|> Repo.shift "ready_dataset"
......@@ -50,8 +50,8 @@ let to_raw { input_tree ; fna ; fna_infos} =
let paste_fna_infos ~(fna_infos_l: text_file workflow list) : text_file workflow =
workflow ~descr:"cat" [
cmd "cat" ~stdout:dest (List.concat [
List.map fna_infos_l ~f:(fun fna_infos -> dep fna_infos) ;
])
List.map fna_infos_l ~f:(fun fna_infos -> dep fna_infos) ;
])
]
let paste d1 d2 =
......@@ -59,10 +59,10 @@ let paste d1 d2 =
let r_d2 = to_raw d2 in
let fna = Bppsuite.paste_fna [r_d1.fna ; r_d2.fna ] in
let fna_infos_l = List.map [r_d1.fna_infos ; r_d2.fna_infos] ~f:(fun fna_infos ->
match fna_infos with
match fna_infos with
| Some i -> [i]
| None -> []
) |> List.concat in
) |> List.concat in
let fna_infos = Some (paste_fna_infos ~fna_infos_l) in
let ready_dataset = of_raw {Raw_dataset.input_tree=r_d1.input_tree ; fna; fna_infos} in
ready_dataset
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright or Copr. Centre National de la Recherche Scientifique (CNRS) (2018)
# Contributors:
# - Carine Rey <carine.rey@ens-lyon.org>
# This software is a computer program whose purpose is to provide a set of scripts for pre and post processing of data for
# convergence detection programs.
# This software is governed by the CeCILL-C license under French law and abiding by the rules of distribution of free software.
# You can use, modify and/ or redistribute the software under the terms of the CeCILL-C license as circulated by CEA, CNRS and
# INRIA at the following URL "http://www.cecill.info".
# As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users
# are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive
# licensors have only limited liability.
# In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or
# reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated
# to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth
# computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements
# in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in
# the same conditions as regards security.
# The fact that you are presently reading this means that you have had knowledge of the CeCILL-C license and that you accept
# its terms.
import argparse
import sys
import os, re
import logging
import pandas as pd
from ete3 import Tree, NodeStyle, TreeStyle, TextFace
from Bio import AlignIO
#===================================================================================================
# inputs
#===================================================================================================
### Option defining
parser = argparse.ArgumentParser(prog="calc_simu_infos.py",
description='')
parser.add_argument('--version', action='version', version='%(prog)s 1.0')
parser.add_argument('--debug', action="store_true",
help="debug mode",
default=False)
##############
requiredOptions = parser.add_argument_group('OPTIONS')
requiredOptions.add_argument('-t', "--tree", type=argparse.FileType('r'),
help='Tree filename', required=True)
requiredOptions.add_argument('-f', "--faa", type=argparse.FileType('r'),
help='Alignment filename', required=True)
requiredOptions.add_argument('-i', "--fna_infos", type=argparse.FileType('r'),
help='faa infos per site filename', required=False, default = None )
requiredOptions.add_argument('-o', '--output', type=str,
help="Output name", required=True)
##############
### Option parsing
args = parser.parse_args()
TreeFile = args.tree
AliFile = args.faa
AliInfoFile = args.fna_infos
OutFile = args.output
#===================================================================================================
# Set up output directory and logger
#===================================================================================================
### Set up the logger
# create logger
logger = logging.getLogger("calc_simu_infos")
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
if args.debug:
ch.setLevel(logging.DEBUG)
else:
ch.setLevel(logging.INFO)
# create formatter and add it to the handlers
formatter_ch = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter_ch)
logger.addHandler(ch)
logger.debug(sys.argv)
#===================================================================================================
# Read input tree
#===================================================================================================
try:
t=Tree(TreeFile.name)
except Exception as exc:
logger.error(str(exc))
sys.exit(1