JacksonBurns / mordred-community

Community-Maintained Version of mordred
https://jacksonburns.github.io/mordred-community/
BSD 3-Clause "New" or "Revised" License
44 stars 3 forks source link

Generate descriptors from charged molecules #14

Closed brunocalcada closed 4 months ago

brunocalcada commented 5 months ago

Hi all,

First, thanks for continuing this community, I use the mordred library on a regular basis.

In a more recent project that I'm working, I need to calculate all the descriptors for some charged molecules however mordred is complaining about the valence of the charged atoms (Explicit valence for atom # 8 N, 4, is greater than permitted).

If I generate the mol file from the smiles string and then calculate the descriptors, everything is ok. However, if a calculate the descriptors from a xyz or sdf file I'm getting that error. Is there a way to tell it that certain atoms have different valence or perhaps overwrite this and force the callculation of the descriptors?

Smiles string: "CCCCCCCCN+(CCCCCCCC)CCCCCCCC" (protonated atom is on square brackets) sdf file (in .txt): molecule_1.txt xyz file ( in .txt): molecule_1.txt

Thank you so much for any feedback in advance :)

JacksonBurns commented 5 months ago

Hi @brunocalcada thanks for the kind words.

That error is likely coming from RDKit, not mordred. Could you verify that the xyz, sdf, and mol files actually turn into the same molecule in RDKit? i.e. load all of the molecules into RDKit and then check if they are the same molecule. You can see which functions mordred uses to do this here: https://github.com/JacksonBurns/mordred-community/blob/fdbd0d9121370f6e4bb3ffe4dd9f4d5b521c775b/mordred/__main__.py#L33

brunocalcada commented 4 months ago

@JacksonBurns thanks for your reply.

Indeed my error was in the sdf file, something was in fact missing there :)

JacksonBurns commented 4 months ago

Glad the issue was discovered!