1
2
3
4
5 """Structural database based on mmCIF.
6 """
7
8 from __future__ import generators
9 import copy
10
11
12 import mmCIF
13
14
16 """Database class for the storage and access of structural data. This
17 database is organized according to mmCIF data tags. Methods to lookup
18 common structure items are included.
19 """
21 col_len = 12
22 dump = ""
23
24 for table in self:
25 table.autoset_columns()
26 dump += "Table: %s\n" % (table.name)
27 for col_name in table.columns:
28 dump += col_name[:col_len-1].ljust(col_len)
29 dump += "\n"
30 dump += "-"*col_len*len(table.columns) + "\n"
31 for row in table:
32 for col_name in table.columns:
33 try:
34 dump += str(row[col_name])[:col_len-1].ljust(col_len)
35 except KeyError:
36 dump += " "*col_len
37 dump += "\n"
38 dump += "\n"
39
40 return dump
41
44
48
58
60 """Utility function for getting a table where there should only be a
61 single row of data.
62 """
63 try:
64 return self[table_name][col_name]
65 except KeyError:
66 return None
67
69 """Utility function for setting a table where there should only be a
70 single row of data.
71 """
72 if val == None:
73 return
74
75 table = self.confirm_table(table_name)
76 if len(table):
77 table[0][col_name] = val
78 else:
79 row = mmCIF.mmCIFRow()
80 table.append(row)
81 row[col_name] = val
82
83 - def get_entry_id(self):
84 """Methods to get/set the structure ID.
85 """
86 return self.get_single("entry", "id")
87
88 - def set_entry_id(self, idcode):
89 self.set_single("entry", "id", idcode)
90
92 """Return the original deposition date as stored in
93 _database_pdb_ref.date_original.
94 """
95 return self.get_single("database_pdb_rev", "date_original")
96
98 self.set_single("database_pdb_rev", "date_original")
99
101 """Return structure keywords as stored in
102 _struct_keywords.text.
103 """
104 return self.get_single("struct_keywords", "text")
106 self.set_single("struct_keywords", "text", text)
107
109 """Return structure keywords as stored in
110 _struct_keywords.text.
111 """
112 return self.get_single("struct_keywords", "text")
114 self.set_single("struct_keywords", "text", text)
115
116
117
118
119
120
121
122
123
124
125
126
127
128