Skip to content

Conversation

johnmay
Copy link
Member

@johnmay johnmay commented Nov 2, 2022

Here we add in some extra arrow types which are controlled by the "direction" attribution on the reaction. I was considering a separate enum (ArrowDisplay?) but it fits more or less into the existing direction attribute.

To paraphrase Oprah, "You get an arrow, you get an arrow, you get an arrow!"

drawing

Note the RETERO_SYNTHETIC arrow swaps the sense of reactant/product. I think that makes sense but happy to discuss.

SVG

NO_GO
nogo
RETRO_SYNTHETIC
retro
BIDIRECTIONAL (restyled)
bidirectional
RESONANCE
resonance

PNG

NO_GO
nogo
RETRO_SYNTHETIC
retro
BIDIRECTIONAL (restyled)
bidirectional
RESONANCE
resonance

Demo Code

SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance());
IReaction reaction = smipar.parseReactionSmiles("[CH3:9][CH:8]([CH3:10])[c:7]1[cH:11][cH:12][cH:13][cH:14][cH:15]1.[CH2:3]([CH2:4][C:5](=[O:6])Cl)[CH2:2][Cl:1]>[Al+3].[Cl-].[Cl-].[Cl-].C(Cl)Cl>[CH3:9][CH:8]([CH3:10])[c:7]1[cH:11][cH:12][c:13]([cH:14][cH:15]1)[C:5](=[O:6])[CH2:4][CH2:3][CH2:2][Cl:1] |f:2.3.4.5| Friedel-Crafts acylation [3.10.1]");

Abbreviations abbreviations = new Abbreviations();
abbreviations.add("[Al+3].[Cl-].[Cl-].[Cl-] AlCl3");
abbreviations.add("ClCCl DCM");
abbreviations.setContractToSingleLabel(true);
for (IAtomContainer mol : ReactionManipulator.getAllAtomContainers(reaction))
    abbreviations.apply(mol);

reaction.setDirection(IReaction.Direction.NO_GO);
new DepictionGenerator().depict(reaction)
                        .writeTo("/tmp/nogo.svg");

reaction = smipar.parseReactionSmiles("[CH3:9][CH:8]([CH3:10])[c:7]1[cH:11][cH:12][cH:13][cH:14][cH:15]1.[CH2:3]([CH2:4][C:5](=[O:6])Cl)[CH2:2][Cl:1]>>[CH3:9][CH:8]([CH3:10])[c:7]1[cH:11][cH:12][c:13]([cH:14][cH:15]1)[C:5](=[O:6])[CH2:4][CH2:3][CH2:2][Cl:1] |f:2.3.4.5| Friedel-Crafts acylation [3.10.1]");
reaction.setDirection(IReaction.Direction.RETRO_SYNTHETIC);
new DepictionGenerator().depict(reaction)
                        .writeTo("/tmp/retro.svg");

reaction.setDirection(IReaction.Direction.BIDIRECTIONAL);
new DepictionGenerator().depict(reaction)
                        .writeTo("/tmp/bidirectional.svg");

reaction = smipar.parseReactionSmiles("c1c(Cl)cccc1[N-][N+]#N>>c1c(Cl)cccc1N=[N+]=[N-]");
reaction.setDirection(IReaction.Direction.RESONANCE);
new DepictionGenerator().depict(reaction)
                        .writeTo("/tmp/resonance.svg");

I was considering a seperate enum (ArrowDisplay) but it fits more or less into the existing direction attribute.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 2, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
2.6% 2.6% Duplication

@egonw egonw merged commit 6afd1a0 into main Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants