Skip to content

Instantly share code, notes, and snippets.

@sneumann
sneumann / OLS2DefinedTerm.sh
Last active December 12, 2023 10:31
Search and replace with DefinedTerm
#!/bin/bash
chmo2definedterm () {
CURIE=`echo "$1" | sed -e 's/.*\(CHMO:[0-9]*\).*/\1/'`
wget -q -O- "https://service.tib.eu/ts4tib/api/ontologies/chmo/terms?obo_id=$CURIE" |\
jq '{ measurementTechnique: { "@type": "DefinedTerm", "@id": ._embedded.terms[0].iri, "termCode": ._embedded.terms[0].obo_id, "name": ._embedded.terms[0].label, "url": ("https://terminology.nfdi4chem.de/ts/ontologies/"+._embedded.terms[0].ontology_name+"/terms?iri="+._embedded.terms[0].iri), "inDefinedTermSet": { "@type": "DefinedTermSet", "@id": ._embedded.terms[0].ontology_iri, "name": ._embedded.terms[0].ontology_name, } } }' |\
grep -v '^[{}]$'
echo ","
}
@sneumann
sneumann / getChemotionLsonLD.sh
Last active December 12, 2023 10:30
Get Chemotion JSON-LD dump
#!/bin/bash
BASEURL=https://www.chemotion-repository.net/api/v1/public/metadata/publications
LIMIT=500
MAXPARALLEL=25
MAXRECORDS=99999999
#MAXRECORDS=2000
# There are currently ~6000 Samples, ~25000 Containers and ~5000 Reactions
@sneumann
sneumann / gist:6cd525f83bc7c8d335169fa8dab6d552
Created October 30, 2023 10:31
Chemotion2JsonLD-DataDump
#!/bin/bash
BASEURL=https://www.chemotion-repository.net/api/v1/public/metadata/publications
LIMIT=500
MAXPARALLEL=25
MAXRECORDS=99999999
MAXRECORDS=2000
# There are currently ~6000 Samples, ~25000 Containers and ~5000 Reactions
@sneumann
sneumann / reaction.json
Created August 29, 2023 10:57
Bioschemas chemical reaction mockup
{
"@context": "https://schema.org",
"@type": "Study",
"@id": "https://dx.doi.org/10.14272/reaction/SA-FUHFF-UHFFFADPSC-UWHQATUHQV-UHFFFADPSC-NUHFF-NUHFF-NUHFF-ZZZ",
"identifier": "CCR-33542",
"dct:conformsTo": {
"@type": "CreativeWork",
"@id": "https://bioschemas.org/types/Study/0.3-DRAFT"
},
"url": "https://www.chemotion-repository.net/inchikey/reaction/SA-FUHFF-UHFFFADPSC-UWHQATUHQV-UHFFFADPSC-NUHFF-NUHFF-NUHFF-ZZZ",
@sneumann
sneumann / MassBank2OAI
Created December 2, 2022 13:04
Import Metadata from MassBank DataDump to FIZ-OAI provider
#!/usr/bin/env bash
export BACKEND=http://localhost:8081/oai-backend
jq -c '.[]' DataDump-IPB.jsonld | \
while read i; do
IDENTIFIER=`echo "$i" | jq '.identifier'`
(
@sneumann
sneumann / Chemotion2OAI.sh
Created November 16, 2022 14:45
Import Metadata from Chemotion to FIZ-OAI provider
## 1) Get paginated list of Molecules from Chemotion
## 2) extract DOI and internal chemotion ID for each molecule with `jq`
## 3) Query each molecule and convert with `jq` to (bio)schemas
## 4) Embedd the JSON in a CDATA in a minimalistic XML
## 5) Pipe the XML to the FIZ-OAI backend running at $BACKEND, e.g. localhost
export BACKEND=http://localhost:8081/oai-backend
for I in 1 2 3 4 5 6 7 8 9 10; do
wget -O- "https://www.chemotion-repository.net/api/v1/public/molecules.json?page=$I&per_page=100" |\
@sneumann
sneumann / convertMzTab2MAF.R
Created October 18, 2022 10:53
Convert an mzTab-M to MetaboLights MAF file using rmzTabM and metabolighteR
library(rmzTabM) ## https://lifs-tools.github.io/rmzTab-m/
library(metabolighteR) ## https://aberhrml.github.io/metabolighteR/
convertMzTab2MAF <- function(mzTabfile, MAFfile) {
mzTabTable <- readMzTab(mzTabfile)
## To turn these tables into objects, use the R6 class constructor method `new()`:
mzTabObject <- MzTab$new()$fromDataFrame(mzTabTable)
metadata <- mzTabObject$metadata
#!/bin/bash
wget -O- https://www.chemotion-repository.net/api/v1/public/molecule.json?id=6338 |\
jq "$(cat <<EOF
{ "@context": "https://schema.org/",
"@type": "MolecularEntity",
"dct:conformsTo": { "http://purl.org/dc/terms/conformsTo": {
"@id": "https://bioschemas.org/profiles/MolecularEntity/0.5-RELEASE",
"@type": "CreativeWork" }
},
"@id": .molecule.tag.taggable_data.chemotion.doi,
@sneumann
sneumann / metaRboomics molecular formulas
Last active September 19, 2022 14:34
Install and benchmark a number of
install.packages("microbenchmark")
install.packages("plyr")
install.packages("rcdk")
install.packages("OrgMassSpecR")
install.packages("CHNOSZ")
BiocManager::install("Rdisop")
BiocManager::install("MetaboCoreUtils")
@sneumann
sneumann / pykubejob.py
Created May 25, 2021 21:49
minimum example to submit Job with pykube
import pykube
from os import environ as os_environ
# pykube imports:
try:
from pykube.config import KubeConfig
from pykube.http import HTTPClient
from pykube.objects import (
Job,
Pod