diff --git a/src/reconstruction/homology/getModelFromHomology.m b/src/reconstruction/homology/getModelFromHomology.m index ca26e70a..00866bdf 100755 --- a/src/reconstruction/homology/getModelFromHomology.m +++ b/src/reconstruction/homology/getModelFromHomology.m @@ -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 @@ -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 diff --git a/tests/function_tests/tReconstruction.m b/tests/function_tests/tReconstruction.m index 71a07e5e..cdc7d5ff 100644 --- a/tests/function_tests/tReconstruction.m +++ b/tests/function_tests/tReconstruction.m @@ -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');