patternjoin 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- patternjoin-0.1.0/.github/install-tbb.sh +15 -0
- patternjoin-0.1.0/.github/workflows/publish.yml +99 -0
- patternjoin-0.1.0/.gitignore +7 -0
- patternjoin-0.1.0/.vscode/settings.json +6 -0
- patternjoin-0.1.0/CMakeLists.txt +27 -0
- patternjoin-0.1.0/LICENSE +21 -0
- patternjoin-0.1.0/PKG-INFO +97 -0
- patternjoin-0.1.0/README.md +71 -0
- patternjoin-0.1.0/benchmark/test_data/P00245-aa +392574 -0
- patternjoin-0.1.0/benchmarks/chart_BCR_1.png +0 -0
- patternjoin-0.1.0/benchmarks/chart_BCR_2.png +0 -0
- patternjoin-0.1.0/benchmarks/chart_TCR_1.png +0 -0
- patternjoin-0.1.0/benchmarks/chart_TCR_2.png +0 -0
- patternjoin-0.1.0/performance_testing/CMakeLists.txt +30 -0
- patternjoin-0.1.0/performance_testing/check_out.py +16 -0
- patternjoin-0.1.0/performance_testing/plot_results.py +187 -0
- patternjoin-0.1.0/performance_testing/pseudocode_core.cpp +4 -0
- patternjoin-0.1.0/performance_testing/pseudocode_core.py +13 -0
- patternjoin-0.1.0/performance_testing/test_data/P00245-aa +392574 -0
- patternjoin-0.1.0/performance_testing/test_results/final_algo_speedup.png +0 -0
- patternjoin-0.1.0/performance_testing/test_results/map_parallel_clear_part.png +0 -0
- patternjoin-0.1.0/performance_testing/test_results/map_parallel_runtime.png +0 -0
- patternjoin-0.1.0/performance_testing/test_results/map_parallel_simsearch_speedup.png +0 -0
- patternjoin-0.1.0/performance_testing/test_results/map_serial_simsearch_time.png +0 -0
- patternjoin-0.1.0/performance_testing/test_results/parallel_results_map.csv +46 -0
- patternjoin-0.1.0/performance_testing/test_results/parallel_results_set.csv +361 -0
- patternjoin-0.1.0/performance_testing/test_results/serial_results_map.csv +13 -0
- patternjoin-0.1.0/performance_testing/test_results/serial_results_set.csv +91 -0
- patternjoin-0.1.0/performance_testing/test_results/set_parallel16_insert_perf.png +0 -0
- patternjoin-0.1.0/performance_testing/test_results/set_parallel_insert_speedup.png +0 -0
- patternjoin-0.1.0/performance_testing/test_results/set_serial_insert_perf.png +0 -0
- patternjoin-0.1.0/performance_testing/test_results/set_serial_insert_time.png +0 -0
- patternjoin-0.1.0/performance_testing/threaded_hash_maps.cpp +428 -0
- patternjoin-0.1.0/performance_testing/threaded_hash_sets.cpp +154 -0
- patternjoin-0.1.0/performance_testing/timing_impl.hpp +28 -0
- patternjoin-0.1.0/pyproject.toml +37 -0
- patternjoin-0.1.0/python/CMakeLists.txt +26 -0
- patternjoin-0.1.0/python/README.md +66 -0
- patternjoin-0.1.0/python/bindings.cpp +27 -0
- patternjoin-0.1.0/python/patternjoin/GCC_RUNTIME_LICENSE.txt +754 -0
- patternjoin-0.1.0/python/patternjoin/THIRD_PARTY_NOTICES.txt +485 -0
- patternjoin-0.1.0/python/patternjoin/__init__.py +38 -0
- patternjoin-0.1.0/python/tests/test_join.py +118 -0
- patternjoin-0.1.0/src/bounded_edit_distance.hpp +136 -0
- patternjoin-0.1.0/src/duplicates_search.hpp +69 -0
- patternjoin-0.1.0/src/file_io.cpp +72 -0
- patternjoin-0.1.0/src/file_io.hpp +26 -0
- patternjoin-0.1.0/src/hash_containers.hpp +23 -0
- patternjoin-0.1.0/src/main.cpp +184 -0
- patternjoin-0.1.0/src/map_patterns.hpp +99 -0
- patternjoin-0.1.0/src/patterns_generators.cpp +189 -0
- patternjoin-0.1.0/src/patterns_generators.hpp +43 -0
- patternjoin-0.1.0/src/sim_search_part_patterns.cpp +159 -0
- patternjoin-0.1.0/src/sim_search_part_patterns.hpp +138 -0
- patternjoin-0.1.0/src/sim_search_patterns.cpp +52 -0
- patternjoin-0.1.0/src/sim_search_patterns.hpp +30 -0
- patternjoin-0.1.0/src/sim_search_semi_patterns.cpp +99 -0
- patternjoin-0.1.0/src/sim_search_semi_patterns.hpp +178 -0
- patternjoin-0.1.0/src/trim_strings.hpp +98 -0
- patternjoin-0.1.0/test/test.py +167 -0
- patternjoin-0.1.0/test/test_cli.py +272 -0
- patternjoin-0.1.0/test/test_cross_join.cpp +156 -0
- patternjoin-0.1.0/thirdparty/concurrentqueue.h +3747 -0
- patternjoin-0.1.0/thirdparty/gtl/adv_utils.hpp +104 -0
- patternjoin-0.1.0/thirdparty/gtl/bit_vector.hpp +1063 -0
- patternjoin-0.1.0/thirdparty/gtl/bits.hpp +618 -0
- patternjoin-0.1.0/thirdparty/gtl/btree.hpp +3919 -0
- patternjoin-0.1.0/thirdparty/gtl/combinators.hpp +64 -0
- patternjoin-0.1.0/thirdparty/gtl/debug_vis/gtl.natvis +162 -0
- patternjoin-0.1.0/thirdparty/gtl/debug_vis/gtl_gdb.py +201 -0
- patternjoin-0.1.0/thirdparty/gtl/debug_vis/gtl_lldb.py +248 -0
- patternjoin-0.1.0/thirdparty/gtl/gtl_base.hpp +989 -0
- patternjoin-0.1.0/thirdparty/gtl/gtl_config.hpp +287 -0
- patternjoin-0.1.0/thirdparty/gtl/intrusive.hpp +385 -0
- patternjoin-0.1.0/thirdparty/gtl/lru_cache.hpp +125 -0
- patternjoin-0.1.0/thirdparty/gtl/meminfo.hpp +199 -0
- patternjoin-0.1.0/thirdparty/gtl/memoize.hpp +322 -0
- patternjoin-0.1.0/thirdparty/gtl/phmap.hpp +5659 -0
- patternjoin-0.1.0/thirdparty/gtl/phmap_dump.hpp +311 -0
- patternjoin-0.1.0/thirdparty/gtl/phmap_fwd_decl.hpp +263 -0
- patternjoin-0.1.0/thirdparty/gtl/phmap_utils.hpp +360 -0
- patternjoin-0.1.0/thirdparty/gtl/soa.hpp +220 -0
- patternjoin-0.1.0/thirdparty/gtl/stopwatch.hpp +88 -0
- patternjoin-0.1.0/thirdparty/gtl/utils.hpp +235 -0
- patternjoin-0.1.0/thirdparty/gtl/vec_utils.hpp +80 -0
- patternjoin-0.1.0/thirdparty/gtl/vector.hpp +1647 -0
- patternjoin-0.1.0/thirdparty/hash_set8.hpp +1535 -0
- patternjoin-0.1.0/thirdparty/hash_table8.hpp +1829 -0
- patternjoin-0.1.0/thirdparty/small_vector.hpp +6461 -0
- patternjoin-0.1.0/thirdparty/unordered_dense.h +2032 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
curl -fLsS --retry 3 \
|
|
5
|
+
https://github.com/uxlfoundation/oneTBB/archive/refs/tags/v2022.0.0.tar.gz \
|
|
6
|
+
-o /tmp/tbb.tar.gz
|
|
7
|
+
echo 'e8e89c9c345415b17b30a2db3095ba9d47647611662073f7fbf54ad48b7f3c2a /tmp/tbb.tar.gz' \
|
|
8
|
+
| sha256sum -c -
|
|
9
|
+
tar -xzf /tmp/tbb.tar.gz -C /tmp
|
|
10
|
+
cmake -S /tmp/oneTBB-2022.0.0 -B /tmp/tbb-build \
|
|
11
|
+
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local \
|
|
12
|
+
-DTBB_TEST=OFF -DTBB_STRICT=OFF -DTBBMALLOC_BUILD=OFF
|
|
13
|
+
cmake --build /tmp/tbb-build --parallel 2
|
|
14
|
+
cmake --install /tmp/tbb-build
|
|
15
|
+
ldconfig
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
name: Python distributions
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
inputs:
|
|
11
|
+
testpypi:
|
|
12
|
+
description: Publish to TestPyPI
|
|
13
|
+
type: boolean
|
|
14
|
+
default: false
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
wheels:
|
|
21
|
+
strategy:
|
|
22
|
+
fail-fast: false
|
|
23
|
+
matrix:
|
|
24
|
+
os: [ubuntu-24.04, macos-15-intel, macos-15]
|
|
25
|
+
runs-on: ${{ matrix.os }}
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v6
|
|
28
|
+
- uses: pypa/cibuildwheel@v4.2.1
|
|
29
|
+
- uses: actions/upload-artifact@v7
|
|
30
|
+
with:
|
|
31
|
+
name: dist-${{ matrix.os }}
|
|
32
|
+
path: wheelhouse/*.whl
|
|
33
|
+
if-no-files-found: error
|
|
34
|
+
|
|
35
|
+
sdist:
|
|
36
|
+
runs-on: ubuntu-24.04
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v6
|
|
39
|
+
- uses: actions/setup-python@v6
|
|
40
|
+
with:
|
|
41
|
+
python-version: '3.12'
|
|
42
|
+
- run: python -m pip install build twine
|
|
43
|
+
- run: python -m build --sdist
|
|
44
|
+
- run: python -m twine check --strict dist/*
|
|
45
|
+
- name: Check release version
|
|
46
|
+
if: github.event_name == 'release'
|
|
47
|
+
env:
|
|
48
|
+
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
|
49
|
+
run: |
|
|
50
|
+
python - <<'PY'
|
|
51
|
+
import os
|
|
52
|
+
import tomllib
|
|
53
|
+
with open('pyproject.toml', 'rb') as source:
|
|
54
|
+
version = tomllib.load(source)['project']['version']
|
|
55
|
+
assert os.environ['RELEASE_TAG'] == f'v{version}'
|
|
56
|
+
PY
|
|
57
|
+
- uses: actions/upload-artifact@v7
|
|
58
|
+
with:
|
|
59
|
+
name: dist-sdist
|
|
60
|
+
path: dist/*.tar.gz
|
|
61
|
+
if-no-files-found: error
|
|
62
|
+
|
|
63
|
+
publish:
|
|
64
|
+
needs: [wheels, sdist]
|
|
65
|
+
if: github.event_name == 'release'
|
|
66
|
+
runs-on: ubuntu-24.04
|
|
67
|
+
environment:
|
|
68
|
+
name: pypi
|
|
69
|
+
url: https://pypi.org/p/patternjoin
|
|
70
|
+
permissions:
|
|
71
|
+
id-token: write
|
|
72
|
+
steps:
|
|
73
|
+
- uses: actions/download-artifact@v8
|
|
74
|
+
with:
|
|
75
|
+
pattern: dist-*
|
|
76
|
+
path: dist
|
|
77
|
+
merge-multiple: true
|
|
78
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
79
|
+
|
|
80
|
+
testpypi:
|
|
81
|
+
needs: [wheels, sdist]
|
|
82
|
+
if: >-
|
|
83
|
+
github.event_name == 'workflow_dispatch' &&
|
|
84
|
+
github.ref == 'refs/heads/main' && inputs.testpypi
|
|
85
|
+
runs-on: ubuntu-24.04
|
|
86
|
+
environment:
|
|
87
|
+
name: testpypi
|
|
88
|
+
url: https://test.pypi.org/p/patternjoin
|
|
89
|
+
permissions:
|
|
90
|
+
id-token: write
|
|
91
|
+
steps:
|
|
92
|
+
- uses: actions/download-artifact@v8
|
|
93
|
+
with:
|
|
94
|
+
pattern: dist-*
|
|
95
|
+
path: dist
|
|
96
|
+
merge-multiple: true
|
|
97
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
98
|
+
with:
|
|
99
|
+
repository-url: https://test.pypi.org/legacy/
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.10)
|
|
2
|
+
project(pattern_join)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
5
|
+
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -Wextra -Wpedantic -Werror")
|
|
6
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
7
|
+
|
|
8
|
+
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
9
|
+
set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include")
|
|
10
|
+
set(OpenMP_C_LIB_NAMES "omp")
|
|
11
|
+
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include")
|
|
12
|
+
set(OpenMP_CXX_LIB_NAMES "omp")
|
|
13
|
+
set(OpenMP_omp_LIBRARY "/usr/local/opt/libomp/lib/libomp.dylib")
|
|
14
|
+
endif()
|
|
15
|
+
|
|
16
|
+
find_package(OpenMP REQUIRED)
|
|
17
|
+
find_package(TBB REQUIRED)
|
|
18
|
+
|
|
19
|
+
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
|
20
|
+
set(OBJ_DIR "${CMAKE_CURRENT_BINARY_DIR}/obj")
|
|
21
|
+
|
|
22
|
+
file(GLOB SOURCES "${SRC_DIR}/*.cpp")
|
|
23
|
+
add_executable(pattern_join ${SOURCES})
|
|
24
|
+
|
|
25
|
+
target_link_libraries(pattern_join PUBLIC OpenMP::OpenMP_CXX TBB::tbb)
|
|
26
|
+
|
|
27
|
+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Daniil Matveev <i@mdaniil.ru>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: patternjoin
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: String similarity joins using C++ and OpenMP
|
|
5
|
+
Author: Daniil Matveev
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2024 Daniil Matveev <i@mdaniil.ru>
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Repository, https://github.com/MatveevDaniil/PatternJoinThreaded
|
|
29
|
+
Requires-Python: >=3.9
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# PatternJoin for Python
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from patternjoin import join
|
|
36
|
+
|
|
37
|
+
join(["cat", "dog"], ["bat", "cat"], cutoff=1, threads=4)
|
|
38
|
+
# [(0, 0), (0, 1)]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`join(a, b=None, *, cutoff=1, metric="L", threads=0)` returns sorted
|
|
42
|
+
zero-based index pairs. `join(a)` means `join(a, a)`: it includes
|
|
43
|
+
the diagonal and both orientations. Duplicate strings retain their
|
|
44
|
+
original positions. Empty iterables and empty strings are valid.
|
|
45
|
+
Inputs can be iterables of ASCII strings, including generators.
|
|
46
|
+
Non-ASCII strings are rejected because the C++ routines count bytes.
|
|
47
|
+
|
|
48
|
+
Cutoffs are 0, 1 or 2. `metric="L"` is Levenshtein distance;
|
|
49
|
+
`metric="H"` counts positional mismatches plus the length difference.
|
|
50
|
+
Nonzero cutoffs use the existing semi-pattern implementation with
|
|
51
|
+
the smaller input indexed. Cutoff 0 uses serial exact matching.
|
|
52
|
+
|
|
53
|
+
`threads=0` uses the OpenMP default, configurable with
|
|
54
|
+
`OMP_NUM_THREADS` before starting Python. Use `threads=1` for serial
|
|
55
|
+
execution or a positive number to set the count for one call.
|
|
56
|
+
Calls release the GIL. More threads need not make small joins faster.
|
|
57
|
+
The package returns results in memory and does not create files.
|
|
58
|
+
|
|
59
|
+
## Build and test
|
|
60
|
+
|
|
61
|
+
A C++20 compiler, CMake, OpenMP and TBB are required. On macOS:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
brew install libomp tbb
|
|
65
|
+
python -m pip install .
|
|
66
|
+
python -m pip install pytest
|
|
67
|
+
python -m pytest python/tests
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
On Linux, install the compiler's OpenMP runtime and TBB development
|
|
71
|
+
package first. If CMake cannot locate TBB, set `CMAKE_PREFIX_PATH`
|
|
72
|
+
to its installation prefix. Native Windows builds are not tested.
|
|
73
|
+
|
|
74
|
+
Build distribution archives with `python -m build`. Locally built
|
|
75
|
+
wheels depend on the installed OpenMP/TBB libraries. For a portable
|
|
76
|
+
macOS wheel, run `delocate-wheel -w wheelhouse dist/*.whl` and test
|
|
77
|
+
the repaired wheel in a fresh environment. Linux wheels need the
|
|
78
|
+
corresponding `auditwheel repair` workflow. Nothing is published
|
|
79
|
+
to PyPI by these commands.
|
|
80
|
+
|
|
81
|
+
## Releases
|
|
82
|
+
|
|
83
|
+
`.github/workflows/publish.yml` builds and tests CPython 3.9–3.14
|
|
84
|
+
wheels for Linux x86-64 and macOS 15+ (Intel and Apple Silicon),
|
|
85
|
+
bundling the native runtime libraries. Pull requests only build/test.
|
|
86
|
+
|
|
87
|
+
Configure a PyPI Trusted Publisher for project `patternjoin`, owner
|
|
88
|
+
`MatveevDaniil`, repository `PatternJoinThreaded`, workflow
|
|
89
|
+
`publish.yml`, environment `pypi`. No API token is needed.
|
|
90
|
+
For a trial upload, configure the same publisher on TestPyPI with
|
|
91
|
+
environment `testpypi`, then manually run the workflow on `main`
|
|
92
|
+
with `testpypi` enabled.
|
|
93
|
+
|
|
94
|
+
To publish, update the version in `pyproject.toml`, merge the change,
|
|
95
|
+
and publish a GitHub release with the matching tag (e.g. `v0.1.0`).
|
|
96
|
+
After all wheel tests pass, the workflow uploads wheels and the
|
|
97
|
+
source archive to PyPI. Each release needs a new version.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# PatternJoinThreaded
|
|
2
|
+
This project is an experimental version of PatternJoin project, and is designed to test parallelization capabilities of our algorithms. In order to read more about the main algorithms please visit our [C++](https://github.com/MatveevDaniil/PatternJoin) or [R](https://matveevdaniil.r-universe.dev/RPatternJoin) packages.
|
|
3
|
+
|
|
4
|
+
Python installation and API: [python/README.md](python/README.md).
|
|
5
|
+
|
|
6
|
+
## What is Edit Similarity Join?
|
|
7
|
+
[_Edit distance_](https://en.wikipedia.org/w/index.php?search=Edit+distance&title=Special:Search&ns0=1) between two words is the minimal number of _elementary operations_ needed to transform one word to another. In this project, we consider [_Levenshtein distance_](https://en.wikipedia.org/wiki/Levenshtein_distance) (allows _substitutions_ and _insertions_/_deletions_ of single letters) and [_Hamming distance_](https://en.wikipedia.org/wiki/Hamming_distance) (allows _substitutions_ of any letters and _insertions_/_deletions_ of letters in the end).
|
|
8
|
+
|
|
9
|
+
_Edit Similarity Join_ is a specific problem when we have a set of words $X=\\{w_1, w_2, \ldots, w_n\\}$ and we want to find all pairs of 'similar words' $Y_c=\\{(w_i, w_j): distance(w_i, w_j) < c\\}$, where $c \in \mathbb{N}_0$ is called a _cutoff_ parameter.
|
|
10
|
+
|
|
11
|
+
## Motivation
|
|
12
|
+
Let's briefly introduce the problem why this project was originally developed.
|
|
13
|
+
|
|
14
|
+
### Intro to TCR(BCR) profiles
|
|
15
|
+
__T-cells__ and __B-cells__ are types of white blood immune cells which play a major role in human immunity. On the surface of each T/B-cell we can find receptors (__TCR__/__BCR__) - special molecules that are responsible for recognizing antigens. The collection of all TCRs/BCRs is called __TCR (BCR) profile__. One way to represent an organism's TCR/BCR profile is to collect the genetic sequences of most variable region (CDR3) of each TCR/BCR. Recent research (for instance [[1]](https://www.nature.com/articles/s41467-019-09278-8), [[2]](https://academic.oup.com/bioinformatics/article/36/6/1731/5686386)) shows that it is useful to (1) represent these profiles as graphs with nodes being TCR/BCR and edge weights edit distances between nodes and (2) run some network analysis on these graphs (take a look at the [NAIR](https://github.com/mlizhangx/Network-Analysis-for-Repertoire-Sequencing-) project if you are interested in network analysis in immunology). In order to build these graphs we need efficient edit similarity join software and this is the main purpose of this project.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Parallel Hash Set and Hash Map Performance benchmarks
|
|
19
|
+
To run performance benchmarks you need to compile performance_testing subproject:
|
|
20
|
+
|
|
21
|
+
```shell
|
|
22
|
+
> cd performance_testing
|
|
23
|
+
> mkdir build; cd build
|
|
24
|
+
> cmake -DCMAKE_BUILD_TYPE=Release ..; make
|
|
25
|
+
> cd ..
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Then in order you can run hash_set and hash_map tests using
|
|
29
|
+
```shell
|
|
30
|
+
# assuming you are in PatternJoinThreaded/performance_testing directory
|
|
31
|
+
> ./build/threaded_hash_sets
|
|
32
|
+
> ./build/threaded_hash_maps
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
When the tests will finish generate figures using
|
|
36
|
+
```shell
|
|
37
|
+
> pip install pandas seaborn matplotlib
|
|
38
|
+
> python plot_results.py
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Parallel Partition-Pattern Join Algorithm
|
|
42
|
+
To run partition_pattern algorithm using several threads firstly compile the project
|
|
43
|
+
```shell
|
|
44
|
+
# assuming you are in PatternJoinThreaded directory
|
|
45
|
+
> mkdir build; cd build; cmake -DCMAKE_BUILD_TYPE=Release ..; make; cd ..
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Below we give an example of algorithm launch:
|
|
49
|
+
```shell
|
|
50
|
+
> export FILE_NAME=./performance_testing/test_data/P00245-aa
|
|
51
|
+
> export CUTOFF=2
|
|
52
|
+
> export METRIC_TYPE=L
|
|
53
|
+
> export METHOD=partition_pattern
|
|
54
|
+
> export INCLUDE_DUPLICATES=false
|
|
55
|
+
> ./build/pattern_join --file_name $FILE_NAME --cutoff $CUTOFF --metric_type $METRIC_TYPE --method $METHOD --include_duplicates $INCLUDE_DUPLICATES
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Full list of arguments:
|
|
59
|
+
- `<file_name>`: The path to the input file.
|
|
60
|
+
- `--file_names <file_a> <file_b>`: Join two files instead of `--file_name`. Results use original A/B indices (`include_duplicates=true`) or unique string pairs (`false`), written to `<file_a>_cross_sp_<cutoff>_<metric>`. Cutoff 0 writes exact-match index pairs to `<file_a>_cross_dupl`. Nonzero cutoffs currently support only `semi_pattern`; use `OMP_NUM_THREADS` to control threads.
|
|
61
|
+
- `<cutoff>`: The edit distance cutoff (`0`, `1` or `2`). If `cutoff` = 0, then the value of `metric_type`, `method`, and `include_duplicates` does not matter.
|
|
62
|
+
- `<metric_type>`: The edit distance metric (`L` for Levenshtein, `H` for Hamming).
|
|
63
|
+
- `<method>`: Two-file joins support `semi_pattern`; single-file joins also support `pattern` and `partition_pattern`.
|
|
64
|
+
- `<include_duplicates>`: Consider duplicates in input (`true` or `false`). If `false` the program will ignore duplicate strings in the input and output unique pairs of strings. If `true`, the program will treat duplicate strings in the input as a pair (index, string) and output pairs of indices.
|
|
65
|
+
|
|
66
|
+
### Input file format
|
|
67
|
+
List of words separated by `\n`: `<word_1>\n<word_2>\n...`.
|
|
68
|
+
|
|
69
|
+
### Output file format
|
|
70
|
+
If `include_duplicates = true`: Space-separated pairs of words separated by `\n`: `<word_i> <word_j>\n...`.
|
|
71
|
+
If `include_duplicates = false`: Space-separated pairs of indeces separated by `\n`: `<idx_i> <idx_j>\n...`.
|