Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to SBML 5.16 #1054

Merged
merged 13 commits into from
Dec 12, 2017
Next Next commit
Further IO updates
  • Loading branch information
tpfau committed Nov 27, 2017
commit 02d616fcb003c5fa46296ba3e220b144af7ea3c1
3 changes: 3 additions & 0 deletions src/analysis/exploration/getModelSubSystems.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
if isfield(model, 'subSystems')
orderedSubs = cellfun(@(x) columnVector(x),model.subSystems,'UniformOUtput',false);
subSystems = setdiff(vertcat(orderedSubs{:}),'');
if isempty(subSystems)
subSystems = {};
end
else
subSystems = {};
end
2 changes: 1 addition & 1 deletion src/base/io/utilities/SBML/makeSBMLAnnotationString.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
if isempty(model.(knownExistentFields{fieldid,3}){position})
continue
end
ids = strsplit(model.(knownExistentFields{fieldid,3}){position},';');
ids = strtrim(strsplit(model.(knownExistentFields{fieldid,3}){position},';'));
correctids = ~cellfun(@isempty, regexp(ids,knownExistentFields{fieldid,5}));
%If we have correct ids, we will annotate those.
if any(correctids)
Expand Down
35 changes: 35 additions & 0 deletions src/base/io/utilities/readSBML.m
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,22 @@
end
end

if isfield(modelSBML,'groups_version') && modelSBML.groups_version == 1
%There is a groups field, we will override existing information for all
%elements in groups if its non empty.
if isfield(modelSBML,'groups_group') && ~isempty(modelSBML.groups_group)
group_ids = {modelSBML.groups_group.groups_id};
group_names = {modelSBML.groups_group.groups_name};
group_member_set = {modelSBML.groups_group.groups_member};
group_members = cellfun(@(x) {x.groups_idRef},group_member_set,'Uniformoutput',false);
groups = cellfun(@(x) getMembersForGroup(x,group_ids,group_members),group_ids,'UniformOutput',false);
%For now, we only assign groups to reactions.
for i = 1:size(group_names,2)
model = addSubSystemsToReactions(model,model.rxns(ismember(model.rxns,groups{i})),group_names{i});
end
end
end


%% Some finishing touches (e.g. check for naming schemes, and compartment
%ids.
Expand Down Expand Up @@ -484,3 +500,22 @@
end
field = {startstruct.(fieldname)};
end


function members = getMembersForGroup(groupID, groupIDs, groupMembers, groupsDone)
%Get all members from a list of groups, which can reference themselves.
if ~exist('groupsDone','var')
groupsDone = {groupID};
end
currentMembers = groupMembers{ismember(groupIDs,groupID)};
groupsInMembers = ismember(groupIDs,currentMembers);
currentGroups = setdiff(groupIDs(groupsInMembers),groupsDone);
groupsDone = union(currentGroups,groupsDone);

members = cellfun(@(x) getMembersForGroup(x,groupIDs,groupMembers,groupsDone),currentGroups,'UniformOutput',false);

members = setdiff(union(currentMembers,vertcat(members{:})),groupsDone);

end


Loading