bella-companion 0.0.6__py3-none-any.whl → 0.0.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of bella-companion might be problematic. Click here for more details.

bella_companion/cli.py CHANGED
@@ -4,12 +4,10 @@ from pathlib import Path
4
4
 
5
5
  from dotenv import load_dotenv
6
6
 
7
- from bella_companion.simulations import (
8
- generate_data,
9
- generate_figures,
10
- run_beast,
11
- summarize_logs,
12
- )
7
+ from bella_companion.fbd_empirical import run_beast as run_fbd_empirical
8
+ from bella_companion.simulations import generate_data, generate_figures
9
+ from bella_companion.simulations import run_beast as run_simulations
10
+ from bella_companion.simulations import summarize_logs
13
11
 
14
12
 
15
13
  def main():
@@ -28,7 +26,7 @@ def main():
28
26
 
29
27
  subparsers.add_parser(
30
28
  "sim-run", help="Run BEAST2 analyses on simulation datasets."
31
- ).set_defaults(func=run_beast)
29
+ ).set_defaults(func=run_simulations)
32
30
 
33
31
  subparsers.add_parser(
34
32
  "sim-summary", help="Summarize BEAST2 log outputs for simulations."
@@ -38,5 +36,9 @@ def main():
38
36
  "sim-figures", help="Generate plots and figures from simulation results."
39
37
  ).set_defaults(func=generate_figures)
40
38
 
39
+ subparsers.add_parser(
40
+ "fbd-empirical-run", help="Run BEAST2 analyses on empirical FBD datasets."
41
+ ).set_defaults(func=run_fbd_empirical)
42
+
41
43
  args = parser.parse_args()
42
44
  args.func()
@@ -0,0 +1,3 @@
1
+ from bella_companion.fbd_empirical.run_beast import run_beast
2
+
3
+ __all__ = ["run_beast"]
@@ -1,3 +1,4 @@
1
+ import json
1
2
  import os
2
3
  from pathlib import Path
3
4
 
@@ -7,48 +8,61 @@ from phylogenie import load_newick
7
8
  from phylogenie.utils import get_node_depths
8
9
  from tqdm import tqdm
9
10
 
10
- import src.config as cfg
11
- from src.utils import run_sbatch
11
+ from bella_companion.utils import submit_job
12
12
 
13
13
  THIS_DIR = Path(__file__).parent
14
- AADD LAYERS RANGE
15
14
 
16
- def main():
17
- output_dir = cfg.BEAST_OUTPUTS_DIR / "fbd-empirical"
15
+
16
+ def run_beast():
17
+ base_output_dir = Path(os.environ["BELLA_BEAST_OUTPUT_DIR"])
18
+ output_dir = base_output_dir / "fbd-empirical"
18
19
  os.makedirs(output_dir, exist_ok=True)
19
20
 
20
- tree_file = THIS_DIR / "data" / "trees.nwk"
21
- change_times_file = THIS_DIR / "data" / "change_times.csv"
22
- sampling_change_times_file = THIS_DIR / "data" / "sampling_change_times.csv"
21
+ data_dir = THIS_DIR / "data"
22
+ tree_file = data_dir / "trees.nwk"
23
+ change_times_file = data_dir / "change_times.csv"
23
24
 
25
+ trees = load_newick(str(tree_file))
26
+ assert isinstance(trees, list)
24
27
  change_times = (
25
28
  pl.read_csv(change_times_file, has_header=False).to_series().to_numpy()
26
29
  )
27
- time_predictor = " ".join(
28
- list(map(str, np.repeat(np.insert(change_times, 0, 0), 4)))
29
- )
30
+ time_predictor = " ".join(list(map(str, np.repeat([0, *change_times], 4))))
30
31
  body_mass_predictor = " ".join(["0", "1", "2", "3"] * (len(change_times) + 1))
31
32
 
32
- trees = load_newick(str(tree_file))
33
- assert isinstance(trees, list)
33
+ job_ids = {}
34
34
  for i, tree in enumerate(tqdm(trees)):
35
35
  process_length = max(get_node_depths(tree).values())
36
- for model in ["hidden-relu", "hidden-tanh"]:
37
- command = " ".join(
38
- [
39
- cfg.RUN_BEAST,
40
- f'-D treeFile={tree_file},treeIndex={i},typeTraitFile={THIS_DIR / "data" / "body_mass.csv"},changeTimesFile={change_times_file},samplingChangeTimesFile={sampling_change_times_file},processLength={process_length},timePredictor="{time_predictor}",bodyMassPredictor="{body_mass_predictor}"',
41
- f"-DF {THIS_DIR / 'params.json'}",
42
- f"-prefix {output_dir / model}",
43
- str(cfg.BEAST_CONFIGS_DIR / "fbd-empirical" / f"{model}.xml"),
44
- ]
45
- )
46
- run_sbatch(
47
- command,
48
- cfg.SBATCH_LOGS_DIR / "fbd-empirical" / model / str(i),
49
- mem_per_cpu="12000",
50
- )
51
-
52
-
53
- if __name__ == "__main__":
54
- main()
36
+ command = " ".join(
37
+ [
38
+ os.environ["BELLA_RUN_BEAST_CMD"],
39
+ f"-D types=0,1,2,3",
40
+ f'-D startTypePriorProbs="0.25 0.25 0.25 0.25"',
41
+ f"-D birthRateUpper=2",
42
+ f"-D deathRateUpper=2",
43
+ f"-D samplingRateUpper=10",
44
+ f'-D samplingRateInit="5 5 5 5 5 5 5"',
45
+ f"-D migrationRateUpper=10",
46
+ f'-D migrationRateInit="0.5 0 0 0.5 0.5 0 0 0.5 0.5 0 0 0.5"',
47
+ f'-D nodes="16 8"',
48
+ f'-D layersRange="0,1,2"',
49
+ f"-D treeFile={tree_file}",
50
+ f"-D treeIndex={i}",
51
+ f"-D changeTimesFile={change_times_file}",
52
+ f"-D samplingChangeTimesFile={data_dir / 'sampling_change_times.csv'}",
53
+ f"-D typeTraitFile={data_dir / 'body_mass.csv'}",
54
+ f"-D processLength={process_length}",
55
+ f'-D timePredictor="{time_predictor}"',
56
+ f'-D bodyMassPredictor="{body_mass_predictor}"',
57
+ f"-prefix {output_dir}{os.sep}",
58
+ str(Path(os.environ["BELLA_BEAST_CONFIGS_DIR"]) / "fbd-empirical.xml"),
59
+ ]
60
+ )
61
+ job_ids[i] = submit_job(
62
+ command,
63
+ Path(os.environ["BELLA_SBATCH_LOG_DIR"]) / "fbd-empirical" / str(i),
64
+ mem_per_cpu="12000",
65
+ )
66
+
67
+ with open(base_output_dir / "fbd_empirical_job_ids.json", "w") as f:
68
+ json.dump(job_ids, f)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bella-companion
3
- Version: 0.0.6
3
+ Version: 0.0.7
4
4
  Summary:
5
5
  Author: gabriele-marino
6
6
  Author-email: gabmarino.8601@gmail.com
@@ -1,13 +1,13 @@
1
1
  bella_companion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- bella_companion/cli.py,sha256=5GbOREOkW0C1Dt43i7Y-Xy1jTr8Tx779is-uQ1nlnUc,1162
2
+ bella_companion/cli.py,sha256=2QM1czJxsfQsOX-miE-OeReXtjMHaR7lX9i73zKki1o,1471
3
+ bella_companion/fbd_empirical/__init__.py,sha256=I-G5rD59c1mNBYuoVNSfq59jD6IuwwJBDkNUCLcY7Qo,87
3
4
  bella_companion/fbd_empirical/data/body_mass.csv,sha256=-UkKNtm9m3g4PjY3BcfdP6z5nL_I6p9cq6cgZ-bWKI8,30360
4
5
  bella_companion/fbd_empirical/data/change_times.csv,sha256=zmc9_z91-XMwKyIoP9v9dVlLcf4MeIHkQiHLjoMriOo,120
5
6
  bella_companion/fbd_empirical/data/sampling_change_times.csv,sha256=Gwi9RcMFy89RyvfxKVZ_MoKVRHOZLuwB_3LEaq8asMQ,32
6
7
  bella_companion/fbd_empirical/data/trees.nwk,sha256=zhvLvPLZelhMThVmvOENkmi3p2aPAARb8KMdHTm6mss,4645318
7
8
  bella_companion/fbd_empirical/figure.py,sha256=4paOXCB1EcxuHzLPxDSleQU2AQ_ndTedtzS1ugiKICs,1018
8
9
  bella_companion/fbd_empirical/notbooks.ipynb,sha256=O45kmz0lZENRDFbKXEWPsIKATfF5GVeS5tCYmrGLnqk,83326
9
- bella_companion/fbd_empirical/params.json,sha256=hU23LniClZL_GSBAxIEJUJgMa93AM8zdtFOq6mt3vkI,311
10
- bella_companion/fbd_empirical/run_beast.py,sha256=pUX4f77kQ_F_tJwRY7Sfz8NUql0sY4VKE1i8pZGte6Y,1952
10
+ bella_companion/fbd_empirical/run_beast.py,sha256=Y2Mcl7tLer-CIgb5rcpZ0sCq7VL6VUejnbZ9mvkRxkU,2532
11
11
  bella_companion/fbd_empirical/summarize_logs.py,sha256=O6rhE606Wa98a8b1KKlLPjUOro1pfyqVTLdQksQMG0g,1439
12
12
  bella_companion/simulations/__init__.py,sha256=EBZAcI8skNPKjrA7CjrqH9ea7DTntmydAD0RqsxNUMM,352
13
13
  bella_companion/simulations/features.py,sha256=DZOBpJGlQ0UinqUZYbEtoemZ2eQGVLV_i-DfpW31qJI,104
@@ -36,7 +36,7 @@ bella_companion/utils/beast.py,sha256=5Vsv98VTE9HrY56WzUSMECjD_rIPxHTMRMD1ZzmA6w
36
36
  bella_companion/utils/explain.py,sha256=uP7HPyn2YiykAI69BQV3RooDpC6qKoCLXfp3Uibp4zk,1475
37
37
  bella_companion/utils/plots.py,sha256=dB_GiJ1HGrZ93cqODz6kB-HeDRPwlm2MkMe9rJZGnfs,3117
38
38
  bella_companion/utils/slurm.py,sha256=v5DaG7YHVyK8KRFptgGDC6I8jxEhyJuMVK9N08pZSAI,1812
39
- bella_companion-0.0.6.dist-info/METADATA,sha256=3smSTa-FBJ-RUBiIt7fiK3VGp4EBlw4nAaScxOkDUG8,576
40
- bella_companion-0.0.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
41
- bella_companion-0.0.6.dist-info/entry_points.txt,sha256=rSeKoAhmjnQqAYFcXBv0gAM2ViJfJe0D8_dD-fWrXeg,50
42
- bella_companion-0.0.6.dist-info/RECORD,,
39
+ bella_companion-0.0.7.dist-info/METADATA,sha256=w-O11B88lzyTN6ENgW_0XTR2UhZEuj6Ar9hxmX_JDWs,576
40
+ bella_companion-0.0.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
41
+ bella_companion-0.0.7.dist-info/entry_points.txt,sha256=rSeKoAhmjnQqAYFcXBv0gAM2ViJfJe0D8_dD-fWrXeg,50
42
+ bella_companion-0.0.7.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- {
2
- "types": "0,1,2,3",
3
- "startTypePriorProbs": "0.25 0.25 0.25 0.25",
4
- "birthRateUpper": 2,
5
- "deathRateUpper": 2,
6
- "samplingRateUpper": 10,
7
- "samplingRateInit": "5 5 5 5 5 5 5",
8
- "migrationRateUpper": 10,
9
- "migrationRateInit": "0.5 0 0 0.5 0.5 0 0 0.5 0.5 0 0 0.5",
10
- "nodes": "16 8"
11
- }