diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b79b13a..71780c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v6.0.0 hooks: - id: requirements-txt-fixer - id: mixed-line-ending diff --git a/data/bingo/config.json b/data/bingo/config.json index cca6784..c36b198 100644 --- a/data/bingo/config.json +++ b/data/bingo/config.json @@ -4,7 +4,9 @@ "has_substructure", "matches_smarts", "mol_equals", - "similarity" + "similarity", + "AnyBingoMol", + "AnyBingoReaction" ] } } diff --git a/data/bingo/functions.json b/data/bingo/functions.json index 9504531..577aa75 100644 --- a/data/bingo/functions.json +++ b/data/bingo/functions.json @@ -20,7 +20,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `_exact_internal`.", + "description": "Calls the bingo cartridge function `_exact_internal`.", "group": "internal", "name": "_exact_internal", "return_type": { @@ -30,7 +30,7 @@ }, "_get_block_count": { "args": {}, - "description": "Calls the rdkit cartridge function `_get_block_count`.", + "description": "Calls the bingo cartridge function `_get_block_count`.", "group": "internal", "name": "_get_block_count", "return_type": { @@ -40,7 +40,7 @@ }, "_get_profiling_info": { "args": {}, - "description": "Calls the rdkit cartridge function `_get_profiling_info`.", + "description": "Calls the bingo cartridge function `_get_profiling_info`.", "group": "internal", "name": "_get_profiling_info", "return_type": { @@ -50,7 +50,7 @@ }, "_get_structures_count": { "args": {}, - "description": "Calls the rdkit cartridge function `_get_structures_count`.", + "description": "Calls the bingo cartridge function `_get_structures_count`.", "group": "internal", "name": "_get_structures_count", "return_type": { @@ -79,7 +79,7 @@ "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" } ], - "description": "Calls the rdkit cartridge function `_gross_internal`.", + "description": "Calls the bingo cartridge function `_gross_internal`.", "group": "internal", "name": "_gross_internal", "return_type": { @@ -108,7 +108,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `_internal_func_011`.", + "description": "Calls the bingo cartridge function `_internal_func_011`.", "group": "internal", "name": "_internal_func_011", "return_type": { @@ -131,7 +131,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `_internal_func_012`.", + "description": "Calls the bingo cartridge function `_internal_func_012`.", "group": "internal", "name": "_internal_func_012", "return_type": { @@ -148,7 +148,7 @@ "type": "int | sqltypes.Integer" } ], - "description": "Calls the rdkit cartridge function `_internal_func_check`.", + "description": "Calls the bingo cartridge function `_internal_func_check`.", "group": "internal", "name": "_internal_func_check", "return_type": { @@ -158,7 +158,7 @@ }, "_match_mass_great": { "args": {}, - "description": "Calls the rdkit cartridge function `_match_mass_great`.", + "description": "Calls the bingo cartridge function `_match_mass_great`.", "group": "internal", "name": "_match_mass_great", "return_type": { @@ -168,7 +168,7 @@ }, "_match_mass_less": { "args": {}, - "description": "Calls the rdkit cartridge function `_match_mass_less`.", + "description": "Calls the bingo cartridge function `_match_mass_less`.", "group": "internal", "name": "_match_mass_less", "return_type": { @@ -178,7 +178,7 @@ }, "_precache_database": { "args": {}, - "description": "Calls the rdkit cartridge function `_precache_database`.", + "description": "Calls the bingo cartridge function `_precache_database`.", "group": "internal", "name": "_precache_database", "return_type": { @@ -188,7 +188,7 @@ }, "_print_profiling_info": { "args": {}, - "description": "Calls the rdkit cartridge function `_print_profiling_info`.", + "description": "Calls the bingo cartridge function `_print_profiling_info`.", "group": "internal", "name": "_print_profiling_info", "return_type": { @@ -198,7 +198,7 @@ }, "_reset_profiling_info": { "args": {}, - "description": "Calls the rdkit cartridge function `_reset_profiling_info`.", + "description": "Calls the bingo cartridge function `_reset_profiling_info`.", "group": "internal", "name": "_reset_profiling_info", "return_type": { @@ -227,7 +227,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `_rexact_internal`.", + "description": "Calls the bingo cartridge function `_rexact_internal`.", "group": "internal", "name": "_rexact_internal", "return_type": { @@ -256,7 +256,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `_rsmarts_internal`.", + "description": "Calls the bingo cartridge function `_rsmarts_internal`.", "group": "internal", "name": "_rsmarts_internal", "return_type": { @@ -285,7 +285,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `_rsub_internal`.", + "description": "Calls the bingo cartridge function `_rsub_internal`.", "group": "internal", "name": "_rsub_internal", "return_type": { @@ -326,7 +326,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `_sim_internal`.", + "description": "Calls the bingo cartridge function `_sim_internal`.", "group": "internal", "name": "_sim_internal", "return_type": { @@ -355,7 +355,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `_smarts_internal`.", + "description": "Calls the bingo cartridge function `_smarts_internal`.", "group": "internal", "name": "_smarts_internal", "return_type": { @@ -384,7 +384,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `_sub_internal`.", + "description": "Calls the bingo cartridge function `_sub_internal`.", "group": "internal", "name": "_sub_internal", "return_type": { @@ -398,7 +398,7 @@ "default": null, "description": "Input reaction", "name": "rxn", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "type": "AnyBingoReactionLike | AnyBingoBinaryReactionLike" }, { "default": "'KEEP'", @@ -421,7 +421,7 @@ "default": null, "description": "Input molecule in any supported format", "name": "mol", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "type": "AnyBingoMolLike | AnyBingoBinaryMolLike" } ], "description": "Generates the canonical SMILES for a molecule.", @@ -438,7 +438,7 @@ "default": null, "description": "Input molecule in any supported format", "name": "mol", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "type": "AnyBingoMolLike | AnyBingoBinaryMolLike" } ], "description": "Check molecule for validity", @@ -455,7 +455,7 @@ "default": null, "description": "Input reaction in any supported format", "name": "rxn", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "type": "AnyBingoReactionLike | AnyBingoBinaryReactionLike" } ], "description": "Check reaction for validity", @@ -472,7 +472,7 @@ "default": null, "description": "Input molecule in any supported format", "name": "mol", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "type": "AnyBingoMolLike | AnyBingoBinaryMolLike" } ], "description": "Converts a molecule to CML format.", @@ -489,7 +489,7 @@ "default": null, "description": "Input molecule in any supported format", "name": "mol", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "type": "AnyBingoMolLike | AnyBingoBinaryMolLike" }, { "default": false, @@ -512,7 +512,7 @@ "default": null, "description": "Input reaction in any supported format", "name": "rxn", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "type": "AnyBingoReactionLike | AnyBingoBinaryReactionLike" }, { "default": false, @@ -521,7 +521,7 @@ "type": "sqltypes.Boolean | bool" } ], - "description": "Calls the rdkit cartridge function `compactreaction`.", + "description": "Calls the bingo cartridge function `compactreaction`.", "group": "general", "name": "compactreaction", "return_type": { @@ -608,7 +608,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `filetoblob`.", + "description": "Calls the bingo cartridge function `filetoblob`.", "group": "general", "name": "filetoblob", "return_type": { @@ -625,7 +625,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `filetotext`.", + "description": "Calls the bingo cartridge function `filetotext`.", "group": "general", "name": "filetotext", "return_type": { @@ -648,7 +648,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `fingerprint`.", + "description": "Calls the bingo cartridge function `fingerprint`.", "group": "general", "name": "fingerprint", "return_type": { @@ -665,7 +665,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `getblockcount`.", + "description": "Calls the bingo cartridge function `getblockcount`.", "group": "general", "name": "getblockcount", "return_type": { @@ -675,7 +675,7 @@ }, "getindexstructurescount": { "args": {}, - "description": "Calls the rdkit cartridge function `getindexstructurescount`.", + "description": "Calls the bingo cartridge function `getindexstructurescount`.", "group": "general", "name": "getindexstructurescount", "return_type": { @@ -689,10 +689,10 @@ "default": null, "description": "", "name": "arg_1", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "type": "AnyBingoMolLike | AnyBingoBinaryMolLike" } ], - "description": "Calls the rdkit cartridge function `getmass`.", + "description": "Calls the bingo cartridge function `getmass`.", "group": "general", "name": "getmass", "return_type": { @@ -706,10 +706,10 @@ "default": null, "description": "", "name": "arg_1", - "type": "str | sqltypes.Text" + "type": "AnyBingoMolLike" } ], - "description": "Calls the rdkit cartridge function `getname`.", + "description": "Calls the bingo cartridge function `getname`.", "group": "general", "name": "getname", "return_type": { @@ -723,22 +723,22 @@ "default": null, "description": "Input molecule or molecular column in any supported format", "name": "mol", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "type": "AnyBingoMolLike | AnyBingoBinaryMolLike" }, { "default": null, "description": "Query molecule in any supported format", "name": "query", - "type": "str | sqltypes.Text" + "type": "TextLike" }, { "default": "'tanimoto'", "description": "string specifying the metric to use: `tanimoto` , `tversky`, or `euclid-sub`. In case of Tversky metric, there are optional \u201calpha\u201d and \u201cbeta\u201d parameters: `tversky 0.9 0.1` denotes alpha = 0.9, beta = 0.1. The default is alpha = beta = 0.5 (Dice index).", "name": "metric", - "type": "str | sqltypes.Text" + "type": "TextLike | Literal['tanimoto', 'euclid-sub']" } ], - "description": "Calls the rdkit cartridge function `getsimilarity`.", + "description": "Calls the bingo cartridge function `getsimilarity`.", "group": "general", "name": "getsimilarity", "return_type": { @@ -755,7 +755,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `getstructurescount`.", + "description": "Calls the bingo cartridge function `getstructurescount`.", "group": "general", "name": "getstructurescount", "return_type": { @@ -765,7 +765,7 @@ }, "getversion": { "args": {}, - "description": "Calls the rdkit cartridge function `getversion`.", + "description": "Calls the bingo cartridge function `getversion`.", "group": "general", "name": "getversion", "return_type": { @@ -778,8 +778,8 @@ { "default": null, "description": "", - "name": "arg_1", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "name": "mol", + "type": "AnyBingoMolLike | AnyBingoBinaryMolLike" }, { "default": null, @@ -788,7 +788,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `getweight`.", + "description": "Calls the bingo cartridge function `getweight`.", "group": "general", "name": "getweight", "return_type": { @@ -801,11 +801,11 @@ { "default": null, "description": "", - "name": "arg_1", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "name": "mol", + "type": "AnyBingoMolLike | AnyBingoBinaryMolLike" } ], - "description": "Calls the rdkit cartridge function `gross`.", + "description": "Calls the bingo cartridge function `gross`.", "group": "general", "name": "gross", "return_type": { @@ -819,28 +819,28 @@ "default": null, "description": "", "name": "arg_1", - "type": "str | sqltypes.Text" + "type": "TextLike" }, { "default": null, "description": "", "name": "arg_2", - "type": "str | sqltypes.Text" + "type": "TextLike" }, { "default": null, "description": "", "name": "arg_3", - "type": "str | sqltypes.Text" + "type": "TextLike" }, { "default": null, "description": "", "name": "arg_4", - "type": "str | sqltypes.Text" + "type": "TextLike" } ], - "description": "Calls the rdkit cartridge function `importrdf`.", + "description": "Calls the bingo cartridge function `importrdf`.", "group": "general", "name": "importrdf", "return_type": { @@ -875,7 +875,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `importsdf`.", + "description": "Calls the bingo cartridge function `importsdf`.", "group": "general", "name": "importsdf", "return_type": { @@ -910,7 +910,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `importsmiles`.", + "description": "Calls the bingo cartridge function `importsmiles`.", "group": "general", "name": "importsmiles", "return_type": { @@ -923,8 +923,8 @@ { "default": null, "description": "", - "name": "arg_1", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "name": "mol", + "type": "AnyBingoMolLike | AnyBingoBinaryMolLike" }, { "default": null, @@ -933,7 +933,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `inchi`.", + "description": "Calls the bingo cartridge function `inchi`.", "group": "general", "name": "inchi", "return_type": { @@ -946,11 +946,11 @@ { "default": null, "description": "", - "name": "arg_1", - "type": "str | sqltypes.Text" + "name": "mol", + "type": "AnyBingoMolLike" } ], - "description": "Calls the rdkit cartridge function `inchikey`.", + "description": "Calls the bingo cartridge function `inchikey`.", "group": "general", "name": "inchikey", "return_type": { @@ -960,7 +960,7 @@ }, "matchexact": { "args": {}, - "description": "Calls the rdkit cartridge function `matchexact`.", + "description": "Calls the bingo cartridge function `matchexact`.", "group": "general", "name": "matchexact", "return_type": { @@ -970,7 +970,7 @@ }, "matchgross": { "args": {}, - "description": "Calls the rdkit cartridge function `matchgross`.", + "description": "Calls the bingo cartridge function `matchgross`.", "group": "general", "name": "matchgross", "return_type": { @@ -980,7 +980,7 @@ }, "matchrexact": { "args": {}, - "description": "Calls the rdkit cartridge function `matchrexact`.", + "description": "Calls the bingo cartridge function `matchrexact`.", "group": "general", "name": "matchrexact", "return_type": { @@ -990,7 +990,7 @@ }, "matchrsmarts": { "args": {}, - "description": "Calls the rdkit cartridge function `matchrsmarts`.", + "description": "Calls the bingo cartridge function `matchrsmarts`.", "group": "general", "name": "matchrsmarts", "return_type": { @@ -1000,7 +1000,7 @@ }, "matchrsub": { "args": {}, - "description": "Calls the rdkit cartridge function `matchrsub`.", + "description": "Calls the bingo cartridge function `matchrsub`.", "group": "general", "name": "matchrsub", "return_type": { @@ -1010,7 +1010,7 @@ }, "matchsim": { "args": {}, - "description": "Calls the rdkit cartridge function `matchsim`.", + "description": "Calls the bingo cartridge function `matchsim`.", "group": "general", "name": "matchsim", "return_type": { @@ -1020,7 +1020,7 @@ }, "matchsmarts": { "args": {}, - "description": "Calls the rdkit cartridge function `matchsmarts`.", + "description": "Calls the bingo cartridge function `matchsmarts`.", "group": "general", "name": "matchsmarts", "return_type": { @@ -1030,7 +1030,7 @@ }, "matchsub": { "args": {}, - "description": "Calls the rdkit cartridge function `matchsub`.", + "description": "Calls the bingo cartridge function `matchsub`.", "group": "general", "name": "matchsub", "return_type": { @@ -1043,11 +1043,11 @@ { "default": null, "description": "", - "name": "arg_1", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "name": "mol", + "type": "AnyBingoMolLike | AnyBingoBinaryMolLike" } ], - "description": "Calls the rdkit cartridge function `molfile`.", + "description": "Calls the bingo cartridge function `molfile`.", "group": "general", "name": "molfile", "return_type": { @@ -1070,7 +1070,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `precachedatabase`.", + "description": "Calls the bingo cartridge function `precachedatabase`.", "group": "general", "name": "precachedatabase", "return_type": { @@ -1083,11 +1083,11 @@ { "default": null, "description": "", - "name": "arg_1", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "name": "rxn", + "type": "AnyBingoReactionLike | AnyBingoBinaryReactionLike" } ], - "description": "Calls the rdkit cartridge function `rcml`.", + "description": "Calls the bingo cartridge function `rcml`.", "group": "general", "name": "rcml", "return_type": { @@ -1100,8 +1100,8 @@ { "default": null, "description": "", - "name": "arg_1", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "name": "rxn", + "type": "AnyBingoReactionLike | AnyBingoBinaryReactionLike" }, { "default": null, @@ -1110,7 +1110,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `rfingerprint`.", + "description": "Calls the bingo cartridge function `rfingerprint`.", "group": "general", "name": "rfingerprint", "return_type": { @@ -1123,11 +1123,11 @@ { "default": null, "description": "", - "name": "arg_1", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "name": "rxn", + "type": "AnyBingoReactionLike | AnyBingoBinaryReactionLike" } ], - "description": "Calls the rdkit cartridge function `rsmiles`.", + "description": "Calls the bingo cartridge function `rsmiles`.", "group": "general", "name": "rsmiles", "return_type": { @@ -1140,11 +1140,11 @@ { "default": null, "description": "", - "name": "arg_1", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "name": "rxn", + "type": "AnyBingoReactionLike | AnyBingoBinaryReactionLike" } ], - "description": "Calls the rdkit cartridge function `rxnfile`.", + "description": "Calls the bingo cartridge function `rxnfile`.", "group": "general", "name": "rxnfile", "return_type": { @@ -1157,11 +1157,11 @@ { "default": null, "description": "", - "name": "arg_1", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "name": "mol", + "type": "AnyBingoMolLike | AnyBingoBinaryMolLike" } ], - "description": "Calls the rdkit cartridge function `smiles`.", + "description": "Calls the bingo cartridge function `smiles`.", "group": "general", "name": "smiles", "return_type": { @@ -1174,8 +1174,8 @@ { "default": null, "description": "", - "name": "arg_1", - "type": "str | sqltypes.Text | bytes | sqltypes.LargeBinary" + "name": "mol", + "type": "AnyBingoMolLike | AnyBingoBinaryMolLike" }, { "default": null, @@ -1184,7 +1184,7 @@ "type": "str | sqltypes.Text" } ], - "description": "Calls the rdkit cartridge function `standardize`.", + "description": "Calls the bingo cartridge function `standardize`.", "group": "general", "name": "standardize", "return_type": { diff --git a/data/bingo/general_extra.txt b/data/bingo/general_extra.txt index 3044c81..b520672 100644 --- a/data/bingo/general_extra.txt +++ b/data/bingo/general_extra.txt @@ -1,16 +1,16 @@ def has_substructure( - mol_column: ColumnElement[AnyBingoMol], query: str, parameters: str = "" + mol: ColumnElement[AnyBingoMol], query: TextLike, parameters: TextLike = "" ): """ Perform substructure search on a molecule column. Parameters ---------- - mol_column : ColumnElement + mol : ColumnElement SQLAlchemy column containing molecule data (SMILES, Molfile, or binary). - query : str + query : TextLike Query molecule as SMILES, SMARTS, or Molfile string. - parameters : str, optional + parameters : TextLike, optional Search parameters for customizing the matching behavior (default is ""). Examples: "TAU" for tautomer search, "RES" for resonance search. @@ -18,24 +18,24 @@ def has_substructure( ------- BinaryExpression SQLAlchemy expression for substructure matching that can be used in WHERE clauses. - + """ - return mol_column.op("@")(text(f"('{query}', '{parameters}')::bingo.sub")) + return mol.op("@")(text(f"('{query}', '{parameters}')::bingo.sub")) def matches_smarts( - mol_column: ColumnElement[AnyBingoMol], query: str, parameters: str = "" + mol: ColumnElement[AnyBingoMol], query: TextLike, parameters: TextLike = "" ): """ Perform SMARTS pattern matching on a molecule column. Parameters ---------- - mol_column : ColumnElement + mol : ColumnElement[AnyBingoMol] SQLAlchemy column containing molecule data (SMILES, Molfile, or binary). - query : str + query : TextLike SMARTS pattern string for matching. - parameters : str, optional + parameters : TextLike, optional Search parameters for customizing the matching behavior (default is ""). Returns @@ -44,20 +44,20 @@ def matches_smarts( SQLAlchemy expression for SMARTS matching that can be used in WHERE clauses. """ - return mol_column.op("@")(text(f"('{query}', '{parameters}')::bingo.smarts")) + return mol.op("@")(text(f"('{query}', '{parameters}')::bingo.smarts")) -def mol_equals(mol_column: ColumnElement[AnyBingoMol], query: str, parameters: str = ""): +def mol_equals(mol: ColumnElement[AnyBingoMol], query: TextLike, parameters: TextLike = ""): """ Perform exact structure matching on a molecule column. Parameters ---------- - mol_column : ColumnElement + mol : ColumnElement[AnyBingoMol] SQLAlchemy column containing molecule data (SMILES, Molfile, or binary). - query : str + query : TextLike Query molecule as SMILES or Molfile string for exact matching. - parameters : str, optional + parameters : TextLike, optional Search parameters for customizing the matching behavior (default is ""). Examples: "TAU" for tautomer matching, "STE" for stereochemistry. @@ -67,15 +67,15 @@ def mol_equals(mol_column: ColumnElement[AnyBingoMol], query: str, parameters: s SQLAlchemy expression for exact matching that can be used in WHERE clauses. """ - return mol_column.op("@")(text(f"('{query}', '{parameters}')::bingo.exact")) + return mol.op("@")(text(f"('{query}', '{parameters}')::bingo.exact")) def similarity( - mol_column: ColumnElement[AnyBingoMol], - query: str, + mol: ColumnElement[AnyBingoMol], + query: TextLike, bottom: float = 0.0, top: float = 1.0, - metric: str = "Tanimoto", + metric: TextLike = "Tanimoto", ) -> BinaryExpression: """ Perform similarity search on a molecule column. This should be used in WHERE clauses, as it @@ -83,15 +83,15 @@ def similarity( Parameters ---------- - mol_column : ColumnElement + mol : AnyBingoMolLike | AnyBingoBinaryMolLike SQLAlchemy column containing molecule data (SMILES, Molfile, or binary). - query : str + query : TextLike Query molecule as SMILES or Molfile string for similarity comparison. bottom : float, optional Minimum similarity threshold (default is 0.0). top : float, optional Maximum similarity threshold (default is 1.0). - metric : str, optional + metric : TextLike, optional Similarity metric to use (default is "Tanimoto"). Other options include "Dice", "Cosine", etc. @@ -101,6 +101,6 @@ def similarity( SQLAlchemy expression for similarity matching that can be used in WHERE clauses. """ - return mol_column.op("%")( + return mol.op("%")( text(f"('{query}', {bottom}, {top}, '{metric}')::bingo.sim") ) \ No newline at end of file diff --git a/data/bingo/general_header.txt b/data/bingo/general_header.txt index 355c54a..81a9db5 100644 --- a/data/bingo/general_header.txt +++ b/data/bingo/general_header.txt @@ -3,18 +3,24 @@ This file defines public Bingo PostgreSQL function wrappers for use with SQLAlch """ -from molalchemy.types import CString -from molalchemy.bingo.types import BingoBinaryMol, BingoBinaryReaction, BingoMol, BingoReaction from sqlalchemy import types as sqltypes -from sqlalchemy.sql import cast, text -from sqlalchemy import Cast +from sqlalchemy.sql import text from sqlalchemy.sql.elements import BinaryExpression from sqlalchemy.sql.elements import ColumnElement from sqlalchemy.sql.functions import GenericFunction from typing import Any, Literal +from ._types import ( + TextLike, + AnyBingoBinaryMolLike, + AnyBingoBinaryReactionLike, + AnyBingoMolLike, + AnyBingoMolLikeCombined, + AnyBingoReactionLike, + AnyBingoReactionLikeCombined, +) -AnyBingoMol = BingoMol | BingoBinaryMol - -AnyBingoReaction = BingoReaction | BingoBinaryReaction +# Backward compatibility aliases +AnyBingoMol = AnyBingoMolLikeCombined +AnyBingoReaction = AnyBingoReactionLikeCombined diff --git a/data/bingo/internal_header.txt b/data/bingo/internal_header.txt index 7bf8e66..78ef830 100644 --- a/data/bingo/internal_header.txt +++ b/data/bingo/internal_header.txt @@ -11,3 +11,11 @@ from sqlalchemy.sql.elements import BinaryExpression from sqlalchemy.sql.elements import ColumnElement from sqlalchemy.sql.functions import GenericFunction from typing import Any, Literal +from ._types import ( + AnyBingoBinaryMolLike, + AnyBingoBinaryReactionLike, + AnyBingoMolLike, + AnyBingoMolLikeCombined, + AnyBingoReactionLike, + AnyBingoReactionLikeCombined, +) diff --git a/data/rdkit/functions.json b/data/rdkit/functions.json index 1195b51..ef97676 100644 --- a/data/rdkit/functions.json +++ b/data/rdkit/functions.json @@ -481,7 +481,7 @@ "default": null, "description": "A set of molecules for which to calculate the MCS.", "name": "mols", - "type": "RdkitMol | sqltypes.Text" + "type": "RdkitMol" } ], "description": "An aggregation function that calculates the Maximum Common Substructure (MCS) for a set of molecules.", diff --git a/data/rdkit/general_header.txt b/data/rdkit/general_header.txt index 33b379d..89fdd2f 100644 --- a/data/rdkit/general_header.txt +++ b/data/rdkit/general_header.txt @@ -9,6 +9,8 @@ from sqlalchemy.sql.elements import ColumnElement from molalchemy.rdkit.types import RdkitBitFingerprint, RdkitMol, RdkitSparseFingerprint, RdkitQMol, RdkitXQMol, RdkitReaction from molalchemy.types import CString +from ._types import AnyRdkitFingerprintLike, AnyRdkitMolLike, AnyRdkitQMolLike, AnyRdkitSparseFingerprintLike, AnyRdkitBitFingerprintLike, AnyRdkitReactionLike, AnyRdkitXQMolLike + from sqlalchemy.sql.functions import GenericFunction diff --git a/data/rdkit/internal_header.txt b/data/rdkit/internal_header.txt index c94a934..547a92a 100644 --- a/data/rdkit/internal_header.txt +++ b/data/rdkit/internal_header.txt @@ -9,6 +9,7 @@ from sqlalchemy.sql.elements import ColumnElement from molalchemy.rdkit.types import RdkitBitFingerprint, RdkitMol, RdkitSparseFingerprint, RdkitQMol, RdkitXQMol, RdkitReaction from molalchemy.types import CString +from ._types import AnyRdkitFingerprintLike, AnyRdkitMolLike, AnyRdkitQMolLike, AnyRdkitSparseFingerprintLike, AnyRdkitBitFingerprintLike, AnyRdkitReactionLike, AnyRdkitXQMolLike from sqlalchemy.sql.functions import GenericFunction diff --git a/dev_scripts/gen_functions.py b/dev_scripts/gen_functions.py index 13fd6a4..fafe17f 100755 --- a/dev_scripts/gen_functions.py +++ b/dev_scripts/gen_functions.py @@ -38,6 +38,14 @@ def json_to_function_code(func_name: str, data: dict, template) -> str: # Process function arguments for param in data["args"]: + if param["type"].startswith("Rdkit"): + if "Sparse" in param["type"] and "Bit" in param["type"]: + param["type"] = "AnyRdkitFingerprintLike" + else: + param_t = param["type"].split("|") + param["type"] = " | ".join( + [f"Any{t.replace(' ', '')}Like" for t in param_t] + ) param_str = f"{param['name']}: {param['type']}" if param["default"] is not None: param_str += f" = {param['default']}" diff --git a/docs/tutorials/01_Getting_Started_bingo_ORM.ipynb b/docs/tutorials/01_Getting_Started_bingo_ORM.ipynb index 8ad1a46..8e0e3aa 100644 --- a/docs/tutorials/01_Getting_Started_bingo_ORM.ipynb +++ b/docs/tutorials/01_Getting_Started_bingo_ORM.ipynb @@ -27,6 +27,24 @@ "The Bingo cartridge provides fast and efficient chemical search capabilities including exact structure search, substructure search, and similarity search with various fingerprint algorithms." ] }, + { + "cell_type": "markdown", + "id": "docker-setup", + "metadata": {}, + "source": [ + "## Setting Up the Database\n", + "To set up a PostgreSQL database with the Bingo extension, you can use our docker images from [Docker Hub](https://hub.docker.com/repository/docker/antonsiomchen/cheminfo-db), e.g `antonsiomchen/cheminfo-db:postgres17.6-bingo1.34.0`\n", + "\n", + "```sh\n", + "docker run -d \\\n", + " --name molalchemy-tutorial-bingo-orm \\\n", + " -e POSTGRES_PASSWORD=example \\\n", + " -e POSTGRES_DB=postgres \\\n", + " -p 5432:5432 \\\n", + " antonsiomchen/cheminfo-db:postgres17.6-bingo1.34.0\n", + "```" + ] + }, { "cell_type": "markdown", "id": "df7708ca", diff --git a/docs/tutorials/01_Getting_Started_rdkit_ORM.ipynb b/docs/tutorials/01_Getting_Started_rdkit_ORM.ipynb index 307750c..869a5bd 100644 --- a/docs/tutorials/01_Getting_Started_rdkit_ORM.ipynb +++ b/docs/tutorials/01_Getting_Started_rdkit_ORM.ipynb @@ -23,7 +23,20 @@ "Before starting this tutorial, make sure you have:\n", "- A PostgreSQL database with RDKit extension installed\n", "- MolAlchemy installed\n", - "- A running PostgreSQL instance (you can use the provided Docker setup)" + "- A running PostgreSQL instance (you can use the provided Docker setup)\n", + "\n", + "\n", + "## Setting Up the Database\n", + "To set up a PostgreSQL database with the RDKit extension, you can use our docker images from [Docker Hub](https://hub.docker.com/repository/docker/antonsiomchen/cheminfo-db), e.g `antonsiomchen/cheminfo-db:postgres18.1-rdkit2025.09.4`\n", + "\n", + "```sh\n", + "docker run -d \\\n", + " --name molalchemy-tutorial-rdkit-orm \\\n", + " -e POSTGRES_PASSWORD=postgres \\\n", + " -e POSTGRES_DB=postgres \\\n", + " -p 5432:5432 \\\n", + " antonsiomchen/cheminfo-db:postgres18.1-rdkit2025.09.4\n", + "```" ] }, { @@ -38,7 +51,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "id": "ddcb2b72", "metadata": {}, "outputs": [ @@ -46,7 +59,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "[('0.76.0', '2024.03.1')]\n" + "[('0.77.0', '2025.09.4')]\n" ] } ], @@ -70,7 +83,7 @@ "from molalchemy.rdkit import functions, index, types\n", "\n", "eng = engine.create_engine(\n", - " \"postgresql+psycopg://postgres:example@localhost:5432/postgres\"\n", + " \"postgresql+psycopg://postgres:postgres@localhost:5432/postgres\"\n", ")\n", "SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=eng)\n", "with SessionLocal() as session:\n", @@ -101,7 +114,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "id": "7c1d4286", "metadata": {}, "outputs": [], @@ -145,7 +158,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "id": "9b32959c", "metadata": {}, "outputs": [], @@ -184,7 +197,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "id": "fe2028ab", "metadata": {}, "outputs": [], @@ -200,7 +213,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "id": "b6e65469", "metadata": {}, "outputs": [ @@ -234,7 +247,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "id": "a5b2666e", "metadata": {}, "outputs": [ @@ -247,7 +260,7 @@ " (Molecule(id=6, name='Levodopa', mol='N[C@@H](Cc1ccc(O)c(O)c1)C(=O)O', is_nsaid=False),)]" ] }, - "execution_count": 7, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -268,7 +281,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "id": "8f356747", "metadata": {}, "outputs": [ @@ -278,7 +291,7 @@ "[(Molecule(id=1, name='Aspirin', mol='CC(=O)Oc1ccccc1C(=O)O', is_nsaid=True),)]" ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -300,7 +313,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "id": "024ffa61", "metadata": {}, "outputs": [ @@ -311,7 +324,7 @@ " (Molecule(id=4, name='Captopril', mol='C[C@H](CS)C(=O)N1CCC[C@H]1C(=O)O', is_nsaid=False),)]" ] }, - "execution_count": 9, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -343,7 +356,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "id": "f5617b86", "metadata": {}, "outputs": [], @@ -380,7 +393,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "id": "5e2c36e8", "metadata": {}, "outputs": [], @@ -402,7 +415,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "id": "45e6718a", "metadata": {}, "outputs": [ @@ -412,7 +425,7 @@ "[(MoleculeFP(id=1, name='Aspirin', mol='CC(=O)Oc1ccccc1C(=O)O', fp='\\\\x0100000004000000ffffffff190000004034df0502000000177ce7070100000050d6601e01000000b ... (218 characters truncated) ... 00000c76fa289010000000b9cd89e01000000c831f8a501000000a7d50bb2010000006455c5bf02000000515fd9bf04000000f9fb51d301000000afbc69ee02000000', is_nsaid=True),)]" ] }, - "execution_count": 12, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -448,18 +461,10 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "id": "9447c97a", "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/tmp/ipykernel_10980/1181603980.py:4: SAWarning: Class tanimoto_sml will not make use of SQL compilation caching as it does not set the 'inherit_cache' attribute to ``True``. This can have significant performance implications including some performance degradations in comparison to prior SQLAlchemy versions. Set this attribute to True if this object can make use of the cache key generated by the superclass. Alternatively, this attribute may be set to False which will disable this warning. (Background on this warning at: https://sqlalche.me/e/20/cprf)\n", - " session.execute(final_query).all()\n" - ] - }, { "data": { "text/plain": [ @@ -470,7 +475,7 @@ " (0.030303030303030304, MoleculeFP(id=4, name='Captopril', mol='C[C@H](CS)C(=O)N1CCC[C@H]1C(=O)O', fp='\\\\x0100000004000000ffffffff20000000f2e0751a01000000b355c52c0100000027b3 ... (344 characters truncated) ... 0000c198c39501000000c8551fa7010000009edbf6b003000000fbab62b101000000886e83c8010000001b29d4d2010000006c006fd701000000417193f501000000', is_nsaid=False))]" ] }, - "execution_count": 13, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -494,7 +499,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "id": "32703967", "metadata": {}, "outputs": [ @@ -534,7 +539,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "id": "68a51b79", "metadata": {}, "outputs": [], @@ -578,7 +583,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "id": "be9e0616", "metadata": {}, "outputs": [], @@ -590,18 +595,18 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 18, "id": "e5ce3158", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[(RawMoleculeFP(id=1, name='Aspirin', mol=b'\\xef\\xbe\\xad\\xde\\x00\\x00\\x00\\x00\\x10\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\r\\x00\\x00\\x00\\r\\x00\\x00\\x00 ... (970 characters truncated) ... 00000c76fa289010000000b9cd89e01000000c831f8a501000000a7d50bb2010000006455c5bf02000000515fd9bf04000000f9fb51d301000000afbc69ee02000000', is_nsaid=True),),\n", - " (RawMoleculeFP(id=2, name='Loratadine', mol=b'\\xef\\xbe\\xad\\xde\\x00\\x00\\x00\\x00\\x10\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x1b\\x00\\x00\\x00\\x1e\\x00\\ ... (2084 characters truncated) ... 0000ac3e61ce01000000269925d3010000004aff1ee10100000030fb63e50100000056c98fe6010000003abe53ed0100000060a959ed01000000d6f410ee01000000', is_nsaid=False),)]" + "[(RawMoleculeFP(id=1, name='Aspirin', mol=b'\\xef\\xbe\\xad\\xde\\x00\\x00\\x00\\x00\\x10\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\r\\x00\\x00\\x00\\r\\x00\\x00\\x00 ... (970 characters truncated) ... 00000c76fa289010000000b9cd89e01000000c831f8a501000000a7d50bb2010000006455c5bf02000000515fd9bf04000000f9fb51d301000000afbc69ee02000000', is_nsaid=True),),\n", + " (RawMoleculeFP(id=2, name='Loratadine', mol=b'\\xef\\xbe\\xad\\xde\\x00\\x00\\x00\\x00\\x10\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x1b\\x00\\x00\\x00\\x1e\\x00\\ ... (2084 characters truncated) ... 0000ac3e61ce01000000269925d3010000004aff1ee10100000030fb63e50100000056c98fe6010000003abe53ed0100000060a959ed01000000d6f410ee01000000', is_nsaid=False),)]" ] }, - "execution_count": 17, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -661,8 +666,8 @@ { "data": { "text/plain": [ - "[(ConvertedMoleculeFP(id=1, name='Aspirin', mol=, fp='\\\\x0100000004000000ffffffff190000004034df050200000 ... (252 characters truncated) ... 00000c76fa289010000000b9cd89e01000000c831f8a501000000a7d50bb2010000006455c5bf02000000515fd9bf04000000f9fb51d301000000afbc69ee02000000', is_nsaid=True),),\n", - " (ConvertedMoleculeFP(id=2, name='Loratadine', mol=, fp='\\\\x0100000004000000ffffffff3400000043892d020100 ... (688 characters truncated) ... 0000ac3e61ce01000000269925d3010000004aff1ee10100000030fb63e50100000056c98fe6010000003abe53ed0100000060a959ed01000000d6f410ee01000000', is_nsaid=False),)]" + "[(ConvertedMoleculeFP(id=1, name='Aspirin', mol=, fp='\\\\x0100000004000000ffffffff190000004034df050200000 ... (252 characters truncated) ... 00000c76fa289010000000b9cd89e01000000c831f8a501000000a7d50bb2010000006455c5bf02000000515fd9bf04000000f9fb51d301000000afbc69ee02000000', is_nsaid=True),),\n", + " (ConvertedMoleculeFP(id=2, name='Loratadine', mol=, fp='\\\\x0100000004000000ffffffff3400000043892d020100 ... (688 characters truncated) ... 0000ac3e61ce01000000269925d3010000004aff1ee10100000030fb63e50100000056c98fe6010000003abe53ed0100000060a959ed01000000d6f410ee01000000', is_nsaid=False),)]" ] }, "metadata": {}, @@ -672,7 +677,7 @@ "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAcIAAACWCAIAAADCEh9HAAAABmJLR0QA/wD/AP+gvaeTAAAeZklEQVR4nO3deVgT97oH8G/CEkGQRRR3Fhcsyq2ggAuIYrWAUFlMtVV7atXaPqfF2tNTe459tN7alm6PcOu91mOlalcbCYIigohWUKig0iK4ICAgsiiL7Fsy94+hESkqAslkJu/nr+bNJPPmefDbmd/85jcihmFACCGkr8RcN0AIIfxGMUoIIf1CMUoIIf1CMUoIIf1CMUoIIf2iz3UDhKhXXV1dWFiYRCLZuHHjkCFDuG6HCJCIJjwRAbt9+7aTk1N1dTUAfX19Hx8fqVQaHBxsYmLCdWtEOChGiWCVlZX5+Pj88ccfYrHY0NCwpaWFrRsbG/v5+QUHBy9evJiOT0n/UYwSYSooKHj22Wdv3Lhha2u7b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y42AAB4nCWOyw0CUQhFW3GpCUP4w8vE1RRgEbZh8d6n7Dgc4F7X/fl6vN763qX/7va5H86jZkOHsk0NnYdxrWk6BEAnHMhZIDkp66QYCOzWXNvq8M4AE9YcUSdslpr4jwW8UKy2jTSdwhWYLTJu9y0ZSy1NANxU28DHkEV4JCzpxDcYv0giva8oJxTbsas6QZBRVjshv9qK2Z+ilkRsVG3p9Ph8AaOXNexrmcq5AAAAAElFTkSuQmCC", "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -722,7 +727,7 @@ ], "metadata": { "kernelspec": { - "display_name": "realchemy", + "display_name": "molalchemy", "language": "python", "name": "python3" }, @@ -736,7 +741,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.18" + "version": "3.10.19" } }, "nbformat": 4, diff --git a/docs/tutorials/02_Getting_Started_rdkit_Core.ipynb b/docs/tutorials/02_Getting_Started_rdkit_Core.ipynb index 145eb9f..5027d84 100644 --- a/docs/tutorials/02_Getting_Started_rdkit_Core.ipynb +++ b/docs/tutorials/02_Getting_Started_rdkit_Core.ipynb @@ -25,6 +25,24 @@ "- A running PostgreSQL instance (you can use the provided Docker setup)" ] }, + { + "cell_type": "markdown", + "id": "docker-setup", + "metadata": {}, + "source": [ + "## Setting Up the Database\n", + "To set up a PostgreSQL database with the RDKit extension, you can use our docker images from [Docker Hub](https://hub.docker.com/repository/docker/antonsiomchen/cheminfo-db), e.g `antonsiomchen/cheminfo-db:postgres18.1-rdkit2025.09.4`\n", + "\n", + "```sh\n", + "docker run -d \\\n", + " --name molalchemy-tutorial-rdkit-core \\\n", + " -e POSTGRES_PASSWORD=example \\\n", + " -e POSTGRES_DB=postgres \\\n", + " -p 5432:5432 \\\n", + " antonsiomchen/cheminfo-db:postgres18.1-rdkit2025.09.4\n", + "```" + ] + }, { "cell_type": "markdown", "id": "07d14494", diff --git a/pyproject.toml b/pyproject.toml index 646d353..ba68ff1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,6 +43,7 @@ build-backend = "hatchling.build" dev = [ "alembic>=1.17.0", "ipykernel>=6.30.1", + "jinja2>=3.1.6", "mypy>=1.18.2", "pandas>=2.3.3", "pytest>=8.4.2", @@ -101,3 +102,5 @@ exclude = [ [tool.mypy] plugins = "sqlalchemy.ext.mypy.plugin" +[tool.pyrefly] + diff --git a/src/molalchemy/__init__.py b/src/molalchemy/__init__.py index ee07931..66cd9b5 100644 --- a/src/molalchemy/__init__.py +++ b/src/molalchemy/__init__.py @@ -1,6 +1,20 @@ from loguru import logger from molalchemy._version import __version__ +from molalchemy.bingo.index import BingoBinaryMolIndex, BingoMolIndex +from molalchemy.bingo.types import BingoBinaryMol, BingoMol +from molalchemy.rdkit.index import RdkitIndex +from molalchemy.rdkit.types import RdkitBitFingerprint, RdkitMol, RdkitSparseFingerprint logger.disable("molalchemy") -__all__ = ["__version__"] +__all__ = [ + "BingoBinaryMol", + "BingoBinaryMolIndex", + "BingoMol", + "BingoMolIndex", + "RdkitBitFingerprint", + "RdkitIndex", + "RdkitMol", + "RdkitSparseFingerprint", + "__version__", +] diff --git a/src/molalchemy/bingo/__init__.py b/src/molalchemy/bingo/__init__.py index 9fe5994..c6d3fa8 100644 --- a/src/molalchemy/bingo/__init__.py +++ b/src/molalchemy/bingo/__init__.py @@ -18,6 +18,4 @@ "BingoReaction", "BingoRxnIndex", "BingoRxnProxy", - "bingo_func", - "bingo_rxn_func", ] diff --git a/src/molalchemy/bingo/comparators.py b/src/molalchemy/bingo/comparators.py index 0b276a2..fed8948 100644 --- a/src/molalchemy/bingo/comparators.py +++ b/src/molalchemy/bingo/comparators.py @@ -35,7 +35,11 @@ def has_substructure(self, query: str, parameters: str = ""): -------- >>> mol_column.has_substructure('c1ccccc1') # benzene ring """ - return self.expr.op("@")(text(f"('{query}', '{parameters}')::bingo.sub")) + return self.expr.op("@")( + text("(:query, :params)\\:\\:bingo.sub").bindparams( + query=query, params=parameters + ) + ) def has_smarts(self, query: str, parameters: str = ""): """ @@ -57,7 +61,11 @@ def has_smarts(self, query: str, parameters: str = ""): -------- >>> mol_column.has_smarts('[#6]1:[#6]:[#6]:[#6]:[#6]:[#6]:1') # aromatic ring """ - return self.expr.op("@")(text(f"('{query}', '{parameters}')::bingo.smarts")) + return self.expr.op("@")( + text("(:query, :params)\\:\\:bingo.smarts").bindparams( + query=query, params=parameters + ) + ) def equals(self, query: str, parameters: str = ""): """ @@ -79,7 +87,11 @@ def equals(self, query: str, parameters: str = ""): -------- >>> mol_column.equals('CCO') # ethanol exact match """ - return self.expr.op("@")(text(f"('{query}', '{parameters}')::bingo.exact")) + return self.expr.op("@")( + text("(:query, :params)\\:\\:bingo.exact").bindparams( + query=query, params=parameters + ) + ) class BingoRxnComparator(UserDefinedType.Comparator): @@ -90,6 +102,9 @@ class BingoRxnComparator(UserDefinedType.Comparator): reaction substructure matching, SMARTS pattern matching, and exact reaction matching. """ + def __eq__(self, other: str): + return self.equals(other) + def has_substructure(self, query: str, parameters: str = ""): """ Check if the reaction contains a given substructure pattern. @@ -110,7 +125,11 @@ def has_substructure(self, query: str, parameters: str = ""): -------- >>> rxn_column.has_substructure('c1ccccc1>>c1ccc(O)cc1') # phenol formation """ - return self.expr.op("@")(text(f"('{query}', '{parameters}')::bingo.rsub")) + return self.expr.op("@")( + text("(:query, :params)\\:\\:bingo.rsub").bindparams( + query=query, params=parameters + ) + ) def has_smarts(self, query: str, parameters: str = ""): """ @@ -132,7 +151,11 @@ def has_smarts(self, query: str, parameters: str = ""): -------- >>> rxn_column.has_smarts('[C:1]>>[C:1][O]') # C-O bond formation """ - return self.expr.op("@")(text(f"('{query}', '{parameters}')::bingo.rsmarts")) + return self.expr.op("@")( + text("(:query, :params)\\:\\:bingo.rsmarts").bindparams( + query=query, params=parameters + ) + ) def equals(self, query: str, parameters: str = ""): """ @@ -154,4 +177,8 @@ def equals(self, query: str, parameters: str = ""): -------- >>> rxn_column.has_equals('CCO>>CC=O') # ethanol to acetaldehyde exact match """ - return self.expr.op("@")(text(f"('{query}', '{parameters}')::bingo.rexact")) + return self.expr.op("@")( + text("(:query, :params)\\:\\:bingo.rexact").bindparams( + query=query, params=parameters + ) + ) diff --git a/src/molalchemy/bingo/functions/__init__.py b/src/molalchemy/bingo/functions/__init__.py index 4b7b146..ec0c02f 100644 --- a/src/molalchemy/bingo/functions/__init__.py +++ b/src/molalchemy/bingo/functions/__init__.py @@ -5,6 +5,8 @@ """ from .general import ( + AnyBingoMol, + AnyBingoReaction, aam, cansmiles, checkmolecule, @@ -75,6 +77,8 @@ ) __all__ = [ + "AnyBingoMol", + "AnyBingoReaction", "_exact_internal", "_get_block_count", "_get_profiling_info", diff --git a/src/molalchemy/bingo/functions/_types.py b/src/molalchemy/bingo/functions/_types.py new file mode 100644 index 0000000..be1af44 --- /dev/null +++ b/src/molalchemy/bingo/functions/_types.py @@ -0,0 +1,80 @@ +from __future__ import annotations + +from typing import ( + TypeAlias, # pragma: no cover + TypeVar, +) + +from sqlalchemy import Column, Function +from sqlalchemy.orm import InstrumentedAttribute, Mapped + +from molalchemy.bingo.types import ( + BingoBinaryMol, + BingoBinaryReaction, + BingoMol, + BingoReaction, +) + +""" +Type aliases for Bingo-SQLAlchemy integration. +These aliases make it easier to annotate columns, mapped attributes, +and SQL functions that return Bingo objects (Mol, BinaryMol, Reaction, BinaryReaction) +while still supporting literal values (e.g. SMILES strings) and raw bytes. +""" + + +T = TypeVar("T") +SQLAlchemyCoercible: TypeAlias = ( + InstrumentedAttribute[T] | Column[T] | Mapped[T] | Function[T] +) + +LiteralStrBytes: TypeAlias = str | bytes + +# Text-like types for string/bytes inputs +TextLike: TypeAlias = ( + str | bytes | Column[str] | Mapped[str] | InstrumentedAttribute[str] +) + +# ---------------------------------------------------------------------- +# Bingo specific type aliases +# ---------------------------------------------------------------------- +BingoMolCoercible: TypeAlias = BingoMol | str +AnyBingoMolLike: TypeAlias = SQLAlchemyCoercible[BingoMolCoercible] | BingoMolCoercible + +BingoBinaryMolCoercible: TypeAlias = BingoBinaryMol | bytes +AnyBingoBinaryMolLike: TypeAlias = ( + SQLAlchemyCoercible[BingoBinaryMolCoercible] | BingoBinaryMolCoercible +) + +BingoReactionCoercible: TypeAlias = BingoReaction | LiteralStrBytes +AnyBingoReactionLike: TypeAlias = ( + SQLAlchemyCoercible[BingoReactionCoercible] | BingoReactionCoercible +) + +BingoBinaryReactionCoercible: TypeAlias = BingoBinaryReaction | LiteralStrBytes +AnyBingoBinaryReactionLike: TypeAlias = ( + SQLAlchemyCoercible[BingoBinaryReactionCoercible] | BingoBinaryReactionCoercible +) + +# ---------------------------------------------------------------------- +# Combined aliases - convenience for functions accepting text or binary +# ---------------------------------------------------------------------- +AnyBingoMolLikeCombined: TypeAlias = AnyBingoMolLike | AnyBingoBinaryMolLike +AnyBingoReactionLikeCombined: TypeAlias = ( + AnyBingoReactionLike | AnyBingoBinaryReactionLike +) + +__all__ = [ + "AnyBingoBinaryMolLike", + "AnyBingoBinaryReactionLike", + "AnyBingoMolLike", + "AnyBingoMolLikeCombined", + "AnyBingoReactionLike", + "AnyBingoReactionLikeCombined", + "BingoBinaryMolCoercible", + "BingoBinaryReactionCoercible", + "BingoMolCoercible", + "BingoReactionCoercible", + "SQLAlchemyCoercible", + "TextLike", +] diff --git a/src/molalchemy/bingo/functions/general.py b/src/molalchemy/bingo/functions/general.py index 4a30269..b26ff43 100644 --- a/src/molalchemy/bingo/functions/general.py +++ b/src/molalchemy/bingo/functions/general.py @@ -9,31 +9,34 @@ from sqlalchemy.sql.elements import BinaryExpression, ColumnElement from sqlalchemy.sql.functions import GenericFunction -from molalchemy.bingo.types import ( - BingoBinaryMol, - BingoBinaryReaction, - BingoMol, - BingoReaction, +from ._types import ( + AnyBingoBinaryMolLike, + AnyBingoBinaryReactionLike, + AnyBingoMolLike, + AnyBingoMolLikeCombined, + AnyBingoReactionLike, + AnyBingoReactionLikeCombined, + TextLike, ) -AnyBingoMol = BingoMol | BingoBinaryMol - -AnyBingoReaction = BingoReaction | BingoBinaryReaction +# Backward compatibility aliases +AnyBingoMol = AnyBingoMolLikeCombined +AnyBingoReaction = AnyBingoReactionLikeCombined def has_substructure( - mol_column: ColumnElement[AnyBingoMol], query: str, parameters: str = "" + mol: ColumnElement[AnyBingoMol], query: TextLike, parameters: TextLike = "" ): """ Perform substructure search on a molecule column. Parameters ---------- - mol_column : ColumnElement + mol : ColumnElement SQLAlchemy column containing molecule data (SMILES, Molfile, or binary). - query : str + query : TextLike Query molecule as SMILES, SMARTS, or Molfile string. - parameters : str, optional + parameters : TextLike, optional Search parameters for customizing the matching behavior (default is ""). Examples: "TAU" for tautomer search, "RES" for resonance search. @@ -43,22 +46,22 @@ def has_substructure( SQLAlchemy expression for substructure matching that can be used in WHERE clauses. """ - return mol_column.op("@")(text(f"('{query}', '{parameters}')::bingo.sub")) + return mol.op("@")(text(f"('{query}', '{parameters}')::bingo.sub")) def matches_smarts( - mol_column: ColumnElement[AnyBingoMol], query: str, parameters: str = "" + mol: ColumnElement[AnyBingoMol], query: TextLike, parameters: TextLike = "" ): """ Perform SMARTS pattern matching on a molecule column. Parameters ---------- - mol_column : ColumnElement + mol : ColumnElement[AnyBingoMol] SQLAlchemy column containing molecule data (SMILES, Molfile, or binary). - query : str + query : TextLike SMARTS pattern string for matching. - parameters : str, optional + parameters : TextLike, optional Search parameters for customizing the matching behavior (default is ""). Returns @@ -67,22 +70,22 @@ def matches_smarts( SQLAlchemy expression for SMARTS matching that can be used in WHERE clauses. """ - return mol_column.op("@")(text(f"('{query}', '{parameters}')::bingo.smarts")) + return mol.op("@")(text(f"('{query}', '{parameters}')::bingo.smarts")) def mol_equals( - mol_column: ColumnElement[AnyBingoMol], query: str, parameters: str = "" + mol: ColumnElement[AnyBingoMol], query: TextLike, parameters: TextLike = "" ): """ Perform exact structure matching on a molecule column. Parameters ---------- - mol_column : ColumnElement + mol : ColumnElement[AnyBingoMol] SQLAlchemy column containing molecule data (SMILES, Molfile, or binary). - query : str + query : TextLike Query molecule as SMILES or Molfile string for exact matching. - parameters : str, optional + parameters : TextLike, optional Search parameters for customizing the matching behavior (default is ""). Examples: "TAU" for tautomer matching, "STE" for stereochemistry. @@ -92,15 +95,15 @@ def mol_equals( SQLAlchemy expression for exact matching that can be used in WHERE clauses. """ - return mol_column.op("@")(text(f"('{query}', '{parameters}')::bingo.exact")) + return mol.op("@")(text(f"('{query}', '{parameters}')::bingo.exact")) def similarity( - mol_column: ColumnElement[AnyBingoMol], - query: str, + mol: ColumnElement[AnyBingoMol], + query: TextLike, bottom: float = 0.0, top: float = 1.0, - metric: str = "Tanimoto", + metric: TextLike = "Tanimoto", ) -> BinaryExpression: """ Perform similarity search on a molecule column. This should be used in WHERE clauses, as it @@ -108,15 +111,15 @@ def similarity( Parameters ---------- - mol_column : ColumnElement + mol : AnyBingoMolLike | AnyBingoBinaryMolLike SQLAlchemy column containing molecule data (SMILES, Molfile, or binary). - query : str + query : TextLike Query molecule as SMILES or Molfile string for similarity comparison. bottom : float, optional Minimum similarity threshold (default is 0.0). top : float, optional Maximum similarity threshold (default is 1.0). - metric : str, optional + metric : TextLike, optional Similarity metric to use (default is "Tanimoto"). Other options include "Dice", "Cosine", etc. @@ -126,9 +129,7 @@ def similarity( SQLAlchemy expression for similarity matching that can be used in WHERE clauses. """ - return mol_column.op("%")( - text(f"('{query}', {bottom}, {top}, '{metric}')::bingo.sim") - ) + return mol.op("%")(text(f"('{query}', {bottom}, {top}, '{metric}')::bingo.sim")) class aam(GenericFunction): @@ -137,7 +138,7 @@ class aam(GenericFunction): def __init__( self, - rxn: str | sqltypes.Text | bytes | sqltypes.LargeBinary, + rxn: AnyBingoReactionLike | AnyBingoBinaryReactionLike, strategy: sqltypes.Text | Literal["CLEAR", "DISCARD", "ALTER", "KEEP"] = "KEEP", **kwargs: Any, ) -> None: @@ -170,7 +171,7 @@ class cansmiles(GenericFunction): name = "cansmiles" def __init__( - self, mol: str | sqltypes.Text | bytes | sqltypes.LargeBinary, **kwargs: Any + self, mol: AnyBingoMolLike | AnyBingoBinaryMolLike, **kwargs: Any ) -> None: """Generates the canonical SMILES for a molecule. @@ -195,7 +196,7 @@ class checkmolecule(GenericFunction): name = "checkmolecule" def __init__( - self, mol: str | sqltypes.Text | bytes | sqltypes.LargeBinary, **kwargs: Any + self, mol: AnyBingoMolLike | AnyBingoBinaryMolLike, **kwargs: Any ) -> None: """Check molecule for validity @@ -220,7 +221,7 @@ class checkreaction(GenericFunction): name = "checkreaction" def __init__( - self, rxn: str | sqltypes.Text | bytes | sqltypes.LargeBinary, **kwargs: Any + self, rxn: AnyBingoReactionLike | AnyBingoBinaryReactionLike, **kwargs: Any ) -> None: """Check reaction for validity @@ -245,7 +246,7 @@ class cml(GenericFunction): name = "cml" def __init__( - self, mol: str | sqltypes.Text | bytes | sqltypes.LargeBinary, **kwargs: Any + self, mol: AnyBingoMolLike | AnyBingoBinaryMolLike, **kwargs: Any ) -> None: """Converts a molecule to CML format. @@ -271,7 +272,7 @@ class compactmolecule(GenericFunction): def __init__( self, - mol: str | sqltypes.Text | bytes | sqltypes.LargeBinary, + mol: AnyBingoMolLike | AnyBingoBinaryMolLike, use_pos: sqltypes.Boolean | bool = False, **kwargs: Any, ) -> None: @@ -301,11 +302,11 @@ class compactreaction(GenericFunction): def __init__( self, - rxn: str | sqltypes.Text | bytes | sqltypes.LargeBinary, + rxn: AnyBingoReactionLike | AnyBingoBinaryReactionLike, use_pos: sqltypes.Boolean | bool = False, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `compactreaction`. + """Calls the bingo cartridge function `compactreaction`. Parameters ---------- @@ -398,7 +399,7 @@ class filetoblob(GenericFunction): name = "filetoblob" def __init__(self, arg_1: str | sqltypes.Text, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `filetoblob`. + """Calls the bingo cartridge function `filetoblob`. Parameters ---------- @@ -420,7 +421,7 @@ class filetotext(GenericFunction): name = "filetotext" def __init__(self, arg_1: str | sqltypes.Text, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `filetotext`. + """Calls the bingo cartridge function `filetotext`. Parameters ---------- @@ -447,7 +448,7 @@ def __init__( arg_2: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `fingerprint`. + """Calls the bingo cartridge function `fingerprint`. Parameters ---------- @@ -470,7 +471,7 @@ class getblockcount(GenericFunction): name = "getblockcount" def __init__(self, arg_1: str | sqltypes.Text, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `getblockcount`. + """Calls the bingo cartridge function `getblockcount`. Parameters ---------- @@ -492,7 +493,7 @@ class getindexstructurescount(GenericFunction): name = "getindexstructurescount" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `getindexstructurescount`. + """Calls the bingo cartridge function `getindexstructurescount`. Parameters ---------- @@ -514,9 +515,9 @@ class getmass(GenericFunction): name = "getmass" def __init__( - self, arg_1: str | sqltypes.Text | bytes | sqltypes.LargeBinary, **kwargs: Any + self, arg_1: AnyBingoMolLike | AnyBingoBinaryMolLike, **kwargs: Any ) -> None: - """Calls the rdkit cartridge function `getmass`. + """Calls the bingo cartridge function `getmass`. Parameters ---------- @@ -537,8 +538,8 @@ class getname(GenericFunction): inherit_cache = True name = "getname" - def __init__(self, arg_1: str | sqltypes.Text, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `getname`. + def __init__(self, arg_1: AnyBingoMolLike, **kwargs: Any) -> None: + """Calls the bingo cartridge function `getname`. Parameters ---------- @@ -561,12 +562,12 @@ class getsimilarity(GenericFunction): def __init__( self, - mol: str | sqltypes.Text | bytes | sqltypes.LargeBinary, - query: str | sqltypes.Text, - metric: str | sqltypes.Text = "tanimoto", + mol: AnyBingoMolLike | AnyBingoBinaryMolLike, + query: TextLike, + metric: TextLike | Literal["tanimoto", "euclid-sub"] = "tanimoto", **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `getsimilarity`. + """Calls the bingo cartridge function `getsimilarity`. Parameters ---------- @@ -593,7 +594,7 @@ class getstructurescount(GenericFunction): name = "getstructurescount" def __init__(self, arg_1: str | sqltypes.Text, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `getstructurescount`. + """Calls the bingo cartridge function `getstructurescount`. Parameters ---------- @@ -615,7 +616,7 @@ class getversion(GenericFunction): name = "getversion" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `getversion`. + """Calls the bingo cartridge function `getversion`. Parameters ---------- @@ -638,15 +639,15 @@ class getweight(GenericFunction): def __init__( self, - arg_1: str | sqltypes.Text | bytes | sqltypes.LargeBinary, + mol: AnyBingoMolLike | AnyBingoBinaryMolLike, arg_2: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `getweight`. + """Calls the bingo cartridge function `getweight`. Parameters ---------- - arg_1 + mol arg_2 kwargs : Any Additional keyword arguments passed to the `GenericFunction`. @@ -656,7 +657,7 @@ def __init__( Function[float | sqltypes.Float] SQLAlchemy function """ - super().__init__(arg_1, arg_2, **kwargs) + super().__init__(mol, arg_2, **kwargs) self.packagenames = ("bingo",) @@ -665,13 +666,13 @@ class gross(GenericFunction): name = "gross" def __init__( - self, arg_1: str | sqltypes.Text | bytes | sqltypes.LargeBinary, **kwargs: Any + self, mol: AnyBingoMolLike | AnyBingoBinaryMolLike, **kwargs: Any ) -> None: - """Calls the rdkit cartridge function `gross`. + """Calls the bingo cartridge function `gross`. Parameters ---------- - arg_1 + mol kwargs : Any Additional keyword arguments passed to the `GenericFunction`. @@ -680,7 +681,7 @@ def __init__( Function[str | sqltypes.Text] SQLAlchemy function """ - super().__init__(arg_1, **kwargs) + super().__init__(mol, **kwargs) self.packagenames = ("bingo",) @@ -690,13 +691,13 @@ class importrdf(GenericFunction): def __init__( self, - arg_1: str | sqltypes.Text, - arg_2: str | sqltypes.Text, - arg_3: str | sqltypes.Text, - arg_4: str | sqltypes.Text, + arg_1: TextLike, + arg_2: TextLike, + arg_3: TextLike, + arg_4: TextLike, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `importrdf`. + """Calls the bingo cartridge function `importrdf`. Parameters ---------- @@ -728,7 +729,7 @@ def __init__( arg_4: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `importsdf`. + """Calls the bingo cartridge function `importsdf`. Parameters ---------- @@ -760,7 +761,7 @@ def __init__( arg_4: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `importsmiles`. + """Calls the bingo cartridge function `importsmiles`. Parameters ---------- @@ -786,15 +787,15 @@ class inchi(GenericFunction): def __init__( self, - arg_1: str | sqltypes.Text | bytes | sqltypes.LargeBinary, + mol: AnyBingoMolLike | AnyBingoBinaryMolLike, arg_2: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `inchi`. + """Calls the bingo cartridge function `inchi`. Parameters ---------- - arg_1 + mol arg_2 kwargs : Any Additional keyword arguments passed to the `GenericFunction`. @@ -804,7 +805,7 @@ def __init__( Function[str | sqltypes.Text] SQLAlchemy function """ - super().__init__(arg_1, arg_2, **kwargs) + super().__init__(mol, arg_2, **kwargs) self.packagenames = ("bingo",) @@ -812,12 +813,12 @@ class inchikey(GenericFunction): inherit_cache = True name = "inchikey" - def __init__(self, arg_1: str | sqltypes.Text, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `inchikey`. + def __init__(self, mol: AnyBingoMolLike, **kwargs: Any) -> None: + """Calls the bingo cartridge function `inchikey`. Parameters ---------- - arg_1 + mol kwargs : Any Additional keyword arguments passed to the `GenericFunction`. @@ -826,7 +827,7 @@ def __init__(self, arg_1: str | sqltypes.Text, **kwargs: Any) -> None: Function[str | sqltypes.Text] SQLAlchemy function """ - super().__init__(arg_1, **kwargs) + super().__init__(mol, **kwargs) self.packagenames = ("bingo",) @@ -836,7 +837,7 @@ class matchexact(GenericFunction): name = "matchexact" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `matchexact`. + """Calls the bingo cartridge function `matchexact`. Parameters ---------- @@ -859,7 +860,7 @@ class matchgross(GenericFunction): name = "matchgross" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `matchgross`. + """Calls the bingo cartridge function `matchgross`. Parameters ---------- @@ -882,7 +883,7 @@ class matchrexact(GenericFunction): name = "matchrexact" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `matchrexact`. + """Calls the bingo cartridge function `matchrexact`. Parameters ---------- @@ -905,7 +906,7 @@ class matchrsmarts(GenericFunction): name = "matchrsmarts" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `matchrsmarts`. + """Calls the bingo cartridge function `matchrsmarts`. Parameters ---------- @@ -928,7 +929,7 @@ class matchrsub(GenericFunction): name = "matchrsub" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `matchrsub`. + """Calls the bingo cartridge function `matchrsub`. Parameters ---------- @@ -951,7 +952,7 @@ class matchsim(GenericFunction): name = "matchsim" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `matchsim`. + """Calls the bingo cartridge function `matchsim`. Parameters ---------- @@ -974,7 +975,7 @@ class matchsmarts(GenericFunction): name = "matchsmarts" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `matchsmarts`. + """Calls the bingo cartridge function `matchsmarts`. Parameters ---------- @@ -997,7 +998,7 @@ class matchsub(GenericFunction): name = "matchsub" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `matchsub`. + """Calls the bingo cartridge function `matchsub`. Parameters ---------- @@ -1019,13 +1020,13 @@ class molfile(GenericFunction): name = "molfile" def __init__( - self, arg_1: str | sqltypes.Text | bytes | sqltypes.LargeBinary, **kwargs: Any + self, mol: AnyBingoMolLike | AnyBingoBinaryMolLike, **kwargs: Any ) -> None: - """Calls the rdkit cartridge function `molfile`. + """Calls the bingo cartridge function `molfile`. Parameters ---------- - arg_1 + mol kwargs : Any Additional keyword arguments passed to the `GenericFunction`. @@ -1034,7 +1035,7 @@ def __init__( Function[str | sqltypes.Text] SQLAlchemy function """ - super().__init__(arg_1, **kwargs) + super().__init__(mol, **kwargs) self.packagenames = ("bingo",) @@ -1045,7 +1046,7 @@ class precachedatabase(GenericFunction): def __init__( self, arg_1: str | sqltypes.Text, arg_2: str | sqltypes.Text, **kwargs: Any ) -> None: - """Calls the rdkit cartridge function `precachedatabase`. + """Calls the bingo cartridge function `precachedatabase`. Parameters ---------- @@ -1068,13 +1069,13 @@ class rcml(GenericFunction): name = "rcml" def __init__( - self, arg_1: str | sqltypes.Text | bytes | sqltypes.LargeBinary, **kwargs: Any + self, rxn: AnyBingoReactionLike | AnyBingoBinaryReactionLike, **kwargs: Any ) -> None: - """Calls the rdkit cartridge function `rcml`. + """Calls the bingo cartridge function `rcml`. Parameters ---------- - arg_1 + rxn kwargs : Any Additional keyword arguments passed to the `GenericFunction`. @@ -1083,7 +1084,7 @@ def __init__( Function[str | sqltypes.Text] SQLAlchemy function """ - super().__init__(arg_1, **kwargs) + super().__init__(rxn, **kwargs) self.packagenames = ("bingo",) @@ -1093,15 +1094,15 @@ class rfingerprint(GenericFunction): def __init__( self, - arg_1: str | sqltypes.Text | bytes | sqltypes.LargeBinary, + rxn: AnyBingoReactionLike | AnyBingoBinaryReactionLike, arg_2: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `rfingerprint`. + """Calls the bingo cartridge function `rfingerprint`. Parameters ---------- - arg_1 + rxn arg_2 kwargs : Any Additional keyword arguments passed to the `GenericFunction`. @@ -1111,7 +1112,7 @@ def __init__( Function[bytes | sqltypes.LargeBinary] SQLAlchemy function """ - super().__init__(arg_1, arg_2, **kwargs) + super().__init__(rxn, arg_2, **kwargs) self.packagenames = ("bingo",) @@ -1120,13 +1121,13 @@ class rsmiles(GenericFunction): name = "rsmiles" def __init__( - self, arg_1: str | sqltypes.Text | bytes | sqltypes.LargeBinary, **kwargs: Any + self, rxn: AnyBingoReactionLike | AnyBingoBinaryReactionLike, **kwargs: Any ) -> None: - """Calls the rdkit cartridge function `rsmiles`. + """Calls the bingo cartridge function `rsmiles`. Parameters ---------- - arg_1 + rxn kwargs : Any Additional keyword arguments passed to the `GenericFunction`. @@ -1135,7 +1136,7 @@ def __init__( Function[str | sqltypes.Text] SQLAlchemy function """ - super().__init__(arg_1, **kwargs) + super().__init__(rxn, **kwargs) self.packagenames = ("bingo",) @@ -1144,13 +1145,13 @@ class rxnfile(GenericFunction): name = "rxnfile" def __init__( - self, arg_1: str | sqltypes.Text | bytes | sqltypes.LargeBinary, **kwargs: Any + self, rxn: AnyBingoReactionLike | AnyBingoBinaryReactionLike, **kwargs: Any ) -> None: - """Calls the rdkit cartridge function `rxnfile`. + """Calls the bingo cartridge function `rxnfile`. Parameters ---------- - arg_1 + rxn kwargs : Any Additional keyword arguments passed to the `GenericFunction`. @@ -1159,7 +1160,7 @@ def __init__( Function[str | sqltypes.Text] SQLAlchemy function """ - super().__init__(arg_1, **kwargs) + super().__init__(rxn, **kwargs) self.packagenames = ("bingo",) @@ -1168,13 +1169,13 @@ class smiles(GenericFunction): name = "smiles" def __init__( - self, arg_1: str | sqltypes.Text | bytes | sqltypes.LargeBinary, **kwargs: Any + self, mol: AnyBingoMolLike | AnyBingoBinaryMolLike, **kwargs: Any ) -> None: - """Calls the rdkit cartridge function `smiles`. + """Calls the bingo cartridge function `smiles`. Parameters ---------- - arg_1 + mol kwargs : Any Additional keyword arguments passed to the `GenericFunction`. @@ -1183,7 +1184,7 @@ def __init__( Function[str | sqltypes.Text] SQLAlchemy function """ - super().__init__(arg_1, **kwargs) + super().__init__(mol, **kwargs) self.packagenames = ("bingo",) @@ -1193,15 +1194,15 @@ class standardize(GenericFunction): def __init__( self, - arg_1: str | sqltypes.Text | bytes | sqltypes.LargeBinary, + mol: AnyBingoMolLike | AnyBingoBinaryMolLike, arg_2: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `standardize`. + """Calls the bingo cartridge function `standardize`. Parameters ---------- - arg_1 + mol arg_2 kwargs : Any Additional keyword arguments passed to the `GenericFunction`. @@ -1211,5 +1212,5 @@ def __init__( Function[str | sqltypes.Text] SQLAlchemy function """ - super().__init__(arg_1, arg_2, **kwargs) + super().__init__(mol, arg_2, **kwargs) self.packagenames = ("bingo",) diff --git a/src/molalchemy/bingo/functions/internal.py b/src/molalchemy/bingo/functions/internal.py index 6775549..474a6b3 100644 --- a/src/molalchemy/bingo/functions/internal.py +++ b/src/molalchemy/bingo/functions/internal.py @@ -22,7 +22,7 @@ def __init__( arg_3: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `_exact_internal`. + """Calls the bingo cartridge function `_exact_internal`. Parameters ---------- @@ -46,7 +46,7 @@ class _get_block_count(GenericFunction): name = "_get_block_count" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `_get_block_count`. + """Calls the bingo cartridge function `_get_block_count`. Parameters ---------- @@ -69,7 +69,7 @@ class _get_profiling_info(GenericFunction): name = "_get_profiling_info" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `_get_profiling_info`. + """Calls the bingo cartridge function `_get_profiling_info`. Parameters ---------- @@ -91,7 +91,7 @@ class _get_structures_count(GenericFunction): name = "_get_structures_count" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `_get_structures_count`. + """Calls the bingo cartridge function `_get_structures_count`. Parameters ---------- @@ -120,7 +120,7 @@ def __init__( arg_3: str | sqltypes.Text | bytes | sqltypes.LargeBinary, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `_gross_internal`. + """Calls the bingo cartridge function `_gross_internal`. Parameters ---------- @@ -150,7 +150,7 @@ def __init__( arg_3: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `_internal_func_011`. + """Calls the bingo cartridge function `_internal_func_011`. Parameters ---------- @@ -176,7 +176,7 @@ class _internal_func_012(GenericFunction): def __init__( self, arg_1: int | sqltypes.Integer, arg_2: str | sqltypes.Text, **kwargs: Any ) -> None: - """Calls the rdkit cartridge function `_internal_func_012`. + """Calls the bingo cartridge function `_internal_func_012`. Parameters ---------- @@ -200,7 +200,7 @@ class _internal_func_check(GenericFunction): name = "_internal_func_check" def __init__(self, arg_1: int | sqltypes.Integer, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `_internal_func_check`. + """Calls the bingo cartridge function `_internal_func_check`. Parameters ---------- @@ -223,7 +223,7 @@ class _match_mass_great(GenericFunction): name = "_match_mass_great" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `_match_mass_great`. + """Calls the bingo cartridge function `_match_mass_great`. Parameters ---------- @@ -246,7 +246,7 @@ class _match_mass_less(GenericFunction): name = "_match_mass_less" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `_match_mass_less`. + """Calls the bingo cartridge function `_match_mass_less`. Parameters ---------- @@ -268,7 +268,7 @@ class _precache_database(GenericFunction): name = "_precache_database" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `_precache_database`. + """Calls the bingo cartridge function `_precache_database`. Parameters ---------- @@ -290,7 +290,7 @@ class _print_profiling_info(GenericFunction): name = "_print_profiling_info" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `_print_profiling_info`. + """Calls the bingo cartridge function `_print_profiling_info`. Parameters ---------- @@ -312,7 +312,7 @@ class _reset_profiling_info(GenericFunction): name = "_reset_profiling_info" def __init__(self, **kwargs: Any) -> None: - """Calls the rdkit cartridge function `_reset_profiling_info`. + """Calls the bingo cartridge function `_reset_profiling_info`. Parameters ---------- @@ -341,7 +341,7 @@ def __init__( arg_3: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `_rexact_internal`. + """Calls the bingo cartridge function `_rexact_internal`. Parameters ---------- @@ -372,7 +372,7 @@ def __init__( arg_3: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `_rsmarts_internal`. + """Calls the bingo cartridge function `_rsmarts_internal`. Parameters ---------- @@ -403,7 +403,7 @@ def __init__( arg_3: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `_rsub_internal`. + """Calls the bingo cartridge function `_rsub_internal`. Parameters ---------- @@ -436,7 +436,7 @@ def __init__( arg_5: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `_sim_internal`. + """Calls the bingo cartridge function `_sim_internal`. Parameters ---------- @@ -469,7 +469,7 @@ def __init__( arg_3: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `_smarts_internal`. + """Calls the bingo cartridge function `_smarts_internal`. Parameters ---------- @@ -500,7 +500,7 @@ def __init__( arg_3: str | sqltypes.Text, **kwargs: Any, ) -> None: - """Calls the rdkit cartridge function `_sub_internal`. + """Calls the bingo cartridge function `_sub_internal`. Parameters ---------- diff --git a/src/molalchemy/bingo/types.py b/src/molalchemy/bingo/types.py index 5fa0104..fa7178d 100644 --- a/src/molalchemy/bingo/types.py +++ b/src/molalchemy/bingo/types.py @@ -4,7 +4,7 @@ chemical molecules and reactions in PostgreSQL using the Bingo cartridge. """ -from typing import Literal +from typing import Any, Literal from sqlalchemy import func from sqlalchemy.types import UserDefinedType @@ -58,7 +58,10 @@ class BingoMol(BingoBaseType): cache_ok = True comparator_factory = BingoMolComparator - def get_col_spec(self): + def __repr__(self): + return "BingoMol()" + + def get_col_spec(self, **kwargs: Any) -> str: """Get the column specification for this type. Returns @@ -143,28 +146,24 @@ def __init__( self.return_type = return_type super().__init__() - def get_col_spec(self): - """Get the column specification for this type. + def __repr__(self): + return f"BingoBinaryMol(preserve_pos={self.preserve_pos!r}, return_type={self.return_type!r})" - Returns - ------- - str - The PostgreSQL column type specification ("bytea"). - """ + def get_col_spec(self, **kwargs: Any) -> str: return "bytea" def bind_expression(self, bindvalue): return func.Bingo.CompactMolecule(bindvalue, self.preserve_pos) - def column_expression(self, col): + def column_expression(self, colexpr): if self.return_type == "smiles": - return func.Bingo.smiles(col) + return func.Bingo.smiles(colexpr) elif self.return_type == "molfile": - return func.Bingo.molfile(col) + return func.Bingo.molfile(colexpr) elif self.return_type == "cml": - return func.Bingo.cml(col) + return func.Bingo.cml(colexpr) elif self.return_type == "bytes": - return col + return colexpr else: raise ValueError( f"Invalid return_type: {self.return_type}. Available options are 'smiles', 'molfile', 'cml', 'bytes'." @@ -218,14 +217,10 @@ class BingoReaction(BingoBaseType): cache_ok = True comparator_factory = BingoRxnComparator - def get_col_spec(self): - """Get the column specification for this type. + def __repr__(self): + return "BingoReaction()" - Returns - ------- - str - The PostgreSQL column type specification ("varchar"). - """ + def get_col_spec(self, **kwargs: Any) -> str: return "varchar" @@ -274,12 +269,8 @@ class BingoBinaryReaction(BingoBaseType): cache_ok = True comparator_factory = BingoRxnComparator - def get_col_spec(self): - """Get the column specification for this type. + def __repr__(self): + return "BingoBinaryReaction()" - Returns - ------- - str - The PostgreSQL column type specification ("bytea"). - """ + def get_col_spec(self, **kwargs: Any) -> str: return "bytea" diff --git a/src/molalchemy/helpers.py b/src/molalchemy/helpers.py index addcfa4..4df64ed 100644 --- a/src/molalchemy/helpers.py +++ b/src/molalchemy/helpers.py @@ -1,3 +1,5 @@ +"""Helper functions for working with Bingo molecule and reaction columns in modern IDEs. Work iprogress""" + from sqlalchemy import Column from sqlalchemy.orm.attributes import InstrumentedAttribute @@ -38,7 +40,7 @@ def bingo_col(column: Column | InstrumentedAttribute) -> BingoMolProxy: """ if isinstance(column, InstrumentedAttribute | Column): if isinstance(column.type, BingoMol) or isinstance(column.type, BingoBinaryMol): - return column + return column # type: ignore else: raise TypeError("Column is not of type BingoMol or BingoBinaryMol") else: @@ -77,7 +79,7 @@ def bingo_rxn_col(column: Column | InstrumentedAttribute) -> BingoRxnProxy: if isinstance(column.type, BingoReaction) or isinstance( column.type, BingoBinaryReaction ): - return column + return column # type: ignore else: raise TypeError( "Column is not of type BingoReaction or BingoBinaryReaction" diff --git a/src/molalchemy/rdkit/__init__.py b/src/molalchemy/rdkit/__init__.py index fd7cc59..e3cc9c6 100644 --- a/src/molalchemy/rdkit/__init__.py +++ b/src/molalchemy/rdkit/__init__.py @@ -1,8 +1,22 @@ from .comparators import RdkitFPComparator, RdkitMolComparator from .index import RdkitIndex +from .types import ( + RdkitBitFingerprint, + RdkitMol, + RdkitQMol, + RdkitReaction, + RdkitSparseFingerprint, + RdkitXQMol, +) __all__ = [ + "RdkitBitFingerprint", "RdkitFPComparator", "RdkitIndex", + "RdkitMol", "RdkitMolComparator", + "RdkitQMol", + "RdkitReaction", + "RdkitSparseFingerprint", + "RdkitXQMol", ] diff --git a/src/molalchemy/rdkit/comparators.py b/src/molalchemy/rdkit/comparators.py index b4182c4..6343323 100644 --- a/src/molalchemy/rdkit/comparators.py +++ b/src/molalchemy/rdkit/comparators.py @@ -5,9 +5,15 @@ class RdkitMolComparator(UserDefinedType.Comparator): def has_substructure(self, query): + """Check if this molecule contains `query` as a substructure (@>).""" return self.expr.op("@>")(query) + def is_substructure_of(self, query): + """Check if this molecule is a substructure of `query` (<@).""" + return self.expr.op("<@")(query) + def equals(self, query): + """Check if this molecule is equal to `query` (@=).""" return self.expr.op("@=")(query) @@ -18,9 +24,18 @@ def nearest_neighbors(self, query, type: Literal["tanimoto", "dice"] = "tanimoto else: # dice return self.expr.op("<#>")(query) - def dice(self, query_fp): + def tanimoto(self, query_fp): + """Tanimoto similarity threshold operator (%). + + Returns whether or not the Tanimoto similarity between two fingerprints + (either two sfp or two bfp values) exceeds rdkit.tanimoto_threshold. """ - operator used for similarity searches using Dice similarity. - Returns whether or not the Dice similarity between two fingerprints (either two sfp or two bfp values) exceeds rdkit.dice_threshold. + return self.expr.op("%")(query_fp) + + def dice(self, query_fp): + """Dice similarity threshold operator (#). + + Returns whether or not the Dice similarity between two fingerprints + (either two sfp or two bfp values) exceeds rdkit.dice_threshold. """ return self.expr.op("#")(query_fp) diff --git a/src/molalchemy/rdkit/functions/_types.py b/src/molalchemy/rdkit/functions/_types.py new file mode 100644 index 0000000..148f24f --- /dev/null +++ b/src/molalchemy/rdkit/functions/_types.py @@ -0,0 +1,95 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, TypeVar + +from sqlalchemy import Column, Function +from sqlalchemy.orm import InstrumentedAttribute, Mapped + +from molalchemy.rdkit.types import ( + RdkitBitFingerprint, + RdkitMol, + RdkitQMol, + RdkitReaction, + RdkitSparseFingerprint, + RdkitXQMol, +) + +""" +Type aliases for RDKit-SQLAlchemy integration. +These aliases make it easier to annotate columns, mapped attributes, +and SQL functions that return RDKit objects (Mol, QMol, ...) while still +supporting literal values (e.g. SMILES strings) and raw bytes. +""" + +# Python 3.10+ has TypeAlias built-in; otherwise fall back to typing_extensions. +if TYPE_CHECKING: + from typing import TypeAlias # pragma: no cover +else: + try: + from typing import TypeAlias # type: ignore + except ImportError: # pragma: no cover + from typing import TypeAlias # type: ignore + +T = TypeVar("T") +SQLAlchemyCoercible: TypeAlias = ( + InstrumentedAttribute[T] | Column[T] | Mapped[T] | Function[T] +) + +LiteralStrBytes: TypeAlias = str | bytes + +# Text-like types for string/bytes inputs +TextLike: TypeAlias = ( + str | bytes | Column[str] | Mapped[str] | InstrumentedAttribute[str] +) + +# ---------------------------------------------------------------------- +# RDKit specific type aliases +# ---------------------------------------------------------------------- +RdkitMolCoercible: TypeAlias = RdkitMol | LiteralStrBytes +AnyRdkitMolLike: TypeAlias = SQLAlchemyCoercible[RdkitMolCoercible] | RdkitMolCoercible +RdkitQMolCoercible: TypeAlias = RdkitQMol | LiteralStrBytes +AnyRdkitQMolLike: TypeAlias = ( + SQLAlchemyCoercible[RdkitQMolCoercible] | RdkitQMolCoercible +) +RdkitXQMolCoercible: TypeAlias = RdkitXQMol | LiteralStrBytes +AnyRdkitXQMolLike: TypeAlias = ( + SQLAlchemyCoercible[RdkitXQMolCoercible] | RdkitXQMolCoercible +) +RdkitBitFingerprintCoercible: TypeAlias = RdkitBitFingerprint | LiteralStrBytes +AnyRdkitBitFingerprintLike: TypeAlias = ( + SQLAlchemyCoercible[RdkitBitFingerprintCoercible] | RdkitBitFingerprintCoercible +) +RdkitSparseFingerprintCoercible: TypeAlias = RdkitSparseFingerprint | LiteralStrBytes +AnyRdkitSparseFingerprintLike: TypeAlias = ( + SQLAlchemyCoercible[RdkitSparseFingerprintCoercible] + | RdkitSparseFingerprintCoercible +) +RdkitReactionCoercible: TypeAlias = RdkitReaction | LiteralStrBytes +AnyRdkitReactionLike: TypeAlias = ( + SQLAlchemyCoercible[RdkitReactionCoercible] | RdkitReactionCoercible +) + +# ---------------------------------------------------------------------- +# Combined fingerprint alias - convenient for functions that accept either. +# ---------------------------------------------------------------------- +AnyRdkitFingerprintLike: TypeAlias = ( + AnyRdkitBitFingerprintLike | AnyRdkitSparseFingerprintLike +) + +__all__ = [ + "AnyRdkitBitFingerprintLike", + "AnyRdkitFingerprintLike", + "AnyRdkitMolLike", + "AnyRdkitQMolLike", + "AnyRdkitReactionLike", + "AnyRdkitSparseFingerprintLike", + "AnyRdkitXQMolLike", + "RdkitBitFingerprintCoercible", + "RdkitMolCoercible", + "RdkitQMolCoercible", + "RdkitReactionCoercible", + "RdkitSparseFingerprintCoercible", + "RdkitXQMolCoercible", + "SQLAlchemyCoercible", + "TextLike", +] diff --git a/src/molalchemy/rdkit/functions/general.py b/src/molalchemy/rdkit/functions/general.py index c94b709..120c395 100644 --- a/src/molalchemy/rdkit/functions/general.py +++ b/src/molalchemy/rdkit/functions/general.py @@ -21,6 +21,16 @@ ) from molalchemy.types import CString +from ._types import ( + AnyRdkitBitFingerprintLike, + AnyRdkitFingerprintLike, + AnyRdkitMolLike, + AnyRdkitQMolLike, + AnyRdkitReactionLike, + AnyRdkitSparseFingerprintLike, + AnyRdkitXQMolLike, +) + def mol_has_substructure( mol_column: ColumnElement[RdkitMol], query: str @@ -87,7 +97,10 @@ class add(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitSparseFingerprint, fp_2: RdkitSparseFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitSparseFingerprintLike, + fp_2: AnyRdkitSparseFingerprintLike, + **kwargs: Any, ) -> None: """Calls the rdkit cartridge function `add`. @@ -113,7 +126,10 @@ class all_values_gt(GenericFunction): inherit_cache = True def __init__( - self, fp: RdkitSparseFingerprint, value: int | sqltypes.Integer, **kwargs: Any + self, + fp: AnyRdkitSparseFingerprintLike, + value: int | sqltypes.Integer, + **kwargs: Any, ) -> None: """Returns a boolean indicating whether or not all elements of the sfp argument are greater than the int argument. @@ -139,7 +155,10 @@ class all_values_lt(GenericFunction): inherit_cache = True def __init__( - self, fp: RdkitSparseFingerprint, value: int | sqltypes.Integer, **kwargs: Any + self, + fp: AnyRdkitSparseFingerprintLike, + value: int | sqltypes.Integer, + **kwargs: Any, ) -> None: """Returns a boolean indicating whether or not all elements of the sfp argument are less than the int argument. @@ -164,7 +183,7 @@ class atompair_fp(GenericFunction): type = RdkitSparseFingerprint() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns an sfp which is the count-based atom-pair fingerprint for a molecule. Parameters @@ -186,7 +205,7 @@ class atompairbv_fp(GenericFunction): type = RdkitBitFingerprint() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns a bit vector atom-pair fingerprint for a molecule. Parameters @@ -210,7 +229,7 @@ class avalon_fp(GenericFunction): def __init__( self, - mol: RdkitMol, + mol: AnyRdkitMolLike, arg_2: sqltypes.Boolean, arg_3: int | sqltypes.Integer, **kwargs: Any, @@ -263,7 +282,10 @@ class bfp_le(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitBitFingerprint, fp_2: RdkitBitFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitBitFingerprintLike, + fp_2: AnyRdkitBitFingerprintLike, + **kwargs: Any, ) -> None: """Returns whether the first bit fingerprint is less than or equal to the second bit fingerprint. Used for operator overloading. @@ -288,7 +310,7 @@ class bfp_to_binary_text(GenericFunction): type = sqltypes.LargeBinary() inherit_cache = True - def __init__(self, fp: RdkitBitFingerprint, **kwargs: Any) -> None: + def __init__(self, fp: AnyRdkitBitFingerprintLike, **kwargs: Any) -> None: """Calls the rdkit cartridge function `bfp_to_binary_text`. Parameters @@ -311,7 +333,10 @@ class dice_dist(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitBitFingerprint, fp_2: RdkitBitFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitBitFingerprintLike, + fp_2: AnyRdkitBitFingerprintLike, + **kwargs: Any, ) -> None: """Returns the Dice distance between two fingerprints of the same type (either two sfp or two bfp values). @@ -338,8 +363,8 @@ class dice_sml(GenericFunction): def __init__( self, - fp_1: RdkitSparseFingerprint | RdkitBitFingerprint, - fp_2: RdkitSparseFingerprint | RdkitBitFingerprint, + fp_1: AnyRdkitFingerprintLike, + fp_2: AnyRdkitFingerprintLike, **kwargs: Any, ) -> None: """Returns the Dice similarity between two fingerprints of the same type (either two sparse fingerprints or two bit vector fingerprints). @@ -367,8 +392,8 @@ class dice_sml_op(GenericFunction): def __init__( self, - arg_1: RdkitSparseFingerprint | RdkitBitFingerprint, - arg_2: RdkitSparseFingerprint | RdkitBitFingerprint, + arg_1: AnyRdkitFingerprintLike, + arg_2: AnyRdkitFingerprintLike, **kwargs: Any, ) -> None: """Returns the Dice similarity between two fingerprints of the same type (either two sfp or two bfp values). @@ -395,7 +420,7 @@ class featmorgan_fp(GenericFunction): inherit_cache = True def __init__( - self, mol: RdkitMol, radius: int | sqltypes.Integer = 2, **kwargs: Any + self, mol: AnyRdkitMolLike, radius: int | sqltypes.Integer = 2, **kwargs: Any ) -> None: """Returns a count-based Morgan fingerprint for a molecule using chemical-feature invariants. This is an FCFP-like fingerprint. @@ -421,7 +446,7 @@ class featmorganbv_fp(GenericFunction): inherit_cache = True def __init__( - self, mol: RdkitMol, radius: int | sqltypes.Integer = 2, **kwargs: Any + self, mol: AnyRdkitMolLike, radius: int | sqltypes.Integer = 2, **kwargs: Any ) -> None: """Returns a bit vector Morgan fingerprint for a molecule using chemical-feature invariants. The second argument provides the radius. This is an FCFP-like fingerprint. @@ -446,7 +471,7 @@ class fmcs(GenericFunction): type = sqltypes.Text() inherit_cache = True - def __init__(self, mols: RdkitMol | sqltypes.Text, **kwargs: Any) -> None: + def __init__(self, mols: AnyRdkitMolLike, **kwargs: Any) -> None: """An aggregation function that calculates the Maximum Common Substructure (MCS) for a set of molecules. Parameters @@ -585,7 +610,7 @@ class layered_fp(GenericFunction): type = RdkitBitFingerprint() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns a bit vector which is the layered fingerprint for a molecule. This is an experimental substructure fingerprint using hashed molecular subgraphs. Parameters @@ -607,7 +632,7 @@ class maccs_fp(GenericFunction): type = RdkitBitFingerprint() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns a bit vector which is the MACCS fingerprint for a molecule. Parameters @@ -631,7 +656,7 @@ class mol_adjust_query_properties(GenericFunction): def __init__( self, - mol: RdkitMol | RdkitQMol, + mol: AnyRdkitMolLike | AnyRdkitQMolLike, query_parameters: CString | Cast[Any] = cast("", CString), **kwargs: Any, ) -> None: @@ -658,7 +683,7 @@ class mol_amw(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the AMW for a molecule. Parameters @@ -680,7 +705,7 @@ class mol_chi0n(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the Chi0n value for a molecule. Parameters @@ -702,7 +727,7 @@ class mol_chi0v(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the Chi0v value for a molecule. Parameters @@ -724,7 +749,7 @@ class mol_chi1n(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, arg_1: RdkitMol, **kwargs: Any) -> None: + def __init__(self, arg_1: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the Chi1n value for a molecule. Parameters @@ -746,7 +771,7 @@ class mol_chi1v(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the Chi1v value for a molecule. Parameters @@ -768,7 +793,7 @@ class mol_chi2n(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the Chi2n value for a molecule. Parameters @@ -790,7 +815,7 @@ class mol_chi2v(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the Chi2v value for a molecule. Parameters @@ -812,7 +837,7 @@ class mol_chi3n(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the Chi3n value for a molecule. Parameters @@ -834,7 +859,7 @@ class mol_chi3v(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the Chi3v value for a molecule. Parameters @@ -856,7 +881,7 @@ class mol_chi4n(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the Chi4n value for a molecule. Parameters @@ -878,7 +903,7 @@ class mol_chi4v(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the Chi4v value for a molecule. Parameters @@ -900,7 +925,7 @@ class mol_exactmw(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the exact molecular weight for a molecule. Parameters @@ -924,7 +949,7 @@ class mol_formula(GenericFunction): def __init__( self, - mol: RdkitMol, + mol: AnyRdkitMolLike, include_isotopes: bool | sqltypes.Boolean = False, use_deuterium_tritium_symbols: bool | sqltypes.Boolean = True, **kwargs: Any, @@ -954,7 +979,7 @@ class mol_fractioncsp3(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the fraction of carbons that are sp3 hybridized in a molecule. Parameters @@ -1066,7 +1091,7 @@ class mol_hallkieralpha(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the Hall-Kier alpha value for a molecule. Parameters @@ -1087,7 +1112,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_hba(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Calls the rdkit cartridge function `mol_hba`. Parameters @@ -1108,7 +1133,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_hbd(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of Lipinski H-bond donors (i.e. number of Os and Ns that have at least one H) for a molecule. Parameters @@ -1130,7 +1155,7 @@ class mol_inchi(GenericFunction): type = CString() inherit_cache = True - def __init__(self, mol: RdkitMol, arg_2: CString, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, arg_2: CString, **kwargs: Any) -> None: """Returns an InChI (International Chemical Identifier) for the given molecule. This function requires that the RDKit be built with InChI support. Parameters @@ -1154,7 +1179,7 @@ class mol_inchikey(GenericFunction): type = CString() inherit_cache = True - def __init__(self, mol: RdkitMol, arg_2: CString, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, arg_2: CString, **kwargs: Any) -> None: """Returns an InChI key for the molecule. Requires RDKit to be built with InChI support. Parameters @@ -1178,7 +1203,7 @@ class mol_kappa1(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the kappa1 value for a molecule. Parameters @@ -1200,7 +1225,7 @@ class mol_kappa2(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the kappa2 value for a molecule. Parameters @@ -1222,7 +1247,7 @@ class mol_kappa3(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol_1: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol_1: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the kappa3 value for a molecule. Parameters @@ -1244,7 +1269,7 @@ class mol_labuteasa(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns Labute's approximate surface area (ASA) for a molecule. Parameters @@ -1266,7 +1291,7 @@ class mol_logp(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the MolLogP for a molecule. Parameters @@ -1288,7 +1313,7 @@ class mol_murckoscaffold(GenericFunction): type = RdkitMol() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the Murcko scaffold for a molecule. The Murcko scaffold consists of all ring systems and the atoms connecting them. Parameters @@ -1312,7 +1337,7 @@ class mol_nm_hash(GenericFunction): def __init__( self, - mol: RdkitMol, + mol: AnyRdkitMolLike, hash_type: CString | Cast[Any] = cast("AnonymousGraph", CString), **kwargs: Any, ) -> None: @@ -1338,7 +1363,7 @@ def __init__( class mol_numaliphaticcarbocycles(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of aliphatic (at least one non-aromatic bond) carbocycles in a molecule. Parameters @@ -1359,7 +1384,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numaliphaticheterocycles(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of aliphatic (at least one non-aromatic bond) heterocycles in a molecule. Parameters @@ -1380,7 +1405,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numaliphaticrings(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of aliphatic (at least one non-aromatic bond) rings in a molecule. Parameters @@ -1401,7 +1426,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numamidebonds(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of amide bonds in a molecule. Parameters @@ -1422,7 +1447,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numaromaticcarbocycles(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Calls the rdkit cartridge function `mol_numaromaticcarbocycles`. Parameters @@ -1443,7 +1468,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numaromaticheterocycles(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of aromatic heterocycles in a molecule. Parameters @@ -1464,7 +1489,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numaromaticrings(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of aromatic rings in a molecule. Parameters @@ -1485,7 +1510,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numatoms(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the total number of atoms in a molecule. Parameters @@ -1506,7 +1531,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numbridgeheadatoms(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of bridgehead atoms in a molecule. Parameters @@ -1527,7 +1552,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numheavyatoms(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of heavy atoms in a molecule. Parameters @@ -1548,7 +1573,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numheteroatoms(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of heteroatoms in a molecule. Parameters @@ -1569,7 +1594,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numheterocycles(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of heterocycles in a molecule. Parameters @@ -1590,7 +1615,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numrings(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of rings in a molecule. Parameters @@ -1611,7 +1636,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numrotatablebonds(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of rotatable bonds in a molecule. Parameters @@ -1632,7 +1657,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numsaturatedcarbocycles(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of saturated carbocycles in a molecule. Parameters @@ -1653,7 +1678,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numsaturatedheterocycles(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of saturated heterocycles in a molecule. Parameters @@ -1674,7 +1699,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numsaturatedrings(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of saturated rings in a molecule. Parameters @@ -1695,7 +1720,7 @@ def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: class mol_numspiroatoms(GenericFunction): inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the number of spiro atoms in a molecule. Parameters @@ -1717,7 +1742,7 @@ class mol_phi(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the Kier Phi value for a molecule. Parameters @@ -1739,7 +1764,7 @@ class mol_send(GenericFunction): type = sqltypes.LargeBinary() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Serializes an RDKit molecule into a binary string representation. Parameters @@ -1763,7 +1788,7 @@ class mol_to_ctab(GenericFunction): def __init__( self, - mol: RdkitMol, + mol: AnyRdkitMolLike, arg_2: sqltypes.Boolean | bool = True, arg_3: sqltypes.Boolean | bool = False, **kwargs: Any, @@ -1791,7 +1816,7 @@ class mol_to_cxsmarts(GenericFunction): type = CString() inherit_cache = True - def __init__(self, mol: RdkitMol | RdkitQMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike | AnyRdkitQMolLike, **kwargs: Any) -> None: """Returns the CXSMARTS for a molecule. Parameters @@ -1813,7 +1838,7 @@ class mol_to_cxsmiles(GenericFunction): type = CString() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the CXSMILES for a molecule. Parameters @@ -1835,7 +1860,7 @@ class mol_to_json(GenericFunction): type = CString() inherit_cache = True - def __init__(self, mol: RdkitMol | RdkitQMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike | AnyRdkitQMolLike, **kwargs: Any) -> None: """Returns the commonchem JSON for a molecule. (*available from the 2021_09 release*) Parameters @@ -1857,7 +1882,7 @@ class mol_to_pkl(GenericFunction): type = sqltypes.LargeBinary() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns a binary string (bytea) for a molecule. This function is available from the Q3 2012 (2012_09) release. Parameters @@ -1879,7 +1904,7 @@ class mol_to_smarts(GenericFunction): type = CString() inherit_cache = True - def __init__(self, mol: RdkitMol | RdkitQMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike | AnyRdkitQMolLike, **kwargs: Any) -> None: """Returns the SMARTS string for a molecule. Parameters @@ -1901,7 +1926,7 @@ class mol_to_smiles(GenericFunction): type = CString() inherit_cache = True - def __init__(self, mol: RdkitMol | RdkitQMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike | AnyRdkitQMolLike, **kwargs: Any) -> None: """Returns a canonical SMILES string for a molecule. Parameters @@ -1925,7 +1950,7 @@ class mol_to_svg(GenericFunction): def __init__( self, - mol: RdkitMol | RdkitQMol, + mol: AnyRdkitMolLike | AnyRdkitQMolLike, arg_2: CString | Cast[Any] = cast("", CString), width: int | sqltypes.Integer = 250, height: int | sqltypes.Integer = 200, @@ -1962,7 +1987,7 @@ class mol_to_v3kctab(GenericFunction): def __init__( self, - mol: RdkitMol, + mol: AnyRdkitMolLike, create_depiction: sqltypes.Boolean | bool = True, **kwargs: Any, ) -> None: @@ -1991,7 +2016,7 @@ class mol_to_xqmol(GenericFunction): def __init__( self, - arg_1: RdkitMol, + arg_1: AnyRdkitMolLike, arg_2: sqltypes.Boolean, arg_3: sqltypes.Boolean, arg_4: sqltypes.Boolean, @@ -2027,7 +2052,7 @@ class mol_tpsa(GenericFunction): type = sqltypes.Float() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns the topological polar surface area for a molecule. Parameters @@ -2050,7 +2075,7 @@ class morgan_fp(GenericFunction): inherit_cache = True def __init__( - self, mol: RdkitMol, radius: int | sqltypes.Integer = 2, **kwargs: Any + self, mol: AnyRdkitMolLike, radius: int | sqltypes.Integer = 2, **kwargs: Any ) -> None: """Returns a count-based Morgan fingerprint (sfp) for a molecule using connectivity invariants. This is an ECFP-like fingerprint. @@ -2076,7 +2101,7 @@ class morganbv_fp(GenericFunction): inherit_cache = True def __init__( - self, mol: RdkitMol, radius: int | sqltypes.Integer = 2, **kwargs: Any + self, mol: AnyRdkitMolLike, radius: int | sqltypes.Integer = 2, **kwargs: Any ) -> None: """Returns a bit vector Morgan fingerprint (bfp) for a molecule using connectivity invariants. The second argument provides the radius. This is an ECFP-like fingerprint. @@ -2193,7 +2218,7 @@ class qmol_send(GenericFunction): type = sqltypes.LargeBinary() inherit_cache = True - def __init__(self, mol: RdkitQMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitQMolLike, **kwargs: Any) -> None: """Returns a binary string (bytea) for a query molecule. Parameters @@ -2215,7 +2240,7 @@ class rdkit_fp(GenericFunction): type = RdkitBitFingerprint() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns a bit vector fingerprint (bfp) which is the RDKit fingerprint for a molecule. This is a daylight-inspired fingerprint using hashed molecular subgraphs. Parameters @@ -2280,7 +2305,10 @@ class reaction_difference_fp(GenericFunction): inherit_cache = True def __init__( - self, rxn_1: RdkitReaction, fp_type: int | sqltypes.Integer, **kwargs: Any + self, + rxn_1: AnyRdkitReactionLike, + fp_type: int | sqltypes.Integer, + **kwargs: Any, ) -> None: """Calculates a sparse fingerprint representing the difference between reactants and products in an RDKit reaction. @@ -2370,7 +2398,7 @@ def __init__(self, rxn_str: CString, **kwargs: Any) -> None: class reaction_numagents(GenericFunction): inherit_cache = True - def __init__(self, rxn: RdkitReaction, **kwargs: Any) -> None: + def __init__(self, rxn: AnyRdkitReactionLike, **kwargs: Any) -> None: """Returns the number of agents in an RDKit reaction. Parameters @@ -2391,7 +2419,7 @@ def __init__(self, rxn: RdkitReaction, **kwargs: Any) -> None: class reaction_numproducts(GenericFunction): inherit_cache = True - def __init__(self, rxn: RdkitReaction, **kwargs: Any) -> None: + def __init__(self, rxn: AnyRdkitReactionLike, **kwargs: Any) -> None: """Returns the number of products in an RDKit reaction. Parameters @@ -2412,7 +2440,7 @@ def __init__(self, rxn: RdkitReaction, **kwargs: Any) -> None: class reaction_numreactants(GenericFunction): inherit_cache = True - def __init__(self, rxn: RdkitReaction, **kwargs: Any) -> None: + def __init__(self, rxn: AnyRdkitReactionLike, **kwargs: Any) -> None: """Returns the number of reactants in an RDKit reaction. Parameters @@ -2434,7 +2462,7 @@ class reaction_send(GenericFunction): type = sqltypes.LargeBinary() inherit_cache = True - def __init__(self, rxn: RdkitReaction, **kwargs: Any) -> None: + def __init__(self, rxn: AnyRdkitReactionLike, **kwargs: Any) -> None: """Serializes an RDKit reaction into a binary representation. Parameters @@ -2457,7 +2485,7 @@ class reaction_structural_bfp(GenericFunction): inherit_cache = True def __init__( - self, rxn: RdkitReaction, radius: int | sqltypes.Integer, **kwargs: Any + self, rxn: AnyRdkitReactionLike, radius: int | sqltypes.Integer, **kwargs: Any ) -> None: """Returns a bit vector fingerprint (bfp) representing the structural features of a chemical reaction. The second argument provides the radius for the fingerprint generation. @@ -2482,7 +2510,7 @@ class reaction_to_ctab(GenericFunction): type = CString() inherit_cache = True - def __init__(self, reaction: RdkitReaction, **kwargs: Any) -> None: + def __init__(self, reaction: AnyRdkitReactionLike, **kwargs: Any) -> None: """Returns a CTAB (mol block) string for a reaction. Parameters @@ -2504,7 +2532,7 @@ class reaction_to_smarts(GenericFunction): type = CString() inherit_cache = True - def __init__(self, rxn: RdkitReaction, **kwargs: Any) -> None: + def __init__(self, rxn: AnyRdkitReactionLike, **kwargs: Any) -> None: """Returns the SMARTS string for a reaction. Parameters @@ -2526,7 +2554,7 @@ class reaction_to_smiles(GenericFunction): type = CString() inherit_cache = True - def __init__(self, rxn: RdkitReaction, **kwargs: Any) -> None: + def __init__(self, rxn: AnyRdkitReactionLike, **kwargs: Any) -> None: """Returns the SMILES string for a reaction. Parameters @@ -2550,7 +2578,7 @@ class reaction_to_svg(GenericFunction): def __init__( self, - rxn: RdkitReaction, + rxn: AnyRdkitReactionLike, highlight_reactants: sqltypes.Boolean, width: int | sqltypes.Integer, height: int | sqltypes.Integer, @@ -2588,8 +2616,11 @@ class rsubstruct(GenericFunction): def __init__( self, - mol: RdkitQMol | RdkitMol | RdkitXQMol | RdkitReaction, - query: RdkitMol | RdkitReaction, + mol: AnyRdkitQMolLike + | AnyRdkitMolLike + | AnyRdkitXQMolLike + | AnyRdkitReactionLike, + query: AnyRdkitMolLike | AnyRdkitReactionLike, **kwargs: Any, ) -> None: """Returns whether or not the second molecule (or reaction) is a substructure of the first molecule (or query molecule/reaction). Doesn't use chirality in the matching. @@ -2615,7 +2646,9 @@ class rsubstruct_chiral(GenericFunction): type = sqltypes.Boolean() inherit_cache = True - def __init__(self, mol: RdkitMol, query_mol: RdkitMol, **kwargs: Any) -> None: + def __init__( + self, mol: AnyRdkitMolLike, query_mol: AnyRdkitMolLike, **kwargs: Any + ) -> None: """Calls the rdkit cartridge function `rsubstruct_chiral`. This function returns whether or not the second molecule is a substructure of the first, considering chirality. Parameters @@ -2640,7 +2673,10 @@ class rsubstruct_query(GenericFunction): inherit_cache = True def __init__( - self, mol_1: RdkitMol | RdkitXQMol | RdkitQMol, mol_2: RdkitMol, **kwargs: Any + self, + mol_1: AnyRdkitMolLike | AnyRdkitXQMolLike | AnyRdkitQMolLike, + mol_2: AnyRdkitMolLike, + **kwargs: Any, ) -> None: """Returns whether or not the second molecule is a substructure of the first molecule. Doesn't use chirality in the matching. @@ -2666,7 +2702,7 @@ class rsubstructfp(GenericFunction): inherit_cache = True def __init__( - self, rxn_1: RdkitReaction, rxn_2: RdkitReaction, **kwargs: Any + self, rxn_1: AnyRdkitReactionLike, rxn_2: AnyRdkitReactionLike, **kwargs: Any ) -> None: """Returns whether or not the second RDKit reaction is a substructure of the first. @@ -2690,7 +2726,7 @@ def __init__( class size(GenericFunction): inherit_cache = True - def __init__(self, bfp: RdkitBitFingerprint, **kwargs: Any) -> None: + def __init__(self, bfp: AnyRdkitBitFingerprintLike, **kwargs: Any) -> None: """Returns the length of (number of bits in) a bit vector fingerprint. Parameters @@ -2714,8 +2750,11 @@ class substruct(GenericFunction): def __init__( self, - mol: RdkitMol | RdkitReaction, - query: RdkitMol | RdkitXQMol | RdkitQMol | RdkitReaction, + mol: AnyRdkitMolLike | AnyRdkitReactionLike, + query: AnyRdkitMolLike + | AnyRdkitXQMolLike + | AnyRdkitQMolLike + | AnyRdkitReactionLike, **kwargs: Any, ) -> None: """Returns whether or not the second molecule/reaction is a substructure of the first one. @@ -2741,7 +2780,9 @@ class substruct_chiral(GenericFunction): type = sqltypes.Boolean() inherit_cache = True - def __init__(self, mol: RdkitMol, query: RdkitMol, **kwargs: Any) -> None: + def __init__( + self, mol: AnyRdkitMolLike, query: AnyRdkitMolLike, **kwargs: Any + ) -> None: """Calls the rdkit cartridge function `substruct_chiral`. Parameters @@ -2766,8 +2807,8 @@ class substruct_count(GenericFunction): def __init__( self, - mol: RdkitMol, - query: RdkitMol | RdkitQMol, + mol: AnyRdkitMolLike, + query: AnyRdkitMolLike | AnyRdkitQMolLike, unique: sqltypes.Boolean | bool = True, **kwargs: Any, ) -> None: @@ -2797,8 +2838,8 @@ class substruct_count_chiral(GenericFunction): def __init__( self, - mol: RdkitMol, - query: RdkitMol | RdkitQMol, + mol: AnyRdkitMolLike, + query: AnyRdkitMolLike | AnyRdkitQMolLike, unique: sqltypes.Boolean, **kwargs: Any, ) -> None: @@ -2828,7 +2869,10 @@ class substruct_query(GenericFunction): inherit_cache = True def __init__( - self, mol_1: RdkitMol, mol_2: RdkitMol | RdkitXQMol | RdkitQMol, **kwargs: Any + self, + mol_1: AnyRdkitMolLike, + mol_2: AnyRdkitMolLike | AnyRdkitXQMolLike | AnyRdkitQMolLike, + **kwargs: Any, ) -> None: """Returns whether or not the second molecule is a substructure of the first molecule. @@ -2854,7 +2898,7 @@ class substructfp(GenericFunction): inherit_cache = True def __init__( - self, rxn_1: RdkitReaction, rxn_2: RdkitReaction, **kwargs: Any + self, rxn_1: AnyRdkitReactionLike, rxn_2: AnyRdkitReactionLike, **kwargs: Any ) -> None: """Returns whether or not the second RDKit reaction is a substructure of the first. @@ -2880,7 +2924,10 @@ class subtract(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitSparseFingerprint, fp_2: RdkitSparseFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitSparseFingerprintLike, + fp_2: AnyRdkitSparseFingerprintLike, + **kwargs: Any, ) -> None: """Returns an sfp formed by the element-wise subtraction of the two sfp arguments. @@ -2906,7 +2953,10 @@ class tanimoto_dist(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitBitFingerprint, fp_2: RdkitBitFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitBitFingerprintLike, + fp_2: AnyRdkitBitFingerprintLike, + **kwargs: Any, ) -> None: """Returns the Tanimoto distance between two bit fingerprints. @@ -2933,8 +2983,8 @@ class tanimoto_sml(GenericFunction): def __init__( self, - fp_1: RdkitSparseFingerprint | RdkitBitFingerprint, - fp_2: RdkitSparseFingerprint | RdkitBitFingerprint, + fp_1: AnyRdkitFingerprintLike, + fp_2: AnyRdkitFingerprintLike, **kwargs: Any, ) -> None: """Returns the Tanimoto similarity between two fingerprints of the same type (either two sparse fingerprints or two bit vector fingerprints). @@ -2960,7 +3010,7 @@ class torsion_fp(GenericFunction): type = RdkitSparseFingerprint() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns a sparse vector topological-torsion fingerprint for a molecule. Parameters @@ -2982,7 +3032,7 @@ class torsionbv_fp(GenericFunction): type = RdkitBitFingerprint() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Returns a bit vector topological-torsion fingerprint for a molecule. Parameters @@ -3006,8 +3056,8 @@ class tversky_sml(GenericFunction): def __init__( self, - fp_1: RdkitBitFingerprint, - fp_2: RdkitBitFingerprint, + fp_1: AnyRdkitBitFingerprintLike, + fp_2: AnyRdkitBitFingerprintLike, alpha: float, beta: float, **kwargs: Any, @@ -3039,7 +3089,7 @@ class xqmol_send(GenericFunction): type = sqltypes.LargeBinary() inherit_cache = True - def __init__(self, mol: RdkitXQMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitXQMolLike, **kwargs: Any) -> None: """Converts `RdkitXQMol` to its binary representation. Parameters diff --git a/src/molalchemy/rdkit/functions/internal.py b/src/molalchemy/rdkit/functions/internal.py index 40a85e8..4a09258 100644 --- a/src/molalchemy/rdkit/functions/internal.py +++ b/src/molalchemy/rdkit/functions/internal.py @@ -18,12 +18,25 @@ ) from molalchemy.types import CString +from ._types import ( + AnyRdkitBitFingerprintLike, + AnyRdkitFingerprintLike, + AnyRdkitMolLike, + AnyRdkitQMolLike, + AnyRdkitReactionLike, + AnyRdkitSparseFingerprintLike, + AnyRdkitXQMolLike, +) + class bfp_cmp(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitBitFingerprint, fp_2: RdkitBitFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitBitFingerprintLike, + fp_2: AnyRdkitBitFingerprintLike, + **kwargs: Any, ) -> None: """Calls the rdkit cartridge function `bfp_cmp`. @@ -49,7 +62,10 @@ class bfp_eq(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitBitFingerprint, fp_2: RdkitBitFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitBitFingerprintLike, + fp_2: AnyRdkitBitFingerprintLike, + **kwargs: Any, ) -> None: """Checks if two bit vector fingerprints are equal. Used for operator overloading. @@ -75,7 +91,10 @@ class bfp_ge(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitBitFingerprint, fp_2: RdkitBitFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitBitFingerprintLike, + fp_2: AnyRdkitBitFingerprintLike, + **kwargs: Any, ) -> None: """Returns whether the first bit fingerprint is greater than or equal to the second bit fingerprint. Used for operator overloading. @@ -101,7 +120,10 @@ class bfp_gt(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitBitFingerprint, fp_2: RdkitBitFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitBitFingerprintLike, + fp_2: AnyRdkitBitFingerprintLike, + **kwargs: Any, ) -> None: """Returns whether the first bit vector fingerprint is 'greater than' the second bit vector fingerprint. Used internally for operator overloading. @@ -149,7 +171,10 @@ class bfp_lt(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitBitFingerprint, fp_2: RdkitBitFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitBitFingerprintLike, + fp_2: AnyRdkitBitFingerprintLike, + **kwargs: Any, ) -> None: """Returns a boolean indicating whether or not the first bit fingerprint is less than the second bit fingerprint. Used internally for operator overloading. @@ -175,7 +200,10 @@ class bfp_ne(GenericFunction): inherit_cache = True def __init__( - self, bfp1: RdkitBitFingerprint, bfp2: RdkitBitFingerprint, **kwargs: Any + self, + bfp1: AnyRdkitBitFingerprintLike, + bfp2: AnyRdkitBitFingerprintLike, + **kwargs: Any, ) -> None: """Compares two bit vector fingerprints for inequality. Used internally for operator overloading. @@ -200,7 +228,7 @@ class bfp_out(GenericFunction): type = CString() inherit_cache = True - def __init__(self, fp: RdkitBitFingerprint, **kwargs: Any) -> None: + def __init__(self, fp: AnyRdkitBitFingerprintLike, **kwargs: Any) -> None: """Returns a bytea with the binary string representation of the fingerprint. Used internally to return fingerprint values to the client. Parameters @@ -247,7 +275,9 @@ def __init__( class mol_cmp(GenericFunction): inherit_cache = True - def __init__(self, mol_1: RdkitMol, mol_2: RdkitMol, **kwargs: Any) -> None: + def __init__( + self, mol_1: AnyRdkitMolLike, mol_2: AnyRdkitMolLike, **kwargs: Any + ) -> None: """Compares two RDKit molecules. Parameters @@ -271,7 +301,9 @@ class mol_eq(GenericFunction): type = sqltypes.Boolean() inherit_cache = True - def __init__(self, mol_1: RdkitMol, mol_2: RdkitMol, **kwargs: Any) -> None: + def __init__( + self, mol_1: AnyRdkitMolLike, mol_2: AnyRdkitMolLike, **kwargs: Any + ) -> None: """Checks if two RDKit molecules are equal. Used internally for operator overloading. Parameters @@ -295,7 +327,9 @@ class mol_ge(GenericFunction): type = sqltypes.Boolean() inherit_cache = True - def __init__(self, arg_1: RdkitMol, arg_2: RdkitMol, **kwargs: Any) -> None: + def __init__( + self, arg_1: AnyRdkitMolLike, arg_2: AnyRdkitMolLike, **kwargs: Any + ) -> None: """Checks if the first RDKit molecule is a superstructure of, or identical to, the second RDKit molecule. Used internally for operator overloading. Parameters @@ -319,7 +353,9 @@ class mol_gt(GenericFunction): type = sqltypes.Boolean() inherit_cache = True - def __init__(self, mol_1: RdkitMol, mol_2: RdkitMol, **kwargs: Any) -> None: + def __init__( + self, mol_1: AnyRdkitMolLike, mol_2: AnyRdkitMolLike, **kwargs: Any + ) -> None: """Compares two RDKit molecules to determine if the first molecule is greater than the second, based on an internal canonical ordering. Used internally for operator overloading. Parameters @@ -365,7 +401,9 @@ class mol_le(GenericFunction): type = sqltypes.Boolean() inherit_cache = True - def __init__(self, mol_1: RdkitMol, mol_2: RdkitMol, **kwargs: Any) -> None: + def __init__( + self, mol_1: AnyRdkitMolLike, mol_2: AnyRdkitMolLike, **kwargs: Any + ) -> None: """Compares two RDKit molecules to check if the first is less than or equal to the second. Used internally for operator overloading Parameters @@ -389,7 +427,9 @@ class mol_lt(GenericFunction): type = sqltypes.Boolean() inherit_cache = True - def __init__(self, mol_1: RdkitMol, mol_2: RdkitMol, **kwargs: Any) -> None: + def __init__( + self, mol_1: AnyRdkitMolLike, mol_2: AnyRdkitMolLike, **kwargs: Any + ) -> None: """Compares two RDKit molecules to determine if the first molecule is less than the second molecule. Used internally for operator overloading Parameters @@ -413,7 +453,9 @@ class mol_ne(GenericFunction): type = sqltypes.Boolean() inherit_cache = True - def __init__(self, mol_1: RdkitMol, mol_2: RdkitMol, **kwargs: Any) -> None: + def __init__( + self, mol_1: AnyRdkitMolLike, mol_2: AnyRdkitMolLike, **kwargs: Any + ) -> None: """Returns a boolean indicating whether or not two molecules are not equal. Used internally for the operator overloading Parameters @@ -437,7 +479,7 @@ class mol_out(GenericFunction): type = CString() inherit_cache = True - def __init__(self, mol: RdkitMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitMolLike, **kwargs: Any) -> None: """Calls the RDKit cartridge function `mol_out` to return a string representation of the molecule. Used internally for displaying molecules in query results. Parameters @@ -481,7 +523,7 @@ class qmol_out(GenericFunction): type = CString() inherit_cache = True - def __init__(self, mol: RdkitQMol, **kwargs: Any) -> None: + def __init__(self, mol: AnyRdkitQMolLike, **kwargs: Any) -> None: """Returns the SMARTS string for a query molecule. This function is used internally for sending the result of a query molecule to the client. Parameters @@ -504,7 +546,7 @@ class reaction_eq(GenericFunction): inherit_cache = True def __init__( - self, rxn_1: RdkitReaction, rxn_2: RdkitReaction, **kwargs: Any + self, rxn_1: AnyRdkitReactionLike, rxn_2: AnyRdkitReactionLike, **kwargs: Any ) -> None: """Checks if two RDKit reactions are equivalent. Used internally for the operator overloading. @@ -552,7 +594,7 @@ class reaction_ne(GenericFunction): inherit_cache = True def __init__( - self, rxn_1: RdkitReaction, rxn_2: RdkitReaction, **kwargs: Any + self, rxn_1: AnyRdkitReactionLike, rxn_2: AnyRdkitReactionLike, **kwargs: Any ) -> None: """Returns true if the two reactions are not equal. Used internally for the operator overloading @@ -577,7 +619,7 @@ class reaction_out(GenericFunction): type = CString() inherit_cache = True - def __init__(self, rxn: RdkitReaction, **kwargs: Any) -> None: + def __init__(self, rxn: AnyRdkitReactionLike, **kwargs: Any) -> None: """Internal function: Converts an RDKit reaction object to its string representation. Parameters @@ -600,8 +642,8 @@ class sfp_cmp(GenericFunction): def __init__( self, - arg_1: RdkitSparseFingerprint, - arg_2: RdkitSparseFingerprint, + arg_1: AnyRdkitSparseFingerprintLike, + arg_2: AnyRdkitSparseFingerprintLike, **kwargs: Any, ) -> None: """Calls the rdkit cartridge function `sfp_cmp`. @@ -628,7 +670,10 @@ class sfp_eq(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitSparseFingerprint, fp_2: RdkitSparseFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitSparseFingerprintLike, + fp_2: AnyRdkitSparseFingerprintLike, + **kwargs: Any, ) -> None: """Returns a boolean indicating whether or not the two sparse fingerprint arguments are equal. Used for the operator overloading @@ -654,7 +699,10 @@ class sfp_ge(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitSparseFingerprint, fp_2: RdkitSparseFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitSparseFingerprintLike, + fp_2: AnyRdkitSparseFingerprintLike, + **kwargs: Any, ) -> None: """Returns a boolean indicating whether the first sparse fingerprint is element-wise greater than or equal to the second sparse fingerprint. Used for the operator overloading @@ -680,7 +728,10 @@ class sfp_gt(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitSparseFingerprint, fp_2: RdkitSparseFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitSparseFingerprintLike, + fp_2: AnyRdkitSparseFingerprintLike, + **kwargs: Any, ) -> None: """Returns a boolean indicating whether all elements of the first sparse fingerprint are greater than the corresponding elements of the second sparse fingerprint. Used for the operator overloading @@ -728,7 +779,10 @@ class sfp_le(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitSparseFingerprint, fp_2: RdkitSparseFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitSparseFingerprintLike, + fp_2: AnyRdkitSparseFingerprintLike, + **kwargs: Any, ) -> None: """Returns a boolean indicating whether the first sparse fingerprint is element-wise less than or equal to the second sparse fingerprint. Used for the operator overloading @@ -754,7 +808,10 @@ class sfp_lt(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitSparseFingerprint, fp_2: RdkitSparseFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitSparseFingerprintLike, + fp_2: AnyRdkitSparseFingerprintLike, + **kwargs: Any, ) -> None: """Returns a boolean indicating whether the first sparse fingerprint is less than the second sparse fingerprint. Used for the operator overloading @@ -780,7 +837,10 @@ class sfp_ne(GenericFunction): inherit_cache = True def __init__( - self, fp_1: RdkitSparseFingerprint, fp_2: RdkitSparseFingerprint, **kwargs: Any + self, + fp_1: AnyRdkitSparseFingerprintLike, + fp_2: AnyRdkitSparseFingerprintLike, + **kwargs: Any, ) -> None: """Returns a boolean indicating whether two sparse fingerprints are not equal. Used for the operator overloading @@ -805,7 +865,7 @@ class sfp_out(GenericFunction): type = CString() inherit_cache = True - def __init__(self, fp: RdkitSparseFingerprint, **kwargs: Any) -> None: + def __init__(self, fp: AnyRdkitSparseFingerprintLike, **kwargs: Any) -> None: """Internal function, that returns a string representation of a sparse fingerprint. Parameters @@ -829,8 +889,8 @@ class tanimoto_sml_op(GenericFunction): def __init__( self, - fp_1: RdkitSparseFingerprint | RdkitBitFingerprint, - fp_2: RdkitSparseFingerprint | RdkitBitFingerprint, + fp_1: AnyRdkitFingerprintLike, + fp_2: AnyRdkitFingerprintLike, **kwargs: Any, ) -> None: """Calculates the Tanimoto similarity between two fingerprints of the same type and returns a boolean result. Used internally for operator overloading. @@ -878,7 +938,7 @@ class xqmol_out(GenericFunction): type = CString() inherit_cache = True - def __init__(self, arg_1: RdkitXQMol, **kwargs: Any) -> None: + def __init__(self, arg_1: AnyRdkitXQMolLike, **kwargs: Any) -> None: """Internal function used to retrieve the string representation of an `RdkitXQMol` object. Parameters diff --git a/src/molalchemy/rdkit/types.py b/src/molalchemy/rdkit/types.py index 7d575b9..06551c9 100644 --- a/src/molalchemy/rdkit/types.py +++ b/src/molalchemy/rdkit/types.py @@ -5,7 +5,7 @@ """ import functools -from typing import Literal +from typing import Any, Literal from rdkit import Chem from sqlalchemy import func @@ -36,7 +36,7 @@ class RdkitMol(RdkitBaseType): cache_ok = True - def get_col_spec(self): + def get_col_spec(self, **kwargs: Any) -> str: return "mol" comparator_factory = RdkitMolComparator @@ -45,13 +45,13 @@ def __init__(self, return_type: Literal["smiles", "bytes", "mol"] = "smiles"): super().__init__() self.return_type = return_type + def __repr__(self): + return f"RdkitMol(return_type={self.return_type!r})" + def column_expression(self, colexpr): from . import functions as rdkit_func - # For mol return type, we want the binary representation - if self.return_type == "mol": - return rdkit_func.mol_send(colexpr, type_=self) - elif self.return_type == "bytes": + if self.return_type in ("mol", "bytes"): return rdkit_func.mol_send(colexpr, type_=self) else: # smiles return colexpr @@ -63,7 +63,10 @@ def process(value): if value is None: return None if isinstance(value, str): - value = Chem.MolFromSmiles(value) + mol = Chem.MolFromSmiles(value) + if mol is None: + raise ValueError(f"Invalid SMILES string: {value!r}") + value = mol if not isinstance(value, Chem.Mol): raise ValueError("Value must be a SMILES string or an RDKit Mol object") return value.ToBinary() @@ -105,7 +108,10 @@ class RdkitBitFingerprint(RdkitBaseType): cache_ok = True comparator_factory = RdkitFPComparator - def get_col_spec(self): + def __repr__(self): + return "RdkitBitFingerprint()" + + def get_col_spec(self, **kwargs: Any) -> str: return "bfp" @@ -120,7 +126,10 @@ class RdkitSparseFingerprint(RdkitBaseType): cache_ok = True comparator_factory = RdkitFPComparator - def get_col_spec(self): + def __repr__(self): + return "RdkitSparseFingerprint()" + + def get_col_spec(self, **kwargs: Any) -> str: return "sfp" @@ -142,7 +151,7 @@ class RdkitReaction(RdkitBaseType): impl = bytes cache_ok = True - def get_col_spec(self): + def get_col_spec(self, **kwargs: Any) -> str: return "reaction" comparator_factory = RdkitMolComparator @@ -158,13 +167,14 @@ def __init__(self, return_type: Literal["smiles", "bytes", "mol"] = "smiles"): super().__init__() self.return_type = return_type + def __repr__(self): + return f"RdkitReaction(return_type={self.return_type!r})" + def column_expression(self, colexpr): from . import functions as rdkit_func - if self.return_type == "mol": - return rdkit_func.rxn.to_binary(colexpr, type_=self) - elif self.return_type == "bytes": - return rdkit_func.rxn.to_binary(colexpr, type_=self) + if self.return_type in ("mol", "bytes"): + return rdkit_func.reaction_send(colexpr, type_=self) else: # smiles return colexpr @@ -189,10 +199,10 @@ def process(value, return_type): class RdkitQMol(RdkitBaseType): - def get_col_spec(self): + def get_col_spec(self, **kwargs: Any) -> str: return "qmol" class RdkitXQMol(RdkitBaseType): - def get_col_spec(self): + def get_col_spec(self, **kwargs: Any) -> str: return "xqmol" diff --git a/src/molalchemy/types.py b/src/molalchemy/types.py index 5547a0e..43d39a0 100644 --- a/src/molalchemy/types.py +++ b/src/molalchemy/types.py @@ -7,5 +7,5 @@ class CString(UserDefinedType): impl = str cache_ok = True - def get_col_spec(self): + def get_col_spec(self, **kwargs) -> str: return "cstring" diff --git a/tests/bingo/functions/__init__.py b/tests/bingo/functions/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/bingo/functions/test_types.py b/tests/bingo/functions/test_types.py new file mode 100644 index 0000000..9def0b4 --- /dev/null +++ b/tests/bingo/functions/test_types.py @@ -0,0 +1,58 @@ +"""Tests for Bingo function type aliases.""" + +from sqlalchemy import Column + +from molalchemy.bingo.functions._types import ( + AnyBingoMolLike, + AnyBingoMolLikeCombined, + BingoMolCoercible, +) +from molalchemy.bingo.types import ( + BingoMol, +) + + +class TestTypeAliasImports: + """Test type aliases can be imported.""" + + def test_import_base_aliases(self): + """Test base type aliases import correctly.""" + assert BingoMolCoercible is not None + + def test_import_any_aliases(self): + """Test Any*Like type aliases import correctly.""" + assert AnyBingoMolLike is not None + + def test_import_combined_aliases(self): + """Test combined type aliases import correctly.""" + assert AnyBingoMolLikeCombined is not None + + +class TestTypeAliasUsage: + """Test type aliases work with SQLAlchemy types.""" + + def test_column_with_type_alias(self): + """Test type aliases work with Column.""" + col = Column("mol", BingoMol()) + assert col is not None + + def test_mapped_with_type_alias(self): + """Test type aliases work with Mapped.""" + # Just verify it doesn't error + assert True + + +class TestBackwardCompatibility: + """Test backward compatibility with existing code.""" + + def test_any_bingo_mol_exists(self): + """Test AnyBingoMol still exists.""" + from molalchemy.bingo.functions import AnyBingoMol + + assert AnyBingoMol is not None + + def test_any_bingo_reaction_exists(self): + """Test AnyBingoReaction still exists.""" + from molalchemy.bingo.functions import AnyBingoReaction + + assert AnyBingoReaction is not None diff --git a/uv.lock b/uv.lock index ee906bf..45a8093 100644 --- a/uv.lock +++ b/uv.lock @@ -530,7 +530,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/7d/ed/6bfa4109fcb23a58819600392564fea69cdc6551ffd5e69ccf1d52a40cbc/greenlet-3.2.4-cp310-cp310-macosx_11_0_universal2.whl", hash = "sha256:8c68325b0d0acf8d91dde4e6f930967dd52a5302cd4062932a6b2e7c2969f47c", size = 271061, upload-time = "2025-08-07T13:17:15.373Z" }, { url = "https://files.pythonhosted.org/packages/2a/fc/102ec1a2fc015b3a7652abab7acf3541d58c04d3d17a8d3d6a44adae1eb1/greenlet-3.2.4-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:94385f101946790ae13da500603491f04a76b6e4c059dab271b3ce2e283b2590", size = 629475, upload-time = "2025-08-07T13:42:54.009Z" }, { url = "https://files.pythonhosted.org/packages/c5/26/80383131d55a4ac0fb08d71660fd77e7660b9db6bdb4e8884f46d9f2cc04/greenlet-3.2.4-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:f10fd42b5ee276335863712fa3da6608e93f70629c631bf77145021600abc23c", size = 640802, upload-time = "2025-08-07T13:45:25.52Z" }, - { url = "https://files.pythonhosted.org/packages/9f/7c/e7833dbcd8f376f3326bd728c845d31dcde4c84268d3921afcae77d90d08/greenlet-3.2.4-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:c8c9e331e58180d0d83c5b7999255721b725913ff6bc6cf39fa2a45841a4fd4b", size = 636703, upload-time = "2025-08-07T13:53:12.622Z" }, { url = "https://files.pythonhosted.org/packages/e9/49/547b93b7c0428ede7b3f309bc965986874759f7d89e4e04aeddbc9699acb/greenlet-3.2.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:58b97143c9cc7b86fc458f215bd0932f1757ce649e05b640fea2e79b54cedb31", size = 635417, upload-time = "2025-08-07T13:18:25.189Z" }, { url = "https://files.pythonhosted.org/packages/7f/91/ae2eb6b7979e2f9b035a9f612cf70f1bf54aad4e1d125129bef1eae96f19/greenlet-3.2.4-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c2ca18a03a8cfb5b25bc1cbe20f3d9a4c80d8c3b13ba3df49ac3961af0b1018d", size = 584358, upload-time = "2025-08-07T13:18:23.708Z" }, { url = "https://files.pythonhosted.org/packages/f7/85/433de0c9c0252b22b16d413c9407e6cb3b41df7389afc366ca204dbc1393/greenlet-3.2.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:9fe0a28a7b952a21e2c062cd5756d34354117796c6d9215a87f55e38d15402c5", size = 1113550, upload-time = "2025-08-07T13:42:37.467Z" }, @@ -541,7 +540,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/a4/de/f28ced0a67749cac23fecb02b694f6473f47686dff6afaa211d186e2ef9c/greenlet-3.2.4-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:96378df1de302bc38e99c3a9aa311967b7dc80ced1dcc6f171e99842987882a2", size = 272305, upload-time = "2025-08-07T13:15:41.288Z" }, { url = "https://files.pythonhosted.org/packages/09/16/2c3792cba130000bf2a31c5272999113f4764fd9d874fb257ff588ac779a/greenlet-3.2.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:1ee8fae0519a337f2329cb78bd7a8e128ec0f881073d43f023c7b8d4831d5246", size = 632472, upload-time = "2025-08-07T13:42:55.044Z" }, { url = "https://files.pythonhosted.org/packages/ae/8f/95d48d7e3d433e6dae5b1682e4292242a53f22df82e6d3dda81b1701a960/greenlet-3.2.4-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:94abf90142c2a18151632371140b3dba4dee031633fe614cb592dbb6c9e17bc3", size = 644646, upload-time = "2025-08-07T13:45:26.523Z" }, - { url = "https://files.pythonhosted.org/packages/d5/5e/405965351aef8c76b8ef7ad370e5da58d57ef6068df197548b015464001a/greenlet-3.2.4-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:4d1378601b85e2e5171b99be8d2dc85f594c79967599328f95c1dc1a40f1c633", size = 640519, upload-time = "2025-08-07T13:53:13.928Z" }, { url = "https://files.pythonhosted.org/packages/25/5d/382753b52006ce0218297ec1b628e048c4e64b155379331f25a7316eb749/greenlet-3.2.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:0db5594dce18db94f7d1650d7489909b57afde4c580806b8d9203b6e79cdc079", size = 639707, upload-time = "2025-08-07T13:18:27.146Z" }, { url = "https://files.pythonhosted.org/packages/1f/8e/abdd3f14d735b2929290a018ecf133c901be4874b858dd1c604b9319f064/greenlet-3.2.4-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2523e5246274f54fdadbce8494458a2ebdcdbc7b802318466ac5606d3cded1f8", size = 587684, upload-time = "2025-08-07T13:18:25.164Z" }, { url = "https://files.pythonhosted.org/packages/5d/65/deb2a69c3e5996439b0176f6651e0052542bb6c8f8ec2e3fba97c9768805/greenlet-3.2.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:1987de92fec508535687fb807a5cea1560f6196285a4cde35c100b8cd632cc52", size = 1116647, upload-time = "2025-08-07T13:42:38.655Z" }, @@ -552,7 +550,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/44/69/9b804adb5fd0671f367781560eb5eb586c4d495277c93bde4307b9e28068/greenlet-3.2.4-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:3b67ca49f54cede0186854a008109d6ee71f66bd57bb36abd6d0a0267b540cdd", size = 274079, upload-time = "2025-08-07T13:15:45.033Z" }, { url = "https://files.pythonhosted.org/packages/46/e9/d2a80c99f19a153eff70bc451ab78615583b8dac0754cfb942223d2c1a0d/greenlet-3.2.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:ddf9164e7a5b08e9d22511526865780a576f19ddd00d62f8a665949327fde8bb", size = 640997, upload-time = "2025-08-07T13:42:56.234Z" }, { url = "https://files.pythonhosted.org/packages/3b/16/035dcfcc48715ccd345f3a93183267167cdd162ad123cd93067d86f27ce4/greenlet-3.2.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:f28588772bb5fb869a8eb331374ec06f24a83a9c25bfa1f38b6993afe9c1e968", size = 655185, upload-time = "2025-08-07T13:45:27.624Z" }, - { url = "https://files.pythonhosted.org/packages/31/da/0386695eef69ffae1ad726881571dfe28b41970173947e7c558d9998de0f/greenlet-3.2.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:5c9320971821a7cb77cfab8d956fa8e39cd07ca44b6070db358ceb7f8797c8c9", size = 649926, upload-time = "2025-08-07T13:53:15.251Z" }, { url = "https://files.pythonhosted.org/packages/68/88/69bf19fd4dc19981928ceacbc5fd4bb6bc2215d53199e367832e98d1d8fe/greenlet-3.2.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c60a6d84229b271d44b70fb6e5fa23781abb5d742af7b808ae3f6efd7c9c60f6", size = 651839, upload-time = "2025-08-07T13:18:30.281Z" }, { url = "https://files.pythonhosted.org/packages/19/0d/6660d55f7373b2ff8152401a83e02084956da23ae58cddbfb0b330978fe9/greenlet-3.2.4-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3b3812d8d0c9579967815af437d96623f45c0f2ae5f04e366de62a12d83a8fb0", size = 607586, upload-time = "2025-08-07T13:18:28.544Z" }, { url = "https://files.pythonhosted.org/packages/8e/1a/c953fdedd22d81ee4629afbb38d2f9d71e37d23caace44775a3a969147d4/greenlet-3.2.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:abbf57b5a870d30c4675928c37278493044d7c14378350b3aa5d484fa65575f0", size = 1123281, upload-time = "2025-08-07T13:42:39.858Z" }, @@ -563,7 +560,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/49/e8/58c7f85958bda41dafea50497cbd59738c5c43dbbea5ee83d651234398f4/greenlet-3.2.4-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:1a921e542453fe531144e91e1feedf12e07351b1cf6c9e8a3325ea600a715a31", size = 272814, upload-time = "2025-08-07T13:15:50.011Z" }, { url = "https://files.pythonhosted.org/packages/62/dd/b9f59862e9e257a16e4e610480cfffd29e3fae018a68c2332090b53aac3d/greenlet-3.2.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:cd3c8e693bff0fff6ba55f140bf390fa92c994083f838fece0f63be121334945", size = 641073, upload-time = "2025-08-07T13:42:57.23Z" }, { url = "https://files.pythonhosted.org/packages/f7/0b/bc13f787394920b23073ca3b6c4a7a21396301ed75a655bcb47196b50e6e/greenlet-3.2.4-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:710638eb93b1fa52823aa91bf75326f9ecdfd5e0466f00789246a5280f4ba0fc", size = 655191, upload-time = "2025-08-07T13:45:29.752Z" }, - { url = "https://files.pythonhosted.org/packages/f2/d6/6adde57d1345a8d0f14d31e4ab9c23cfe8e2cd39c3baf7674b4b0338d266/greenlet-3.2.4-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:c5111ccdc9c88f423426df3fd1811bfc40ed66264d35aa373420a34377efc98a", size = 649516, upload-time = "2025-08-07T13:53:16.314Z" }, { url = "https://files.pythonhosted.org/packages/7f/3b/3a3328a788d4a473889a2d403199932be55b1b0060f4ddd96ee7cdfcad10/greenlet-3.2.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:d76383238584e9711e20ebe14db6c88ddcedc1829a9ad31a584389463b5aa504", size = 652169, upload-time = "2025-08-07T13:18:32.861Z" }, { url = "https://files.pythonhosted.org/packages/ee/43/3cecdc0349359e1a527cbf2e3e28e5f8f06d3343aaf82ca13437a9aa290f/greenlet-3.2.4-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:23768528f2911bcd7e475210822ffb5254ed10d71f4028387e5a99b4c6699671", size = 610497, upload-time = "2025-08-07T13:18:31.636Z" }, { url = "https://files.pythonhosted.org/packages/b8/19/06b6cf5d604e2c382a6f31cafafd6f33d5dea706f4db7bdab184bad2b21d/greenlet-3.2.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:00fadb3fedccc447f517ee0d3fd8fe49eae949e1cd0f6a611818f4f6fb7dc83b", size = 1121662, upload-time = "2025-08-07T13:42:41.117Z" }, @@ -574,7 +570,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/22/5c/85273fd7cc388285632b0498dbbab97596e04b154933dfe0f3e68156c68c/greenlet-3.2.4-cp314-cp314-macosx_11_0_universal2.whl", hash = "sha256:49a30d5fda2507ae77be16479bdb62a660fa51b1eb4928b524975b3bde77b3c0", size = 273586, upload-time = "2025-08-07T13:16:08.004Z" }, { url = "https://files.pythonhosted.org/packages/d1/75/10aeeaa3da9332c2e761e4c50d4c3556c21113ee3f0afa2cf5769946f7a3/greenlet-3.2.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:299fd615cd8fc86267b47597123e3f43ad79c9d8a22bebdce535e53550763e2f", size = 686346, upload-time = "2025-08-07T13:42:59.944Z" }, { url = "https://files.pythonhosted.org/packages/c0/aa/687d6b12ffb505a4447567d1f3abea23bd20e73a5bed63871178e0831b7a/greenlet-3.2.4-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:c17b6b34111ea72fc5a4e4beec9711d2226285f0386ea83477cbb97c30a3f3a5", size = 699218, upload-time = "2025-08-07T13:45:30.969Z" }, - { url = "https://files.pythonhosted.org/packages/dc/8b/29aae55436521f1d6f8ff4e12fb676f3400de7fcf27fccd1d4d17fd8fecd/greenlet-3.2.4-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b4a1870c51720687af7fa3e7cda6d08d801dae660f75a76f3845b642b4da6ee1", size = 694659, upload-time = "2025-08-07T13:53:17.759Z" }, { url = "https://files.pythonhosted.org/packages/92/2e/ea25914b1ebfde93b6fc4ff46d6864564fba59024e928bdc7de475affc25/greenlet-3.2.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:061dc4cf2c34852b052a8620d40f36324554bc192be474b9e9770e8c042fd735", size = 695355, upload-time = "2025-08-07T13:18:34.517Z" }, { url = "https://files.pythonhosted.org/packages/72/60/fc56c62046ec17f6b0d3060564562c64c862948c9d4bc8aa807cf5bd74f4/greenlet-3.2.4-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:44358b9bf66c8576a9f57a590d5f5d6e72fa4228b763d0e43fee6d3b06d3a337", size = 657512, upload-time = "2025-08-07T13:18:33.969Z" }, { url = "https://files.pythonhosted.org/packages/23/6e/74407aed965a4ab6ddd93a7ded3180b730d281c77b765788419484cdfeef/greenlet-3.2.4-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:2917bdf657f5859fbf3386b12d68ede4cf1f04c90c3a6bc1f013dd68a22e2269", size = 1612508, upload-time = "2025-11-04T12:42:23.427Z" }, @@ -1136,6 +1131,7 @@ dependencies = [ dev = [ { name = "alembic" }, { name = "ipykernel" }, + { name = "jinja2" }, { name = "mypy" }, { name = "pandas" }, { name = "pytest" }, @@ -1165,6 +1161,7 @@ requires-dist = [ dev = [ { name = "alembic", specifier = ">=1.17.0" }, { name = "ipykernel", specifier = ">=6.30.1" }, + { name = "jinja2", specifier = ">=3.1.6" }, { name = "mypy", specifier = ">=1.18.2" }, { name = "pandas", specifier = ">=2.3.3" }, { name = "pytest", specifier = ">=8.4.2" },