exonize_analysis module¶
Expansion
¶
Expansion class represents an expansion graph for a specific gene expansion.
Attributes: |
|
---|
__init__(expansion_id, nodes, edges)
¶
Initializes an Expansion instance.
Parameters: |
|
---|
ExpansionsContainer
¶
A container for managing gene expansions across an entire genome.
Attributes: |
|
---|
genes
property
¶
Returns a list of gene IDs.
Returns: |
|
---|
Examples:
>>> expansions_container.genes
['GENE123', 'GENE456', 'GENE789']
__contains__(n)
¶
Checks if a gene ID exists in the ExpansionsContainer.
Parameters: |
|
---|
Returns: |
|
---|
Examples:
>>> "GENE123" in expansions_container
True
__getitem__(gene_id)
¶
Retrieves a Gene object by gene ID.
Parameters: |
|
---|
Returns: |
|
---|
Examples:
>>> gene = expansions_container["GENE123"]
>>> print(gene)
<Gene GENE123 with 0 expansions (iterable of expansion graphs)>
__init__(exonize_db_path)
¶
Initializes a ExpansionsContainer instance and builds ExpansionsContainer from the database.
Parameters: |
|
---|
__iter__()
¶
Returns an iterator over the Gene objects.
Returns: |
|
---|
Examples:
>>> for gene in expansions_container:
... print(gene)
__len__()
¶
Returns the number of genes in the ExpansionsContainer.
Returns: |
|
---|
Examples:
>>> len(expansions_container)
18
build_expansions()
¶
Constructs the gene expansions from the Exonize database.
This method initializes each Gene object and populates its expansions based on data from the Exonize database. Each expansion consists of nodes and edges, forming a graph for each gene.
Examples:
>>> expansions_container.build_expansions()
>>> print(len(expansions_container))
18
read_genome(file_path)
¶
Reads the genome file and stores it in the genome dictionary.
Parameters: |
|
---|
Examples:
>>> gene = expansions_container.read_genome(
file_path='genome.fa.gz'
)
Gene
¶
Gene class is a container for gene expansion graphs.
Attributes: |
|
---|
__getitem__(expansion_id)
¶
Retrieves the expansion graph for the specified expansion ID.
Parameters: |
|
---|
Returns: |
|
---|
Examples:
>>> gene[1] # Retrieves the expansion graph for expansion ID 1
__init__(gene_id, coordinates, strand, chromosome)
¶
Initializes a Gene instance.
Parameters: |
|
---|
__iter__()
¶
Returns an iterator over the expansion graphs.
Returns: |
|
---|
Examples:
>>> for graph in gene:
... print(graph)
__len__()
¶
Returns the number of expansions associated with the gene.
Returns: |
|
---|
Examples:
>>> len(gene)
0
__repr__()
¶
Returns a string representation of the Gene object.
Returns: |
|
---|
Examples:
>>> repr(gene)
'<Gene GENE123 with 0 expansions (iterable of expansion graphs)>'
build_gene_graph()
¶
Builds and returns a consolidated gene graph containing nodes and edges from all expansion graphs.
Returns: |
|
---|
Examples:
>>> combined_graph = gene.build_gene_graph()
>>> print(combined_graph.nodes)
>>> print(combined_graph.edges)
draw_expansions_multigraph(expansion_id=None, figure_path=None, figure_size=(8.0, 8.0), legend=True, connect_overlapping_nodes=False, color_tandem_pair_edges=False, full_expansion=False, tandem_edges_color='blue')
¶
Draws a multi-graph of gene expansions.
Parameters: |
|
---|
draw_gene_structure(expansion_id=None, save_path=None)
¶
Visualize the gene structure, highlighting coding exons and expansion events.
This method uses the dna_features_viewer library to plot the gene structure, showing the locations
of coding exons and expansion events within the specified gene. The plot can be saved to a file if
save_path
is provided.
Parameters: |
|
---|
Returns: |
|
---|
write_expansion_sequences(expansion_id, output_path=None, full_expansion=False)
¶
Writes the sequences of the expansion events to a FASTA file.
Parameters: |
|
---|
Returns: |
|
---|
Examples:
>>> expansions_container["GENE123"].write_expansion_sequences(expansion_id=0, full_expansion=True)