Skip to content

Instantly share code, notes, and snippets.

@fredrikw
fredrikw / CheS-Mapper-iss1.sdf
Created March 28, 2012 08:52
Test file for CheS-Mapper issue #1
benz
ChemDraw03281210432D
6 6 0 0 0 0 0 0 0 0999 V2000
-0.7145 0.4125 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-0.7145 -0.4125 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.0000 -0.8250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.7145 -0.4125 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.7145 0.4125 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.0000 0.8250 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
@fredrikw
fredrikw / mediakeys.py
Created November 15, 2012 11:07
Python script to control the mediakeys on OS X. Used to emulate the mediakey on a keyboard with no such keys. Easiest used in combination with a launcher/trigger software such as Quicksilver.
#!/usr/bin/python
# CLI program to control the mediakeys on OS X. Used to emulate the mediakey on a keyboard with no such keys.
# Easiest used in combination with a launcher/trigger software such as Quicksilver.
# Main part taken from http://stackoverflow.com/questions/11045814/emulate-media-key-press-on-mac
# Glue to make it into cli program by Fredrik Wallner http://www.wallner.nu/fredrik/
import Quartz
import sys
@fredrikw
fredrikw / ob-2-3-2-patch.diff
Last active December 18, 2015 22:59
A patch to change pybel.py from version 2.3.2 to apply commit df59c4a630cf753723d1318c40479d48b7507e1c (fixes Molecule.draw())
--- ../scripts/python/pybel.py 2012-10-03 21:08:52.000000000 +0200
+++ /usr/local/lib/pybel.py 2013-06-24 22:40:30.024896494 +0200
@@ -495,7 +495,9 @@
Tkinter and Python Imaging Library are required for image display.
"""
- if not "png2" in outformats:
+ obconversion = ob.OBConversion()
+ formatok = obconversion.SetOutFormat("_png2")
+ if not formatok:
@fredrikw
fredrikw / testmychemmatch.sql
Created May 19, 2015 09:54
Test script for MATCH_SUBSTRUCT in mychem
CREATE DATABASE mychem_match_test;
USE mychem_match_test;
CREATE TABLE `compound_mol` (
`compound_id` int(11) NOT NULL AUTO_INCREMENT,
`mol` text,
PRIMARY KEY (`compound_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO `compound_mol` (`mol`) VALUES (SMILES_TO_MOLECULE('c1ccccc1')), (SMILES_TO_MOLECULE('c1ccccc1O')), (SMILES_TO_MOLECULE('c1cnccc1'));
CREATE TABLE `compound_ser_mol` (
`compound_id` int(11) NOT NULL,
@fredrikw
fredrikw / permuteSMILESStereo.py
Created January 18, 2018 14:52
Small example function for permutating stereochemistry in SMILES strings
import re
import itertools
import pybel
def permuteSMILESStereo(smile):
stereo = re.search(r"(\[[^\]]+@+[^\]]*\]|[/\\])", smile)
if stereo:
left = smile[:stereo.start()]
rights = permuteSMILESStereo(smile[stereo.end():])
@fredrikw
fredrikw / Dockerfile
Last active May 3, 2021 08:50
Test dockerfile for pandas issue 41237 (https://github.com/pandas-dev/pandas/issues/41237)
FROM python
WORKDIR /usr/src/app
RUN pip install pandas
# Change the above line for the following to get the expected table not found error
# RUN pip install pandas sqlalchemy
RUN echo 'import pandas as pd\n\
saconnstring="sqlite:///test.db"\n\
print(pd.read_sql_table("test", saconnstring))\n\
print("Done")\n' >> testscript.py