Package biana :: Package BianaObjects :: Module UserEntity'
[hide private]
[frames] | no frames]

Source Code for Module biana.BianaObjects.UserEntity'

 1  """ 
 2      BIANA: Biologic Interactions and Network Analysis 
 3      Copyright (C) 2009  Javier Garcia-Garcia, Emre Guney, Baldo Oliva 
 4   
 5      This program is free software: you can redistribute it and/or modify 
 6      it under the terms of the GNU General Public License as published by 
 7      the Free Software Foundation, either version 3 of the License, or 
 8      (at your option) any later version. 
 9   
10      This program is distributed in the hope that it will be useful, 
11      but WITHOUT ANY WARRANTY; without even the implied warranty of 
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13      GNU General Public License for more details. 
14   
15      You should have received a copy of the GNU General Public License 
16      along with this program.  If not, see <http://www.gnu.org/licenses/>. 
17   
18  """ 
19   
20  import sets 
21   
22 -class UserEntity(object):
23 """ 24 A container class to represent a User Entity 25 26 A user entity is composed by one or several externalEntities 27 28 It only contains the collection of external entity ids 29 """ 30
31 - def __init__(self, id, listExternalEntityId=None):
32 """ 33 externalEntities 34 """ 35 # Set that stores the identifiers of externalEntities 36 37 self.id = id 38 39 if listExternalEntityId is None: 40 self.setExternalEntityId = sets.Set() 41 else: 42 self.setExternalEntityId = sets.Set(listExternalEntityId) 43 44 return
45
46 - def addExternalEntity(self, externalEntityId):
47 self.setExternalEntityId.add(externalEntityId) 48 return
49
50 - def containsExternalEntity(self, externalEntityId):
51 if externalEntityId in self.setExternalEntityId: 52 return True 53 return False
54
55 - def getSize(self):
56 return len(self.setExternalEntityId)
57
58 - def __str__(self):
59 return "User Entity with id %s,composed by %s external Entities" %(self.id, self.getSize())
60 #return "%s" % self.id 61
63 return self.setExternalEntityId
64