Skip to content

Commit

Permalink
feat: refactor adding of new grRules
Browse files Browse the repository at this point in the history
  • Loading branch information
edkerk committed May 23, 2022
1 parent 6a0556e commit bbaefdb
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 292 deletions.
14 changes: 14 additions & 0 deletions code/curateMetsRxnsGenes.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@
% Output:
% newModel curated RAVEN model structure

if nargin==4
error('Provide both a ''rxnsInfo'' and a ''rxnsCoeffs'' file')
end
if nargin<4
rxnsInfo='none';
rxnsCoeffs='none';
end
if nargin<3
genesInfo='none';
end
newModel=model;

%% Metabolites
if ~strcmp(metsInfo,'none')
fid = fopen(metsInfo);
Expand Down Expand Up @@ -302,6 +313,9 @@
emptyMiriam = all(cellfun(@isempty,miriamValues),1);
miriamName(emptyMiriam) = [];
miriamValues(:,emptyMiriam) = [];
if ~isfield(newModel,[type 'Miriams']);
newModel.([type 'Miriams'])=cell(numel(newModel.([type 's'])),1);
end
if ~isempty(miriamName)
for i=1:numel(miriamName)
newModel = editMiriam(newModel,type,modelIndex,miriamName{i},miriamValues(:,i),'replace');
Expand Down
7 changes: 0 additions & 7 deletions code/modelCuration/addDBNewGeneAnnotation.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,5 @@
end
end

% Add protein name for genes
for i = 1:length(model.genes)
model.proteins{i} = strcat('COBRAProtein',num2str(i));
end

% Save model:
model = rmfield(model,'grRules');
saveYeastModel(model)
cd modelCuration
40 changes: 13 additions & 27 deletions code/modelCuration/addTransNewGPR.m
Original file line number Diff line number Diff line change
@@ -1,42 +1,28 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% addTransNewGPR
% Add changes from the database new anootation for new genes + manual curation on those changes
% Input: model, databasenewGPR.tsv,SGDgeneNames.tsv.
% As for the reference of new GPR, please find detailed information in:
% data/databases/DBnewGeneAnnotation.tsv
% NOTE: changeGeneAssociation.m is a function from cobra
% Add changes from the database new anootation for new genes + manual
% curation on those changes
% As for the reference of new GPRs, please find detailed information in:
% data/modelCuration/transRxnNewGPR/TransRxnNewGPR.tsv
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Load model
cd ..
model = loadYeastModel;

% Add new genes
newModel = curateMetsRxnsGenes(model,'none','../data/modelCuration/transRxnNewGPR/transRxnNewGPRGenes.tsv');

% Change GPR relations
fid = fopen('../data/modelCuration/TransRxnNewGPR.tsv');
changegpr = textscan(fid,'%s %s','Delimiter','\t','HeaderLines',1);
fid = fopen('../data/modelCuration/transRxnNewGPR/TransRxnNewGPR.tsv');
changegpr = textscan(fid,'%q %q %q','Delimiter','\t','HeaderLines',1);
newGPR.ID = changegpr{1};
newGPR.GPR = changegpr{2};
fclose(fid);
for i = 1:length(newGPR.ID)
rxnIndex = find(strcmp(model.rxns, newGPR.ID(i)));
model = changeGrRules(model, model.rxns{rxnIndex}, newGPR.GPR{i});
end

% Delete unused genes (if any)
model = deleteUnusedGenes(model);
newModel=changeGrRules(newModel,newGPR.ID,newGPR.GPR);

% Add gene standard name for new genes
fid = fopen('../data/databases/SGDgeneNames.tsv');
yeast_gene_annotation = textscan(fid,'%s %s','Delimiter','\t','HeaderLines',1);
fclose(fid);
for i = 1: length(model.genes)
geneIndex = strcmp(yeast_gene_annotation{1}, model.genes{i});
if sum(geneIndex) == 1 && ~isempty(yeast_gene_annotation{2}{geneIndex})
model.geneNames{i} = yeast_gene_annotation{2}{geneIndex};
else
model.geneNames{i} = model.genes{i};
end
end

saveYeastModel(model)
% Delete unused genes (if any)
newModel = deleteUnusedGenes(newModel);
saveYeastModel(newModel)
cd modelCuration
129 changes: 0 additions & 129 deletions data/modelCuration/TransRxnNewGPR.tsv

This file was deleted.

129 changes: 0 additions & 129 deletions data/modelCuration/TransRxnNewGPR_proof.tsv

This file was deleted.

Loading

0 comments on commit bbaefdb

Please sign in to comment.