jpegdna.format package¶
Module contents¶
Formatter collections for the Jpeg DNA codecs
- class jpegdna.format.AbstractFormatter[source]¶
Bases:
abc.ABC
Abstract class for formatter definition
- abstract deformat(oligos)[source]¶
Decoding method
- Parameters
code (list) – Formated oligos to deformat
- Returns
Deformated strand
- Return type
str
- abstract format(inp)[source]¶
Encoding method
- Parameters
inp (str) – Strand to format
- Returns
Formatted oligos
- Return type
list
- full_deformat(oligos, *args)[source]¶
Encoding method
- Parameters
code (list) – Formated oligos to deformat
args (any) – Deformatting arguments
- Returns
Deformated strand
- Return type
str
- full_format(inp, *args)[source]¶
Encoding method
- Parameters
inp (str) – Strand to format
args (any) – Header info
- Returns
Formatted oligos
- Return type
list
jpegdna.format.dataformatter module¶
Formatting method for data oligo
- class jpegdna.format.dataformatter.DataFormatter(header, oligo_length=200, debug=False)[source]¶
Bases:
jpegdna.format.AbstractFormatter
Formatter for the strand coming out of the compression algorithm
- Variables
oligo_length – Size of the oligos used for formatting
jpegdna.format.frequenciesformatter module¶
Formatting method for frequencies
- class jpegdna.format.frequenciesformatter.GrayFrequenciesFormatter(max_cat, max_runcat, dc_freq_len, ac_freq_len, header, dc_header, ac_header, oligo_length=200, debug=False)[source]¶
Bases:
jpegdna.format.AbstractFormatter
Formatter for the gray DC and AC frequencies
- Variables
max_cat – max value for the categories
max_runcat – max value for the run/categories
dc_freq_len – codeword length for encoding the dc frequencies
ac_freq_len – codeword length for encoding the ac frequencies
oligo_length – Size of the oligos used for formatting
- decode_frequencies(strand, freq_type)[source]¶
Decode the frequencies using fixed-length codebooks
- Parameters
strand (str) – encoded frequency values
freq_type (str) – DC/AC frequency indicator
- Returns
list of frequency values
- Return type
list(int)
- deformat(oligos)[source]¶
Deformats and decodes both DC and AC frequency oligos
- Parameters
oligos (list(str)) – formatted frequency oligos for AC and DC
- Returns
decoded frequency tables
- Return type
tuple(list(int))
- deformat_frequencies(oligos)[source]¶
Deformat the oligos describing either the DC or the AC frequencies
- Parameters
oligos – oligos to deformat
freq_type (str) – DC/AC frequency indicator
- Returns
strand encoding the frequencies
- Return type
str
- encode_frequencies(freqs, freq_type)[source]¶
Encode the frequencies using fixed-length codebooks
- Parameters
freqs (list(int)) – frequency values to encode
freq_type (str) – DC/AC frequency indicator
- Returns
strand encoding the frequencies
- Return type
str
- class jpegdna.format.frequenciesformatter.RGBFrequenciesFormatter(max_cat, max_runcat, dc_freq_len, ac_freq_len, header, dc_header, ac_header, oligo_length=200, debug=False)[source]¶
Bases:
jpegdna.format.frequenciesformatter.GrayFrequenciesFormatter
Formatter for the RGB DC and AC frequencies
- Variables
max_cat – max value for the categories
max_runcat – max value for the run/categories
dc_freq_len – codeword length for encoding the dc frequencies
ac_freq_len – codeword length for encoding the ac frequencies
oligo_length – Size of the oligos used for formatting
jpegdna.format.generalinfoformatter module¶
Formatting method for general info oligo
- class jpegdna.format.generalinfoformatter.GeneralInfoFormatter(alpha, freq_origin, m, n, blockdims, max_cat, max_runcat, dc_freq_len, ac_freq_len, image_type, sampler, header, oligo_length=200, debug=False)[source]¶
Bases:
jpegdna.format.AbstractFormatter
Formatter for the general information related to the compression
- Variables
alpha – alpha value of the compression, if it is known
freq_origin – origin of the frequencies (“default” or “from_img”)
m – first dimension of the image
n – second dimension of the image
blockdims – dimensions of the block used for DCT
max_cat – max value for the categories
max_runcat – max value for the run/categories
dc_freq_len – codeword length for encoding the dc frequencies
ac_freq_len – codeword length for encoding the ac frequencies
oligo_length – Size of the oligos used for formatting
jpegdna.format.jpegdnaformatter module¶
Gray-level strand formatter
- class jpegdna.format.jpegdnaformatter.JpegDNAFormatter(alpha, image_type, sampler='4:2:2', freq_origin=None, primer='illumina', oligo_length=200, debug=False)[source]¶
Bases:
jpegdna.format.AbstractFormatter
Jpeg DNA gray level formatter class
- Parameters
aplha – Alpha value (quantization step multiplier)
freq_origin (str) – Choose between default and adapted frequencies
primer (str) – Primer name used
- PRIMERS = {'illumina': ('GTTCAGAGTTCTACAGTCCGACGATC', 'TGGAATTCTCGGGTGCCAAGG'), 'none': ('', '')}[source]¶
- add_ids(oligos, n)[source]¶
Adding primers to formatted oligos
- Parameters
oligos (list) – list of formatted oligos without offset
- Returns
list of oligos with offset added at the beginning of each oligo
- Rtpye
list
- add_parity_strand(data, image_id, sense_nt)[source]¶
Computes the parity strand for the current oligo
- Parameters
data (str) – strand on which to compute parities for each base
image_id (str) – id of the image
sense_nt – sense nucelotide
- add_primers_and_sense(oligos)[source]¶
Adding primers to formatted oligos
- Parameters
oligos (list) – list of formatted oligos without primers
- Returns
list of oligos with primers added at the beginning and at the end of each oligo
- Rtpye
list
- add_sense_nt(pos)[source]¶
Compute the sens nucleotide either the beginning one or the ending one
- Parameters
pos (str) – either “begin” or “end”, position of the sense nt to compute
- Returns
sense nucleotide
- Return type
str
- cut_payload(el, n)[source]¶
Cuts the payoad in two halves after the n-th nucleotide
- Parameters
el (string) – Stand to be cut
- Returns
Two cuts
- Return type
Tuple(string)
- deformat(oligos)[source]¶
Decoding method
- Parameters
code (list) – Formated oligos to deformat
- Returns
Deformated strand
- Return type
str
- format(inp)[source]¶
Encoding method
- Parameters
inp (str) – Strand to format
- Returns
Formatted oligos
- Return type
list
- full_deformat(oligos, *args)[source]¶
Encoding method
- Parameters
code (list) – Formated oligos to deformat
args (any) – Deformatting arguments
- Returns
Deformated strand
- Return type
str
- full_format(inp, *args)[source]¶
Encoding method
- Parameters
inp (str) – Strand to format
args (any) – Header info
- Returns
Formatted oligos
- Return type
list