Re: [Rdkit-discuss] molecule layout to optimise available space
Hi Tim, That's a nice one. For people not familiar with the problem: The RDKit coordinate generation prefers aligning molecules with the X axis; this can lead to "sub-optimal" drawings if your drawing canvas is taller than it is wide. One easy solution is to just generate coordinates as usual and then rotate them to favor the Y axis if your canvas is larger along Y. Here's a gist showing how to do that: https://gist.github.com/greglandrum/12b793b240d27e3c0899c9c6c62d4f30 -greg On Fri, Feb 11, 2022 at 10:20 AM Tim Dudgeon wrote: > At Dave Cosgrove's suggestion I raise this as a new topic, though it was > touched on briefly recently. > > I'd like to know if it's possible to depict a molecule in a way that takes > into account the dimensions of the box it will appear in. In my case I have > a rectangle that is short and wide (aspect ratio of 1:3) and the molecules > are typically compressed because of the lack of available height. So is it > possible to make the layout engine aware of the bounds it has available > (e.g. in my example short and wide)? > > Thanks > Tim > ___ > Rdkit-discuss mailing list > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss > ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] molecule layout to optimise available space
Hi Greg, yes, but my situation is that the X dimension is much larger than the Y and most of the time things are aligned nicely. But not always. Here is an example. OC(C(=O)NC=1C=CC=CC1NS(=O)(=O)C=2C=CC(F)=CC2)C=3C=CC=NC3 [image: image.png] Clearly there is potential to lay this out using more of the X dimension and less of the Y. Tim On Fri, Feb 11, 2022 at 1:57 PM Greg Landrum wrote: > Hi Tim, > > That's a nice one. > > For people not familiar with the problem: > The RDKit coordinate generation prefers aligning molecules with the X > axis; this can lead to "sub-optimal" drawings if your drawing canvas is > taller than it is wide. > > One easy solution is to just generate coordinates as usual and then rotate > them to favor the Y axis if your canvas is larger along Y. > Here's a gist showing how to do that: > https://gist.github.com/greglandrum/12b793b240d27e3c0899c9c6c62d4f30 > > -greg > > > On Fri, Feb 11, 2022 at 10:20 AM Tim Dudgeon > wrote: > >> At Dave Cosgrove's suggestion I raise this as a new topic, though it was >> touched on briefly recently. >> >> I'd like to know if it's possible to depict a molecule in a way that >> takes into account the dimensions of the box it will appear in. In my case >> I have a rectangle that is short and wide (aspect ratio of 1:3) and the >> molecules are typically compressed because of the lack of available height. >> So is it possible to make the layout engine aware of the bounds it has >> available (e.g. in my example short and wide)? >> >> Thanks >> Tim >> ___ >> Rdkit-discuss mailing list >> Rdkit-discuss@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss >> > ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] molecule layout to optimise available space
Oh, you want the layout itself changed, not just the orientation. No, there's nothing in place to do that and adding such a thing would be extremely non-trivial. -greg On Fri, Feb 11, 2022 at 3:49 PM Tim Dudgeon wrote: > Hi Greg, > yes, but my situation is that the X dimension is much larger than the Y > and most of the time things are aligned nicely. But not always. Here is an > example. > OC(C(=O)NC=1C=CC=CC1NS(=O)(=O)C=2C=CC(F)=CC2)C=3C=CC=NC3 > [image: image.png] > Clearly there is potential to lay this out using more of the X dimension > and less of the Y. > > Tim > > On Fri, Feb 11, 2022 at 1:57 PM Greg Landrum > wrote: > >> Hi Tim, >> >> That's a nice one. >> >> For people not familiar with the problem: >> The RDKit coordinate generation prefers aligning molecules with the X >> axis; this can lead to "sub-optimal" drawings if your drawing canvas is >> taller than it is wide. >> >> One easy solution is to just generate coordinates as usual and then >> rotate them to favor the Y axis if your canvas is larger along Y. >> Here's a gist showing how to do that: >> https://gist.github.com/greglandrum/12b793b240d27e3c0899c9c6c62d4f30 >> >> -greg >> >> >> On Fri, Feb 11, 2022 at 10:20 AM Tim Dudgeon >> wrote: >> >>> At Dave Cosgrove's suggestion I raise this as a new topic, though it was >>> touched on briefly recently. >>> >>> I'd like to know if it's possible to depict a molecule in a way that >>> takes into account the dimensions of the box it will appear in. In my case >>> I have a rectangle that is short and wide (aspect ratio of 1:3) and the >>> molecules are typically compressed because of the lack of available height. >>> So is it possible to make the layout engine aware of the bounds it has >>> available (e.g. in my example short and wide)? >>> >>> Thanks >>> Tim >>> ___ >>> Rdkit-discuss mailing list >>> Rdkit-discuss@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss >>> >> ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] molecule layout to optimise available space
Greg, Thanks for the clarification. On Fri, Feb 11, 2022 at 3:19 PM Greg Landrum wrote: > Oh, you want the layout itself changed, not just the orientation. > > No, there's nothing in place to do that and adding such a thing would be > extremely non-trivial. > > -greg > > > On Fri, Feb 11, 2022 at 3:49 PM Tim Dudgeon wrote: > >> Hi Greg, >> yes, but my situation is that the X dimension is much larger than the Y >> and most of the time things are aligned nicely. But not always. Here is an >> example. >> OC(C(=O)NC=1C=CC=CC1NS(=O)(=O)C=2C=CC(F)=CC2)C=3C=CC=NC3 >> [image: image.png] >> Clearly there is potential to lay this out using more of the X dimension >> and less of the Y. >> >> Tim >> >> On Fri, Feb 11, 2022 at 1:57 PM Greg Landrum >> wrote: >> >>> Hi Tim, >>> >>> That's a nice one. >>> >>> For people not familiar with the problem: >>> The RDKit coordinate generation prefers aligning molecules with the X >>> axis; this can lead to "sub-optimal" drawings if your drawing canvas is >>> taller than it is wide. >>> >>> One easy solution is to just generate coordinates as usual and then >>> rotate them to favor the Y axis if your canvas is larger along Y. >>> Here's a gist showing how to do that: >>> https://gist.github.com/greglandrum/12b793b240d27e3c0899c9c6c62d4f30 >>> >>> -greg >>> >>> >>> On Fri, Feb 11, 2022 at 10:20 AM Tim Dudgeon >>> wrote: >>> At Dave Cosgrove's suggestion I raise this as a new topic, though it was touched on briefly recently. I'd like to know if it's possible to depict a molecule in a way that takes into account the dimensions of the box it will appear in. In my case I have a rectangle that is short and wide (aspect ratio of 1:3) and the molecules are typically compressed because of the lack of available height. So is it possible to make the layout engine aware of the bounds it has available (e.g. in my example short and wide)? Thanks Tim ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss >>> ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
Re: [Rdkit-discuss] molecule layout to optimise available space
If the issue is a 2D coordinate issue (rather than a drawing layout one), is there a way to do post-coordgen "bond rotation" in 2D coordinate space? (That is, flip the cis/trans choice for certain bonds). I could imagine an algorithm which samples the "2D rotatable" bonds on Tim's structure, then figures out that by flipping the N-phenyl bond (and potentially others) it makes the molecule suitably long and thin. On Fri, Feb 11, 2022 at 9:24 AM Tim Dudgeon wrote: > Greg, > Thanks for the clarification. > > On Fri, Feb 11, 2022 at 3:19 PM Greg Landrum > wrote: > >> Oh, you want the layout itself changed, not just the orientation. >> >> No, there's nothing in place to do that and adding such a thing would be >> extremely non-trivial. >> >> -greg >> >> >> On Fri, Feb 11, 2022 at 3:49 PM Tim Dudgeon >> wrote: >> >>> Hi Greg, >>> yes, but my situation is that the X dimension is much larger than the Y >>> and most of the time things are aligned nicely. But not always. Here is an >>> example. >>> OC(C(=O)NC=1C=CC=CC1NS(=O)(=O)C=2C=CC(F)=CC2)C=3C=CC=NC3 >>> [image: image.png] >>> Clearly there is potential to lay this out using more of the X dimension >>> and less of the Y. >>> >>> Tim >>> >>> On Fri, Feb 11, 2022 at 1:57 PM Greg Landrum >>> wrote: >>> Hi Tim, That's a nice one. For people not familiar with the problem: The RDKit coordinate generation prefers aligning molecules with the X axis; this can lead to "sub-optimal" drawings if your drawing canvas is taller than it is wide. One easy solution is to just generate coordinates as usual and then rotate them to favor the Y axis if your canvas is larger along Y. Here's a gist showing how to do that: https://gist.github.com/greglandrum/12b793b240d27e3c0899c9c6c62d4f30 -greg On Fri, Feb 11, 2022 at 10:20 AM Tim Dudgeon wrote: > At Dave Cosgrove's suggestion I raise this as a new topic, though it > was touched on briefly recently. > > I'd like to know if it's possible to depict a molecule in a way that > takes into account the dimensions of the box it will appear in. In my case > I have a rectangle that is short and wide (aspect ratio of 1:3) and the > molecules are typically compressed because of the lack of available > height. > So is it possible to make the layout engine aware of the bounds it has > available (e.g. in my example short and wide)? > > Thanks > Tim > ___ > Rdkit-discuss mailing list > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss > ___ > Rdkit-discuss mailing list > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss > ___ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss