-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
85 lines (65 loc) · 2.67 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python3
'''
This version composites everything together into a single SVG image per
frame, converts each frame with inkscape, then uses ffmpeg to create the movie.
It uses less disk space than layers.py.
'''
# Check environment to make sure we've got everything we need.
import pathlib
import tskit
import sqlite3
import numpy
import midiutil
import srt
#import config_ne2 as config
import config
#import config_1kg_bertin_short as config
assert pathlib.Path(config.treeseq).exists()
assert pathlib.Path(config.ffmpeg).exists()
assert pathlib.Path(config.inkscape).exists()
assert pathlib.Path(config.timidity).exists()
# And now the stuff we need for this script.
import sys
import argparse
import chromosome_movie
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('commands', nargs='+',
choices=['all', 'database', 'chromosome_map', 'clef', 'world_map', 'background', 'order', 'foreground', 'audio', 'movie', 'preview'])
args = parser.parse_args()
commands = args.commands
#for folder in config.folders:
# folder.mkdir(parents=True, exist_ok=True)
if 'database' in commands or 'all' in commands:
obj = chromosome_movie.database.Database(config)
obj.write_db()
if 'chromosome_map' in commands or 'all' in commands:
obj = chromosome_movie.chromosome_map.ChromosomeMap(config)
obj.write_db()
if 'clef' in commands or 'all' in commands:
obj = chromosome_movie.clef.Clef(config)
obj.write_svg()
if 'world_map' in commands or 'all' in commands or 'reorder' in commands:
obj = chromosome_movie.world_map.WorldMap(config)
obj.write()
if 'background' in commands or 'all' in commands or 'reorder' in commands:
obj = chromosome_movie.composite.Background(config)
obj.write_svg()
obj.write_png()
if 'order' in commands or 'all' in commands or 'reorder' in commands:
obj = chromosome_movie.order.Order(config)
obj.write_db()
if 'foreground' in commands or 'all' in commands or 'reorder' in commands:
obj = chromosome_movie.composite.Foreground(config)
obj.write_svg()
obj.write_png()
if 'audio' in commands or 'all' in commands or 'reorder' in commands:
obj = chromosome_movie.audio.Audio(config)
obj.write_midi()
if 'movie' in commands or 'all' in commands or 'reorder' in commands:
obj = chromosome_movie.movie.Movie(config)
obj.write_bg_fg_mp4()
if 'preview' in commands:
obj = chromosome_movie.movie.Movie(config, layer_names=['average_location', 'local_frequencies'])
obj.write_concat()
obj.write_preview()