1# 2# @file stripPackage.R 3# @brief Strips the given package from the given SBML file. 4# @author Frank Bergmann 5# 6# <!-------------------------------------------------------------------------- 7# This sample program is distributed under a different license than the rest 8# of libSBML. This program uses the open-source MIT license, as follows: 9# 10# Copyright (c) 2013-2018 by the California Institute of Technology 11# (California, USA), the European Bioinformatics Institute (EMBL-EBI, UK) 12# and the University of Heidelberg (Germany), with support from the National 13# Institutes of Health (USA) under grant R01GM070923. All rights reserved. 14# 15# Permission is hereby granted, free of charge, to any person obtaining a 16# copy of this software and associated documentation files (the "Software"), 17# to deal in the Software without restriction, including without limitation 18# the rights to use, copy, modify, merge, publish, distribute, sublicense, 19# and/or sell copies of the Software, and to permit persons to whom the 20# Software is furnished to do so, subject to the following conditions: 21# 22# The above copyright notice and this permission notice shall be included in 23# all copies or substantial portions of the Software. 24# 25# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 28# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 30# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 31# DEALINGS IN THE SOFTWARE. 32# 33# Neither the name of the California Institute of Technology (Caltech), nor 34# of the European Bioinformatics Institute (EMBL-EBI), nor of the University 35# of Heidelberg, nor the names of any contributors, may be used to endorse 36# or promote products derived from this software without specific prior 37# written permission. 38# ------------------------------------------------------------------------ --> 39# 40# 41# Usage: R --slave -f stripPackage.R --args <full path to input file> <package-to-strip> <full path to output file> 42# 43# 44 45library(libSBML) 46 47args <- commandArgs(trailingOnly = TRUE) 48 49if (length(args) != 3) 50{ 51 stop("Usage: stripPackage input-filename package-to-strip output-filename\n"); 52} 53 54doc = readSBML(args[1]); 55 56if (SBMLDocument_getNumErrors(doc) > 0) { 57 SBMLDocument_printErrors(doc); 58} else { 59 props = ConversionProperties(); 60 ConversionProperties_addOption(props, "stripPackage", TRUE, "Strip SBML Level 3 package constructs from the model"); 61 ConversionProperties_addOption(props, "package", args[2], "Name of the SBML Level 3 package to be stripped"); 62 if (SBMLDocument_convert(doc, props) != 0) { 63 stop("Error: conversion failed...\n"); 64 } 65 writeSBML(doc, args[3]); 66} 67 68