回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>下面是python脚本,它标识在不同文件的列表中是否找到某些单词。在</p>
<pre><code>experiment=open('potentiation.txt')
lines=experiment.read().splitlines()
receptors=['crystal_1.txt', 'modeller_1.txt', 'moe_1.txt',
'nci5_modeller0000_1.txt', 'nci5_modeller0001_1.txt',
'nci5_modeller0002_1.txt', 'nci5_modeller0003_1.txt',
'nci5_modeller0004_1.txt', 'nci5_modeller0005_1.txt',
'nci5_modeller0006_1.txt', 'nci5_modeller0007_1.txt',
'nci5_modeller0008_1.txt', 'nci5_modeller0009_1.txt',
'nci5_modeller0010_1.txt', 'nci5_modeller0011_1.txt',
'nci5_moe0000_1.txt', 'nci5_moe0001_1.txt', 'nci5_moe0002_1.txt',
'nci5_moe0003_1.txt', 'nci5_moe0004_1.txt', 'nci5_moe0005_1.txt',
'nci5_moe0006_1.txt', 'nci5_moe0007_1.txt', 'nci5_moe0008_1.txt',
'nci5_moe0009_1.txt', 'nci5_moe0010_1.txt', 'nci5_moe0011_1.txt',
'nci5_moe0012_1.txt', 'nci5_moe0013_1.txt', 'nci5_moe0014_1.txt']
for ligand in lines:
for protein in receptors:
file1=open(protein,"r")
read1=file1.read()
find_hit=read1.find(ligand)
if find_hit == -1:
print ligand,protein,"Not Found"
else:
print ligand,protein, "Found"
</code></pre>
<p>此代码的输出示例如下:</p>
^{pr2}$
<p>我的问题是如何将输出格式化为一个类似下面示例的csv文件?在</p>
<pre class="lang-none prettyprint-override"><code>Ligand nci5_moe0012_1. nci5_moe_0013_1 nci5_moe_0014
345647 Not Found Not Found Found
</code></pre>