1 """
2 Classes for dealing with STAR syntax
3 """
4 from bmrblib.pystarlib.Utils import Lister
5
6
7 """
8 Saveframe class
9 """
11 - def __init__( self,
12 title = 'general_sf_title',
13 tagtables = None,
14 text = '',
15 verbosity = 2,
16 comment = ''):
17 self.title = title
18
19
20
21 self.tagtables = tagtables
22
23 if self.tagtables == None:
24 self.tagtables = []
25
26 self.text = text
27 self.verbosity = verbosity
28 self.comment = comment
29
30 "Returns the STAR text representation"
31 - def star_text (self,
32 flavor = 'NMR-STAR'
33 ):
34 str = "\n"
35 str = str + 'save_%s\n' % self.title
36
37 for tagtable in self.tagtables:
38 str = str + tagtable.star_text( flavor=flavor )
39
40 str = str + '\nsave_\n'
41 return str
42
43 "Simple checks on integrity"
45 if recursive:
46 for tagtable in self.tagtables:
47 if tagtable.check_integrity():
48 print("ERROR: integrity check failed for tagtable")
49 return 1
50 if self.verbosity >= 9:
51 print('Checked integrity of SaveFrame(%2s tagtables, recurs.=%s) : OK [%s]' % (
52 len(self.tagtables), recursive, self.title ))
53
54 """
55 Or print Warning and return None
56 """
58 possibleTagNamesSFCategory = [ '_Saveframe_category',
59 '.Sf_category' ]
60 if not self.tagtables:
61 print("WARNING: no tagtable found in Saveframe")
62 return None
63
64 tT = self.tagtables[0]
65 if not tT.tagvalues[0]:
66 print("WARNING: empty tagtable found in Saveframe")
67 return None
68 found = 0
69 for possi in possibleTagNamesSFCategory:
70 if tT.tagnames[0].endswith(possi):
71 found = 1
72 if not found:
73 print("WARNING: first tag doesn't look like a Sf_category; taking value anyway")
74
75 return tT.tagvalues[0][0]
76