Skip to content

Instantly share code, notes, and snippets.

@goraj
goraj / dask.py
Created February 4, 2019 18:58
dask.py
import time
import numpy as np
import pandas as pd
from dask.distributed import Client
from dask_jobqueue import SGECluster
from distributed.deploy.local import LocalCluster
from math import sqrt
from joblib import Parallel, delayed
N_CORES = 2
@goraj
goraj / UGE.md
Last active February 15, 2019 22:55
Add and retrieve additional attributes (-ac) for SGE/UGE cluster jobs

Add and retrieve additional attributes (-ac) for SGE/UGE cluster jobs

Add tags to running job

qalter -ac tag1=test 18458303

qalter -ac tag2=test 18458303

qalter -ac -ac tag1=test tag2=test 18458303

<?xml version="1.0" encoding="UTF-8"?><cml xmlns="http://www.chemaxon.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.chemaxon.com/marvin/help/formats/schema/mrvSchema_6_2_0.xsd" version="ChemAxon file format v6.2, generated by v6.3.0">
<MDocument><MChemicalStruct><reaction><arrow type="DEFAULT" x1="-7.259480881745031" y1="1.3737404197296181" x2="-1.0587105901089497" y2="1.3539927419708107"></arrow><propertyList><property dictRef="NAME" title="NAME"><scalar><![CDATA[Suzuki coupling]]></scalar></property><property dictRef="EXPLAIN_REACTIVITY" title="EXPLAIN_REACTIVITY"><scalar><![CDATA[First reactant is boronic acid, boronic ester, borane, trifluoroborate salt or boronic acid anhydride. Second reactant may be halogenide or organosulfonate or methyl sulfide as these compounds behave as pseudohalogen compounds.]]></scalar></property><property dictRef="EXPLAIN_EXCLUDE" title="EXPLAIN_EXCLUDE"><scalar><![CDATA[Second reactant may not contain such functional groups which co
@goraj
goraj / arthor_alchemy.py
Last active September 2, 2019 07:27
Using NextMoveSoftware Arthor in SQLAlchemy
def get_matching_buildingblocks(
db: Session,
smarts: str,
limit: int,
) -> List[BuildingBlock]:
r = db.query(BBSelect) \
.filter(func.arthor.matches(column('atdb'), smarts)) \
.limit(limit) \
.all()
return [
Ki_identifier = [
"Adjusted Ki",
"Ki",
"ki",
"Ki app (inact)",
"Ki app",
"Ki(app)",
"Ki_app",
u"Ki’",
u"Ki”",
@goraj
goraj / hv.py
Last active October 22, 2019 15:25
holoviews hover support for RDKit molobjects
import numpy as np
import pandas as pd
from rdkit import Chem
from rdkit.Chem import Draw
from bokeh.models import HoverTool
import holoviews as hv
@goraj
goraj / holoview_escape.py
Created October 22, 2019 15:32
holoview_escape.py
import numpy as np
import pandas as pd
from bokeh.models import HoverTool
import holoviews as hv
hv.notebook_extension("bokeh")
@goraj
goraj / rdkit_iron.py
Created October 24, 2019 17:17
rdkit_iron.py
from rdkit import Chem
from rdkit.Chem.MolStandardize import rdMolStandardize
# works
smiles_charged = '[CH2-][Fe++][CH2-]'
# does not work
smiles_charged = 'CCCC(=O)c1ccc[c-]1[Fe++][c-]1cccc1C(=O)CCC'
smiles_charged = 'Cc1ccc(C(=O)C=Cc2ccc[c-]2[Fe++][c-]2cccc2)c(O)c1'
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 25 23:16:39 2019
rdkit.Chem.rdFingerprintGenerator.GetRDKitFPGenerator([(int)minPath=1[, (int)maxPath=7[, (bool)useHs=True[, (bool)branchedPaths=True[, (bool)useBondOrder=True[, (bool)countSimulation=False[, (AtomPairsParameters)countBounds=None[, (int)fpSize=2048[, (int)numBitsPerFeature=2[, (AtomPairsParameters)atomInvariantsGenerator=None]]]]]]]]]]) → FingerprintGenerator64 :
Get an RDKit fingerprint generator
ARGUMENTS:
minPath: the minimum path length (in bonds) to be included
@goraj
goraj / explode_multi_column.py
Last active May 31, 2023 11:09
explode_multi_column.py
from typing import List
import pandas as pd
def explode_multi_column(
df: pd.DataFrame, index_cols: List[str], sep: str
):
"""
In [13]: