.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gallery/sequence/homology/luxa_comparison.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_gallery_sequence_homology_luxa_comparison.py: Fetching and aligning a protein from different species ====================================================== .. currentmodule:: biotite.sequence.align This script creates a multiple sequence alignment of the bacterial luciferase gene *luxA* using the :func:`align_multiple()` function provided by *Biotite*. .. GENERATED FROM PYTHON SOURCE LINES 11-55 .. image-sg:: /examples/gallery/sequence/homology/images/sphx_glr_luxa_comparison_001.png :alt: luxa comparison :srcset: /examples/gallery/sequence/homology/images/sphx_glr_luxa_comparison_001.png, /examples/gallery/sequence/homology/images/sphx_glr_luxa_comparison_001_2_00x.png 2.00x :class: sphx-glr-single-img .. code-block:: Python # Code source: Patrick Kunzmann # License: BSD 3 clause import matplotlib.pyplot as plt import biotite.database.entrez as entrez import biotite.sequence as seq import biotite.sequence.align as align import biotite.sequence.graphics as graphics import biotite.sequence.io.fasta as fasta # Search for protein products of LexA gene in UniProtKB/Swiss-Prot database query = entrez.SimpleQuery("luxA", "Gene Name") & entrez.SimpleQuery( "srcdb_swiss-prot", "Properties" ) uids = entrez.search(query, db_name="protein") fasta_file = fasta.FastaFile.read( entrez.fetch_single_file(uids, None, db_name="protein", ret_type="fasta") ) ids = [] sequences = [] for header, seq_str in fasta_file.items(): # Extract the UniProt Entry name from header identifier = header.split("|")[-1].split()[0] ids.append(identifier) sequences.append(seq.ProteinSequence(seq_str)) matrix = align.SubstitutionMatrix.std_protein_matrix() alignment, order, tree, distances = align.align_multiple( sequences, matrix, gap_penalty=(-10, -1), terminal_penalty=False ) # Order alignment according to the guide tree alignment = alignment[:, order] ids = [ids[i] for i in order] fig = plt.figure(figsize=(8.0, 20.0)) ax = fig.add_subplot(111) graphics.plot_alignment_type_based( ax, alignment, labels=ids, show_numbers=True, spacing=2.0, color_scheme="blossom" ) fig.tight_layout() plt.show() .. _sphx_glr_download_examples_gallery_sequence_homology_luxa_comparison.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: luxa_comparison.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: luxa_comparison.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: luxa_comparison.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_