% Change directory to the COBRA toolbox directory
cd ../../../GitHub/cobratoolbox;
% Initialize the COBRA toolbox without updating the path (false)
initCobraToolbox(false);

% Load the model
% Read the Saccharomyces cerevisiae metabolic model from 'yeast-GEM.xml' file
model = readCbModel('yeast-GEM.xml');

%% Gene knockout simulations
% Knockout of ERG10 gene (YPL028W)
model_1 = deleteModelGenes(model, {'YPL028W'});
% Knockout of ERG13 gene (YML126C)
model_2 = deleteModelGenes(model, {'YML126C'});
% Knockout of HMG1 and HMG2 genes (YML075C, YLR450W)
model_3 = deleteModelGenes(model, {'YML075C', 'YLR450W'});
% Knockout of ERG12 gene (YMR208W)
model_4 = deleteModelGenes(model, {'YMR208W'});
% Knockout of ERG8 gene (YMR220W)
model_5 = deleteModelGenes(model, {'YMR220W'});
% Knockout of ERG19 gene (YNR043W)
model_6= deleteModelGenes(model, {'YNR043W'});

%% Growth rate calculations
% Perform Flux Balance Analysis using default objective (growth rate, units: mmol/gDW/h)
% Growth rate of the original model
FBAsolution_0 = optimizeCbModel(model, 'max');
fprintf('Original Growth Rate: %f mmol/gDCW/hr\n', FBAsolution_0.f);

% Growth rate after knocking out ERG10
FBAsolution_1 = optimizeCbModel(model_1, 'max');
fprintf('Growth Rate after ERG10 Knockout: %f mmol/gDCW/hr\n', FBAsolution_1.f);

% Growth rate after knocking out ERG13
FBAsolution_2 = optimizeCbModel(model_2, 'max');
fprintf('Growth Rate after ERG13 Knockout: %f mmol/gDCW/hr\n', FBAsolution_2.f);

% Growth rate after knocking out HMG1/2
FBAsolution_3 = optimizeCbModel(model_3, 'max');
fprintf('Growth Rate after HMG1/2 Knockout: %f mmol/gDCW/hr\n', FBAsolution_3.f);

% Growth rate after knocking out ERG12
FBAsolution_4 = optimizeCbModel(model_4, 'max');
fprintf('Growth Rate after ERG12 Knockout: %f mmol/gDCW/hr\n', FBAsolution_4.f);

% Growth rate after knocking out ERG8
FBAsolution_5 = optimizeCbModel(model_5, 'max');
fprintf('Growth Rate after ERG8 Knockout: %f mmol/gDCW/hr\n', FBAsolution_5.f);

% Growth rate after knocking out ERG19
FBAsolution_6 = optimizeCbModel(model_6, 'max');
fprintf('Growth Rate after ERG19 Knockout: %f mmol/gDCW/hr\n', FBAsolution_6.f);
