-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprep_for_optfill_ED1.pl
147 lines (97 loc) · 3.63 KB
/
prep_for_optfill_ED1.pl
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!usr/bin/perl -w
#Written by: Wheaton Schroeder
#Written to prepare all the datafiles necessary to do OptFill on the ED model
require "perl_lib_1.pm";
use strict;
system("python convertDB1.py");
system("python convertWLSmodel.py");
printf "\n\nSuccessfully ran convert scripts\n\n";
#get model reaction list
open(MODELRXNS, "<rxns.txt") or die "Could not open the model reaction list file, reason: $!\n";
chomp(my @model_rxns = <MODELRXNS>);
#remove the "/" characters
pop @model_rxns;
shift @model_rxns;
#get the model metabolite list
open(MODELMETS, "<mets.txt") or die "Could not open the model metabolite list file, reason: $!\n";
chomp(my @model_mets = <MODELMETS>);
pop @model_mets;
shift @model_mets;
#get the database reaction list
open(DBRXNS, "<rxns_db_1.txt") or die "Could not open the database reaction list file, reason: $!\n";
chomp(my @db_rxns = <DBRXNS>);
pop @db_rxns;
shift @db_rxns;
#get the database metabolite list
open(DBMETS, "<mets_db_1.txt") or die "Could not open the database metabolite list file, reason: $!\n";
chomp(my @db_mets = <DBMETS>);
pop @db_mets;
shift @db_mets;
#create the all_mets file
open(ALLMETS, ">all_mets_1.txt") or die "could not write to all_mets_1.txt, reason: $!\n";
#write the leading "/"
printf ALLMETS "\/\n";
#combine the two metabolite lists
my @all_mets = @db_mets;
for(my $a=0; $a <= $#model_mets; $a++) {
push @all_mets, $model_mets[$a];
}
#remove redundant metabolites
my $nr_all_mets_ref = &RemoveRedundancies(\@all_mets);
my @nr_all_mets = @$nr_all_mets_ref;
#write the non-redundante metabolite list
for(my $b=0; $b <= $#nr_all_mets; $b++) {
printf ALLMETS "%s\n", $nr_all_mets[$b];
}
#put trailing "/"
printf ALLMETS "\/";
#write the all_rxns_1.txt file
open(ALLRXNS, ">all_rxns_1.txt") or die "could not write all_rxns.tx, reason: $!\n";
#write the leading "/"
printf ALLRXNS "\/\n";
#combine the two metabolite lists
my @all_rxns = @db_rxns;
for(my $c=0; $c <= $#model_rxns; $c++) {
push @all_rxns, $model_rxns[$c];
}
#remove redundant metabolites
my $nr_all_rxns_ref = &RemoveRedundancies(\@all_rxns);
my @nr_all_rxns = @$nr_all_rxns_ref;
#write the non-redundante metabolite list
for(my $d=0; $d <= $#nr_all_rxns; $d++) {
printf ALLRXNS "%s\n", $nr_all_rxns[$d];
}
#put trailing "/"
printf ALLRXNS "\/";
#create the combined Sij matrix
open(MODELSIJ, "<Sij.txt") or die "could not open model Sij matrix, reason: $!\n";
chomp(my @model_sij = <MODELSIJ>);
pop @model_sij;
shift @model_sij;
open(DBSIJ, "<Sij_db_1.txt") or die "could not open database Sij matrix, reason: $!\n";
chomp(my @db_sij = <DBSIJ>);
pop @db_sij;
shift @db_sij;
my @sij_all = @db_sij;
for(my $e = 0; $e <= $#model_sij; $e++) {
push @sij_all, $model_sij[$e];
}
my $nr_sij_all_ref = &RemoveRedundancies(\@sij_all);
my @nr_sij_all = @$nr_sij_all_ref;
open(SIJALL, ">Sij_all_1.txt") or die "could not write to Sij_all_1.txt, reason: $!\n";
printf SIJALL "\/\n";
#create biomass precursor file
open(BIOPRE, ">biomass_precursors_1.txt") or die "could not create biomass precursor file, reason: $!\n";
printf BIOPRE "\/\n";
for(my $f = 0; $f <= $#nr_sij_all; $f++) {
#print Sij line
printf SIJALL "%s\n", $nr_sij_all[$f];
#create biomass precursors files by looking for biomass reaction
#do this by finding Sij entries where the reaction is named "biomass" then get compounds
if($nr_sij_all[$f] =~ /\'(.+?)\'\.\'biomass_wt_37\'/) {
printf BIOPRE "\'%s\'\n", $1;
}
}
printf SIJALL "\/";
printf BIOPRE "\/";
printf "Successfully created all OptFill input files\n\n";