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 import sys
22 import re
23
24
25 ATTRIBUTE_IDENTIFIER_TO_OBJECT = {}
26
27
29 """
30 Class that represents an external entity attribute
31 """
32
33
34
35 - def __init__(self, attribute_identifier, value, type=None, version=None, additional_fields={}):
36
37
38 self.value = value
39 self.type = type
40 self.version = version
41 self.additional_fields = additional_fields
42 self.attribute_identifier = attribute_identifier
43
44
46
47 if( field_name == "value" ):
48 return self.value
49 elif( field_name == "type" ):
50 return self.type
51 elif( field_name == "version" ):
52 return self.version
53 else:
54 return self.additional_fields[field_name]
55
56
58
59 temp1 = ["value: %s" %self.value]
60 if( self.type is not None ):
61 temp1.append("type: %s" %self.type)
62 if( self.version is not None ):
63 temp1.append("version: " %self.version)
64 temp2 = [ ("%s: %s") %(x,self.additional_fields[x]) for x in self.additional_fields ]
65
66 return "Attribute %s. %s %s" %(self.attribute_identifier,"\t".join(temp1),"\t".join(temp2))
67
70
71
72
74 """Other can be either string of dictionary however comparison below is generic enough"""
75 return str(self.value).lower() == str(other.value).lower()
76
77
78
79
80 - def isFullTextSearchable(attribute_identifier, biana_database):
81
82
83 return attribute_identifier.lower() in biana_database.VALID_EXTERNAL_ENTITY_DESCRIPTIVE_SEARCHABLE_ATTRIBUTE_TYPES_SET
84
85 isFullTextSearchable = staticmethod(isFullTextSearchable)
86
87
88
89
91 return attribute_identifier.lower() in biana_database.VALID_EXTERNAL_ENTITY_NUMERIC_ATTRIBUTE_TYPES_SET
92
93 isNumericAttribute = staticmethod(isNumericAttribute)
94
95
97 return attribute_identifier.lower() in biana_database.VALID_EXTERNAL_ENTITY_SPECIAL_ATTRIBUTE_TYPES_SET
98
99 isSpecialAttribute = staticmethod(isSpecialAttribute)
100
101
103
104 return attribute_identifier.lower() in biana_database.VALID_EXTERNAL_ENTITY_ATTRIBUTE_TYPES_DICT
105
106 isValidAttribute = staticmethod(isValidAttribute)
107
108
109
111
112
113 return attribute_identifier.lower() in biana_database.VALID_EXTERNAL_ENTITY_IDENTIFIER_ATTRIBUTE_TYPES_SET or attribute_identifier.lower() in biana_database.VALID_EXTERNAL_ENTITY_VERSIONABLE_IDENTIFIER_ATTRIBUTE_TYPES_SET
114
115 isIdentifierType = staticmethod(isIdentifierType)
116
117
118
120
121 return attribute_identifier.lower() in biana_database.VALID_EXTERNAL_ENTITY_VERSIONABLE_IDENTIFIER_ATTRIBUTE_TYPES_SET
122
123 isVersionableIdentifier = staticmethod(isVersionableIdentifier)
124