Skip to content

Instantly share code, notes, and snippets.

😎
I may be slow to respond.

Ralf Stephan rwst

😎
I may be slow to respond.
Block or report user

Report or block rwst

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rwst
rwst / move-sitelinks.py
Last active Nov 7, 2019
produces QS commands to move all sitelinks from a list of WD items to corresponding items
View move-sitelinks.py
@rwst
rwst / tpfam.py
Created Oct 4, 2019
Maintaining transport protein WD item links to resp. families via QS statements
View tpfam.py
import csv
from anytree import Node, find, findall, PreOrderIter, RenderTree, Resolver, AsciiStyle, ChildResolverError
from sys import *
class TCNode(Node):
q = ''
lab = ''
print_missing_triples = False
print_qs = True
@rwst
rwst / enzfam-subclass.py
Created Sep 28, 2019
creates QS subclass-of statements for Wikidata enzyme families, to create hierarchy
View enzfam-subclass.py
import csv
from anytree import Node, find, findall, PreOrderIter, RenderTree, Resolver, AsciiStyle, ChildResolverError
from sys import *
class ECNode(Node):
q = ''
lab = ''
tree = ECNode('Root')
@rwst
rwst / missing-gene-disease.py
Created Aug 24, 2019
creates QS statements associating gene items with disease items, from WD and UniProt data
View missing-gene-disease.py
from sys import *
import csv
reader = csv.DictReader(open('gene-diseaseassoc.tab', 'r'), delimiter='\t')
genes = {}
for item in reader:
iturl = item.get('item')
it = iturl[iturl.rfind('/')+1:]
disurl = item.get('dis')
dis = disurl[disurl.rfind('/')+1:]
@rwst
rwst / add-omim.py
Created Aug 21, 2019
creating QuickStatement batches for missing claims on Wikidata objects about genes and their corresponding OMIM entries
View add-omim.py
from sys import *
import csv
reader = csv.DictReader(open('gene-entrezids.tab', 'r'), delimiter='\t')
genes = {}
for item in reader:
gid = item.get('geneid')
iturl = item.get('item')
iturl = iturl[iturl.rfind('/')+1:]
gitem = genes.get(gid)
@rwst
rwst / piranha-degree.cpp
Created Nov 16, 2015
benchmark program, compile with g++ -O0 -std=c++11 piranha-degree.cpp -lgmp -lmpfr -lpthread
View piranha-degree.cpp
#define BENCHPRESS_CONFIG_MAIN
#include <cstddef>
#include <benchpress/benchpress.hpp>
//#include "series-benchmark.h"
#include <string>
#include <iostream>
#include <tuple>
#include <type_traits>
@rwst
rwst / patchbot-13282-log.txt
Created May 4, 2014
infinite loop when testing sage-patchbot with ticket 13282
View patchbot-13282-log.txt
Forcing sage-location, probably because a new package was installed.
Updating various hardcoded paths...
(Please wait at most a few minutes.)
DO NOT INTERRUPT THIS.
Done updating paths.
Found package ccache in /scratch/sage/upstream/ccache-3.1.9.spkg
Package ccache-3.1.9 is already installed.
Use 'sage -f /scratch/sage/upstream/ccache-3.1.9.spkg' to force a reinstallation.
--2014-05-04 08:27:25-- http://coates.ma.ic.ac.uk/grdb_polytopes-0.1.spkg
Resolving coates.ma.ic.ac.uk (coates.ma.ic.ac.uk)... 155.198.35.88
@rwst
rwst / general_binet
Last active Jan 3, 2016
The general Binet form of the nth element of a binary recurrence over the integers is, given a(n) = c*a(n-1) + d*a(n-2). The Pari code is blinding fast, dependent on precision. It can maybe jump in when a floating point result is sufficient. The Sage function gives an expression in square roots.
View general_binet
(Pari/GP)
a(c,d,a0,a1,n)=my(r1,r2,s);s=sqrt(c^2+4*d);r1=2*d/(-c+s);r2=2*d/(-c-s);return(((a1-c*a0+a0*r1)*r1^n-(a1-c*a0+a0*r2)*r2^n)/s)
(Sage)
def a(c,d,a0,a1,n):
r1=2*d/(-c+sqrt(c^2+4*d))
r2=2*d/(-c-sqrt(c^2+4*d))
@rwst
rwst / gist:3315686
Created Aug 10, 2012
fixes stacktrace with JCP issue #60
View gist:3315686
diff --git a/src/main/org/openscience/jchempaint/controller/ReactionHub.java b/src/main/org/openscience/jchempaint/controller/ReactionHub.java
index beb8ebe..d973f2e 100644
--- a/src/main/org/openscience/jchempaint/controller/ReactionHub.java
+++ b/src/main/org/openscience/jchempaint/controller/ReactionHub.java
@@ -72,7 +72,7 @@ public class ReactionHub {
chemModel.setReactionSet(reactionSet);
chemModel.getMoleculeSet().removeAtomContainer(oldcontainer);
if(chemModel.getMoleculeSet().getAtomContainerCount()==0)
- chemModel.getMoleculeSet().addAtomContainer(chemModel.getBuilder().newInstance(IAtomContainer.class));
+ chemModel.getMoleculeSet().addAtomContainer(chemModel.getBuilder().newInstance(IMolecule.class));
@rwst
rwst / applet-3.0.1.patch.txt
Created Jul 3, 2012
patch by Wayne Volkmuth for cpy/paste via MDLCT, issue #85
View applet-3.0.1.patch.txt
diff -C3 -r org.openscience.cdk.jchempaint30/src/main/org/openscience/jchempaint/action/CopyPasteAction.java org.openscience.cdk.jchempaint.patched/src/main/org/openscience/jchempaint/action/CopyPasteAction.java
*** org.openscience.cdk.jchempaint30/src/main/org/openscience/jchempaint/action/CopyPasteAction.java 2009-12-08 03:48:25.000000000 -0800
--- org.openscience.cdk.jchempaint.patched/src/main/org/openscience/jchempaint/action/CopyPasteAction.java 2010-09-13 11:07:35.000000000 -0700
***************
*** 28,41 ****
*/
package org.openscience.jchempaint.action;
- import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
You can’t perform that action at this time.