-
Notifications
You must be signed in to change notification settings - Fork 22
/
metadata.sh
executable file
·40 lines (32 loc) · 1.27 KB
/
metadata.sh
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
#!/bin/bash
SETUP="
import tskit, pyslim
ts = tskit.load('benchmark/metadata.trees')
pts = pyslim.load('benchmark/metadata.trees')
tables = ts.tables
tables.individuals.metadata_schema = tskit.MetadataSchema(None)
tables.nodes.metadata_schema = tskit.MetadataSchema(None)
tables.mutations.metadata_schema = tskit.MetadataSchema(None)
nts = tables.tree_sequence()
def tskit_fn(ts):
pid = [ind.metadata['pedigree_id'] for ind in ts.individuals()]
sid = [n.metadata['slim_id'] for n in ts.nodes()]
s = [m.metadata['mutation_list'][0]['selection_coeff'] for m in ts.mutations()]
return 0
def pyslim_fn(ts):
pid = [ind.metadata.pedigree_id for ind in pts.individuals()]
sid = [n.metadata.slim_id for n in pts.nodes()]
s = [m.metadata[0].selection_coeff for m in pts.mutations()]
return 0
def decode_fn(ts):
pid = [pyslim.decode_individual(ind.metadata).pedigree_id for ind in nts.individuals()]
sid = [pyslim.decode_node(n.metadata).slim_id for n in nts.nodes()]
s = [pyslim.decode_mutation(m.metadata)[0].selection_coeff for m in nts.mutations()]
return 0
"
echo "tskit:"
python3 -m timeit -s "$SETUP" "tskit_fn(ts)"
echo "pyslim:"
python3 -m timeit -s "$SETUP" "pyslim_fn(ts)"
echo "pyslim decode:"
python3 -m timeit -s "$SETUP" "decode_fn(nts)"