@@ -315,3 +315,84 @@ def test_draw_bidentate_with_charge_separation(self):
315
315
from cairo import PDFSurface
316
316
surface , _cr , (_xoff , _yoff , _width , _height ) = self .drawer .draw (molecule , file_format = "pdf" )
317
317
assert isinstance (surface , PDFSurface )
318
+
319
+ def test_draw_cation (self ):
320
+ try :
321
+ from cairocffi import PDFSurface
322
+ except ImportError :
323
+ from cairo import PDFSurface
324
+ path = "test_molecule.pdf"
325
+ if os .path .exists (path ):
326
+ os .unlink (path )
327
+ polycycle = Molecule (smiles = "C1=NC2=C(N1)C(=O)[NH2+]C(=N2)N" )
328
+ surface , _cr , (_xoff , _yoff , width , height ) = self .drawer .draw (polycycle , file_format = "pdf" , target = path )
329
+ assert isinstance (surface , PDFSurface )
330
+ assert width > height
331
+ os .unlink (path )
332
+
333
+ def test_draw_anion (self ):
334
+ try :
335
+ from cairocffi import PDFSurface
336
+ except ImportError :
337
+ from cairo import PDFSurface
338
+ path = "test_molecule.pdf"
339
+ if os .path .exists (path ):
340
+ os .unlink (path )
341
+ polycycle = Molecule (smiles = "c1ccc2c3ccccc3[CH-]c2c1" )
342
+ surface , _cr , (_xoff , _yoff , width , height ) = self .drawer .draw (polycycle , file_format = "pdf" , target = path )
343
+ assert isinstance (surface , PDFSurface )
344
+ assert width > height
345
+ os .unlink (path )
346
+
347
+ def test_draw_zwitterion (self ):
348
+ try :
349
+ from cairocffi import PDFSurface
350
+ except ImportError :
351
+ from cairo import PDFSurface
352
+ path = "test_molecule.pdf"
353
+ if os .path .exists (path ):
354
+ os .unlink (path )
355
+ polycycle = Molecule (smiles = "[NH3+]CC(=O)[O-]" )
356
+ surface , _cr , (_xoff , _yoff , width , height ) = self .drawer .draw (polycycle , file_format = "pdf" , target = path )
357
+ assert isinstance (surface , PDFSurface )
358
+ assert width > height
359
+ os .unlink (path )
360
+
361
+ def test_draw_cation_on_surface (self ):
362
+ molecule = Molecule ().from_adjacency_list (
363
+ """
364
+ 1 X u0 p0 c0 {3,S}
365
+ 2 X u0 p0 c0 {3,S}
366
+ 3 O u0 p1 c+1 {1,S} {2,S} {4,S}
367
+ 4 H u0 p0 c0 {3,S}
368
+ """
369
+ )
370
+ try :
371
+ from cairocffi import PDFSurface
372
+ except ImportError :
373
+ from cairo import PDFSurface
374
+ path = "test_molecule.pdf"
375
+ if os .path .exists (path ):
376
+ os .unlink (path )
377
+ surface , _cr , (_xoff , _yoff , _width , _height ) = self .drawer .draw (molecule , file_format = "pdf" , target = path )
378
+ assert isinstance (surface , PDFSurface )
379
+ os .unlink (path )
380
+
381
+
382
+ def test_draw_anion_on_surface (self ):
383
+ molecule = Molecule ().from_adjacency_list (
384
+ """
385
+ 1 X u0 p0 c0 {2,S}
386
+ 2 O u0 p3 c-1 {1,S}
387
+ """
388
+ )
389
+ try :
390
+ from cairocffi import PDFSurface
391
+ except ImportError :
392
+ from cairo import PDFSurface
393
+ path = "test_molecule.pdf"
394
+ if os .path .exists (path ):
395
+ os .unlink (path )
396
+ surface , _cr , (_xoff , _yoff , _width , _height ) = self .drawer .draw (molecule , file_format = "pdf" , target = path )
397
+ assert isinstance (surface , PDFSurface )
398
+ os .unlink (path )
0 commit comments