Skip to content

Can I remove the (1) that results after using rdkit.Chem.PandasTools.WriteSDF so it works with Maestro? #5465

Answered by ptosco
DKchemistry asked this question in Q&A
Discussion options

You must be logged in to vote

@DKchemistry Simplest way would be to strip the number with a regex:

from io import StringIO
import re

strip_number = re.compile(r"^(>  <\S+>)(\s+\(\d+\)\s*)$", re.MULTILINE)

with StringIO() as buf:
    PandasTools.WriteSDF(df, buf, properties=list(df.columns))
    sdf = buf.getvalue()
sdf = strip_number.sub(r"\1", sdf)
with open("file.sdf", "w") as hnd:
    hnd.write(sdf)

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@DKchemistry
Comment options

Answer selected by DKchemistry
Comment options

You must be logged in to vote
4 replies
@DKchemistry
Comment options

@ricrogz
Comment options

@ricrogz
Comment options

@DKchemistry
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants