1 /** 2 * @file FbcAssociation.h 3 * @brief Implementation of the FbcAssociation class 4 * @author SBMLTeam 5 * 6 * <!-------------------------------------------------------------------------- 7 * This file is part of libSBML. Please visit http://sbml.org for more 8 * information about SBML, and the latest version of libSBML. 9 * 10 * Copyright (C) 2020 jointly by the following organizations: 11 * 1. California Institute of Technology, Pasadena, CA, USA 12 * 2. University of Heidelberg, Heidelberg, Germany 13 * 3. University College London, London, UK 14 * 15 * Copyright (C) 2019 jointly by the following organizations: 16 * 1. California Institute of Technology, Pasadena, CA, USA 17 * 2. University of Heidelberg, Heidelberg, Germany 18 * 19 * Copyright (C) 2013-2018 jointly by the following organizations: 20 * 1. California Institute of Technology, Pasadena, CA, USA 21 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK 22 * 3. University of Heidelberg, Heidelberg, Germany 23 * 24 * Copyright (C) 2009-2013 jointly by the following organizations: 25 * 1. California Institute of Technology, Pasadena, CA, USA 26 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK 27 * 28 * Copyright (C) 2006-2008 by the California Institute of Technology, 29 * Pasadena, CA, USA 30 * 31 * Copyright (C) 2002-2005 jointly by the following organizations: 32 * 1. California Institute of Technology, Pasadena, CA, USA 33 * 2. Japan Science and Technology Agency, Japan 34 * 35 * This library is free software; you can redistribute it and/or modify it 36 * under the terms of the GNU Lesser General Public License as published by 37 * the Free Software Foundation. A copy of the license agreement is provided 38 * in the file named "LICENSE.txt" included with this software distribution 39 * and also available online as http://sbml.org/software/libsbml/license.html 40 * ------------------------------------------------------------------------ --> 41 * 42 * @class FbcAssociation 43 * @sbmlbrief{fbc} Base class for FbcAnd, FbcOr, and GeneProductRef 44 * 45 * The FbcAssociation class is the abstract base class for the classes that 46 * can be used as children of the GeneProductAssociation child of a Reaction. 47 * The FbcAnd class is used when all of its children are definitely associated 48 * with the Reaction; the FbcOr class is used when at least one of its children 49 * are associated with the Reaction; and the GeneProductRef class is used to 50 * denote a particular GeneProduct. 51 * 52 * @copydetails doc_note_fbcv2_annotation_replacement 53 * 54 * @see ListOfFbcAssociations 55 * @see FbcAnd 56 * @see FbcOr 57 * @see GeneProductRef 58 * 59 * <!-- ------------------------------------------------------------------- --> 60 * @class ListOfFbcAssociations 61 * @sbmlbrief{fbc} A list of FbcAssociation objects. 62 * 63 * @htmlinclude not-sbml-warning.html 64 * 65 * The ListOfFbcAssociations is a container of FbcAssociation objects for the 66 * FbcAnd and FbcOr classes. Unlike the ListOf___ classes in SBML, the 67 * ListOfFbcAssociations is not a class that appears in the “fbc” 68 * Version 2 specification, and instead is used internally in libSBML as 69 * a convenience class to store arbitrary numbers of FbcAssociation objects. 70 * Also unlike other ListOf___ classes, the FbcAnd and FbcOr classes require 71 * at least two child FbcAssociation objects, so valid ListOfFbcAssociations 72 * libsbml objects will always contain two or more children. These children 73 * will have element names associated with their derived class, not the base 74 * FbcAssociation class: <code><fbc:and></code>, 75 * <code><fbc:or></code>, and <code><fbc:geneProductRef></code>. 76 * 77 * @copydetails doc_note_fbcv2_annotation_replacement 78 * 79 * @warning It is important to be clear that <em>ListOfFbcAssociations is not 80 * written out in the XML output produced by libSBML</em>—the 81 * constructs only exist in software to enable software applications to 82 * manipulate FbcAssociation objects in a way that mirrors how other lists of 83 * components in SBML are manipulated. ListOfFbcAssociations is abstracted 84 * away when an SBML “fbc” model file is actually written out in 85 * the final XML form. 86 * 87 * @see FbcAssociation 88 * @see FbcAnd 89 * @see FbcOr 90 * @see GeneProductRef 91 */ 92 93 #ifndef FbcAssociation_H__ 94 #define FbcAssociation_H__ 95 96 97 #include <sbml/common/extern.h> 98 #include <sbml/common/sbmlfwd.h> 99 #include <sbml/packages/fbc/common/fbcfwd.h> 100 101 102 #ifdef __cplusplus 103 104 105 #include <string> 106 107 108 #include <sbml/SBase.h> 109 #include <sbml/ListOf.h> 110 #include <sbml/packages/fbc/extension/FbcExtension.h> 111 112 113 LIBSBML_CPP_NAMESPACE_BEGIN 114 115 class FbcAnd; 116 class FbcOr; 117 class GeneProductRef; 118 class FbcModelPlugin; 119 120 121 class LIBSBML_EXTERN FbcAssociation : public SBase 122 { 123 124 protected: 125 /** @cond doxygenLibsbmlInternal */ 126 std::string mElementName; 127 /** @endcond */ 128 129 public: 130 131 /** 132 * Creates a new FbcAssociation with the given SBML Level, Version, and 133 * “fbc”package version. 134 * 135 * @param level an unsigned int, the SBML Level to assign to this 136 * FbcAssociation. 137 * 138 * @param version an unsigned int, the SBML Version to assign to this 139 * FbcAssociation. 140 * 141 * @param pkgVersion an unsigned int, the SBML “fbc” package 142 * Version to assign to this FbcAssociation. 143 * 144 * @copydetails doc_note_setting_lv_pkg 145 */ 146 FbcAssociation(unsigned int level = FbcExtension::getDefaultLevel(), 147 unsigned int version = FbcExtension::getDefaultVersion(), 148 unsigned int pkgVersion = FbcExtension::getDefaultPackageVersion()); 149 150 151 /** 152 * Creates a new FbcAssociation with the given FbcPkgNamespaces object. 153 * 154 * @copydetails doc_what_are_sbml_package_namespaces 155 * 156 * @param fbcns the FbcPkgNamespaces object. 157 * 158 * @copydetails doc_note_setting_lv_pkg 159 */ 160 FbcAssociation(FbcPkgNamespaces* fbcns); 161 162 163 /** 164 * Copy constructor for FbcAssociation. 165 * 166 * @param orig the FbcAssociation instance to copy. 167 */ 168 FbcAssociation(const FbcAssociation& orig); 169 170 171 /** 172 * Assignment operator for FbcAssociation. 173 * 174 * @param rhs the object whose values are used as the basis 175 * of the assignment. 176 */ 177 FbcAssociation& operator=(const FbcAssociation& rhs); 178 179 180 /** 181 * Creates and returns a deep copy of this FbcAssociation object. 182 * 183 * @return a (deep) copy of this FbcAssociation object. 184 */ 185 virtual FbcAssociation* clone () const; 186 187 188 /** 189 * Destructor for FbcAssociation. 190 */ 191 virtual ~FbcAssociation(); 192 193 194 /** 195 * Returns @c true, if this abstract FbcAssociation is of type FbcAnd. 196 * 197 * @return @c true, if this abstract FbcAssociation is of type FbcAnd. 198 * 199 */ 200 virtual bool isFbcAnd() const; 201 202 203 /** 204 * Returns @c true, if this abstract FbcAssociation is of type FbcOr. 205 * 206 * @return @c true, if this abstract FbcAssociation is of type FbcOr. 207 * 208 */ 209 virtual bool isFbcOr() const; 210 211 212 /** 213 * Returns @c true, if this abstract FbcAssociation is of type 214 * GeneProductRef. 215 * 216 * @return @c true, if this abstract FbcAssociation is of type 217 * GeneProductRef. 218 * 219 */ 220 virtual bool isGeneProductRef() const; 221 222 223 /** 224 * Returns the XML element name of this object. 225 * 226 * For FbcAssociation, the XML element name is always @c "fbcAssociation". 227 * 228 * @return the name of this element, i.e. @c "fbcAssociation". 229 */ 230 virtual const std::string& getElementName () const; 231 232 233 /** 234 * Returns the libSBML type code for this SBML object. 235 * 236 * @copydetails doc_what_are_typecodes 237 * 238 * @return the SBML type code for this object: 239 * @sbmlconstant{SBML_FBC_ASSOCIATION, SBMLTypeCode_t} (default). 240 * 241 * @copydetails doc_warning_typecodes_not_unique 242 * 243 * @see getElementName() 244 * @see getPackageName() 245 */ 246 virtual int getTypeCode () const; 247 248 249 /** 250 * Predicate returning @c true if all the required attributes 251 * for this FbcAssociation object have been set. 252 * 253 * @note FbcAssociation has no required attributes, so this 254 * method always returns @c true. 255 * 256 * @return a boolean value indicating whether all the required 257 * attributes for this object have been defined. 258 */ 259 virtual bool hasRequiredAttributes() const; 260 261 262 /** @cond doxygenLibsbmlInternal */ 263 264 /** 265 * Subclasses should override this method to write out their contained 266 * SBML objects as XML elements. Be sure to call your parent's 267 * implementation of this method as well. 268 */ 269 virtual void writeElements (XMLOutputStream& stream) const; 270 271 /** @endcond */ 272 273 274 /** @cond doxygenLibsbmlInternal */ 275 276 /** 277 * Accepts the given SBMLVisitor. 278 */ 279 virtual bool accept (SBMLVisitor& v) const; 280 281 /** @endcond */ 282 283 284 /** 285 * Parses a gene association in infix format and returns a corresponding 286 * Association object. 287 * 288 * This parses a string that has a list of gene names and conjunctions 289 * or disjunctions. For example: 290 * @verbatim 291 (b2422) and (b2425) and (b2423) and (b2424) or (b2422) and (b2423) and (b2424) and (b2413) and (b3917) 292 @endverbatim 293 * 294 * The 'and' operator takes precedence over the 'or' operator, meaning that 295 * the above input string would turn into two groups of gene names: either 296 * "b2422, b2425, b2423, and b2424" or "b2422, b2423, b2424, b2413, and b3917". 297 * Parentheses may be added to make things more clear, and to encode 298 * alternative schemes. 299 * 300 * This method also creates missing GeneProduct objects, in case the unique 301 * reference does not yet exist. 302 * 303 * @param association the string to parse. 304 * @param plugin the FbcModelPlugin on which to add the geneProduct elements. 305 * @param usingId boolean indicating whether the infix assumes identifiers (@c true) 306 * or labels (@c false default). 307 * @param addMissingGP boolean indicating whether to add missing geneProducts 308 * (@c true default) or not (@c false). 309 * 310 * @return the parsed association, or @c NULL in case of an error. 311 * 312 * @copydetails doc_note_static_methods 313 */ 314 static FbcAssociation* parseFbcInfixAssociation(const std::string& association, 315 FbcModelPlugin* plugin, 316 bool usingId=false, 317 bool addMissingGP=true); 318 319 320 /** 321 * Converts this FbcAssociation object into an infix string representation. 322 * 323 * @return the association as infix string. 324 */ 325 virtual std::string toInfix(bool usingId=false) const; 326 327 328 /** @cond doxygenLibsbmlInternal */ 329 330 /** 331 * Sets the parent SBMLDocument. 332 */ 333 virtual void setSBMLDocument (SBMLDocument* d); 334 335 /** @endcond */ 336 337 338 /** @cond doxygenLibsbmlInternal */ 339 340 /** 341 * Enables/Disables the given package with this element. 342 */ 343 virtual void enablePackageInternal(const std::string& pkgURI, 344 const std::string& pkgPrefix, bool flag); 345 346 /** @endcond */ 347 348 349 #ifndef SWIG 350 351 352 353 /** @cond doxygenLibsbmlInternal */ 354 355 /** 356 * Returns the value of the "attributeName" attribute of this Association. 357 * 358 * @param attributeName, the name of the attribute to retrieve. 359 * 360 * @param value, the address of the value to record. 361 * 362 * @copydetails doc_returns_success_code 363 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 364 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 365 */ 366 virtual int getAttribute(const std::string& attributeName, bool& value) 367 const; 368 369 /** @endcond */ 370 371 372 373 /** @cond doxygenLibsbmlInternal */ 374 375 /** 376 * Returns the value of the "attributeName" attribute of this Association. 377 * 378 * @param attributeName, the name of the attribute to retrieve. 379 * 380 * @param value, the address of the value to record. 381 * 382 * @copydetails doc_returns_success_code 383 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 384 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 385 */ 386 virtual int getAttribute(const std::string& attributeName, int& value) const; 387 388 /** @endcond */ 389 390 391 392 /** @cond doxygenLibsbmlInternal */ 393 394 /** 395 * Returns the value of the "attributeName" attribute of this Association. 396 * 397 * @param attributeName, the name of the attribute to retrieve. 398 * 399 * @param value, the address of the value to record. 400 * 401 * @copydetails doc_returns_success_code 402 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 403 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 404 */ 405 virtual int getAttribute(const std::string& attributeName, 406 double& value) const; 407 408 /** @endcond */ 409 410 411 412 /** @cond doxygenLibsbmlInternal */ 413 414 /** 415 * Returns the value of the "attributeName" attribute of this Association. 416 * 417 * @param attributeName, the name of the attribute to retrieve. 418 * 419 * @param value, the address of the value to record. 420 * 421 * @copydetails doc_returns_success_code 422 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 423 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 424 */ 425 virtual int getAttribute(const std::string& attributeName, 426 unsigned int& value) const; 427 428 /** @endcond */ 429 430 431 432 /** @cond doxygenLibsbmlInternal */ 433 434 /** 435 * Returns the value of the "attributeName" attribute of this Association. 436 * 437 * @param attributeName, the name of the attribute to retrieve. 438 * 439 * @param value, the address of the value to record. 440 * 441 * @copydetails doc_returns_success_code 442 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 443 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 444 */ 445 virtual int getAttribute(const std::string& attributeName, 446 std::string& value) const; 447 448 /** @endcond */ 449 450 451 452 /** @cond doxygenLibsbmlInternal */ 453 454 /** 455 * Predicate returning @c true if this Association's attribute 456 * "attributeName" is set. 457 * 458 * @param attributeName, the name of the attribute to query. 459 * 460 * @return @c true if this Association's attribute "attributeName" has been 461 * set, otherwise @c false is returned. 462 */ 463 virtual bool isSetAttribute(const std::string& attributeName) const; 464 465 /** @endcond */ 466 467 468 469 /** @cond doxygenLibsbmlInternal */ 470 471 /** 472 * Sets the value of the "attributeName" attribute of this Association. 473 * 474 * @param attributeName, the name of the attribute to set. 475 * 476 * @param value, the value of the attribute to set. 477 * 478 * @copydetails doc_returns_success_code 479 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 480 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 481 */ 482 virtual int setAttribute(const std::string& attributeName, bool value); 483 484 /** @endcond */ 485 486 487 488 /** @cond doxygenLibsbmlInternal */ 489 490 /** 491 * Sets the value of the "attributeName" attribute of this Association. 492 * 493 * @param attributeName, the name of the attribute to set. 494 * 495 * @param value, the value of the attribute to set. 496 * 497 * @copydetails doc_returns_success_code 498 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 499 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 500 */ 501 virtual int setAttribute(const std::string& attributeName, int value); 502 503 /** @endcond */ 504 505 506 507 /** @cond doxygenLibsbmlInternal */ 508 509 /** 510 * Sets the value of the "attributeName" attribute of this Association. 511 * 512 * @param attributeName, the name of the attribute to set. 513 * 514 * @param value, the value of the attribute to set. 515 * 516 * @copydetails doc_returns_success_code 517 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 518 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 519 */ 520 virtual int setAttribute(const std::string& attributeName, double value); 521 522 /** @endcond */ 523 524 525 526 /** @cond doxygenLibsbmlInternal */ 527 528 /** 529 * Sets the value of the "attributeName" attribute of this Association. 530 * 531 * @param attributeName, the name of the attribute to set. 532 * 533 * @param value, the value of the attribute to set. 534 * 535 * @copydetails doc_returns_success_code 536 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 537 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 538 */ 539 virtual int setAttribute(const std::string& attributeName, 540 unsigned int value); 541 542 /** @endcond */ 543 544 545 546 /** @cond doxygenLibsbmlInternal */ 547 548 /** 549 * Sets the value of the "attributeName" attribute of this Association. 550 * 551 * @param attributeName, the name of the attribute to set. 552 * 553 * @param value, the value of the attribute to set. 554 * 555 * @copydetails doc_returns_success_code 556 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 557 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 558 */ 559 virtual int setAttribute(const std::string& attributeName, 560 const std::string& value); 561 562 /** @endcond */ 563 564 565 566 /** @cond doxygenLibsbmlInternal */ 567 568 /** 569 * Unsets the value of the "attributeName" attribute of this Association. 570 * 571 * @param attributeName, the name of the attribute to query. 572 * 573 * @copydetails doc_returns_success_code 574 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 575 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 576 */ 577 virtual int unsetAttribute(const std::string& attributeName); 578 579 /** @endcond */ 580 581 582 583 584 #endif /* !SWIG */ 585 586 587 588 protected: 589 590 virtual void setElementName(const std::string& name); 591 592 /** @cond doxygenLibsbmlInternal */ 593 594 /** 595 * Get the list of expected attributes for this element. 596 */ 597 virtual void addExpectedAttributes(ExpectedAttributes& attributes); 598 599 /** @endcond */ 600 601 602 /** @cond doxygenLibsbmlInternal */ 603 604 /** 605 * Read values from the given XMLAttributes set into their specific fields. 606 */ 607 virtual void readAttributes (const XMLAttributes& attributes, 608 const ExpectedAttributes& expectedAttributes); 609 610 /** @endcond */ 611 612 613 /** @cond doxygenLibsbmlInternal */ 614 615 /** 616 * Write values of XMLAttributes to the output stream. 617 */ 618 virtual void writeAttributes (XMLOutputStream& stream) const; 619 620 /** @endcond */ 621 622 friend class GeneProductAssociation; 623 624 }; 625 626 class LIBSBML_EXTERN ListOfFbcAssociations : public ListOf 627 { 628 629 public: 630 631 /** 632 * Creates a new ListOfFbcAssociations with the given SBML Level, Version, 633 * and “fbc”package version. 634 * 635 * @param level an unsigned int, the SBML Level to assign to this 636 * ListOfFbcAssociations. 637 * 638 * @param version an unsigned int, the SBML Version to assign to this 639 * ListOfFbcAssociations. 640 * 641 * @param pkgVersion an unsigned int, the SBML “fbc” package 642 * Version to assign to this ListOfFbcAssociations. 643 * 644 * @copydetails doc_note_setting_lv_pkg 645 */ 646 ListOfFbcAssociations(unsigned int level = FbcExtension::getDefaultLevel(), 647 unsigned int version = FbcExtension::getDefaultVersion(), 648 unsigned int pkgVersion = FbcExtension::getDefaultPackageVersion()); 649 650 651 /** 652 * Creates a new ListOfFbcAssociations with the given FbcPkgNamespaces 653 * object. 654 * 655 * @copydetails doc_what_are_sbml_package_namespaces 656 * 657 * @param fbcns the FbcPkgNamespaces object. 658 * 659 * @copydetails doc_note_setting_lv_pkg 660 */ 661 ListOfFbcAssociations(FbcPkgNamespaces* fbcns); 662 663 664 /** 665 * Creates and returns a deep copy of this ListOfFbcAssociations object. 666 * 667 * @return a (deep) copy of this ListOfFbcAssociations object. 668 */ 669 virtual ListOfFbcAssociations* clone () const; 670 671 672 /** 673 * Get a FbcAssociation from the ListOfFbcAssociations. 674 * 675 * @param n the index number of the FbcAssociation to get. 676 * 677 * @return the nth FbcAssociation in this ListOfFbcAssociations. 678 * If the index @p n is invalid, @c NULL is returned. 679 * 680 * @see size() 681 * @see getNumFbcAssociations() 682 */ 683 virtual FbcAssociation* get(unsigned int n); 684 685 686 /** 687 * Get a FbcAssociation from the ListOfFbcAssociations. 688 * 689 * @param n the index number of the FbcAssociation to get. 690 * 691 * @return the nth FbcAssociation in this ListOfFbcAssociations. 692 * If the index @p n is invalid, @c NULL is returned. 693 * 694 * @see size() 695 * @see getNumFbcAssociations() 696 */ 697 virtual const FbcAssociation* get(unsigned int n) const; 698 699 700 /** 701 * Get a FbcAssociation from the ListOfFbcAssociations based on its 702 * identifier. 703 * 704 * @param sid a string representing the identifier of the FbcAssociation to 705 * get. 706 * 707 * @return FbcAssociation in this ListOfFbcAssociations with the given id 708 * or @c NULL if no such FbcAssociation exists. 709 * 710 * @see get(unsigned int n) 711 * @see size() 712 */ 713 virtual FbcAssociation* get(const std::string& sid); 714 715 716 /** 717 * Get a FbcAssociation from the ListOfFbcAssociations based on its 718 * identifier. 719 * 720 * @param sid a string representing the identifier of the FbcAssociation to 721 * get. 722 * 723 * @return FbcAssociation in this ListOfFbcAssociations with the given id 724 * or @c NULL if no such FbcAssociation exists. 725 * 726 * @see get(unsigned int n) 727 * @see size() 728 */ 729 virtual const FbcAssociation* get(const std::string& sid) const; 730 731 732 /** 733 * Adds a copy the given FbcAssociation object to this 734 * ListOfFbcAssociations. 735 * 736 * @param fa the FbcAssociation object to add. 737 * 738 * @copydetails doc_returns_success_code 739 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 740 * @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t} 741 */ 742 int addFbcAssociation(const FbcAssociation* fa); 743 744 745 /** 746 * Get the number of FbcAssociation objects in this ListOfFbcAssociations. 747 * 748 * @return the number of FbcAssociation objects in this 749 * ListOfFbcAssociations. 750 */ 751 unsigned int getNumFbcAssociations() const; 752 753 754 /** 755 * Creates a new FbcAnd object. 756 * 757 * This method creates a new FbcAssociation object of subclass FbcAnd, adds 758 * it to the ListOfFbcAssociations, and returns the FbcAssociation object 759 * created. 760 * 761 * @return a new FbcAssociation object instance. 762 * 763 * @see createOr() 764 * @see createGeneProductRef() 765 * @see addFbcAssociation(const FbcAssociation* fa) 766 */ 767 FbcAnd* createAnd(); 768 769 770 /** 771 * Creates a new FbcOr object. 772 * 773 * This method creates a new FbcAssociation object of subclass FbcOr, adds 774 * it to the ListOfFbcAssociations, and returns the FbcAssociation object 775 * created. 776 * 777 * @return a new FbcAssociation object instance. 778 * 779 * @see createAnd() 780 * @see createGeneProductRef() 781 * @see addFbcAssociation(const FbcAssociation* fa) 782 */ 783 FbcOr* createOr(); 784 785 786 /** 787 * Creates a new GeneProductRef object. 788 * 789 * This method creates a new FbcAssociation object of subclass 790 * GeneProductRef, adds it to the ListOfFbcAssociations, and returns the 791 * FbcAssociation object created. 792 * 793 * @return a new FbcAssociation object instance. 794 * 795 * @see createOr() 796 * @see createAnd() 797 * @see addFbcAssociation(const FbcAssociation* fa) 798 */ 799 GeneProductRef* createGeneProductRef(); 800 801 802 /** 803 * Removes the nth FbcAssociation 804 * 805 * This method removes the nth object from this ListOfFbcAssociations and 806 * returns a pointer to it. 807 * 808 * @param n the index of the FbcAssociation to remove. 809 * 810 * @see size() 811 */ 812 virtual FbcAssociation* remove(unsigned int n); 813 814 815 /** 816 * Removes the FbcAssociation with the given identifier 817 * 818 * This method searches for and removes the FbcAssociation object with the 819 * given identifier @p sid, and returns a pointer to it. The caller owns 820 * the returned item and is responsible for deleting it. If none of the 821 * items in this list have the identifier @p sid, then @c NULL is returned. 822 * 823 * @param sid the identifier of the FbcAssociation to remove. 824 * 825 * @return the FbcAssociation removed. As mentioned above, the caller owns 826 * the returned item. 827 */ 828 virtual FbcAssociation* remove(const std::string& sid); 829 830 831 /** 832 * Returns the XML element name of this object. 833 * 834 * For ListOfFbcAssociations, the XML element name is always 835 * @c "listOfFbcAssociations". 836 * 837 * @return the name of this element. 838 */ 839 virtual const std::string& getElementName () const; 840 841 842 /** 843 * Returns the libSBML type code for this SBML object. 844 * 845 * @copydetails doc_what_are_typecodes 846 * 847 * @return the SBML type code for this object: 848 * @sbmlconstant{SBML_LIST_OF, SBMLTypeCode_t} (default). 849 * 850 * @copydetails doc_warning_typecodes_not_unique 851 * 852 * @see getElementName() 853 * @see getPackageName() 854 */ 855 virtual int getTypeCode () const; 856 857 858 /** 859 * Returns the libSBML type code for the objects contained in this ListOf. 860 * 861 * @copydetails doc_what_are_typecodes 862 * 863 * @return the SBML type code for the objects contained in this ListOf 864 * instance: @sbmlconstant{SBML_FBC_ASSOCIATION, SBMLTypeCode_t} (default). 865 * 866 * @see getElementName() 867 * @see getPackageName() 868 */ 869 virtual int getItemTypeCode () const; 870 871 872 protected: 873 874 /** @cond doxygenLibsbmlInternal */ 875 876 /** 877 * Creates a new FbcAssociation in this ListOfFbcAssociations 878 */ 879 virtual SBase* createObject(XMLInputStream& stream); 880 881 /** @endcond */ 882 883 884 /** @cond doxygenLibsbmlInternal */ 885 886 /** 887 * Write the namespace for the “fbc” package. 888 */ 889 virtual void writeXMLNS(XMLOutputStream& stream) const; 890 891 /** @endcond */ 892 893 894 virtual bool isValidTypeForList(SBase * item); 895 896 897 friend class FbcAnd; 898 friend class FbcOr; 899 900 }; 901 902 903 904 LIBSBML_CPP_NAMESPACE_END 905 906 #endif /* __cplusplus */ 907 908 #ifndef SWIG 909 910 LIBSBML_CPP_NAMESPACE_BEGIN 911 BEGIN_C_DECLS 912 913 /** 914 * Creates a new FbcAssociation_t structure using the given SBML @p level and 915 * @p version, and the @p pkgVersion package version. 916 * 917 * @param level an unsigned int, the SBML level to assign to this 918 * FbcAssociation_t structure. 919 * 920 * @param version an unsigned int, the SBML version to assign to this 921 * FbcAssociation_t structure. 922 * 923 * @param pkgVersion an unsigned int, the version of the package to assign 924 * to this FbcAssociation_t structure. 925 * 926 * @returns the newly-created FbcAssociation_t structure, or a null pointer if 927 * an error occurred during construction. 928 * 929 * @copydetails doc_note_setting_lv 930 * 931 * @memberof FbcAssociation_t 932 */ 933 LIBSBML_EXTERN 934 FbcAssociation_t * 935 FbcAssociation_create(unsigned int level, unsigned int version, 936 unsigned int pkgVersion); 937 938 939 /** 940 * Frees the given FbcAssociation_t structure. 941 * 942 * @param fa the FbcAssociation_t structure to be freed. 943 * 944 * @memberof FbcAssociation_t 945 */ 946 LIBSBML_EXTERN 947 void 948 FbcAssociation_free(FbcAssociation_t * fa); 949 950 951 /** 952 * Creates a deep copy of the given FbcAssociation_t structure. 953 * 954 * @param fa the FbcAssociation_t structure to be copied. 955 * 956 * @returns a (deep) copy of the given FbcAssociation_t structure, or a null 957 * pointer if a failure occurred. 958 * 959 * @memberof FbcAssociation_t 960 */ 961 LIBSBML_EXTERN 962 FbcAssociation_t * 963 FbcAssociation_clone(FbcAssociation_t * fa); 964 965 966 /** 967 * Predicate returning @c 1 (true) or @c 0 (false) depending on whether all the required 968 * attributes of the given FbcAssociation_t structure have been set. 969 * 970 * @param fa the FbcAssociation_t structure to check. 971 * 972 * @return @c 1 (true) if all the required attributes for this 973 * structure have been defined, @c 0 (false) otherwise. 974 * 975 * @memberof FbcAssociation_t 976 */ 977 LIBSBML_EXTERN 978 int 979 FbcAssociation_hasRequiredAttributes(const FbcAssociation_t * fa); 980 981 982 983 /** 984 * Return the structure indicated by the given @p sid. 985 * 986 * @param lo the ListOf_t structure to use. 987 * 988 * @param sid a string matching the "id" attribute of the element sought. 989 * 990 * @return the structure for the given variable, or @c NULL if no such 991 * object exists in the list. 992 * 993 * @memberof ListOfFbcAssociations_t 994 */ 995 LIBSBML_EXTERN 996 FbcAssociation_t * 997 ListOfFbcAssociations_getById(ListOf_t * lo, const char * sid); 998 999 1000 /** 1001 * Removes the structure with the given @p sid 1002 * from the given ListOf_t structure and returns a pointer to it. 1003 * 1004 * * The caller owns the returned structure and is responsible for deleting it. 1005 * 1006 * @param lo the ListOf_t structure. 1007 * @param sid the string of the "id" attribute of the sought structure. 1008 * 1009 * @return the structure removed. As mentioned above, the 1010 * caller owns the returned structure. @c NULL is returned if no 1011 * structure with the "id" attribute exists in the given ListOf_t structure. 1012 * 1013 * @memberof ListOfFbcAssociations_t 1014 */ 1015 LIBSBML_EXTERN 1016 FbcAssociation_t * 1017 ListOfFbcAssociations_removeById(ListOf_t * lo, const char * sid); 1018 1019 1020 /** 1021 * Converts this FbcAssociation_t into an infix string representation. 1022 * 1023 * @param fa the FbcAssociation_t structure to convert. 1024 * 1025 * @return the association as infix string. 1026 * 1027 * @memberof FbcAssociation_t 1028 */ 1029 LIBSBML_EXTERN 1030 char * 1031 FbcAssociation_toInfix(const FbcAssociation_t * fa); 1032 1033 /** 1034 * Parses a gene association in infix format and returns a corresponding 1035 * Association object. 1036 * 1037 * This parses a string that has a list of gene names and conjunctions 1038 * or disjunctions. For example: 1039 * @verbatim 1040 (b2422) and (b2425) and (b2423) and (b2424) or (b2422) and (b2423) and (b2424) and (b2413) and (b3917) 1041 @endverbatim 1042 * 1043 * The 'and' operator takes precedence over the 'or' operator, meaning that 1044 * the above input string would turn into two groups of gene names: either 1045 * "b2422, b2425, b2423, and b2424" or "b2422, b2423, b2424, b2413, and b3917". 1046 * Parentheses may be added to make things more clear, and to encode 1047 * alternative schemes. 1048 * 1049 * This method also creates missing GeneProduct objects, in case the unique 1050 * reference does not yet exist. 1051 * 1052 * Note that the function assumes that the infix contains identifiers and not 1053 * labels, and that any missing geneProducts are to be added. 1054 * 1055 * @param infix the string to parse. 1056 * @param plugin the FbcModelPlugin on which to add the geneProduct elements. 1057 * 1058 * @return the parsed association, or @c NULL in case of an error. 1059 * 1060 * @copydetails doc_note_static_methods 1061 * @memberof FbcAssociation_t 1062 */ 1063 LIBSBML_EXTERN 1064 FbcAssociation_t* 1065 FbcAssociation_parseFbcInfixAssociation(const char * infix, SBasePlugin_t* plugin); 1066 1067 END_C_DECLS 1068 LIBSBML_CPP_NAMESPACE_END 1069 1070 #endif /* !SWIG */ 1071 1072 #endif /* FbcAssociation_H__ */ 1073 1074