From 36d12ed11837eb095bbc93ca8bcb081489d3cd62 Mon Sep 17 00:00:00 2001 From: Tyler Peryea Date: Mon, 16 Oct 2023 13:58:41 -0400 Subject: [PATCH 1/5] update transaction not to require new --- .../module/substance/tasks/StructureRecalcTaskInitializer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/tasks/StructureRecalcTaskInitializer.java b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/tasks/StructureRecalcTaskInitializer.java index 56230653f..8e7a150e7 100644 --- a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/tasks/StructureRecalcTaskInitializer.java +++ b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/tasks/StructureRecalcTaskInitializer.java @@ -74,7 +74,7 @@ public void run(SchedulerPlugin.JobStats stats, SchedulerPlugin.TaskListener l) try{ adminService.runAs(adminAuth, (Runnable)() -> { TransactionTemplate tx = new TransactionTemplate(platformTransactionManager); - tx.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); + //tx.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); try { tx.executeWithoutResult(status -> { structureRepository.findById(id).ifPresent(s -> { From 74e86e1373bcd84de5f7bad023e9d884198e5339 Mon Sep 17 00:00:00 2001 From: Tyler Peryea Date: Mon, 30 Oct 2023 19:36:03 -0400 Subject: [PATCH 2/5] testing fix --- .../substance/GSRSRendererConfiguration.java | 108 ++++++++++++++++++ .../substance/RendererOptionsConfig.java | 53 +++++---- .../substance/SubstanceCoreConfiguration.java | 4 +- .../controllers/SubstanceController.java | 12 ++ .../tasks/StructureRecalcTaskInitializer.java | 2 +- .../CalculateMatchablesScheduledTask.java | 1 + 6 files changed, 153 insertions(+), 27 deletions(-) create mode 100644 gsrs-module-substances-core/src/main/java/gsrs/module/substance/GSRSRendererConfiguration.java diff --git a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/GSRSRendererConfiguration.java b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/GSRSRendererConfiguration.java new file mode 100644 index 000000000..fdfbbd704 --- /dev/null +++ b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/GSRSRendererConfiguration.java @@ -0,0 +1,108 @@ +package gsrs.module.substance; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Optional; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import gov.nih.ncats.molvec.internal.util.CachedSupplier; +import gov.nih.ncats.molwitch.renderer.RendererOptions; +import gsrs.module.substance.RendererOptionsConfig.FullRenderOptions; +import lombok.AccessLevel; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +@Configuration +@ConfigurationProperties("gsrs.renderers") +@Data +@Slf4j +public class GSRSRendererConfiguration { + + private String selected; + + private LinkedHashMap list; + + @JsonIgnore + @Getter(value=AccessLevel.NONE) + @Setter(value=AccessLevel.NONE) + private CachedSupplier> _fullRenderer = CachedSupplier.of(()->{ + Map renderMap = new HashMap<>(); + + int i=0; + if(list!=null) { + for(Map m:list.values()) { + String name = m.getOrDefault("name", "").toString(); + FullRenderOptions base = FullRenderOptions.builder().build(); + if(name==null || name.length()==0) { + log.error("Render settings must have names, gsrs.renderers.list[%i] does not have a name. That render config will be skipped.", i); + continue; + } + + Map renderer = (Map) m.get("renderer"); + if(renderer==null || !(renderer instanceof Map)) { + log.error("Render settings must have 'renderer' setting, gsrs.renderers.list[%i].renderer is not expected format.", i); + continue; + } + + if(renderer.get("preset")!=null) { + String preset=renderer.get("preset").toString(); + base=renderMap.getOrDefault(preset, getFullRendererOptionsByName(preset).orElse(null)); + if(base==null) { + log.warn("Render settings preset '%s' not found as a valid preset. The default render config will be used instead.", preset); + base = FullRenderOptions.builder().build(); + } + } + Map options = (Map) renderer.get("options"); + if(options!=null) { + + } + + + + renderMap.put(name,base); + i++; + } + } + return renderMap; + }); + + + + private Optional getDefaultRendererOptionsByName(String name){ + if(name !=null) { + if ("INN".equalsIgnoreCase(name)) { + return Optional.ofNullable(FullRenderOptions.builder().options(RendererOptions.createINNLike()).build()); + } + if ("USP".equalsIgnoreCase(name)) { + return Optional.ofNullable(FullRenderOptions.builder().options(RendererOptions.createUSPLike()) + .showShadow(false) + .build()); + } + if ("DEFAULT".equalsIgnoreCase(name)) { + return Optional.ofNullable(FullRenderOptions.builder().options(RendererOptions.createDefault()).build()); + } + String lowerName = name.toLowerCase(); + if (lowerName.contains("ball") && lowerName.contains("stick")) { + return Optional.ofNullable(FullRenderOptions.builder().options(RendererOptions.createBallAndStick()).build()); + } + } + return Optional.empty(); + } + + public Optional getFullRendererOptionsByName(String name){ + //TODO: not sure the CONF part is needed anymore + if(name !=null && !("CONF".equalsIgnoreCase(name))) { + return Optional.ofNullable(getDefaultRendererOptionsByName(name) + .orElseGet(()->_fullRenderer.get().get(name))); + } + return Optional.empty(); + } + +} diff --git a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/RendererOptionsConfig.java b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/RendererOptionsConfig.java index 0288a8842..fad88a42a 100644 --- a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/RendererOptionsConfig.java +++ b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/RendererOptionsConfig.java @@ -2,7 +2,9 @@ import java.io.IOException; import java.io.InputStream; +import java.util.Map; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ClassPathResource; @@ -14,12 +16,18 @@ import gov.nih.ncats.molwitch.renderer.RendererOptions; import lombok.Builder; import lombok.Data; +import lombok.extern.slf4j.Slf4j; @Configuration @Data +@Slf4j public class RendererOptionsConfig { + @Autowired + GSRSRendererConfiguration rendererConf; + + @Value("${substance.renderer.configPath:#{null}}") private String rendererOptionsJsonFilePath; @Value("${substance.renderer.style:#{null}}") @@ -34,23 +42,36 @@ public static class FullRenderOptions{ private RendererOptions options; @Builder.Default private boolean showShadow=true; + @Builder.Default + private boolean addBorder=false; + private String colorBg; + private String colorBorder; public FullRenderOptions copy() { - return FullRenderOptions.builder().options(options.copy()).showShadow(showShadow).build(); + return toBuilder() + .build(); + } + public FullRenderOptionsBuilder toBuilder(){ + return FullRenderOptions.builder() + .options(options.copy()) + .showShadow(showShadow) + .addBorder(addBorder) + .colorBg(colorBg) + .colorBorder(colorBorder); } } private CachedSupplier rendererSupplier = CachedSupplier.of(()->{ if(legacyStyle !=null){ - FullRenderOptions opt = getRendererOptionsByName(legacyStyle); + FullRenderOptions opt = rendererConf.getFullRendererOptionsByName(legacyStyle).orElse(null); if(opt !=null){ return opt; } } if(style !=null){ - FullRenderOptions opt = getRendererOptionsByName(style); + FullRenderOptions opt = rendererConf.getFullRendererOptionsByName(style).orElse(null); if(opt !=null){ return opt; } @@ -60,9 +81,11 @@ public FullRenderOptions copy() { Resource optionsJson = new ClassPathResource(rendererOptionsJsonFilePath); if(optionsJson !=null) { try (InputStream in = optionsJson.getInputStream()) { - return FullRenderOptions.builder().options(mapper.readValue(in, RendererOptions.class)).build(); + RendererOptions options= RendererOptions.createFromMap((Map) mapper.readValue(in, Map.class)); + + return FullRenderOptions.builder().options(options).build(); } catch (IOException e) { - e.printStackTrace(); + log.error("Error deserializing renderer options"); } } } @@ -73,24 +96,4 @@ public FullRenderOptions getDefaultRendererOptions(){ return rendererSupplier.get(); } - private FullRenderOptions getRendererOptionsByName(String name){ - if(name !=null && !("CONF".equalsIgnoreCase(name))) { - if ("INN".equalsIgnoreCase(name)) { - return FullRenderOptions.builder().options(RendererOptions.createINNLike()).build(); - } - if ("USP".equalsIgnoreCase(name)) { - return FullRenderOptions.builder().options(RendererOptions.createUSPLike()) - .showShadow(false) - .build(); - } - if ("DEFAULT".equalsIgnoreCase(name)) { - return FullRenderOptions.builder().options(RendererOptions.createDefault()).build(); - } - String lowerName = name.toLowerCase(); - if (lowerName.contains("ball") && lowerName.contains("stick")) { - return FullRenderOptions.builder().options(RendererOptions.createBallAndStick()).build(); - } - } - return null; - } } diff --git a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/SubstanceCoreConfiguration.java b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/SubstanceCoreConfiguration.java index e35e98614..5fa213c7d 100644 --- a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/SubstanceCoreConfiguration.java +++ b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/SubstanceCoreConfiguration.java @@ -35,7 +35,9 @@ ConfigBasedDefinitionalElementConfiguration.class, ConfigBasedDefinitionalElementFactory.class, LegacyGinasAppController.class, NameStandardizerConfiguration.class, - ProxyConfiguration.class, StructureResolverService.class, StructureResolverServiceConfiguration.class, + ProxyConfiguration.class, + GSRSRendererConfiguration.class, + StructureResolverService.class, StructureResolverServiceConfiguration.class, SubstanceDataConfiguration.class, StructureResolverController.class, SubstanceSpreadsheetExporterConfiguration.class, diff --git a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/controllers/SubstanceController.java b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/controllers/SubstanceController.java index 2a4ab2510..0d883257e 100644 --- a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/controllers/SubstanceController.java +++ b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/controllers/SubstanceController.java @@ -1476,6 +1476,18 @@ public byte[] renderChemical (Structure struc, Chemical chem, String format, renderer.setShadowVisible(false); } + if (fullRendererOptions.isAddBorder()) { + renderer.setBorderVisible(true); + if(fullRendererOptions.getColorBorder()!=null) { + renderer.setBorderColorARGB(fullRendererOptions.getColorBorder()); + } + } + + if (fullRendererOptions.getColorBg()!=null) { + renderer.setBorderColorARGB(fullRendererOptions.getColorBg()); + } + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); if (parameters != null && parameters.hasValuesForAll()) { diff --git a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/tasks/StructureRecalcTaskInitializer.java b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/tasks/StructureRecalcTaskInitializer.java index 8e7a150e7..b5d888fc0 100644 --- a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/tasks/StructureRecalcTaskInitializer.java +++ b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/tasks/StructureRecalcTaskInitializer.java @@ -74,7 +74,7 @@ public void run(SchedulerPlugin.JobStats stats, SchedulerPlugin.TaskListener l) try{ adminService.runAs(adminAuth, (Runnable)() -> { TransactionTemplate tx = new TransactionTemplate(platformTransactionManager); - //tx.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); +// tx.setPropagationBehavior(TransactionDefinition.); try { tx.executeWithoutResult(status -> { structureRepository.findById(id).ifPresent(s -> { diff --git a/gsrs-module-substances-data-exchange/src/main/java/gsrs/dataexchange/tasks/CalculateMatchablesScheduledTask.java b/gsrs-module-substances-data-exchange/src/main/java/gsrs/dataexchange/tasks/CalculateMatchablesScheduledTask.java index 9d2e5f62d..2617dbbfb 100644 --- a/gsrs-module-substances-data-exchange/src/main/java/gsrs/dataexchange/tasks/CalculateMatchablesScheduledTask.java +++ b/gsrs-module-substances-data-exchange/src/main/java/gsrs/dataexchange/tasks/CalculateMatchablesScheduledTask.java @@ -41,6 +41,7 @@ public class CalculateMatchablesScheduledTask extends ScheduledTaskInitializer{ @Autowired private PlatformTransactionManager platformTransactionManager; + SubstanceStagingAreaEntityService substanceStagingAreaEntityService = new SubstanceStagingAreaEntityService(); @Autowired From 7f2a3e540a2ab5c856f304e740cc1c9f8b8b86a1 Mon Sep 17 00:00:00 2001 From: Tyler Peryea Date: Tue, 31 Oct 2023 15:26:01 -0400 Subject: [PATCH 3/5] updated cdk renderer --- .../controllers/LegacyGinasAppController.java | 30 +++++++++++++++++++ .../controllers/SubstanceController.java | 7 ++++- .../java/ix/core/chem/InchiStandardizer.java | 11 +++++-- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/controllers/LegacyGinasAppController.java b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/controllers/LegacyGinasAppController.java index f65b78d6e..c7ea94dc1 100644 --- a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/controllers/LegacyGinasAppController.java +++ b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/controllers/LegacyGinasAppController.java @@ -1,6 +1,8 @@ package gsrs.module.substance.controllers; import com.fasterxml.jackson.databind.JsonNode; + +import gov.nih.ncats.molwitch.Atom; import gov.nih.ncats.molwitch.Chemical; import gov.nih.ncats.molwitch.MolwitchException; import gsrs.cache.GsrsCache; @@ -296,7 +298,35 @@ private static Chemical parseAndComputeCoordsIfNeeded(String input) throws IOExc Chemical c = Chemical.parse(input); if(!c.getSource().get().getType().includesCoordinates()){ try { + // If it's an in-line format, there's an extra cleanup step + // we do to avoid an issue with parsing some query forms + // TODO: this is really a hack because molwitch-cdk considers any + // molecule with a * to be query-based, and turns lots of + // other atoms inside into query atoms. This makes some downstream + // renderer calculations not work well. The solution here is + // to actually parse * atoms as Helium atoms and give them a * alias. + // Since this is only used for rendering, it tends to be okay. + // If this were ever used for "real" calculations we'd need to do + // something more thorough. + String potentialCXSmarts = c.getSource().get().getData(); + + if(potentialCXSmarts.contains("*")) { + //this means there's a query atom + potentialCXSmarts = potentialCXSmarts.replace("[*]", "[He:17]"); + potentialCXSmarts = potentialCXSmarts.replace("*", "[He:17]"); + c=Chemical.parse(potentialCXSmarts); + c.atoms().filter(at->at.getAtomToAtomMap().isPresent() && at.getAtomToAtomMap().getAsInt()==17) + .filter(at->"He".equals(at.getSymbol())) + .forEach(at->{ + Atom aa=at; + if(!aa.getAlias().isPresent()) { + aa.setAlias("*"); + aa.setAtomToAtomMap(0); + } + }); + } c.generateCoordinates(); + } catch (MolwitchException e) { throw new IOException("error generating coordinates",e); } diff --git a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/controllers/SubstanceController.java b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/controllers/SubstanceController.java index 0d883257e..71ec302e0 100644 --- a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/controllers/SubstanceController.java +++ b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/controllers/SubstanceController.java @@ -1405,7 +1405,6 @@ public byte[] renderChemical (Structure struc, Chemical chem, String format, rendererOptions.changeSettings(newDisplay); } - //TODO: This would be nice to get back eventually, for standardization: //chem.reduceMultiples(); @@ -1532,6 +1531,7 @@ private static void preProcessChemical(Chemical c, RendererOptions renderOption boolean hasRgroups=hasRGroups(c); int rgroupColor=1; + if(hasRgroups){ if(fuse){ compColor=colorChemicalComponents(c); @@ -1616,6 +1616,8 @@ public static boolean hasRGroups(Chemical c){ // } // } boolean r=false; + + for(Atom ca:c.getAtoms()){ if(ca.getRGroupIndex().isPresent()){ r= true; @@ -1626,6 +1628,9 @@ public static boolean hasRGroups(Chemical c){ if(alias.startsWith("_R")){ ca.setRGroup(Integer.parseInt(alias.replace("_R", ""))); r= true; + }else if(alias.startsWith("R")){ + ca.setRGroup(Integer.parseInt(alias.replace("R", ""))); + r= true; } } } diff --git a/gsrs-module-substances-core/src/main/java/ix/core/chem/InchiStandardizer.java b/gsrs-module-substances-core/src/main/java/ix/core/chem/InchiStandardizer.java index 66ecdb36b..02f26b9e4 100644 --- a/gsrs-module-substances-core/src/main/java/ix/core/chem/InchiStandardizer.java +++ b/gsrs-module-substances-core/src/main/java/ix/core/chem/InchiStandardizer.java @@ -55,9 +55,14 @@ public String canonicalSmiles(Structure s, String mol) { @Override public Chemical standardize(Chemical orig, Supplier molSupplier, Consumer valueConsumer) throws IOException { -// if(true){ -// return orig; -// } + // This is currently a no-op for now. The inchi standardizer appears to have some + // bugs that are not well understood. + // In general it's not actually needed, since we tend to use the inchi hasher which will already do a pre-standardization step. + // + + if(true){ + return orig; + } if(orig.getAtomCount() > maxNumberOfAtoms || orig.hasPseudoAtoms()){ return orig; } From 3e3b558e69da6c0d0f35014f32901e8cf32167fa Mon Sep 17 00:00:00 2001 From: Tyler Peryea Date: Fri, 3 Nov 2023 15:05:33 -0400 Subject: [PATCH 4/5] allow render configs to work --- gsrs-module-substances-core/pom.xml | 2 +- .../substance/GSRSRendererConfiguration.java | 33 ++++++++-- .../substance/RendererOptionsConfig.java | 8 ++- .../src/main/resources/substances-core.conf | 63 +++++++++++++++++++ 4 files changed, 98 insertions(+), 8 deletions(-) diff --git a/gsrs-module-substances-core/pom.xml b/gsrs-module-substances-core/pom.xml index 87456547b..a82d33b28 100644 --- a/gsrs-module-substances-core/pom.xml +++ b/gsrs-module-substances-core/pom.xml @@ -46,7 +46,7 @@ gov.nih.ncats molwitch-renderer - 1.0.14-SNAPSHOT + 1.0.15-SNAPSHOT gov.nih.ncats diff --git a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/GSRSRendererConfiguration.java b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/GSRSRendererConfiguration.java index fdfbbd704..220b2ec9f 100644 --- a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/GSRSRendererConfiguration.java +++ b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/GSRSRendererConfiguration.java @@ -13,6 +13,7 @@ import gov.nih.ncats.molvec.internal.util.CachedSupplier; import gov.nih.ncats.molwitch.renderer.RendererOptions; import gsrs.module.substance.RendererOptionsConfig.FullRenderOptions; +import gsrs.module.substance.RendererOptionsConfig.FullRenderOptions.FullRenderOptionsBuilder; import lombok.AccessLevel; import lombok.Data; import lombok.Getter; @@ -39,7 +40,7 @@ public class GSRSRendererConfiguration { if(list!=null) { for(Map m:list.values()) { String name = m.getOrDefault("name", "").toString(); - FullRenderOptions base = FullRenderOptions.builder().build(); + FullRenderOptionsBuilder baseBuilder = FullRenderOptions.builder(); if(name==null || name.length()==0) { log.error("Render settings must have names, gsrs.renderers.list[%i] does not have a name. That render config will be skipped.", i); continue; @@ -53,20 +54,40 @@ public class GSRSRendererConfiguration { if(renderer.get("preset")!=null) { String preset=renderer.get("preset").toString(); - base=renderMap.getOrDefault(preset, getFullRendererOptionsByName(preset).orElse(null)); - if(base==null) { + + FullRenderOptions opt=Optional.ofNullable(renderMap.get(preset)).orElseGet(()->getDefaultRendererOptionsByName(preset).orElse(null)); + + + if(opt==null) { log.warn("Render settings preset '%s' not found as a valid preset. The default render config will be used instead.", preset); - base = FullRenderOptions.builder().build(); + opt = FullRenderOptions.builder().build(); } + baseBuilder=opt.toBuilder(); } Map options = (Map) renderer.get("options"); if(options!=null) { - + RendererOptions ropts= baseBuilder.build().getOptions(); + ropts=ropts.changeSettings(options); + baseBuilder=baseBuilder.options(ropts); } + FullRenderOptionsBuilder baseBuilderFinal = baseBuilder; + + Optional.ofNullable(renderer.get("add-shadow")).ifPresent(ss->{ + baseBuilderFinal.showShadow("true".equalsIgnoreCase(ss.toString())); + }); + Optional.ofNullable(renderer.get("add-border")).ifPresent(ss->{ + baseBuilderFinal.addBorder("true".equalsIgnoreCase(ss.toString())); + }); + Optional.ofNullable(renderer.get("color-bg")).ifPresent(ss->{ + baseBuilderFinal.colorBg(ss.toString()); + }); + Optional.ofNullable(renderer.get("color-border")).ifPresent(ss->{ + baseBuilderFinal.colorBorder(ss.toString()); + }); - renderMap.put(name,base); + renderMap.put(name,baseBuilderFinal.build()); i++; } } diff --git a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/RendererOptionsConfig.java b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/RendererOptionsConfig.java index fad88a42a..a47abc6f6 100644 --- a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/RendererOptionsConfig.java +++ b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/RendererOptionsConfig.java @@ -2,7 +2,9 @@ import java.io.IOException; import java.io.InputStream; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -10,9 +12,12 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.databind.ObjectMapper; import gov.nih.ncats.common.util.CachedSupplier; +import gov.nih.ncats.molwitch.renderer.ARGBColor; +import gov.nih.ncats.molwitch.renderer.ColorPalette; import gov.nih.ncats.molwitch.renderer.RendererOptions; import lombok.Builder; import lombok.Data; @@ -51,7 +56,8 @@ public static class FullRenderOptions{ public FullRenderOptions copy() { return toBuilder() .build(); - } + } + public FullRenderOptionsBuilder toBuilder(){ return FullRenderOptions.builder() .options(options.copy()) diff --git a/gsrs-module-substances-core/src/main/resources/substances-core.conf b/gsrs-module-substances-core/src/main/resources/substances-core.conf index 8661c5cb1..ab8f19378 100644 --- a/gsrs-module-substances-core/src/main/resources/substances-core.conf +++ b/gsrs-module-substances-core/src/main/resources/substances-core.conf @@ -753,3 +753,66 @@ gsrs.processing-strategy = { {"regex": "E4562650", "userRoles": ["SuperUpdate", "SuperDataEntry"], "newMessageType": "WARNING"} ] } + + + + + + + + + + +# This shows how special render settings can be applied +# at a pretty deep explicit level. This is ported over largely from how +# it was done in GSRS 2.8 +# +# +# 1. Supports embedded JSON options definitions for the structure renderer +# 2. Supports naming styles for use +# 3. Supports using previously named styles and making variations of them +# +gsrs.renderers.list=[ +{ + "name" : "CLEAN", + "renderer" :{ + "preset": "USP", //Note this part + "options" : { + "PROP_KEY_DRAW_GREYSCALE" : false, + "ATOM_LABEL_FONT_FRACTION" : 0.47918, + "ATOM_LABEL_BOND_GAP_FRACTION" :1.02, + "BOND_STROKE_WIDTH_FRACTION" : 0.032, + "BOND_DOUBLE_GAP_FRACTION": 0.1995, + "BOND_STEREO_WEDGE_ANGLE" : 0.13659, + "BOND_STEREO_DASH_NUMBER" :8, + "SUBSCRIPT_Y_DISPLACEMENT_FRACTION" : 0.17, + "DRAW_WEDGE_AS_POINT" : false, + "DRAW_STEREO_WEDGE_JOIN" : true, + "DRAW_STEREO_LAST_DASH_ON_NON_SYMBOLS" : false, + "colorPalette" : { + "atomColors" : { + "C" : "FFFF0000" // red carbons (ugly) + } + } + }, + "add-shadow" : true, + "add-border" : false + } +}, +{ + "name" : "CLEAN1", + "renderer" :{ + "preset": "CLEAN", //Note this part + "options" : { + "BOND_STROKE_WIDTH_FRACTION" : 0.64 + }, + "add-shadow" : false, + "add-border" : false + } +} +] + +# Here, you can specify the main renderer style to use, which can be one of the default supported cases +# or can be one of the specified cases in the list above. + +#gsrs.renderers.selected="CLEAN1" From 47da798df7ceb83fdc3ac3f74895efa1f931ac9e Mon Sep 17 00:00:00 2001 From: Mitch Miller Date: Fri, 3 Nov 2023 16:11:10 -0400 Subject: [PATCH 5/5] Renamed example rendering style --- .../src/main/resources/substances-core.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsrs-module-substances-core/src/main/resources/substances-core.conf b/gsrs-module-substances-core/src/main/resources/substances-core.conf index ab8f19378..87930f0a6 100644 --- a/gsrs-module-substances-core/src/main/resources/substances-core.conf +++ b/gsrs-module-substances-core/src/main/resources/substances-core.conf @@ -800,7 +800,7 @@ gsrs.renderers.list=[ } }, { - "name" : "CLEAN1", + "name" : "MONSTRUOUS", "renderer" :{ "preset": "CLEAN", //Note this part "options" : {