Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/reconstruction/homology/getModelFromHomology.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@
% unneccesary old genes, the models should not have "or"-relations in their
% grRules (use expandModel).
%
% The gene ids of the new organism in blastStructure become its gene ids in
% the draft model, so they cannot contain whitespace, parentheses, "|" or
% "&". FASTA headers from UniProt, such as "sp|P33284|HXK_KLULA", should be
% reduced to the accession first.
%
% The resulting draft model contains only reactions associated with
% orthologous genes, plus the gene-free ones with keepGeneFree. With
% complexPolicy "flag", the old (original) genes involved in "and" relations
Expand Down Expand Up @@ -423,6 +428,17 @@
finalMappings{i}=finalMappings{i}(usedNewGenes,:);
end

%Gene ids end up in grRules, which are split at whitespace and parentheses,
%and which COBRA also splits at "|" and "&"
unusable=allGenes{1}(~cellfun(@isempty,regexp(allGenes{1},'[\s()|&]','once')));
if ~isempty(unusable)
error('RAVEN:badInput',['%d gene ids of "%s" cannot be written into a grRule, '...
'because they contain whitespace, parentheses, "|" or "&": %s. Map them '...
'to gene ids first, or use the accession alone for UniProt headers such '...
'as "sp|P33284|HXK_KLULA".'],numel(unusable),getModelFor,...
strjoin(unusable(1:min(3,end))',', '));
end

%Now is it time to choose which reactions should be included from which
%models. If there is a preferred order specified then each gene can only
%result in reactions from one model, otherwise they should all be included
Expand Down
7 changes: 7 additions & 0 deletions tests/function_tests/tReconstruction.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ function getModelFromHomologyComplexPolicyAndOptions(testCase)
testCase.verifyEqual(flag.rxnNotes{1}, 'Included by getModelFromHomology');
end

function getModelFromHomologyRejectsGeneIdsThatSplit(testCase)
src = testCase.model; src.id = 'srcModel';
newGenes = cellstr(strcat('sp|P', string(1:10)', '|X_BUG'));
bs = makeFakeBlastStructure([src.genes(1:10), newGenes], 'srcModel', 'tgtOrg');
testCase.verifyError(@() getModelFromHomology({src}, bs, 'tgtOrg'), 'RAVEN:badInput');
end

function getModelFromHomologyRejectsUnknownComplexPolicy(testCase)
src = testCase.model; src.id = 'srcModel';
bs = makeFakeBlastStructure([src.genes(1:10), strcat('t_', src.genes(1:10))], 'srcModel', 'tgtOrg');
Expand Down
Loading