Skip to content

Commit

Permalink
upload helper scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscozorrilla committed Jan 4, 2024
1 parent 699c122 commit 935dfb7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions code/04_gf_rxns_compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
while read model;do
media=$(basename $(dirname $model));
species=$(basename ${model%.*});
less $model|grep GAP_FILL -B 12|grep "reaction id"|sed 's/ fast.*$//g'|sed 's/^.*<//g'|sed 's/reaction id="//g'|sed 's/ name="//g'|sed 's/ reversible="//g'|sed 's/"$//g'|tr '"' '\t'|sed "s/^/$media\t$species\t/g";
done< <(find models/ -name "*.xml")
5 changes: 5 additions & 0 deletions code/04_model_summary_compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
while read file;do
media=$(basename $(dirname $file));
model=$(basename $file|sed 's/.xml_summary.txt//g');
paste $file|grep -v Reactions|grep -v Metabolites|sed 's/ /\t/g'|sed "s/^/${model}\t${media}\t/g";
done< <(find models/ -name "*summary.txt") > model_summary.tsv
30 changes: 30 additions & 0 deletions code/04_model_summary_generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys
import glob
import cobra
import reframed
from reframed import load_cbmodel
from reframed import Environment
from reframed import FBA

# Loop to read in models in hardcoded folder with .xml extension
for file in glob.iglob(r'*.xml'):

# Use try to handle exceptions with reading SMBL model
try:

# Load model
model = load_cbmodel(file, flavor='fbc2')

# open file
sys.stdout = open(file+"_summary.txt", "w")

# get summary
summary = model.summary()


# Catch cobra.io.sbml.CobraSBMLError and continue loop
except cobra.io.sbml.CobraSBMLError:

# Print message with model ID for log
print("The model",file,"raised an SBML error and could not be read in by COBRA")
pass

0 comments on commit 935dfb7

Please sign in to comment.