Skip to content

Instantly share code, notes, and snippets.

@goraj
goraj / openeye_bug.ipynb
Created Mar 31, 2022
openeye_bug.ipynb
View openeye_bug.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@goraj
goraj / nautilus_parquet_example.py
Last active Feb 19, 2022
nautilus parquet example
View nautilus_parquet_example.py
from nautilus_trader.backtest.data.wranglers import BarDataWrangler
from nautilus_trader.persistence.external.readers import ParquetReader
from nautilus_trader.persistence.catalog import DataCatalog
from functools import partial
from nautilus_trader.core.datetime import dt_to_unix_nanos
from nautilus_trader.model.c_enums.bar_aggregation import BarAggregation
from nautilus_trader.model.data.bar import Bar, BarType, BarSpecification
from nautilus_trader.model.enums import AggregationSource, PriceType
from nautilus_trader.persistence.external.core import process_files, write_objects
@goraj
goraj / st_rerun.py
Last active Apr 2, 2021 — forked from demmerichs/st_rerun.py
Rerun a Streamlit 0.57.3 app from the top! See https://discuss.streamlit.io/t/update-sidebar/531
View st_rerun.py
import streamlit.ReportThread as ReportThread
from streamlit.ScriptRequestQueue import RerunData
from streamlit.ScriptRunner import RerunException
from streamlit.server.Server import Server
def rerun():
"""Rerun a Streamlit app from the top!"""
widget_states = _get_widget_states()
raise RerunException(RerunData(widget_states))
View gist:40852460e320a82284f6a4b81a49e201
{
"smarts": "[#9,#17,#35,#53]-[*:1]",
"limit": 10,
"offset": 0,
"search_conditions": [
{
"condition": "and_",
"filters": [
{
"kind": "location",
@goraj
goraj / GetSparseCountFingerprint.py
Created Nov 5, 2019
GetSparseCountFingerprint.py
View GetSparseCountFingerprint.py
from scipy.sparse import csr_matrix
from rdkit import Chem
from rdkit.Chem.rdFingerprintGenerator import GetRDKitFPGenerator
smiles = 'CC1=C(C=C(C=C1)NC(=O)C2=CC=C(C=C2)CN3CCN(CC3)C)NC4=NC=CC(=N4)C5=CN=CC=C5'
molobj = Chem.MolFromSmiles(smiles)
for max_path in [2,3,4,5,6,7]:
rdk_gen = GetRDKitFPGenerator(maxPath=max_path)
fp = rdk_gen.GetSparseCountFingerprint(molobj)
@goraj
goraj / explode_multi_column.py
Last active Oct 29, 2019
explode_multi_column.py
View 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]:
View GetRDKitFPGenerator.py
# -*- 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
View 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'
@goraj
goraj / holoview_escape.py
Created Oct 22, 2019
holoview_escape.py
View 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 / hv.py
Last active Oct 22, 2019
holoviews hover support for RDKit molobjects
View hv.py
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