1#!/usr/bin/env perl 2# -*-Perl-*- 3## 4## \file addCVTerms.pl 5## \brief adds controlled vocabulary terms to a species in a model 6## \author Sarah Keating 7## 8## <!-------------------------------------------------------------------------- 9## This sample program is distributed under a different license than the rest 10## of libSBML. This program uses the open-source MIT license, as follows: 11## 12## Copyright (c) 2013-2018 by the California Institute of Technology 13## (California, USA), the European Bioinformatics Institute (EMBL-EBI, UK) 14## and the University of Heidelberg (Germany), with support from the National 15## Institutes of Health (USA) under grant R01GM070923. All rights reserved. 16## 17## Permission is hereby granted, free of charge, to any person obtaining a 18## copy of this software and associated documentation files (the "Software"), 19## to deal in the Software without restriction, including without limitation 20## the rights to use, copy, modify, merge, publish, distribute, sublicense, 21## and/or sell copies of the Software, and to permit persons to whom the 22## Software is furnished to do so, subject to the following conditions: 23## 24## The above copyright notice and this permission notice shall be included in 25## all copies or substantial portions of the Software. 26## 27## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 30## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 32## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 33## DEALINGS IN THE SOFTWARE. 34## 35## Neither the name of the California Institute of Technology (Caltech), nor 36## of the European Bioinformatics Institute (EMBL-EBI), nor of the University 37## of Heidelberg, nor the names of any contributors, may be used to endorse 38## or promote products derived from this software without specific prior 39## written permission. 40## ------------------------------------------------------------------------ --> 41## 42 43use LibSBML; 44no strict; 45 46if ($#ARGV != 1) { 47 print "usage: addCVTerms <input-filename> <output-filename>\n"; 48 print " Adds controlled vocabulary term to a species\n"; 49 exit 2; 50} 51 52$d = LibSBML::readSBML($ARGV[0]); 53$errors = $d->getNumErrors(); 54 55if ($errors > 0) { 56 print("Read Error(s):"); 57 $d->printErrors(); 58 print("Correct the above and re-run."); 59 exit $errors; 60} 61 62$n = $d->getModel()->getNumSpecies(); 63 64if ($n <= 0) { 65 print("Model has no species.\n Cannot add CV terms\n"); 66 exit 0; 67} 68 69$s = $d->getModel()->getSpecies(0); 70if ( not $s->isSetMetaId()) { 71 $s->setMetaId("metaid_s0000052"); 72} 73 74$cv = new LibSBML::CVTerm(); 75$cv->setQualifierType($LibSBML::BIOLOGICAL_QUALIFIER); 76$cv->setBiologicalQualifierType($LibSBML::BQB_IS_VERSION_OF); 77$cv->addResource("http://www.geneontology.org/#GO:0005892"); 78 79$cv2 = new LibSBML::CVTerm(); 80$cv2->setQualifierType($LibSBML::BIOLOGICAL_QUALIFIER); 81$cv2->setBiologicalQualifierType($LibSBML::BQB_IS); 82$cv2->addResource("http://www.geneontology.org/#GO:0005895"); 83 84$cv1 = new LibSBML::CVTerm(); 85$cv1->setQualifierType($LibSBML::BIOLOGICAL_QUALIFIER); 86$cv1->setBiologicalQualifierType($LibSBML::BQB_IS_VERSION_OF); 87$cv1->addResource("http://www.ebi.ac.uk/interpro/#IPR002394"); 88 89$s->addCVTerm($cv); 90$s->addCVTerm($cv2); 91$s->addCVTerm($cv1); 92 93LibSBML::writeSBML($d, $ARGV[1]); 94 95exit $errors; 96 97