API reference

sequenticon.sequenticon(sequence, output_format='png', size=60, output_path=None)

Return sequenticon image data for the provided sequence.

Note: to change the number of rows and columns, or the colors of the sequenticon, change the values in sequenticons.SETTINGS.

Parameters:
  • sequence (str) – A string, for instance “ATTGTGCGTGTGC”. Sequenticon is case-insensitive and will upper-case the full sequence.

  • output_format (str) – One of “png”, “base64”, “html_image”. If “png”, raw PNG image data is returned (as bytes). If “base64”, the png data is base64-encoded (as a string), and if “html_image”, the returned string is <img src=’data:X’/> where X is the base64 image data (this string is ready to be used in a webpage).

  • size (int) – The sequenticon image will be of dimensions (size x size), in pixels.

  • output_path (str, optional) – Optional path to a PNG file to which to write the sequenticon.

sequenticon.sequenticon_batch(sequences, output_format='png', size=60, output_path=None)

Utility to generate sequenticons for a batch of sequences.

Parameters:
  • sequences (list) – A list of either name, sequence tuples, Biopython records (with different IDs), or paths to GenBank or FASTA files containing one or more records each.

  • output_format (str) – One of “png”, “base64”, “html_image”. If “png”, raw PNG image data is returned (as bytes). If “base64”, the PNG data is base64-encoded (as a string), and if “html_image”, the returned string is <img src=’data:X’/> where X is the base64 image data (this string is ready to be used in a webpage).

  • size (int) – The sequenticon image will be of dimensions (size x size), in pixels.

  • target (str, optional) – An optional folder or zip path in which to write the PNG files.

Returns:

sequenticons – A list of the form [(sequence_name, sequenticon_image_data), …].

Return type:

list of tuples

sequenticon.sequenticon_batch_pdf(sequences, target=None, title='Sequenticons batch')

Generate a PDF report with sequenticons for a batch of sequences.

Parameters:
  • sequences (list) – A list of either name, sequence tuples, Biopython records (with different IDs), or paths to GenBank or FASTA files containing one or more records each.

  • target (str or file-like object, optional) – Path to a PDF file, file-like object, or None to return raw PDF data.

  • title (str) – Title that will appear in the document.

sequenticon.load_records(path)