<p>解决这个问题的纯原生python库方法-让我们知道它与bash828x828的比较应该是在公园里散步。在</p>
<h3>元素列计数:</h3>
<p>为了简单和说明性的目的,我特意在序列翻转中添加了一个步骤——您可以通过更改类对象的逻辑或用法、函数修饰符等来改进它。。。在</p>
<h2>Python 2.7代码:</h2>
<pre><code>shiftcol = 2 # shift columns as first two are to be ignored
with open('phased.txt') as f:
data = [x.strip().split('\t')[shiftcol:] for x in f.readlines()][1:]
# Step 1: Flipping the data first
flip = []
for idx, rows in enumerate(data):
for i in range(len(rows)):
if len(flip) <= i:
flip.append([])
flip[i].append(rows[i])
# Step 2: counts store in temp dictionary
for idx, v in enumerate(flip):
for e in v:
tmp = {}
for i, z in enumerate(flip):
if i != idx and e != '0':
# Dictionary to store results
if i+1 not in tmp: # note has_key will be deprecated
tmp[i+1] = {'match': 0, 'notma': 0}
tmp[i+1]['match'] += z.count(e)
tmp[i+1]['notma'] += len([x for x in z if x != e])
# results compensate for column shift..
for key, count in tmp.iteritems():
print idx+shiftcol+1, key+shiftcol, ': ', count
</code></pre>
<h3>样本输出</h3>
^{pr2}$