Package: mappy-rs
Mappy-rsA multi-threaded minimap2 aligner for python. Built forreadfishcompatibility.Heavily leaning on and inspired by Joeseph Guhlin's minimap2-rsrepository. They also have a more heavily featured python client, which also provides multithreaded alignment. This client provides a more simple streaming interface for use in pipelines.pip install mappy-rsDevelopersStart with some Docs on Py03 -https://pyo3.rs/latest/If you wish to contribute, have a look atCONTRIBUTING.mdIn order to build an importable module:python-mvenv.envsource-m.env/bin/activate
pipinstall".[tests]"To run the tests:# Pythonpytest# Rustcargot--no-default-featuresThen in your python shell of choice:importmappy_rsaligner=mappy_rs.Aligner("resources/test/test.mmi")The current iteration ofmappy-rsserves as a drop in formappy, implementing all the same methods. However if this is the use case, you may well be better off usingmappy, as the extra level of Rust between your python and C++ may well add slightly slower performance.MultithreadingIn order to use multi threading, one must first enable it.importmappy_rsaligner=mappy_rs.Aligner("resources/test/test.mmi")# Use 10 threadsaligner.enable_threading(10)Enabling threading makes themap_batchmethod available.
This method requires a list or iterable of dictionaries, which can have any number of keys and depth, butmustcontain the keyseqwith a string value in the top-level dictionary.
Currently, the maximum batch size to be iterated in one call is 20000.For example:importmappy_rsaligner=mappy_rs.Aligner("resources/test/test.mmi")aligner.enable_threading(10)seqs=[{"seq":"ACGTAGCATCGAGACTACGA","Other_random_key":"banter"},{"seq":"ACGTAGCATCGAGACTACGA","Other_random_key":"banter"},]for(mapping,data)inaligner.map_batch(seqs):print(list(mapping))print(data)BenchmarksA simple benchmark against classic mappy, and mappy_rs with incrementing numbers of threads, run on a 2018 Macbook.DevicePropertyValueModel NameMacBook ProModel IdentifierMacBookPro15,2Processor NameQuad-Core Intel Core i7Processor Speed2.7 GHzNumber of Processors1Total Number of Cores4L2 Cache (per Core)256 KBL3 Cache8 MBHyper-Threading TechnologyEnabledMemory16 GBResultsName (time in s)MinMaxMeanStdDevMedianIQROutliersOPSRoundsIterationstest_benchmark_multi[5]26.8900 (1.0)30.0969 (1.0)28.0622 (1.0)1.2614 (1.0)27.9017 (1.0)1.6081 (1.35)1;00.0356 (1.0)51test_benchmark_multi[4]28.5573 (1.06)43.4543 (1.44)32.3371 (1.15)6.2815 (4.98)29.7480 (1.07)5.2148 (4.37)1;10.0309 (0.87)51test_benchmark_multi[3]31.6497 (1.18)36.9986 (1.23)33.5103 (1.19)2.0542 (1.63)32.8415 (1.18)1.9576 (1.64)1;00.0298 (0.84)51test_benchmark_multi[2]43.2616 (1.61)86.3859 (2.87)53.8572 (1.92)18.3339 (14.53)45.9328 (1.65)14.6382 (12.26)1;10.0186 (0.52)51test_classic_mappy[mappy_al]78.5566 (2.92)82.8876 (2.75)79.6177 (2.84)1.8343 (1.45)78.8350 (2.83)1.1938 (1.0)1;10.0126 (0.35)51test_classic_mappy[mappy_al_rs]83.7239 (3.11)87.9675 (2.92)85.4424 (3.04)1.6806 (1.33)85.6335 (3.07)2.3310 (1.95)2;00.0117 (0.33)51test_benchmark_multi[1]84.8418 (3.16)94.0907 (3.13)86.7404 (3.09)4.1096 (3.26)84.8749 (3.04)2.4310 (2.04)1;10.0115 (0.32)51Changelog0.0.6Lowered backoff time formap_batchto 50 milliseconds, with 6 attempts. Each attempt will double the previous back off time.Improved error handling formap_batch, now will raise aRuntimeErrorif the backoff time is exceeded. Also prevented loggingInternal error returning data, the receiver iterator has finished. sending on a disconnected channel 2870to stderr excessively.Added tests for mapping more than 50000 reads, usingback_off=Trueandback_off=False