Commit Graph

107 Commits

Author SHA1 Message Date
lummyk
ec6ee2bba7 Replace fill-opacity= with fill-opacity: (#3368) 2020-09-18 15:11:17 +02:00
David Cosgrove
bf86d93346 Fix drawing of N plus (#3165)
* Fixed poor position of + charge in S NH2+ group.  Also made it say Cu2+ rather than Cu+2.

* Fixed bug where H of [NH+](C)(C)C sometimes went on top of bond.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2020-06-09 16:05:39 +02:00
David Cosgrove
2424b9f57f Fixed double bonds in polycyclic aromatic systems drawn outside the ring. (#3068)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2020-05-08 04:30:17 +02:00
David Cosgrove
6fb55c641b Fixed bug with annotation on degree-1 atoms. (#3042)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2020-03-28 05:12:56 +01:00
Greg Landrum
1fcf7d65d2 Tweaks and refinements to new drawing code. (#3034)
* Several things here

1) move "atomNote" and "bondNote" to common_properties
2) move addStereoAnnotation to the MolDraw2DUtils namespace
3) add addAtomIndices and addBondIndices
4) initialize MolDrawOptions members directly instead of via the ctor
5) add tests for all that
6) the usual reformatting

* Move the annotations functions to MolDraw2DDetails,
no need for them to be in the public API

Remove MolDraw2DDetails.h from the installed headers.

* turn off redundant prepareMolsForDrawing in _moltoimg
2020-03-26 10:40:06 +01:00
David Cosgrove
ea54f66558 Commit of 2D draw annotation. (#3010)
* Commit of 2D draw annotation.

* update expected psql results

* First pass at improved radical drawing.

* Fix?

* Fixed different string draw behaviour.

* Removed vestiges of previous radical handling.

* Fixed bug with annnotation placement and added fallback postion.

* Removed unused var.

* update expected reaction svg

* Added option for always having circular highlights.

* Updated JSON to drawOptionns.

* Fixed bug in scale calculation.  Centres drawn molecule with option not to.

* Tidied up scale calculation.

* Changed atomHighlightCircles to atomHighlightsAreCircles.
Used shared_ptr for StringRect as VS barfed on unique_ptr.

* Fixed bug with reaction cruft not following now-centred molecules.

* temporary stash

* Stepped back centring of molecule by drawMolecule and fixes to drawReaction prompted by it.

* allow annotations to be disabled at the class level.
disable them for MolDraw2DCairo on win32 (where they just don't work)

* some test cleanup

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: greg landrum <greg.landrum@gmail.com>
2020-03-20 13:54:45 +01:00
David Cosgrove
774892a9ab 2ddrawenhancements2931 (#2979)
* First pass of fixing layout of OH/NH type drawing.

* Fixed scale for N/S NH type groups.

* Fixed bond end points with new display of heteroatoms.

* Fixed case where it drew aromatic dashed bonds in wrong ring for morphine.

* Minor edit.

* Fixed non-drawing of chiral bonds.

* Removed use of boost for_each.

* Modern atom traversal.

* Put in fixed scale for drawings.
Made drawMolecule() take note of prepareMolsBeforeDrawing.
Updated more iterators to modern idiom.

* Added fixed bond length for drawing.

* Fixed drawing of CH4, NH3 etc.

* Stash of working but ugly, prior to re-work.

* Better, simpler splitting of atom symbols.

* Took clang-tidy's advice about use of override.

* Tidied up drawing of text strings.

* Tweaked what is classed as vertical bond in drawing.

* fixedBondLength now down-scales if it would overflow the draw window.

* Some tidying.

* Tests for new parameters in JSON.
Fixed some existing tests where, for example, scale on picture is now different.

* Added option to rotate 2D draw coords before drawing.

* First pass at highlighting atoms in multiple colours.  Circles only at the moment.

* Line width scales if big enough.

* Tweaked SVG text drawing.

* Added highlighting with more than 1 colour on an atom.  C++ only.

* Fixed some issues with widths of highlights in a frustrating game of whackamole.
Updated some tests accordingly.

* Added Python wrapper for new drawing code.

* Removed debugging writes.

* Added C++ test for multi-coloured highlights.

* Added python test for multi-coloured highlights.

* Attempt to show radicals.

* Tidied up radicals in drawing, including a bullet instead of full stop in SVG.

* Fixed catch_tests.cpp for MolDraw2D.

* Fixed crash in Python wrappers on OSX.

* Fixed test5_2.svg bug (trailing </tspan>).
Made wavy line width scale as other lines do.

* Improved placing of charges.

* We're already in the future.

* Fixed a number of bugs that made drawMolecules not set the scales properly.

* Fixed Cairo wavy line width.

* Fixed non-closure of collision boxes.

* Added maximum font size for text, with tests.

* Addressed all Greg's first PR change requests.

* Fixed crash in extractAtomsymbols.

* stop using coordgen and adjust tests to reflect that
there's a bit of reformatting in here too

* Fixed layout of reactions.

* Fiddled with moldraw2DTest1 tests again.

* Fiddled with catch test.

* Fixed istope postion in W atom labels.

* Minor tweak to cairo,

* update expected results

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2020-03-10 17:33:59 +01:00
Greg Landrum
d41752d558 run clang-tidy with readability-braces-around-statements (#2899)
* run clang-tidy with readability-braces-around-statements
clang-format the results
clean up all the parts that clang-tidy-8 broke

* fix problem on windows
2020-01-25 14:19:32 +01:00
Eisuke Kawashima
5cd27a242f Fix typo (#2862)
* Fix typo

* Reflect the comments

* Fix more typos
2019-12-31 06:43:27 +01:00
Greg Landrum
ab061d532f fix start/end atoms when wedging bonds (#2861) 2019-12-27 07:21:49 -05:00
Paolo Tosco
81ac6d3880 Fixes #2762 (#2764)
* - fixes #2762

* - reverted fabs()
2019-11-29 13:37:15 +01:00
Greg Landrum
881d4e2b42 Enable SimilarityMaps in C++ (#2562)
* basic conrec integration

* basic conrec integration

* add molecule contouring

* update

* add an alpha channel to the color

* allow filling the grid

* cleanup

* remove some debugging output

* first pass at getting similarity maps to actually work

* updates

* add another test
explicitly set linewidth to 1

* some SVG cleanup

* add option for extra padding

* update expected test results

* efficiency

* at least something of a test

* forgot an import

* fix SWIG wrappers

* cleanups in response to review

* allow calling the functions without providing levels

* allow contouring numpy grids
2019-07-28 08:59:06 -04:00
Ric
6224a42516 Build warnings revisited (#2318)
* unused vars in bison parser cleanup

* initialization order in TopologicalTorsionGenerator

* unused params in SLN bison

* sln flex unused params

* throwing destructor in TDTWriter

* signed comparison in substructmethods

* unused input param in smiles/smarts bison

* unused ms param in sln bison

* signed comparison in FingerprintGenerator

* store return of fscanf in StructCheckerOptions

* unreferenced var in catch

* uninitialized value in FileParserUtils

* avoid override overload warning in MolDraw2DSVG

* non-final overrides in Validate.h

* unused static var in Avalon

* unused vars in catch blocks

* make AvalonTools avalonSimilarityBits & avalonSSSBits const int

* assert fscanf result in StructCheckerOptions
2019-03-08 16:42:54 +01:00
Greg Landrum
7869e086cd Improve interactivity of output SVG (#2253)
* Add clickable atoms when tagAtoms() is called

* add python tests

* add class tags for atoms and bonds

* add marker to allow easy insertion of extra text
2019-02-15 15:41:10 -05:00
Greg Landrum
01b79a05e4 Fixes #2151 (#2152)
* move definition of ctor to header
clang-format

* Fixes #2151
a bit of clang-format as well
2018-11-05 07:14:00 -05:00
Ric
a6b26253ff Fix (most of) mem problems (#2123)
* do not use new on loggers

* del pointers in testDistGeom

* Update Dict hasNonPOD status on bulk update

* delete new Dicts in memtest1.cpp

* fixes in MolSuppliers and testFMCS

* PeriodicTable singleton as unique_ptr

* fix EEM_arrays leak

* fix leaks in testPBF

* fix ParamCollection leak in test UFF

* fix leaks in MMFF

* clear prop dict before read in in pickler

* fix leaks in testFreeSASA

* fix leaks in test3D

* modernize Dict.h & SmilesParse.cpp

* fix leaks in testQuery

* fix leaks in testCrystalFF

* fix leaks in cxsmilesTest

* fix leaks in Catalog & mol cat test

* fix leaks in ShapeUtils & tests

* fix leaks in testSubgraphs1

* fix leaks testFingerprintGenerators

* fix leaks in Catalog/FilterCatalog

* fix leaks in graphmolqueryTest

* these changes reduce bison parse leaks

* fixed leaks in testChirality.cpp

* fix leaks + 2 tests in testMolWriter

* fix 4m leaks in substructLibraryTest

* small improvements to molTautomerTest; still leaks

* fix leaks in testRGroupDecomp

* fix leaks in test; parser still leaks

* fix leaks in itertest

* fix 4m leaks in testDepictor

* fixes in smatest; still leaking due to parser

* fixes in testSLNParse; still leaking due to parser

* flex/bison: always add atoms with ownership; smarts error cleanup

* fix leaks in testReaction

* fix leaks in testSubstructMatch

* fix leaks in resMolSupplierTest

* fix leaks in testChemTransforms + bug in ChemTransforms

* fix leaks in testPickler

* fix leaks in testMolTransform

* fix leaks in testFragCatalog

* fix leak in testSLNParse. Still leaks due to Smiles

* fixed most leaks in testMolSupplier

* pre bison fix

* fix some atom & bond parse problems; others still fail

* bison smiles & smarts, atoms & bonds more or less fixed

* fix leaks in molopstest.cpp

* fix leaks in testFingerprints, MACCS.cpp & AtomPairs.cpp

* fix leaks in moldraw2Dtest1

* fix leaks in testDescriptors

* fix leaks in testInchi

* fix leaks in testUFFForceFieldHelpers

* fix leaks in hanoiTest & new_canon.h

* fix leaks in testMMFFForceField

* fix leaks in graphmolTest1

* fix leaks in testMMFFForceFieldHelpers

* fix leaks in testDistGeomHelpers

* fix leaks in testMolAlign

* initialize occupancy & temp facto with default values

* fix leak in TautomerTransform

* updated suppressions

* fix testStructChecker

* fix logging & py tests

* fix TautomerTransform class/struct issue

* remove misplaced delete in testSLNParse

* deinit in testAvalonLib1

* fix Avalon-triggered(?) bug in StructChecker/Pattern.cpp

* fix random testMolWriter/Supplier fails

- diversify output file names to avoid clashing.
- unify Writers close/destruct behavior.
- flushing/closing in tests.

* use reset in FFs Params.cpp

* comments on testMMFFForceField

* unrequired 'if's added to mol suppliers

* correct cast in FilterCatalog.h

* use unique_ptr in MACCS Patterns

* remove unrequred if in new_canon

* update & move suppressions
2018-10-29 14:33:26 +00:00
Paolo Tosco
f7c888844d moved test.h from RDBoost to RDGeneral for consistency with export.h (#2074) 2018-10-11 17:35:23 -04:00
Greg Landrum
2ec3b2543d Fixes #2063 (#2075) 2018-10-02 11:39:37 -04:00
Greg Landrum
abcecf7456 enable SVG parsing from Python (#2045)
* add SVG parsing to python
re-enable the moldraw2d tests

* A couple of fixes connected to #2029

* handle problems parsing atom/bond SMILES

* wrap the whole thing in the <metadata> tag

* patch a memory allocation problem in the maeparser v1.0.0 (#2044)
2018-09-17 20:20:21 +02:00
Greg Landrum
b91daa8ab9 Allow dumping interchange information into SVG files (#2030)
* add atoms

* add bonds

* backup

* Fixes #2029

* Get metadata working for drawMolecules()

* add to python wrapper
const correctness

* also connected to #2029: make sure bond direction also ends up in the output

* initial version of an SVG->ROMol parser
this is in the wrong place, but I wanted to make sure it actually works

* move svg parser to a more reasonable location
there is still some work to be done here

* add conformer parsing
2018-09-17 06:49:43 +02:00
Greg Landrum
77078eac66 Add an auto-populated file with cmake config options (#1874)
* this is a rough first pass, needs to be finished and is a strong argument for changing the names of some of the #defines that are currently used

* rationalize the rest of the #defines
add something to the release notes about this
2018-06-09 05:41:28 +02:00
Paolo Tosco
c08ea49bda - enable building DLLs on Windows (#1861)
* - enable building DLLs on Windows

* - export.h and test.h are now auto-generated by CMake
2018-05-16 08:42:41 +02:00
Matt Swain
a6354d1501 Make svg xmlns prefix use more consistent (#1866)
Set svg as the default xmlns, so no prefix is needed for every svg tag. Also remove all code in python wrappers that stripped these prefixes.
2018-05-14 17:07:55 +02:00
Greg Landrum
c9e3d9a040 Fixes #1829 (#1830) 2018-04-20 04:02:37 +02:00
Greg Landrum
656a62ca9e add an additional test to make sure the generated PNG is not empty 2018-04-19 06:26:15 +02:00
Greg Landrum
3637cd4d75 Fixes Issue 1614 (#1781)
* This makes assignStereochemistry cleanIt=True not remove CIS/TRANS
bond stereo chemistry that was manually added as described in issue #1614.

Incorrect CIS/TRANS stereochemistry will still be removed by
'cleanIt=true' if symmetry is detected. However, this symmetry
detection doesn't work in more complex pseudo-stereo chemistry cases:
bond stereo that depends on other bond stereo to break symmetry; and
bond stereo that depends on other atom stereo centers to break
symmetry. Test cases for these cases have been added ifdef'd in based
on USE_NEW_STEREOCHEMISTRY.

However, getting USE_NEW_STEREOCHEMISTRY to work in a copacetic way is
not trivial, I tried a little bit here to no avail. I'm leaving the
test cases checked in as they should be useful when we decide to make
the plunge into using Canon::chiralRankMolAtoms for symmetry detection
instead of the CIP ranks.

So this fixes at least the glaring issue of STEREOCIS and STEREOTRANS
being incorrectly removed by 'cleanIt=true' when it is indeed valid
stereo. The checks made for symmetry are rudimentary, but don't feel
complete.

* add another test; make what's being tested explicit

* test smiles generation and function when Hs have been added

* add a test that fails

* I think that it's ok to remove this

* backup

* At this point all tests pass.
Bond wedging is now handled even if sanitization is turned off when mol files are read

* adjust to code changes

* fix a couple problems caused by rebase

* update docs
2018-04-01 17:48:36 +02:00
Greg Landrum
108d84ab1e Switch from boost::thread to std::thread (#1745)
* boost::thread mostly gone... still need to get rid of once
everything compiles

* replace boost::call_once

* remove link-time dependency on boost::thread

* first pass at using async

* switch to using async everywhere
2018-02-22 03:43:07 +01:00
Greg Landrum
42eecc664d Integrate Coordgen (#1708)
* first pass, does not yet actually work

* pass2, same problems

* pass2, same problems

* another test

* new tests; bugfix

* move the code out to a header

* add a double bond example

* enable auto-downloads of the code

* move the function to its own namespace

* first pass at a basic python wrapper

* change coordgen commit used

* try supporting bond stereo; does not currently work

* cis/trans seems to now work.

* first pass at templates; needs testing

* use the fixed flag too

* need mol align

* expand test

* initial pass at python wrapper for template

* simplify tests

* add an option to directly use a substructure match for alignment

* scaling

* add #define

* Define a cache setting for RDK_COORDGEN_LIBS to allow these to be used in other packages

* return the conformer id from addCoords

* Make CoordGen the default when it’s available.
This is a backup commit… the tests don’t even come close to passing.

* add some debugging options for a bit

* add alignment step to testing when using non-fixed coords

* Add global to allow use of CoordGen to be disabled
get the basic depictor tests working

* make coordgen the default when it is available

* make sure things continue to work when coordgen is disabled

* get windows builds working

* mods to get this building on windows.
something is screwy with the fileParsersTest1

* no need to generate coords for the 1K C string

* fix java wrappers

* works on linux

* update the (stupid) way dependencies were handled on windows.
this allows a lot of cleanup of cmake files (still more to do)
the linux build is unlikely to work due to the way _statics aren't handled

* docs

* extend forceRDKit applicability

* switch coordgen version

* try using templates

* try to get the template dir finding reasonably robust w.r.t. conda install

* continuing to iterate on the way the template file is installed

* fix a problem caused by the merge

* remove test that should never have been checked in

* update expected results for cartridge tests

* switch back to using the RDKit as the default coordinate generator
2018-02-15 05:36:03 +01:00
Greg Landrum
1efa8e696e another clang-format run 2017-10-12 06:42:15 +02:00
Greg Landrum
f94e277856 another pass of clang modernize 2017-10-12 06:35:51 +02:00
Greg Landrum
87786c08b5 Merge branch 'master' into modern_cxx
# Conflicts:
#	.travis.yml
#	Code/GraphMol/FileParsers/MolFileParser.cpp
#	Code/GraphMol/FileParsers/MolFileStereochem.cpp
#	Code/GraphMol/ForceFieldHelpers/UFF/testUFFHelpers.cpp
#	Code/GraphMol/MolAlign/testMolAlign.cpp
#	Code/GraphMol/MolDraw2D/MolDraw2D.cpp
#	Code/GraphMol/MolDraw2D/Wrap/rdMolDraw2D.cpp
#	Code/GraphMol/QueryOps.cpp
#	Code/GraphMol/ROMol.cpp
#	Code/GraphMol/SmilesParse/test.cpp
#	Code/GraphMol/Trajectory/Trajectory.cpp
#	Code/GraphMol/Wrap/Atom.cpp
#	Code/GraphMol/Wrap/Bond.cpp
#	Code/GraphMol/new_canon.cpp
#	Code/RDGeneral/testDict.cpp
#	Code/SimDivPickers/Wrap/MaxMinPicker.cpp
2017-10-05 05:58:38 +02:00
Greg Landrum
56b472ef97 Support continuous highlighting in drawMolecules(). (#1579)
Add a fillHighlights option to DrawOptions
2017-09-22 07:25:17 +02:00
Greg Landrum
9af90524a4 Provide support for color palettes in MolDraw2D (#1546)
* first steps towards flexible colour palettes

* add B&W palette and a test for it

* add python support;
this is, once again, not the best API due to the inability to auto-translate boost::tuples at this point

* more palette control from python

* rename some of the swig-wrapped types to make them more consistent

* handle palettes that do not have a default value
2017-09-08 10:52:01 +02:00
Greg Landrum
16023c83ae Support drawing reactions from C++ (#1444)
* expose and test GetDrawCoords()

* very basics are working; still loads of work to do

* very basics are working; still loads of work to do

* symbols and arrows kind of work

* switch to Nadine's approach for drawing
needs more work (like arrows and pluses) but already is not too bad

* better, but agents still to close to arrow and arrow is too short

* add a test for rxns without agents

* fix picking of cid;
drawing reactions without reactants or without products should in theory now work, but additional work is needed to get the arrows to show up

* make reactions without reactants or without products draw properly

* tweak vshift a bit; would be good to have a better solution to this

* do not draw H2O as OH2

* add option to use highlighting to show atom maps

* highlight bonds too

* cleanup

* add drawReaction to the python wrapper

* docs

* remove some printing

* fix (for real) the drawing of degree zero atoms

* ensure ring finding gets done; add some more tests

* add some SMARTS-based tests; these do not work

* improve reactant highlighting in rxn drawing

- define default colors for highlighting of reactants, atom or bonds
in the drawing options
- make highlighting colors customizable through the API

* rename to test4 in prep for merge

* temporarily disable test4 since it does not work anyway

* fix some kekulization problems

* fix YA unicode problem

* remove a stupid typo
2017-07-07 05:12:33 +02:00
Greg Landrum
5741d37c39 Support drawing reactions from C++ (#1444)
* expose and test GetDrawCoords()

* very basics are working; still loads of work to do

* very basics are working; still loads of work to do

* symbols and arrows kind of work

* switch to Nadine's approach for drawing
needs more work (like arrows and pluses) but already is not too bad

* better, but agents still to close to arrow and arrow is too short

* add a test for rxns without agents

* fix picking of cid;
drawing reactions without reactants or without products should in theory now work, but additional work is needed to get the arrows to show up

* make reactions without reactants or without products draw properly

* tweak vshift a bit; would be good to have a better solution to this

* do not draw H2O as OH2

* add option to use highlighting to show atom maps

* highlight bonds too

* cleanup

* add drawReaction to the python wrapper

* docs

* remove some printing

* fix (for real) the drawing of degree zero atoms

* ensure ring finding gets done; add some more tests

* add some SMARTS-based tests; these do not work

* improve reactant highlighting in rxn drawing

- define default colors for highlighting of reactants, atom or bonds
in the drawing options
- make highlighting colors customizable through the API

* rename to test4 in prep for merge

* temporarily disable test4 since it does not work anyway

* fix some kekulization problems

* fix YA unicode problem

* remove a stupid typo
2017-07-05 14:25:31 -04:00
Greg Landrum
7c0bb0b743 clang-tidy output 2017-04-22 17:09:24 +02:00
Greg Landrum
2a916b1a74 the functionality was already there, this just shows how to use it (#1355) 2017-03-12 09:57:43 -04:00
Greg Landrum
09d7314aed Feat/github1325 (#1347)
* Fixes #1325

* add a smart PRECONDITION
2017-03-08 23:17:29 -05:00
Greg Landrum
527b6cd922 Fixes #1322 (#1342) 2017-03-04 12:33:34 -05:00
Greg Landrum
f196567182 Fixes #1271 (#1272)
* Fixes #1271

* add a comment or two

* fix single-atom molecules too

* add a test for grid drawing too

* simplification of the special cases; no need to make things so complex
2017-01-22 13:49:09 -05:00
Greg Landrum
fc5b52afcd Fixes #1035 (#1135) 2016-11-01 11:41:12 +01:00
Greg Landrum
dc7c9b6f31 Provide SVG output from the cartridge (#1109)
* a bit of header cleanup

* Fixes #1106

* First pass, basics.
Still need tests and handling of parameters.

* initial pass at including JSON parsing of options (not complete)

* handle errors while parsing json instead of just crashing the server

* updated (and working) JSON configuration

* first drawing tests

* document the new function

* it helps to save before committing
2016-10-21 17:05:59 -04:00
Greg Landrum
f0de22fd73 Fixes #1090 (#1105) 2016-10-17 13:05:21 -04:00
Greg Landrum
65f3cab86a Fixes #1056 (#1101) 2016-10-14 11:36:46 -04:00
Greg Landrum
98e3e941da Merge branch 'feat/draw_multiple_mols' of https://github.com/greglandrum/rdkit into greglandrum-feat/draw_multiple_mols 2016-09-14 16:42:48 -07:00
Greg Landrum
23fce87073 Draw crossed bonds (#1052)
* remove dead code

* Draw crossed bonds
2016-09-14 11:01:50 -04:00
Greg Landrum
eb2b81c1e2 handle null molecules 2016-08-31 20:13:45 +02:00
Greg Landrum
53247114a3 more grid 2016-08-31 07:20:21 +02:00
Greg Landrum
29d9251f93 first pass at drawing a grid 2016-08-31 05:01:50 +02:00
Greg Landrum
435a07a30e better control over scaling 2016-08-30 17:56:34 +02:00