This project is a tool for words edit similarity joins (a.k.a. all-pairs similarity search) under small (
Edit distance between two words is the minimal number of elementary operations needed to transform one word to another. In this project, we consider Levenshtein distance (allows substitutions and insertions/deletions of single letters) and Hamming distance (allows substitutions of any letters and insertions/deletions of letters in the end).
Edit Similarity Join is a specific problem when we have a set of words
Let's briefly introduce the problem why this project was originally developed.
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], [2]) 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 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.
In progress..🧙
From the command line (Windows/macOS/Linux):
> git clone https://github.com/MatveevDaniil/PatternJoin.git
> cd PatternJoin
> mkdir build
> cd build
> cmake ..
> make
Assuming you are in the build directory
> pattern_join --file_name <..> --cutoff <..> --metric_type <..> --method <..> --include_duplicates <..>
> pattern_join.exe --file_name <..> --cutoff <..> --metric_type <..> --method <..> --include_duplicates <..>
<file_name>
: The path to the input file.<cutoff>
: The edit distance cutoff (0
,1
or2
). Ifcutoff
= 0, then the value ofmetric_type
,method
andinclude_duplicates
does not matter.<metric_type>
: The edit distance metric (L
for Levenshtein,H
for Hamming).<method>
: The core method of edit similarity join (pattern
,semi_pattern
, orpartition_pattern
). As default, we recommend usingpartition_pattern
as the most memory-efficient while still fast method. For more details take a look to the paper.<include_duplicates>
: Consider duplicates in input (true
orfalse
). Iffalse
the program will ignore duplicate strings in the input and output unique pairs of strings. Iftrue
program will treat duplicate strings in the input as a pair (index, string) and output pairs of indeces.
List of words separated by \n
: <word_1>\n<word_2>\n...
.
If include_duplicates = true
: Space-separated pairs of words separated by \n
: <word_i> <word_j>\n...
.
If include_duplicates = false
: Space-separated pairs of indeces separated by \n
: <idx_i> <idx_j>\n...
.
The performance of PatternJoin project is compared to several state-of-the-art projects for exact edit similarity join. Exact means that we find all pairs with a given edit distance threshold. Several projects such as VChunk, EmbedJoin, MinJoin and others were excluded due to low recall on tested datasets while not being faster. All compared projects were obtained from original authors (see table below). All tests were done on the same laptop with 16gb RAM and 2.2 GHz CPU.
Algorithm | Paper | Source code |
---|---|---|
QChunk* | link | link |
PassJoin | link | link |
TrieJoin | link | link |
AdaptJoin | link | link |
*Although QChunk algorithm is designed for exact similarity join we noticed that it produce some wrong pairs and ommit some correct pairs of strings. However recall and precision were
We obtained dataset from Cytomegalovirus research and took the largest TCR CDR3 Amino Acid profile (TODO: submit data) from it. There are
(TODO: introduce data). The number of sequences is
Currently, the project is using third-party software for hashmap, hashsets, and inlined vectors. Hashmaps and hashset are taken from the ankerl project and inlined vector from gch project. You can easily replace any of these containers with any other implementations of hashmap/hashset/vector by changing the corresponding line in src/hash_containers.h:
// src/hash_containers.hpp
using str2int = your_map<std::string, int>;
using ints = your_vector<int>;
using str2ints = your_map<std::string, ints>;
using int_pair_set = your_set<std::pair<int, int>>;
using str_pair_set = your_set<std::pair<std::string, std::string>>
- Finish documentation.
- Create R/Python packages.
- PAPER
- Cover edit distances
$\geq 3$ .