Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ exclude =
__pycache__,
build,
.eggs,
bbtools.egg-info,
bbtools/legacy/*.py,
bblean.egg-info,
bblean/legacy/*.py,
docs,
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ repos:
hooks:
- id: black
files: \.py$
exclude: bbtools/bblean\.py$|bbtools/bblean_v1\.py$|bbtools/bb_int64\.py$
stages: [pre-push]

- repo: https://github.com/PyCQA/flake8
Expand All @@ -38,7 +37,7 @@ repos:
hooks:
- id: autoflake
files: \.py$
exclude: bbtools/bblean\.py$|bbtools/bblean_v1\.py$|bbtools/bb_int64\.py$
exclude: bblean/bitbirch\.py$|bblean/legacy/bb_uint8\.py$|bblean/legacy/bb_int64_dense\.py$
stages: [pre-push]

- repo: local
Expand Down
35 changes: 23 additions & 12 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
BitBirch-Tools Python Package: An open-source clustering module based on iSIM.
BitBirch-Lean Python Package: An open-source clustering module based on iSIM.

If you find this code useful, please cite the BitBirch paper:
https://doi.org/10.1039/D5DD00030K

Copyright (C) 2025 The Miranda-Quintana Lab BitBirch developers, including:

Copyright (C) 2025 The Miranda-Quintana Lab and other BitBirch developers, including:
- Ramon Alain Miranda Quintana <ramirandaq@gmail.com>, <quintana@chem.ufl.edu>
- Krisztina Zsigmond <kzsigmond@ufl.edu>
- Ignacio Pickering <ipickering@chem.ufl.edu>
- Kenneth Lopez Perez <klopezperez@chem.ufl.edu>
- Miroslav Lzicar <miroslav.lzicar@deepmedchem.com>

Authors of ./bblean/multiround.py are:
- Ramon Alain Miranda Quintana <ramirandaq@gmail.com>, <quintana@chem.ufl.edu>
- Ignacio Pickering <ipickering@chem.ufl.edu>

This program is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software Foundation,
version 3 (SPDX-License-Identifier: GPL-3.0-only).

Portions of the file ./bblean/bitbirch.py are licensed under the BSD 3-Clause License
Copyright (c) 2007-2024 The scikit-learn developers. All rights reserved.
(SPDX-License-Identifier: BSD-3-Clause). Copies or reproductions of code in the
./bblean/bitbirch.py file must in addition adhere to the BSD-3-Clause license terms. A
copy of the BSD-3-Clause license can be located at the root of this repository, under
./LICENSES/BSD-3-Clause.txt.

Portions of the file ./bblean/bitbirch.py were previously licensed under the LGPL 3.0
license (SPDX-License-Identifier: LGPL-3.0-only), they are relicensed in this program
as GPL-3.0, with permission of all original copyright holders:
- Ramon Alain Miranda Quintana <ramirandaq@gmail.com>, <quintana@chem.ufl.edu>
- Vicky (Vic) Jung <jungvicky@ufl.edu>
- Kenneth Lopez Perez <klopezperez@chem.ufl.edu>
- Kate Huddleston <kdavis2@chem.ufl.edu>

This program is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation, version
3 (SPDX-License-Identifier: GPL-3.0-only). Portions of the file ./bbtools/bb_lean.py are
licensed under the BSD 3-Clause License Copyright (c) 2007-2024 The scikit-learn
developers. All rights reserved. (SPDX-License-Identifier: BSD-3-Clause). Copies or
reproductions of code in the ./bbtools/bb_lean.py file must in addition adhere to the
BSD-3-Clause license terms. A copy of the BSD-3-Clause license can be located at the
root of this repository, under ./LICENSES/BSD-3-Clause.txt.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BitBirch-Tools
# BitBirch-Lean

## Overview

Expand All @@ -8,6 +8,7 @@ From source, using a conda environment:

```bash
conda env create --file ./environment.yaml
conda activate bblean
pip install -e .
```

Expand Down
1 change: 0 additions & 1 deletion _examples_NOT_PORTED/refinement/refine_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@
"metadata": {},
"outputs": [],
"source": [
"# This function can be found in bbtools.refinement\n",
"def radius(fps):\n",
" bb.set_merge('radius')\n",
" brc = bb.BitBirch(branching_factor=branching_factor, threshold=threshold)\n",
Expand Down
7 changes: 7 additions & 0 deletions bblean/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
r"""
bblean
"""

from bblean.bitbirch import BitBirch # type: ignore

__all__ = ["BitBirch"]
2 changes: 1 addition & 1 deletion bbtools/_console.py → bblean/_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from rich.console import Console

from bbtools.memory import get_peak_memory, PeakMemoryStats
from bblean.memory import get_peak_memory, PeakMemoryStats


class BBConsole(Console):
Expand Down
52 changes: 27 additions & 25 deletions bbtools/bb_lean/bitbirch.py → bblean/bitbirch.py
Original file line number Diff line number Diff line change
@@ -1,60 +1,62 @@
# type: ignore
# BitBirch-Tools Python Package: An open-source clustering module based on iSIM.
# BitBirch-Lean Python Package: An open-source clustering module based on iSIM.
#
# If you find this code useful, please cite the BitBirch paper:
# https://doi.org/10.1039/D5DD00030K
#
# Copyright (C) 2025 The Miranda-Quintana Lab BitBirch developers, including:
#
# Copyright (C) 2025 The Miranda-Quintana Lab and other BitBirch developers, including:
# - Ramon Alain Miranda Quintana <ramirandaq@gmail.com>, <quintana@chem.ufl.edu>
# - Krisztina Zsigmond <kzsigmond@ufl.edu>
# - Ignacio Pickering <ipickering@chem.ufl.edu>
# - Kenneth Lopez Perez <klopezperez@chem.ufl.edu>
# - Miroslav Lzicar <miroslav.lzicar@deepmedchem.com>
# - Vicky (Vic) Jung <jungvicky@ufl.edu>
# - Kate Huddleston <kdavis2@chem.ufl.edu>
#
# Authors of ./bblean/multiround.py are:
# - Ramon Alain Miranda Quintana <ramirandaq@gmail.com>, <quintana@chem.ufl.edu>
# - Ignacio Pickering <ipickering@chem.ufl.edu>
#
# This program is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software Foundation,
# version 3 (SPDX-License-Identifier: GPL-3.0-only). Portions of this file are licensed
# under the BSD 3-Clause License Copyright (c) 2007-2024 The scikit-learn developers.
# All rights reserved. (SPDX-License-Identifier: BSD-3-Clause). Copies or reproductions
# of code in this file must in addition adhere to the BSD-3-Clause license terms. A copy
# of the BSD-3-Clause license can be located at the root of this repository, under
# version 3 (SPDX-License-Identifier: GPL-3.0-only).
#
# Portions of this file are licensed under the BSD 3-Clause License
# Copyright (c) 2007-2024 The scikit-learn developers. All rights reserved.
# (SPDX-License-Identifier: BSD-3-Clause). Copies or reproductions of code in this
# file must in addition adhere to the BSD-3-Clause license terms. A
# copy of the BSD-3-Clause license can be located at the root of this repository, under
# ./LICENSES/BSD-3-Clause.txt.
#
# Portions of this file were previously licensed under the LGPL 3.0
# license (SPDX-License-Identifier: LGPL-3.0-only), they are relicensed in this program
# as GPL-3.0, with permission of all original copyright holders:
# - Ramon Alain Miranda Quintana <ramirandaq@gmail.com>, <quintana@chem.ufl.edu>
# - Vicky (Vic) Jung <jungvicky@ufl.edu>
# - Kenneth Lopez Perez <klopezperez@chem.ufl.edu>
# - Kate Huddleston <kdavis2@chem.ufl.edu>
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this
# program. This copy can be located at the root of this repository, under
# ./LICENSES/GPL-3.0-only.txt. If not, see <http://www.gnu.org/licenses/gpl-3.0.html>.

# TODO: remove this?
# Parts of the BitBIRCH algorithm were previously released under the LGPL-3.0 license
# by:
# Ramon Alain Miranda Quintana <ramirandaq@gmail.com>, <quintana@chem.ufl.edu>
# Vicky (Vic) Jung <jungvicky@ufl.edu>
# Kenneth Lopez Perez <klopezperez@chem.ufl.edu>
# Kate Huddleston <kdavis2@chem.ufl.edu>

from numpy.typing import NDArray, DTypeLike
# type: ignore
import typing as tp
from collections import defaultdict
from weakref import WeakSet

import numpy as np
from scipy import sparse
import numpy as np
from numpy.typing import NDArray, DTypeLike

from bbtools.utils import calc_centroid, min_safe_uint
from bbtools.packing import (
from bblean.utils import calc_centroid, min_safe_uint
from bblean.packing import (
pack_fingerprints,
unpack_fingerprints,
popcount,
jt_sim_packed,
)
from bbtools.merges import get_merge_accept_fn, MergeAcceptFunction
from bblean.merges import get_merge_accept_fn, MergeAcceptFunction


# For backwards compatibility with the global "set_merge", keep weak references to all
Expand Down
20 changes: 10 additions & 10 deletions bbtools/cli.py → bblean/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import typer
from typer import Typer, Argument, Option, Abort, Context

from bbtools.memory import monitor_rss_daemon, get_peak_memory
from bbtools.config import DEFAULTS, collect_system_specs_and_dump_config
from bbtools.packing import pack_fingerprints
from bbtools.utils import _import_bitbirch_variant, batched
from bblean.memory import monitor_rss_daemon, get_peak_memory
from bblean.config import DEFAULTS, collect_system_specs_and_dump_config
from bblean.packing import pack_fingerprints
from bblean.utils import _import_bitbirch_variant, batched

app = Typer(
rich_markup_mode="markdown",
Expand All @@ -32,15 +32,15 @@
[https://doi.org/10.1039/D5DD00030K](https://doi.org/10.1039/D5DD00030K)
- BitBirch refinement strategies:
(TODO)
- BitBirch-Lean and BB-Tools:
- BitBirch-Lean:
(TODO)
""", # noqa
)


def _print_help_banner(ctx: Context, value: bool) -> None:
if value:
from bbtools._console import get_console
from bblean._console import get_console

console = get_console()
console.print_banner()
Expand Down Expand Up @@ -146,7 +146,7 @@ def _fps_from_smiles(
"""
import numpy as np
from rdkit.Chem import rdFingerprintGenerator, DataStructs, MolFromSmiles
from bbtools._console import get_console
from bblean._console import get_console

console = get_console(silent=not verbose)

Expand Down Expand Up @@ -320,7 +320,7 @@ def _run(
) -> None:
r"""Run standard BitBirch clustering"""
import numpy as np
from bbtools._console import get_console
from bblean._console import get_console

console = get_console(silent=not verbose)

Expand Down Expand Up @@ -527,8 +527,8 @@ def _multiround(
] = True,
) -> None:
r"""Run multi-round BitBirch clustering, with the option to parallelize"""
from bbtools._console import get_console
from bbtools.multiround import run_multiround_bitbirch
from bblean._console import get_console
from bblean.multiround import run_multiround_bitbirch

console = get_console(silent=not verbose)

Expand Down
4 changes: 2 additions & 2 deletions bbtools/config.py → bblean/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import json
import sys
import dataclasses
from bbtools.memory import system_mem_gib
from bblean.memory import system_mem_gib
import multiprocessing as mp
import os

import numpy as np

from bbtools.utils import cpu_name
from bblean.utils import cpu_name


@dataclasses.dataclass(slots=True)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bbtools/merges.py → bblean/merges.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import warnings

from bbtools.utils import calc_centroid
from bblean.utils import calc_centroid


def jt_isim(c_total: NDArray[np.integer], n_objects: int) -> float:
Expand Down
48 changes: 45 additions & 3 deletions bbtools/multiround.py → bblean/multiround.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
# BitBirch-Lean Python Package: An open-source clustering module based on iSIM.
#
# If you find this code useful, please cite the BitBirch paper:
# https://doi.org/10.1039/D5DD00030K
#
# Copyright (C) 2025 The Miranda-Quintana Lab and other BitBirch developers, including:
# - Ramon Alain Miranda Quintana <ramirandaq@gmail.com>, <quintana@chem.ufl.edu>
# - Krisztina Zsigmond <kzsigmond@ufl.edu>
# - Ignacio Pickering <ipickering@chem.ufl.edu>
# - Kenneth Lopez Perez <klopezperez@chem.ufl.edu>
# - Miroslav Lzicar <miroslav.lzicar@deepmedchem.com>
#
# Authors of this file are:
# - Ramon Alain Miranda Quintana <ramirandaq@gmail.com>, <quintana@chem.ufl.edu>
# - Ignacio Pickering <ipickering@chem.ufl.edu>
#
# This program is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software Foundation,
# version 3 (SPDX-License-Identifier: GPL-3.0-only).
#
# Portions of ./bblean/bitbirch.py are licensed under the BSD 3-Clause License
# Copyright (c) 2007-2024 The scikit-learn developers. All rights reserved.
# (SPDX-License-Identifier: BSD-3-Clause). Copies or reproductions of code in the
# ./bblean/bitbirch.py file must in addition adhere to the BSD-3-Clause license terms. A
# copy of the BSD-3-Clause license can be located at the root of this repository, under
# ./LICENSES/BSD-3-Clause.txt.
#
# Portions of ./bblean/bitbirch.py were previously licensed under the LGPL 3.0
# license (SPDX-License-Identifier: LGPL-3.0-only), they are relicensed in this program
# as GPL-3.0, with permission of all original copyright holders:
# - Ramon Alain Miranda Quintana <ramirandaq@gmail.com>, <quintana@chem.ufl.edu>
# - Vicky (Vic) Jung <jungvicky@ufl.edu>
# - Kenneth Lopez Perez <klopezperez@chem.ufl.edu>
# - Kate Huddleston <kdavis2@chem.ufl.edu>
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this
# program. This copy can be located at the root of this repository, under
# ./LICENSES/GPL-3.0-only.txt. If not, see <http://www.gnu.org/licenses/gpl-3.0.html>.
import functools
import pickle
import gc
Expand All @@ -10,9 +52,9 @@
import numpy as np
from numpy.typing import NDArray

from bbtools._console import get_console
from bbtools.utils import numpy_streaming_save, batched, _import_bitbirch_variant
from bbtools.config import DEFAULTS
from bblean._console import get_console
from bblean.utils import numpy_streaming_save, batched, _import_bitbirch_variant
from bblean.config import DEFAULTS


def _glob_and_sort_by_uint_bits(path: Path | str, glob_expr: str) -> list[Path]:
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions bbtools/utils.py → bblean/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def _import_bitbirch_variant(
raise ValueError(f"Unknown variant {variant}")
# Most up-to-date bb varaint
if variant in ["lean", "lean_dense"]:
module = importlib.import_module("bbtools.bb_lean")
module = importlib.import_module("bblean.bitbirch")
# Legacy variant of bb that uses uint8 and supports packing, but no extra optim
elif variant in ["uint8", "uint8_dense"]:
module = importlib.import_module("bbtools.legacy.bb_uint8")
module = importlib.import_module("bblean.legacy.bb_uint8")
# Legacy variant of bb that uses dense int64 fps
elif variant == "int64_dense":
module = importlib.import_module("bbtools.legacy.bb_int64_dense")
module = importlib.import_module("bblean.legacy.bb_int64_dense")

Cls = getattr(module, "BitBirch")
fn = getattr(module, "set_merge")
Expand Down
7 changes: 0 additions & 7 deletions bbtools/__init__.py

This file was deleted.

3 changes: 0 additions & 3 deletions bbtools/bb_lean/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion environment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: bbtools
name: bblean
channels:
- nodefaults
- https://conda.anaconda.org/conda-forge
Expand Down
Loading