Package: minimappers2
Python bindings for theRust FFIminimap2library. In development! Feedback appreciated!Why?PyO3makes it very easy to create Python libraries via Rust. Further, we can usePolarsto export results as a dataframe (which can be used as-is, or converted to Pandas). Python allows for faster experimentation with novel algorithms, integration into machine learning pipelines, and provides an opportunity for those not familiar with Rust nor C/C++ to use minimap2.Current StateVery early alpha. Please use, and open an issue for any features you need that are missing, and for any bugs you find.How to useRequirementsPolars and PyArrow, these should be installed when you install minimappers2Creating an Aligner Instancealigner=map_ont()aligner.threads(4)If you want an alignment performed, rather than just matches, enable .cigar()aligner=map_hifi()aligner.cigar()Please note, at this time the following syntax isNOTsupported:aligner=map_ont().threads(4).cigar()Creating an indexaligner.index("ref.fa")To save a built-index, for future processing use:aligner.index_and_save("ref.fa","ref.mmi")Then next time you use the index will be faster if you use the saved index instead.aligner.load_index("ref.mmi")Aligning a Single Sequencequery=Sequence(seq_name,seq)aligner.map1(query)# Exampleseq="CCAGAACGTACAAGGAAATATCCTCAAATTATCCCAAGAATTGTCCGCAGGAAATGGGGATAATTTCAGAAATGAGAG"result=aligner.map1(Sequence("MySeq",seq))Where seq_name and seq are both strings. The output is a Polars DataFrame.Aligning Multiple Sequencesseqs=[Sequence("name of seq 1",seq1),Sequence("name of seq 2",seq1)]result=aligner.map(seqs)Example NotebookPlease see theexample notebookfor more examples.Mapping a filePleaseopen an issueif you need to map files from this API.ResultsAll results are returned asPolarsdataframes. You can convert Polars dataframes to Pandas dataframes with.to_pandas()Polars is the fastest dataframe library in the Python Ecosystem.Polars provides a nice data bridge between Rust and Python.For more information, please see thePolars User Guideor thePolars Guide for Pandas users.Example of ResultsHere is an image of the resulting dataframeNOTEMapq, Cigar, and others will not show up unless .cigar() is enabled on the aligner itself.ErrorsAs this is a very-early stage library, error checking is not yet implemented. When things crash you will likely need to restart your python interpreter (jupyter kernel). Let me know what happened andopen an issueand I will get to it.CompatabilityWindows: UnlikelyLinux: LikelyMac: Unknownx86_64: Likelyaarch64: Unknownneon: No (Open an issue)Google Colab: No, not sure why though.PerformanceEffort has been made to make this as performant as possible, but if you need more performance, please use minimap2 directly and import the results.CitationYou should cite the minimap2 papers if you use this in your work.Li, H. (2018). Minimap2: pairwise alignment for nucleotide sequences.Bioinformatics,34:3094-3100. [doi:10.1093/bioinformatics/bty191][doi]and/or:Li, H. (2021). New strategies to improve minimap2 alignment accuracy.Bioinformatics,37:4572-4574. [doi:10.1093/bioinformatics/btab705][doi2]Changelog0.1.0Initial Functions implementedReturn results as Polars dfsFunding