Advertisement
sentinelwex

term

Dec 19th, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.94 KB | None | 0 0
  1. <?php
  2. /**
  3.  * A Human Phenotype Ontology Term
  4.  *
  5.  * @author csaba
  6.  *
  7.  */
  8. class Term implements JsonSerializable{
  9.     /**
  10.      * Term id
  11.      * @var unknown
  12.      */
  13.     protected $id;
  14.    
  15.     /**
  16.      * Term name
  17.      * @var unknown
  18.      */
  19.     protected $name;
  20.    
  21.     /**
  22.      * Term definition
  23.      * @var unknown
  24.      */
  25.     protected $def;
  26.    
  27.     /**
  28.      * Term synonym's ids
  29.      * @var unknown
  30.      */
  31.     protected $synonyms = array();
  32.    
  33.     /**
  34.      * Comment
  35.      * @var unknown
  36.      */
  37.     protected $comment;
  38.    
  39.     /**
  40.      * Cross references to God knows where
  41.      * @var unknown
  42.      */
  43.     protected $xref = array();
  44.    
  45.     /**
  46.      * Reference to parent Term
  47.      * @var unknown
  48.      */
  49.     protected $is_a = array();
  50.    
  51.    
  52.     //SETTERS
  53.    
  54.     /**
  55.      * Sets id attribute
  56.      * @param unknown $id
  57.      */
  58.     public function setId($id) {
  59.             $this->id = $id;
  60.     }
  61.    
  62.     /**
  63.      * Sets name attribute
  64.      * @param unknown $name
  65.      */
  66.     public function setName($name) {
  67.         $this->name = $name;
  68.     }  
  69.    
  70.     /**
  71.      * Sets def attribute
  72.      * @param unknown $def
  73.      */
  74.     public function setDef($def) {
  75.         $this->def = $def;
  76.     }
  77.    
  78.     /**
  79.      * Sets comment attribute
  80.      * @param unknown $id
  81.      */
  82.     public function setComment($comment) {
  83.         $this->comment = $comment;
  84.     }
  85.    
  86.     /**
  87.      * Adds a new synonym to synonym array
  88.      * @param unknown $syn
  89.      */
  90.     public function addSynonym(&$syn) {
  91.         $this->synonyms[] = $syn;
  92.        
  93.     }
  94.    
  95.     /**
  96.      * Adds a new xref to xref assoc array
  97.      * @param unknown $xrefId
  98.      * @param unknown $xrefName
  99.      */
  100.     public function addXref($xrefId,$xrefName){
  101.         $this->xref[$xrefId]=$xrefName;
  102.        
  103.     }
  104.  
  105.     /**
  106.      * Adds a new is_a relationship to is_a assoc array
  107.      * @param unknown $is_aId
  108.      * @param unknown $is_aName
  109.      */
  110.     public function addIs_a($is_aId,$is_aName){
  111.         $this->is_a[$is_aId]=$is_aName;
  112.        
  113.     }
  114.    
  115.    
  116.    
  117.     //GETTERS
  118.    
  119.    
  120.     public function getId(){
  121.         return $this->id;
  122.     }
  123.    
  124.     public function getName(){
  125.         return $this->name;
  126.     }  
  127.  
  128.     public function getDef(){
  129.         return $this->def;
  130.     }
  131.  
  132.     public function getComment(){
  133.         return $this->comment;
  134.     }
  135.    
  136.     public function getSynonyms(){
  137.         return $this->synonyms;
  138.     }
  139.    
  140.     public function getXrefKeys(){
  141.         return array_keys($this->xref);
  142.     }
  143.    
  144.     public function getIs_aKeys(){
  145.         return array_keys($this->is_a);
  146.     }
  147.  
  148.     public function XrefKeyExists($key){
  149.         return isset($this->xref[$key]);
  150.     }
  151.    
  152.     public function Is_aKeyExists($key){
  153.         return isset($this->is_a[$key]);
  154.     }
  155.    
  156.     public function __toString(){
  157.         $syns=null;
  158.         foreach ($this->synonyms as $syn){
  159.             $syns.=$syn.';';
  160.         }
  161.        
  162.         $xrefstring=null;
  163.         foreach ($this->xref as $key=>$value){
  164.             $xrefstring.=$value.';';
  165.         }
  166.        
  167.         $is_astring=null;
  168.         foreach ($this->is_a as $key=>$value){
  169.             $is_astring.=$value.';';
  170.         }
  171.        
  172.        
  173.         return 'id: '.$this->getId().' Name: '.$this->getName().' Def: '.$this->getDef()
  174.         .' Comm: '.$this->getComment().' Syns: '.$syns.' Xrefs: '.$xrefstring.'Is_a: '.$is_astring;
  175.     }
  176.    
  177.     public function jsonSerialize()
  178.     {
  179.         return get_object_vars($this);
  180.     }
  181.  
  182. }
  183.  
  184. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement