The following below is python script that identifies whether certain words are found or not found in a list of different files.
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"
An example of the output of this code is below:
345647 nci5_moe0012_1.txt Not Found
345647 nci5_moe0013_1.txt Not Found
345647 nci5_moe0014_1.txt Found
My question is how can I take the output and format it into a csv file that looks like the example below?
Ligand nci5_moe0012_1. nci5_moe_0013_1 nci5_moe_0014
345647 Not Found Not Found Found