Skip to content

Instantly share code, notes, and snippets.

View egonw's full-sized avatar
💭
I want peace and climate action

Egon Willighagen egonw

💭
I want peace and climate action
View GitHub Profile
@egonw
egonw / extractBioschemas.groovy
Created February 12, 2025 19:11
Extract chemical from a Beilstein Journal of Organic Chemistry article
// Copyright (c) 2022-2024 Egon Willighagen <egon.willighagen@gmail.com>
//
// How to cite: https://joss.theoj.org/papers/10.21105/joss.02558
//
// GPL v3
@Grab(group='io.github.egonw.bacting', module='managers-rdf', version='1.0.4')
@Grab(group='io.github.egonw.bacting', module='managers-ui', version='1.0.4')
@Grab(group='io.github.egonw.bacting', module='net.bioclipse.managers.jsoup', version='1.0.4')
@Grab(group='org.nanopub', module='nanopub', version='1.66')
import org.nanopub.Nanopub;
import org.nanopub.NanopubCreator;
import org.nanopub.NanopubUtils;
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
import org.eclipse.rdf4j.model.vocabulary.FOAF;
import org.eclipse.rdf4j.model.vocabulary.RDF;
import org.eclipse.rdf4j.model.vocabulary.RDFS;
import org.eclipse.rdf4j.model.vocabulary.SKOS;
@egonw
egonw / makeNanoPub.groovy
Created December 29, 2024 11:03
Making NanoPub Template NanoPubs
@Grab(group='org.nanopub', module='nanopub', version='1.66')
import org.nanopub.Nanopub;
import org.nanopub.NanopubCreator;
import org.nanopub.NanopubUtils;
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
import org.eclipse.rdf4j.model.vocabulary.FOAF;
import org.eclipse.rdf4j.model.vocabulary.RDF;
import org.eclipse.rdf4j.model.vocabulary.RDFS;
import org.eclipse.rdf4j.model.vocabulary.SKOS;
@egonw
egonw / WP2223.diff
Last active September 2, 2024 05:09
diff --git a/WP2223.gpml b/WP2223.gpml.new
index 8d01090..d2897db 100644
--- a/WP2223.gpml
+++ b/WP2223.gpml.new
@@ -1,183 +1,187 @@
<?xml version="1.0" encoding="UTF-8"?>
<Pathway xmlns="http://pathvisio.org/GPML/2013a" Name="LIN-12/Notch Lateral Signaling" Data-Source="WikiPathways" Version="WP2223_r135294" Author="[Kyook, MaintBot, RaatsS, Khanspers]" Last-Modified="20240815205238" Organism="Caenorhabditis elegans">
<Comment Source="WikiPathways-description">Lateral signaling targets and negative regulation of LET-23 signaling. The LIN-12/Notch pathway plays two related roles in vulval development; to prevent adjacent induced vulval precursor cells (VPCs) from both becoming 1° VPCs and to induce VPCs adjacent to the 1°VPC to take a 2° cell fate.
-See figure 14 in http://www.wormbook.org/chapters/www_vulvaldev/vulvaldev.pdf.
-</Comment>
@egonw
egonw / willighagen_cito.rq
Created August 11, 2024 15:15
Wikidata SPARQL query to how the citation network between my articles
# tool: scholia
#defaultView:Graph
PREFIX target: <http://www.wikidata.org/entity/Q124174475>
SELECT
?citing_work ?citing_workLabel ?rgb
?cited_work ?cited_workLabel
WITH {
SELECT (COUNT(*) AS ?count) ?citing_work WHERE {
@Grab(group='io.github.egonw.bacting', module='managers-ui', version='1.0.0')
@Grab(group='io.github.egonw.bacting', module='net.bioclipse.managers.wikidata', version='1.0.0')
import java.util.*;
import java.text.SimpleDateFormat;
workspaceRoot = "."
ui = new net.bioclipse.managers.UIManager(workspaceRoot);
wikidata = new net.bioclipse.managers.WikidataManager(workspaceRoot);
@egonw
egonw / WriteSDF.groovy
Created May 1, 2024 19:06
Groovy script using SPARQL to retrieve polymers with CXSMILES from Wikidata (CCZero), generates coordinates, and then writes an SD file.
// CC-BY 4.0 International. (c) 2024 Egon Willighagen
@Grab(group='io.github.egonw.bacting', module='managers-ui', version='0.5.2')
@Grab(group='io.github.egonw.bacting', module='managers-rdf', version='0.5.2')
@Grab(group='org.openscience.cdk', module='cdk-smiles', version='2.9')
@Grab(group='org.openscience.cdk', module='cdk-silent', version='2.9')
@Grab(group='org.openscience.cdk', module='cdk-ctab', version='2.9')
@Grab(group='org.openscience.cdk', module='cdk-sdg', version='2.9')
import org.openscience.cdk.smiles.SmilesParser;
@egonw
egonw / citoPubs.rq
Created April 8, 2024 05:13
CiTO nanopublications
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix np: <http://www.nanopub.org/nschema#>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dct: <http://purl.org/dc/terms/>
select ?np ?label ?subj ?citationrel ?obj ?date where {
graph npa:graph {
?np npa:hasValidSignatureForPublicKey ?pubkey .
@egonw
egonw / inosc.rq
Created March 21, 2024 07:25
INOSC - International Network of Open Science & Scholarship Communities
#defaultView:Map
SELECT ?osc ?oscLabel ?location WHERE {
?osc wdt:P1344 wd:Q104785223 .
{
?osc wdt:P625 ?location .
} UNION {
?osc wdt:P159 / wdt:P625 ?location .
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
@egonw
egonw / foo.groovy
Created March 17, 2024 13:47
Script to convert https://nanocommons.github.io/specifications/nanomile/ content (somewhat cleaned up) to ERM Identifier DB content
new File("/tmp/foo.tsv").eachLine { line ->
fields = line.split('\t')
nanomileid = fields[0]
ermid = fields[1]
ermidShort = ermid.split(':')[1]
content = """---
title: "Material: ${ermidShort}"
type: ChemicalSubstance
id: ${ermidShort}
tag: ${ermid}