Nov-16-2018, 03:38 PM
Dear friends:
I must extract information from a sdf file containing molecule dates:
.
.
.
43 46 1 0 0 0 0
46 47 1 0 0 0 0
46 49 2 0 0 0 0
47 48 1 0 0 0 0
50 51 3 0 0 0 0
51 52 1 0 0 0 0
M END
> <Name>
4_pentynoic_acid
> <activity>
non
$$$$
CHAPS
MOE2011 3D
Structure written by Hyleos SD API
100103 0 0 1 0 0 0 0 0999 V2000
13.3220 1.0470 0.2750 S 0 0 0 0 0 0 0 0 0 0 0 0
.
.
.
I would like to obtain the following information for each molecule in a new file (result.txt):
Name: 4_pentynoic_acid, activity: non.
This sdf file contains 400 other molecules each one with its name and its activity.
Could you help me find the way to obtain this code?
Thank you very much!!
This is what I have been trying:
I must extract information from a sdf file containing molecule dates:
.
.
.
43 46 1 0 0 0 0
46 47 1 0 0 0 0
46 49 2 0 0 0 0
47 48 1 0 0 0 0
50 51 3 0 0 0 0
51 52 1 0 0 0 0
M END
> <Name>
4_pentynoic_acid
> <activity>
non
$$$$
CHAPS
MOE2011 3D
Structure written by Hyleos SD API
100103 0 0 1 0 0 0 0 0999 V2000
13.3220 1.0470 0.2750 S 0 0 0 0 0 0 0 0 0 0 0 0
.
.
.
I would like to obtain the following information for each molecule in a new file (result.txt):
Name: 4_pentynoic_acid, activity: non.
This sdf file contains 400 other molecules each one with its name and its activity.
Could you help me find the way to obtain this code?
Thank you very much!!
This is what I have been trying:
infile = open('Substrates.sdf', 'r') outfile = open('result.txt', 'w') copy = False tmpLines = [] for line in infile: if line == '<Name>': copy = True tmpLines = [] elif line == '$$$$': copy = False for tmpLine in tmpLines: outfile.write(tmpLine) elif copy: tmpLines.append(line)