Constraints reports¶
Misc. plotting and reporting methods, some of which are really arbitrary.
Here is a typical example of use:
>>> import dnachisel.reports.constraint_reports as cr
>>> dataframe = cr.constraints_breaches_dataframe(constraints, sequences)
>>> dataframe.to_excel("output_breaches.xlsx")
>>> records = cr.records_from_breaches_dataframe(dataframe, sequences)
>>> cr.breaches_records_to_pdf(records, 'output_breaches_plots.pdf')
-
dnachisel.reports.constraints_reports.
records_from_breaches_dataframe
(dataframe, sequences)[source]¶ Generate records with annotations indicating constraints breaches.
- Parameters
dataframe
A breaches dataframe returned by
constraints_breaches_dataframe
sequences
Either a list [(“name”, “sequence”)…] or a dict {“name”: “sequence”} or a list of biopython records whole id is the sequence name.
-
dnachisel.reports.constraints_reports.
breaches_records_to_pdf
(breaches_records, pdf_path=None, figure_width=10, logger='bar')[source]¶ Plots figures of the breaches annotated in the records into a PDF file.
- Parameters
breaches_records
A least of records annotated with breaches, as returned by the
pdf_path
Either the path to a PDF, or a file handle (open in wb mode) or None for this method to return binary PDF data.
logger
Either “bar” for a progress bar, None for no logging, or any Proglog logger. The bar name is “sequence”.
-
dnachisel.reports.constraints_reports.
constraints_breaches_dataframe
(constraints, sequences, display_constraints_locations=False)[source]¶ Return a dataframe summarizing constraints breaches in the sequences.
Output dataframe schema (cst = constraint):
/
Cst1
Cst2
Seq1
10-50(+)
100-200(+), 300-350(+)
seq2
Seq3
2-10(+)
Seq4
500-1000(-)
- Parameters
constraints
A list of DNA Chisel Specifications.
sequences
Either a list [(“name”, “sequence”)…] or a dict {“name”: “sequence”} or a list of biopython records whole id is the sequence name.
Examples
>>> import dnachisel as dc >>> from dnachisel.utils import constraints_breaches_dataframe >>> sequences = [ >>> ("SEQ 1", "ATTGTGCATGTGACAC"), >>> ("SEQ 2", "ACATGTGTTGTGACAC"), >>> ("SEQ 3", "TTGTGCACACATGTGA"), >>> ] >>> constraints = [ >>> dc.AvoidPattern('ATTG'), >>> dc.EnforceGCContent(0.4, 0.6), >>> dc.UniquifyAllKmers(5) >>> ] >>> dataframe = constraints_breaches_dataframe(constraints, sequences) >>> dataframe.to_excel('summary_spreadsheet.xlsx')