.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gallery/sequence/region_visualization.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_region_visualization.py: Visualization of region in proximity to *lac* operon ==================================================== This script creates a feature map for the region around the *lac* operon in the E. coli BL21 genome. .. GENERATED FROM PYTHON SOURCE LINES 8-52 .. image-sg:: /examples/gallery/sequence/images/sphx_glr_region_visualization_001.png :alt: region visualization :srcset: /examples/gallery/sequence/images/sphx_glr_region_visualization_001.png :class: sphx-glr-single-img .. code-block:: Python # Code source: Patrick Kunzmann # License: BSD 3 clause import biotite.sequence as seq import biotite.sequence.graphics as graphics import biotite.sequence.io.genbank as gb import biotite.database.entrez as entrez import numpy as np import matplotlib.pyplot as plt # Download E. coli BL21 genome file = entrez.fetch("CP001509", None, suffix="gb", db_name="nuccore", ret_type="gb") gb_file = gb.GenBankFile.read(file) _, seq_length, _, _, _, _ = gb.get_locus(gb_file) annotation = gb.get_annotation(gb_file, include_only=["gene"]) # Find the minimum and maximum locations of lac genes min_loc = seq_length max_loc = 1 for feature in annotation: for loc in feature.locs: # Ignore if feature is only a pseudo-gene (e.g. gene fragment) # and check if feature is lacA gene (begin of lac operon) if "gene" in feature.qual \ and "pseudo" not in feature.qual \ and feature.qual["gene"] == "lacA": if min_loc > loc.first: min_loc = loc.first if max_loc < loc.last: max_loc = loc.last # Extend the location range by 1000 (arbitrary) in each direction min_loc -= 10000 max_loc += 10000 # Visualize the region as feature map fig = plt.figure(figsize=(8.0, 8.0)) ax = fig.add_subplot(111) graphics.plot_feature_map( ax, annotation, loc_range=(min_loc, max_loc), symbols_per_line=2000, show_numbers=True, show_line_position=True ) fig.tight_layout() plt.show() .. _sphx_glr_download_examples_gallery_sequence_region_visualization.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: region_visualization.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: region_visualization.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_