Nov-23-2018, 09:40 AM
good morning guys,
I need help:
I have done a program to obtain some data and then I have to append this data to the original file. My original file is something like this (with hundred more lines):
Verapamil,sub,COC1=C(OC)C=C(CCN©CCCC(C#N)(C©C)C2=CC(OC)=C(OC)C=C2)C=C1
Norverapamil,sub,COC1=CC=C(CCNCCCC(C#N)(C©C)C2=CC(OC)=C(OC)C=C2)C=C1OC
levofloxacin,sub,C[C@H]1COC2=C3N1C=C(C(O)=O)C(=O)C3=CC(F)=C2N1CCN©CC1
.
.
.
I need to take each third entry (in bold), process it to obtain a data and append this value to the original file, separated by comma.
I show you my program below. I am able to obtain the values and I see them on the screen but I don't find the way to append them to the original file. Could you help me with this, please?
I need help:
I have done a program to obtain some data and then I have to append this data to the original file. My original file is something like this (with hundred more lines):
Verapamil,sub,COC1=C(OC)C=C(CCN©CCCC(C#N)(C©C)C2=CC(OC)=C(OC)C=C2)C=C1
Norverapamil,sub,COC1=CC=C(CCNCCCC(C#N)(C©C)C2=CC(OC)=C(OC)C=C2)C=C1OC
levofloxacin,sub,C[C@H]1COC2=C3N1C=C(C(O)=O)C(=O)C3=CC(F)=C2N1CCN©CC1
.
.
.
I need to take each third entry (in bold), process it to obtain a data and append this value to the original file, separated by comma.
I show you my program below. I am able to obtain the values and I see them on the screen but I don't find the way to append them to the original file. Could you help me with this, please?
import os import subprocess path_input = '/home/c.blanes/pgp/training.txt' obabel = '/usr/bin/obabel ' f = open(path_input, 'r') for line in f.readlines(): smiles = line.split(',')[2].strip('\n') print(smiles) launch = obabel + '-:\'%s\' -otxt --append TPSA'%(smiles) print (launch) subprocess.call(launch, shell=True)