-
Notifications
You must be signed in to change notification settings - Fork 3
/
Snakefile
106 lines (88 loc) · 2.99 KB
/
Snakefile
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import os
import glob
def get_ids_from_path_pattern(path_pattern):
ids = sorted([os.path.basename(os.path.splitext(val)[0])
for val in (glob.glob(path_pattern))])
return ids
IDs = get_ids_from_path_pattern('models/*')
rule all:
input:
expand(f'sim_detailed/{{IDs}}/done.log', IDs=IDs)
shell:
"""
echo "Gathering {input} ... "
"""
rule smetana_global:
input:
f'models/{{IDs}}'
output:
f'sim/{{IDs}}/done.log'
message:
"""
This rule will look for communities of GEMs in the models subdir and simulate them 100 times using the SMETANA global algorithm
Assumes GEMs were carved using the cobra flag
"""
shell:
"""
# Activate conda environment
echo -e "Activating conda environment ... "
set +u;source activate carve;set -u;
# This is just to make sure that output folder exists
mkdir -p $(dirname {output})
# Move to input folder with GEMs subdir
cd {input}
# Run SMETANA on loop 100 times
for i in {{1..100}}; do echo "Running simulation $i out of 100 ... "; smetana --flavor ucsd -o ../../$(dirname {output})/sim_${{i}}.tsv -v -g models/*.xml; done
# Create dummy file and return to original dir
cd ../..
touch {output}
"""
rule smetana_detailed_gut:
input:
f'models/{{IDs}}'
output:
f'sim_detailed/{{IDs}}/done.log'
message:
"""
This rule will look for communities of GEMs in the models subdir and simulate them using the SMETANA detailed algorithm
Assumes GEMs were carved using the cobra flag
"""
shell:
"""
# Activate conda environment
echo -e "Activating conda environment ... "
set +u;source activate carve;set -u;
# This is just to make sure that output folder exists
mkdir -p $(dirname {output})
# Move to input folder with GEMs subdir
cd {input}
# Run SMETANA detailed
smetana --flavor cobra -o ../../$(dirname {output})/detailed.tsv -v -d --mediadb ../media_db.tsv -m M11 models/*.xml
# Create dummy file and return to original dir
cd ../..
touch {output}
"""
rule carve:
input:
f'models/{{IDs}}/genomes'
output:
directory(f'models/{{IDs}}/models')
message:
"""
This rule runs carveme in series for a number of subfolders in parallel
Note that this is not a practical implementation if gapfilling media is not the same for all communities
"""
shell:
"""
# Activate conda environment
echo -e "Activating conda environment ... "
set +u;source activate carve;set -u;
# This is just to make sure that output folder exists
mkdir -p $(dirname {output})
# Move to input folder with GEMs subdir
cd {input}
# Run carveme
while read model;do
carve -v --mediadb ../media_db.tsv -g M8 --cobra -o ../models/${model}.xml $model;
done< <(ls|grep faa)
"""