Skip to content

Instantly share code, notes, and snippets.

@fredrikw
fredrikw / permuteSMILESStereo.py
Created Jan 18, 2018
Small example function for permutating stereochemistry in SMILES strings
View permuteSMILESStereo.py
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 / testmychemmatch.sql
Created May 19, 2015
Test script for MATCH_SUBSTRUCT in mychem
View testmychemmatch.sql
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 / ob-2-3-2-patch.diff
Last active Dec 18, 2015
A patch to change pybel.py from version 2.3.2 to apply commit df59c4a630cf753723d1318c40479d48b7507e1c (fixes Molecule.draw())
View ob-2-3-2-patch.diff
--- ../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 / mediakeys.py
Created Nov 15, 2012
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.
View mediakeys.py
#!/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 / CheS-Mapper-iss1.sdf
Created Mar 28, 2012
Test file for CheS-Mapper issue #1
View CheS-Mapper-iss1.sdf
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
You can’t perform that action at this time.