Package: pyfamsa
🐍🧮 PyFAMSACythonbindings and Python interface toFAMSA, an algorithm for ultra-scale multiple sequence alignments.⚠️ This package is based on FAMSA 2.🗺️ OverviewFAMSAis a method published in
2016 by Deorowiczet al.[1]for large-scale multiple sequence alignments.
It uses state-of-the-art time and memory optimizations as well as a fast
guide tree heuristic to reach very high performance and accuracy.PyFAMSA is a Python module that provides bindings toFAMSAusingCython. It implements a user-friendly, Pythonic
interface to align protein sequences using different parameters and access
results directly. It interacts with the FAMSA library interface, which has
the following advantages:single dependency: pyfamsa is distributed as a Python package, so you
can add it as a dependency to your project, and stop worrying about the
FAMSA binary being present on the end-user machine.no intermediate files: Everything happens in memory, in a Python object
you control, so you don't have to invoke the FAMSA CLI using a
sub-process and temporary files.friendly interface: The different guide tree build methods and
heuristics can be selected from the Python code with a simple keyword
argument when configuring a newAligner.🔧 InstallingPyFAMSA can be installed directly fromPyPI,
which hosts some pre-built wheels for the x86-64 architecture (Linux/OSX)
and the Aarch64 architecture (Linux only), as well as the code required to
compile from source with Cython:$pipinstallpyfamsaOtherwise, have a look at theInstallation pageof theonline documentation💡 ExampleLet's create some sequences in memory, align them using the UPGMA method,
(without any heuristic), and simply print the alignment on screen:frompyfamsaimportAligner,Sequencesequences=[Sequence(b"Sp8",b"GLGKVIVYGIVLGTKSDQFSNWVVWLFPWNGLQIHMMGII"),Sequence(b"Sp10",b"DPAVLFVIMLGTITKFSSEWFFAWLGLEINMMVII"),Sequence(b"Sp26",b"AAAAAAAAALLTYLGLFLGTDYENFAAAAANAWLGLEINMMAQI"),Sequence(b"Sp6",b"ASGAILTLGIYLFTLCAVISVSWYLAWLGLEINMMAII"),Sequence(b"Sp17",b"FAYTAPDLLLIGFLLKTVATFGDTWFQLWQGLDLNKMPVF"),Sequence(b"Sp33",b"PTILNIAGLHMETDINFSLAWFQAWGGLEINKQAIL"),]aligner=Aligner(guide_tree="upgma")msa=aligner.align(sequences)forsequenceinmsa:print(sequence.id.decode().ljust(10),sequence.sequence.decode())This should output the following:Sp10       --------DPAVLFVIMLGTIT-KFS--SEWFFAWLGLEINMMVII
Sp17       ---FAYTAPDLLLIGFLLKTVA-TFG--DTWFQLWQGLDLNKMPVF
Sp26       AAAAAAAAALLTYLGLFLGTDYENFA--AAAANAWLGLEINMMAQI
Sp33       -------PTILNIAGLHMETDI-NFS--LAWFQAWGGLEINKQAIL
Sp6        ------ASGAILTLGIYLFTLCAVIS--VSWYLAWLGLEINMMAII
Sp8        ------GLGKVIVYGIVLGTKSDQFSNWVVWLFPWNGLQIHMMGII🧶 Thread-safetyAlignerobjects are thread-safe, and thealignmethod is re-entrant. You
could batch process several alignments in parallel using aThreadPoolwith a single
aligner object:importglobimportmultiprocessing.poolimportBio.SeqIOfrompyfamsaimportAligner,Sequencefamilies=[[Sequence(r.id.encode(),r.seq.encode())forrinBio.SeqIO.parse(file,"fasta")]forfileinglob.glob("pyfamsa/tests/data/*.faa")]aligner=Aligner()withmultiprocessing.pool.ThreadPool()aspool:alignments=pool.map(aligner.align,families)🔎 See AlsoDone with your protein alignment? You may be interested in trimming it: in that
case, you could use thepytrimalPython
package, which wrapstrimAl2.0. Or perhaps
you want to build a HMM from the alignment? Then maybe have a look atpyhmmer, a Python package which
wrapsHMMER.💭 Feedback⚠️ Issue TrackerFound a bug ? Have an enhancement request ? Head over to theGitHub issue trackerif you need to report or ask something. If you are filing in on a bug,
please include as much information as you can about the issue, and try to
recreate the same bug in a simple, easily reproducible situation.🏗️ ContributingContributions are more than welcome! SeeCONTRIBUTING.mdfor more details.📋 ChangelogThis project adheres toSemantic Versioningand provides achangelogin theKeep a Changelogformat.⚖️ LicenseThis library is provided under theGNU General Public License v3.0. FAMSA is developed by theREFRESH Bioinformatics Groupand is
distributed under the terms of the GPLv3 as well. Seevendor/FAMSA/LICENSEfor more information. In addition, FAMSA vendors several libraries for
compatibility, all of which are redistributed with PyFAMSA under their own
terms:atomic_wait(MIT License),mimalloc(MIT License),libdeflate(MIT License),  Boost (Boost Software License).This project is in no way not affiliated, sponsored, or otherwise endorsed
by theFAMSA authors. It was developed
byMartin Larraldeduring his PhD project
at theEuropean Molecular Biology Laboratoryin
theZeller team.📚 References[1]Deorowicz, Sebastian, Debudaj-Grabysz, Agnieszka & Gudyś, Adam. ‘FAMSA: Fast and accurate multiple sequence alignment of huge protein families’. Sci Rep 6, 33964 (2016).doi:10.1038/srep33964