import re
pseudo_file = """
> <Enzymologic: Ki nM 1>
257000
> <Enzymologic: IC50 nM 1>
n/a
> <ITC: Delta_G0 kJ/mole 1>
n/a
> <Enzymologic: Ki nM 1>
5000
> <Enzymologic: EC50/IC50 nM 1>
1000"""
searchtxt = "nzymologic: Ki nM 1>", "<Enzymologic: IC50 nM 1>"
regx_AAA = re.compile('([^:]+: )([^ \t]+)(.*)')
tu = tuple(regx_AAA.sub('\\1.*?\\2.*?\\3',x) for x in searchtxt)
model = '%%-%ss %%s\n' % len(searchtxt[0])
regx_BBB = re.compile(('%s[ \t\r\n]+(.+)[ \t\r\n]+'
'.+?%s[ \t\r\n]+(.+?)[ \t]*(?=\r?\n|\Z)') % tu)
print 'tu ==',tu
print 'model==',model
print 'regx_BBB.findall(pseudo_file)==\n',regx_BBB.findall(pseudo_file)
with open('woof.txt','w') as f:
f.write(model % searchtxt)
f.writelines(model % x for x in regx_BBB.findall(pseudo_file))
tu == ('nzymologic: .*?Ki.*? nM 1>', '<Enzymologic: .*?IC50.*? nM 1>')
model== %-20s %s
regx_BBB.findall(pseudo_file)==
[('257000', 'n/a'), ('5000', '1000')]
woof.txt:
> <Enzymologic: Ki nM 1> > <Enzymologic: IC50 nM 1>
257000 n/a
5000 1000
regx_BBB, tu, , " > " searchtxt
, tu . *? searchtxt, regx_BBB , IC50, , searchtxt
, "nzymologic: Ki nM 1>" "<Enzymologic: IC50 nM 1>" searchtxt, , , , , .
, : : searchtxt
.
1
, '> <Enzymologic: IC50 nM 1>' '> <Enzymologic: EC50/IC50 nM 1>' '> <Enzymologic: Ki nM 1>'
, , , ( : )
, regx_BBB:
regx_AAA = re.compile('([^:]+: )([^ \t]+)(.*)')
li = [ regx_AAA.sub('\\1.*?\\2.*?\\3',x) for x in searchtxt]
regx_BBB = re.compile('|'.join(li).join('()') + '[ \t\r\n]+(.+?)[ \t]*(?=\r?\n|\Z)')
But formatting the recording file will be more difficult. I'm tired of writing new complete code, not knowing what exactly is needed