1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
chunck of the real data:
...
rs11637397 rs640249 0.194 0.68 0.031 0.03 0.37 38796 -
rs11635293 rs640249 0.194 0.68 0.031 0.03 0.37 38581 -
rs11634797 rs640249 1.0 1.27 0.042 0.21 1.0 40889 -
rs11634692 rs640249 0.263 0.43 0.019 0.03 0.55 33870 -
rs11634368 rs640249 1.0 2.61 0.08 0.46 1.0 1378 -
rs11633567 rs640249 0.335 0.94 0.042 0.08 0.57 20864 -
rs11629839 rs640249 0.546 0.6 0.022 0.09 0.83 49941 -
rs11073074 rs640249 0.248 0.77 0.036 0.05 0.45 40090 -
rs11073072 rs640249 0.235 0.2 0.009 0.02 0.58 30743 -
rs11073070 rs640249 0.408 2.86 0.16 0.21 0.56 16940 -
rs11073068 rs640249 0.263 0.43 0.019 0.03 0.55 27355 -
rs11073065 rs640249 0.081 0.01 0.0 0.01 0.65 58635 -
rs10519956 rs640249 0.265 0.58 0.026 0.04 0.51 29845 -
rs10459664 rs640249 0.263 0.43 0.019 0.03 0.55 26752 -
rs10152216 rs640249 1.0 0.0 0.0 0.0 0.0 23581 -
rs9806429 rs640249 0.437 0.17 0.009 0.04 0.86 36819 -
rs8041657 rs640249 0.112 0.02 0.001 0.01 0.66 28698 -
rs8041201 rs640249 0.728 6.2 0.279 0.51 0.86 8616 -
rs8039338 rs640249 0.218 0.68 0.034 0.04 0.41 32964 -
rs8038673 rs640249 0.62 6.6 0.3 0.44 0.76 14454 -
rs8033707 rs640249 0.092 0.01 0.0 0.01 0.73 31961 -
rs8032163 rs640249 0.213 0.66 0.031 0.03 0.41 32178 -
rs8026263 rs640249 0.28 0.51 0.023 0.04 0.56 18160 -
rs7182728 rs640249 1.0 0.0 0.0 0.0 0.0 11055 -
rs7180455 rs640249 0.298 1.01 0.04 0.08 0.51 37167 -
rs7179902 rs640249 0.433 0.45 0.017 0.06 0.76 16155 -
rs7176763 rs640249 0.17 0.23 0.01 0.01 0.44 19905 -
rs7175090 rs640249 0.808 10.67 0.493 0.64 0.91 7545 -
rs7174852 rs640249 0.266 0.52 0.022 0.04 0.52 38131 -
rs7173974 rs640249 0.433 0.14 0.005 0.04 0.86 31588 -
rs7169540 rs640249 0.265 0.58 0.026 0.04 0.51 30196 -
rs7168956 rs640249 1.0 3.01 0.092 0.51 1.0 692 -
rs7168187 rs640249 0.729 6.23 0.274 0.51 0.86 6246 -
rs7167879 rs640249 0.248 0.77 0.036 0.05 0.45 31494 -
rs7166484 rs640249 0.049 0.05 0.002 -0.01 0.24 5320 -
rs7165006 rs640249 0.398 0.41 0.018 0.05 0.74 5789 -
...

def my_fun(row):
    if row['L1'] == 'rs640249':
        return row['L2'], row['L1']
    else:
        return row['L1'], row['L2']

def sort_LD(rscode, LDfiles):
    colnames = ['L1', 'L2', 'D', 'LOD', 'r2', 'CIlow', 'CIhi', 'Dist', 'T-int']
    for inf in LDfiles:
        outname = inf + '_sorted.test'
        df = read_csv(inf, sep='\t', skiprows=1, names=colnames)
        df = df.apply(my_fun, axis=1)
        #for row_index, row in df.iterrows():                                                                                                            #    if row['L1'] == 'rs640249':                                                                                                                 #        df.set_value(row_index, 'L1' , row['L2'])                                                                                               #        df.set_value(row_index, 'L2' , row['L1'])                                                                                               #cond = ((df['L1'] != rscode) & (df['L2'] != rscode))                                                                                            #df['L3'] = df['L1'].map(lambda x: int(str(x)[2:]))                                                                                              #outdata = df.drop(df[cond].index.values).sort(columns='L3', ascending=False, axis=0)                                                            DataFrame.to_csv(df, outname, cols = colnames, sep=' ', header=False, index=False)


Traceback (most recent call last):
  File "/home/ferreirafm/bin/pygrep.py", line 124, in <module>
    main()
  File "/home/ferreirafm/bin/pygrep.py", line 111, in main
    sort_LD(rscode, LDfiles)
  File "/home/ferreirafm/bin/pygrep.py", line 46, in sort_LD
    df = df.apply(my_fun, axis=1)
  File "/usr/lib64/python3.2/site-packages/pandas/core/frame.py", line 3576, in apply
    return self._apply_standard(f, axis)
  File "/usr/lib64/python3.2/site-packages/pandas/core/frame.py", line 3650, in _apply_standard
    columns=res_index)
  File "/usr/lib64/python3.2/site-packages/pandas/core/frame.py", line 373, in __init__
    mgr = self._init_dict(data, index, columns, dtype=dtype)
  File "/usr/lib64/python3.2/site-packages/pandas/core/frame.py", line 470, in _init_dict
    mgr = BlockManager(blocks, axes)
  File "/usr/lib64/python3.2/site-packages/pandas/core/internals.py", line 493, in __init__
    self._verify_integrity()
  File "/usr/lib64/python3.2/site-packages/pandas/core/internals.py", line 575, in _verify_integrity
    assert(block.values.shape[1:] == mgr_shape[1:])
AssertionError

This paste never expires. View raw. Pasted through import.