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 time
21 import sets
22
23
25 """
26 Class to represent an external database (any database giving biologic relevant information)
27 """
28
29
30 - def __init__(self, databaseName, databaseVersion, databaseFile, databaseDescription, defaultExternalEntityAttribute, databaseDate=None, externalDatabaseID=None, isPromiscuous=False):
31 """
32 Initializes a ExternalDatabase Object
33
34 "databaseName" is the name for the external database (i.e. swissprot, IntAct, Reactome...)
35
36 "datavaseVersion" is the version of the database. The combination of databaseName and databaseVersion must be unique!
37
38 "databaseFile" is the parsed database file. If there are multiple files, it is an empty string
39
40 "databaseDescription" is a longer description of the database (for example, "public repository of interactions of ncbi", etc.)
41
42 "externalDatabaseID" is a unique identifier for the database. When parsing it should not be added, only when this information is persistent in the database
43
44 "defaultExternalEntityAttribute" is the default attribute type of the data an external database is providing
45
46 "databaseDate" Parsing date. If it is None, automatically assigns to current date to it
47 "isPromiscuous" Flag deciding whether database gives information that is going to be added to more than one user entiries
48 """
49
50 self.databaseName = databaseName.lower()
51 self.databaseVersion = databaseVersion.lower()
52 self.databaseFile = databaseFile
53 self.databaseDescription = databaseDescription
54 self.defaultExternalEntityAttribute = defaultExternalEntityAttribute
55 self.isPromiscuous = isPromiscuous
56
57 self.externalDatabaseID = externalDatabaseID
58
59 if( databaseDate is None ):
60 date = time.localtime()
61 actual_date = "%s-%s-%s" %(date[0],date[1],date[2])
62 self.databaseDate = actual_date
63 else:
64 self.databaseDate = databaseDate
65
66 self.valid_eE_attributes = sets.Set()
67 self.valid_eEr_attributes = sets.Set()
68 self.valid_eE_types = sets.Set()
69 self.valid_eEr_types = sets.Set()
70
71 self.parsing_time = None
72
74 self.valid_eE_attributes.add(attribute_identifier.lower())
75
77 self.valid_eEr_attributes.add(attribute_identifier.lower())
78
80 self.valid_eE_types.add(eE_type.lower())
81
83 self.valid_eEr_types.add(eEr_type.lower())
84
86 return self.valid_eE_attributes
87
89 return self.valid_eEr_attributes
90
92 return self.valid_eE_types
93
95 """
96 Checks if this external database contains external entities of the type "eE_type"
97 """
98 return self.valid_eE_types.has_key(eE_type)
99
101 return self.valid_eEr_types
102
104 return self.databaseName
105
107 return self.databaseVersion
108
110 return self.databaseFile
111
113 return self.databaseDate
114
116 return self.databaseDescription
117
119 return self.defaultExternalEntityAttribute
120
122 return self.externalDatabaseID
123
124 - def set_id(self, externalDatabaseID):
125 self.externalDatabaseID = externalDatabaseID
126
128 self.parsing_time = time
129
131 return self.parsing_time
132
134 return self.isPromiscuous
135
137 return "%s [%s]" %(self.databaseName,self.databaseVersion)
138