Skip to content

Instantly share code, notes, and snippets.

View rwst's full-sized avatar
😎
I may be slow to respond.

Ralf Stephan rwst

😎
I may be slow to respond.
View GitHub Profile
@rwst
rwst / general_binet
Last active January 3, 2016 21:59
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.
(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 / patchbot-13282-log.txt
Created May 4, 2014 14:56
infinite loop when testing sage-patchbot with ticket 13282
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 / piranha-degree.cpp
Created November 16, 2015 08:17
benchmark program, compile with g++ -O0 -std=c++11 piranha-degree.cpp -lgmp -lmpfr -lpthread
#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 / add-omim.py
Created August 21, 2019 06:56
creating QuickStatement batches for missing claims on Wikidata objects about genes and their corresponding OMIM entries
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 / missing-gene-disease.py
Created August 24, 2019 17:08
creates QS statements associating gene items with disease items, from WD and UniProt data
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 / enzfam-subclass.py
Created September 28, 2019 13:12
creates QS subclass-of statements for Wikidata enzyme families, to create hierarchy
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 / tpfam.py
Created October 4, 2019 05:53
Maintaining transport protein WD item links to resp. families via QS statements
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 / move-sitelinks.py
Last active November 7, 2019 09:42
produces QS commands to move all sitelinks from a list of WD items to corresponding items
@rwst
rwst / gist:258cb717ed548210913803ea7577fb31
Created February 17, 2021 17:02
wdtaxonomy -iS Q3516872 (molecular biology technique)
molecular biology technique (Q3516872) ↑
|-polymerase chain reaction (Q176996)
|-cell-free protein synthesis (Q189030)
|-Rapid amplification of cDNA ends (Q381434)
|-SuperSAGE (Q826829)
|-restriction fragment length polymorphism (Q857299)
|-Tandem affinity purification (Q893051)
|-DNA-DNA hybridization (Q900923)
|-Chromatin immunoprecipitation (Q901026)
|-Immunophenotyping (Q902926)
@rwst
rwst / gist:8b78842260faff8402a5a10fc33908a9
Created February 17, 2021 17:05
wdtaxonomy -iS Q26879200 (biochemistry method)
biochemistry method (Q26879200) ↑↑
|-Bradford protein assay (Q247562)
|-Serial analysis of gene expression (Q286721)
|-Förster resonance energy transfer (Q367473)
|-Bimolecular fluorescence complementation (Q863465)
|-Electrophoretic mobility shift assay (Q903596)
|-density gradient electrophoresis (Q1209472)
|-Protein Misfolding Cyclic Amplification (Q2044394)
|-perfusion culture (Q2070705)
|-submersed fermentation (Q2361902)