In [1]:
import numpy as np

In [13]:
with open('flyreg.v2.meme') as f:
    my_list = []
    for line in f:
        
        if 'MOTIF'in line:
            split_line = line.split()
            print('ID: '+ split_line[1])
        #if 'letter-probability'in line:
            #nextline = next(f)
        if line.strip().startswith(('0')):
            print(line)
            row = [float(x.strip()) for x in line.strip().split('\t')]
            my_list.append(row)
            
        if 'URL' in line:
            break   
    print(my_list)
    print(np.vstack(my_list))


ID: abd-A
  0.135135	  0.054054	  0.351351	  0.459459	

  0.270270	  0.405405	  0.081081	  0.243243	

  0.594595	  0.405405	  0.000000	  0.000000	

  0.972973	  0.000000	  0.000000	  0.027027	

  0.000000	  0.000000	  0.000000	  1.000000	

  0.297297	  0.054054	  0.000000	  0.648649	

  0.891892	  0.027027	  0.000000	  0.081081	

  0.486486	  0.054054	  0.108108	  0.351351	

[[0.135135, 0.054054, 0.351351, 0.459459], [0.27027, 0.405405, 0.081081, 0.243243], [0.594595, 0.405405, 0.0, 0.0], [0.972973, 0.0, 0.0, 0.027027], [0.0, 0.0, 0.0, 1.0], [0.297297, 0.054054, 0.0, 0.648649], [0.891892, 0.027027, 0.0, 0.081081], [0.486486, 0.054054, 0.108108, 0.351351]]
[[ 0.135135  0.054054  0.351351  0.459459]
 [ 0.27027   0.405405  0.081081  0.243243]
 [ 0.594595  0.405405  0.        0.      ]
 [ 0.972973  0.        0.        0.027027]
 [ 0.        0.        0.        1.      ]
 [ 0.297297  0.054054  0.        0.648649]
 [ 0.891892  0.027027  0.        0.081081]
 [ 0.486486  0.054054  0.108108  0.351351]]

In [14]:
import re

In [15]:
re.match('(\d+\.\d+)\w(\d+\.\d+)\w(\d+\.\d+)\w(\d+\.\d+)\n')


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-15-c2330b789bf4> in <module>()
----> 1 regex = re.regex('(\d+\.\d+)\w(\d+\.\d+)\w(\d+\.\d+)\w(\d+\.\d+)\n')

AttributeError: module 're' has no attribute 'regex'

In [28]:
[float(x) for x in re.findall(r'\d+\.\d+', bob)]


Out[28]:
[0.12,
 20.1,
 20.1,
 0.11112,
 0.32,
 20.1,
 20.1,
 0.11112,
 0.42,
 20.1,
 20.1,
 0.11112,
 0.42,
 20.1,
 20.1,
 0.11112]

In [27]:
bob = """
0.12 20.10\t20.10\t0.11112
0.32 20.10\t20.10\t0.11112
0.42 20.10\t20.10\t0.11112
0.42 20.10\t20.10\t0.11112"""

In [ ]: