Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexicanvas cuts off bottom of reaction #6685

Closed
DavidACosgrove opened this issue Sep 2, 2023 · 5 comments · Fixed by #6686
Closed

Flexicanvas cuts off bottom of reaction #6685

DavidACosgrove opened this issue Sep 2, 2023 · 5 comments · Fixed by #6686
Labels
Milestone

Comments

@DavidACosgrove
Copy link
Collaborator

Drawing a reaction in a flexicanvas cuts off the bottom of the image:

image

To Reproduce

TEST_CASE("") {
  const char *rxnBlock = R"RXN($RXN

      Mrv1920  090120231611

  3  1
$MOL

  Mrv1920 09012316112D

  1  0  0  0  0  0            999 V2000
  -12.3227   -0.2785    0.0000 Cl  0  0  0  0  0  0  0  0  0  0  0  0
M  END
$MOL

  Mrv1920 09012316112D

 11 11  0  0  0  0            999 V2000
   -6.0796   -0.5503    0.0000 Cl  0  0  0  0  0  0  0  0  0  0  0  0
   -6.7352   -0.0493    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -6.6291    0.7688    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -7.4967   -0.3666    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -8.1522    0.1344    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -8.9137   -0.1829    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -9.5692    0.3181    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  -10.3307    0.0008    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  -10.4370   -0.8173    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -9.7813   -1.3182    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -9.0199   -1.0009    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0  0  0  0
  2  3  2  0  0  0  0
  2  4  1  0  0  0  0
  4  5  1  0  0  0  0
  5  6  1  0  0  0  0
  6  7  4  0  0  0  0
  7  8  4  0  0  0  0
  8  9  4  0  0  0  0
  9 10  4  0  0  0  0
 10 11  4  0  0  0  0
 11  6  4  0  0  0  0
M  END
$MOL

  Mrv1920 09012316112D

 10 10  0  0  0  0            999 V2000
   -3.2982    1.9786    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.4043    1.1605    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -2.7488    0.6596    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.9872    0.9767    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
   -2.8547   -0.1585    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.1992   -0.6594    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.3055   -1.4777    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.0669   -1.7949    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.7225   -1.2939    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.6163   -0.4759    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0  0  0  0
  2  3  1  0  0  0  0
  3  4  2  0  0  0  0
  3  5  1  0  0  0  0
  5  6  1  0  0  0  0
  6  7  1  0  0  0  0
  7  8  1  0  0  0  0
  8  9  1  0  0  0  0
  9 10  1  0  0  0  0
 10  5  1  0  0  0  0
M  END
$MOL

  Mrv1920 09012316112D

 20 21  0  0  0  0            999 V2000
    7.3862    1.9786    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    7.2800    1.1605    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    7.9356    0.6596    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    8.6971    0.9768    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    7.8294   -0.1586    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    8.4850   -0.6595    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    8.3789   -1.4777    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    7.6173   -1.7950    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    6.9619   -1.2939    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    7.0679   -0.4758    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
    6.4124    0.0252    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    6.5186    0.8432    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    5.6509   -0.2920    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    4.9954    0.2089    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    4.2337   -0.1084    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.5784    0.3926    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.8166    0.0753    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.7107   -0.7427    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.3661   -1.2438    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    4.1276   -0.9266    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0  0  0  0
  2  3  1  0  0  0  0
  3  4  2  0  0  0  0
  3  5  1  0  0  0  0
  5  6  1  0  0  0  0
  6  7  1  0  0  0  0
  7  8  1  0  0  0  0
  8  9  1  0  0  0  0
  9 10  1  0  0  0  0
 10 11  1  0  0  0  0
 11 12  2  0  0  0  0
 11 13  1  0  0  0  0
 13 14  1  0  0  0  0
 14 15  1  0  0  0  0
 15 16  4  0  0  0  0
 16 17  4  0  0  0  0
 17 18  4  0  0  0  0
 18 19  4  0  0  0  0
 19 20  4  0  0  0  0
 10  5  1  0  0  0  0
 20 15  4  0  0  0  0
M  END)RXN";

  std::string nameBase = "testGithub6683_";
  std::unique_ptr<ChemicalReaction> rxn(RxnBlockToChemicalReaction(rxnBlock));
  MolDraw2DSVG drawer(-1, -1);
  drawer.drawReaction(*rxn);
  drawer.finishDrawing();
  std::string text = drawer.getDrawingText();
  std::ofstream outs((nameBase + "1.svg").c_str());
  outs << text;
  outs.close();
}

Expected behavior
I would have hoped to have seen the bottom of the piperidine.

Screenshots
If applicable, add screenshots to help explain your problem.

Configuration (please complete the following information):

  • RDKit version: current master branc
  • OS: macOS

Additional context
This is a simpler version of the display of the reaction @paconius is using in #6683. This may or may not be the same bug, but clearly needs fixing. Looking into it now.

@paconius
Copy link

paconius commented Sep 2, 2023

Hi David, I'm guessing that the clipping is not related to the svg issue in the orig. discussion based on the following. I've seen a number of cases where the image is clipped. usually on the left or right, but sometimes on the top/bottom as you observed. These clipping cases can be "fixed" by increasing the 'padding' parameter in draw options. However, no value of the padding parameter seems to be able to fix the negative widths in the SVG.
I could be wrong about this, as I am just speaking from limited observations.

@DavidACosgrove
Copy link
Collaborator Author

I think you’re right, now I’ve fixed it, but we can always hope! I’ll look at the other one early next week. It’s clearly a bug- whatever is going on, it should never produce negative values for width and height.

@paconius
Copy link

paconius commented Sep 2, 2023

Here are a couple more rxn blocks that produce clipped svg images. Perhaps useful for testing your fix for the clipping problem. FIrst one is clipped on the left side. Second one is clipped on the right side. The images show the clipping produced when the padding parameter is left unchanged.
image

$RXN

      Mrv1920  090220231847

  2  1
$MOL

  Mrv1920 09022318472D          

  2  1  0  0  0  0            999 V2000
   -7.4817   -0.2130    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
   -6.6567   -0.2130    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0  0  0  0
M  END
$MOL

  Mrv1920 09022318472D          

  9  8  0  0  0  0            999 V2000
   -3.3781    2.1354    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.5235    1.3233    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
   -4.2996    1.0435    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.8932    0.7914    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.0387   -0.0206    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.7812   -0.3803    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.8567   -1.3430    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.4672   -0.6157    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -1.6500   -0.5031    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0  0  0  0
  2  3  1  0  0  0  0
  2  4  1  0  0  0  0
  4  5  2  0  0  0  0
  5  6  1  0  0  0  0
  7  8  1  0  0  0  0
  8  9  2  0  0  0  0
  8  5  1  0  0  0  0
M  END
$MOL

  Mrv1920 09022318472D          

  8  8  0  0  0  0            999 V2000
    5.5359   -0.2650    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    5.3537    1.0574    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    4.6115    0.6978    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.7993    0.8433    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.4102    0.1159    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
    3.9815   -0.4790    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
    4.7240   -0.1195    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.5929    0.0033    0.0000 H   0  0  0  0  0  0  0  0  0  0  0  0
  2  3  1  0  0  0  0
  3  4  4  0  0  0  0
  4  5  4  0  0  0  0
  5  6  4  0  0  0  0
  6  7  4  0  0  0  0
  7  1  1  0  0  0  0
  7  3  4  0  0  0  0
  5  8  1  0  0  0  0
M  END

@paconius
Copy link

paconius commented Sep 2, 2023

image

$RXN

      Mrv1920  090220231850

  1  2
$MOL

  Mrv1920 09022318502D          

 20 22  0  0  0  0            999 V2000
   -2.4533   -0.5079    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.0179    0.0939    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.8212   -0.0941    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -4.0600   -0.8837    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -4.8633   -1.0715    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
   -5.4277   -0.4698    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -6.2311   -0.6577    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -6.7954   -0.0558    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -7.5987   -0.2436    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -7.8377   -1.0333    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -7.2734   -1.6351    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -6.4701   -1.4473    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -5.1888    0.3199    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -4.3855    0.5077    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -4.1465    1.2974    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -4.7110    1.8993    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -5.5142    1.7114    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -5.7532    0.9218    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -3.4957   -1.4854    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
   -2.6923   -1.2975    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  4  0  0  0  0
  2  3  4  0  0  0  0
  3  4  4  0  0  0  0
  4  5  1  0  0  0  0
  5  6  2  3  0  0  0
  6  7  1  0  0  0  0
  7  8  4  0  0  0  0
  8  9  4  0  0  0  0
  9 10  4  0  0  0  0
 10 11  4  0  0  0  0
 11 12  4  0  0  0  0
  6 13  1  0  0  0  0
 13 14  4  0  0  0  0
 14 15  4  0  0  0  0
 15 16  4  0  0  0  0
 16 17  4  0  0  0  0
 17 18  4  0  0  0  0
  4 19  4  0  0  0  0
 19 20  4  0  0  0  0
 20  1  4  0  0  0  0
 12  7  4  0  0  0  0
 18 13  4  0  0  0  0
M  END
$MOL

  Mrv1920 09022318502D          

  7  7  0  0  0  0            999 V2000
    5.5920    0.3948    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    5.0277    0.9966    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    4.2244    0.8087    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.9855    0.0191    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    3.1821   -0.1689    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
    4.5499   -0.5827    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    5.3531   -0.3949    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  4  0  0  0  0
  2  3  4  0  0  0  0
  3  4  4  0  0  0  0
  4  5  1  0  0  0  0
  4  6  4  0  0  0  0
  6  7  4  0  0  0  0
  7  1  4  0  0  0  0
M  END
$MOL

  Mrv1920 09022318502D          

  1  0  0  0  0  0            999 V2000
    8.3990    0.0732    0.0000 Cl  0  0  0  0  0  0  0  0  0  0  0  0
M  END

@greglandrum greglandrum added this to the 2023_09_1 milestone Sep 9, 2023
@paconius
Copy link

paconius commented Sep 9, 2023

@DavidACosgrove : I see your fixes were merged yesterday. Thanks for your help with this. I can further test and provide feedback whenever the next rdkit-dev becomes avaialble. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants