.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gallery/sequence/read_quality.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_read_quality.py: Quality of sequence reads ========================= This script plots the sequencing quality scores from an FASTQ file along with the sequence (base calls). .. GENERATED FROM PYTHON SOURCE LINES 8-49 .. image-sg:: /examples/gallery/sequence/images/sphx_glr_read_quality_001.png :alt: read quality :srcset: /examples/gallery/sequence/images/sphx_glr_read_quality_001.png :class: sphx-glr-single-img .. code-block:: Python # Code source: Patrick Kunzmann # License: BSD 3 clause from io import StringIO import numpy as np import matplotlib.pyplot as plt import biotite import biotite.sequence as seq import biotite.sequence.io.fastq as fastq # Sample FASTQ file from https://en.wikipedia.org/wiki/FASTQ_format fastq_content = StringIO(""" @SEQ_ID GATTTGGGGTTCAAAGCAGTATCGATCAAATAGTAAATCCATTTGTTCAACTCACAGTTT + !''*((((***+))%%%++)(%%%%).1***-+*''))**55CCF>>>>>>CCCCCCC65 """) fastq_file = fastq.FastqFile.read(fastq_content, offset="Sanger") sequence, scores = fastq.get_sequence(fastq_file, "SEQ_ID") figure, ax = plt.subplots(figsize=(8.0, 2.0)) ax.bar( x=np.arange(len(sequence)), height=scores, color=biotite.colors["orange"], width=1.0, linewidth=1, edgecolor="white" ) # -1 to put space between Y-axis and sequence ax.set_xlim(-1, len(sequence)) # The range of Phred scores ax.set_ylim(0, 40) ax.set_ylabel("Phred score") ax.spines["right"].set_visible(False) ax.spines["top"].set_visible(False) ax.spines["bottom"].set_visible(False) # Show sequence as X-axis ticks ax.set_xticks(np.arange(len(sequence))) ax.set_xticklabels(sequence.symbols) ax.xaxis.set_ticks_position("none") figure.tight_layout() plt.show() .. _sphx_glr_download_examples_gallery_sequence_read_quality.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: read_quality.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: read_quality.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_