Created
August 28, 2009 10:57
-
-
Save baoilleach/176902 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""sdfdatareader.py | |
Super fast skimmer over sdf files just to return the data | |
fields | |
""" | |
def sdf(filename): | |
input = open(filename, "r") | |
data = {} | |
for line in input: | |
if line.startswith("> <"): | |
k = line.rstrip()[3:-1] | |
v = [] | |
line = input.next().strip() | |
while line: | |
v.append(line) | |
line = input.next().strip() | |
data[k] = "\n".join(v) | |
elif line.startswith("$$$$"): | |
yield data | |
data = {} | |
if __name__ == "__main__": | |
filename = r"myfile.sdf" | |
for mol in sdf(filename): | |
data = mol | |
print data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment