gain.genomic_resources.implementations package

Subpackages

Submodules

gain.genomic_resources.implementations.ann_data_resource_impl module

Provides the ann_data resource implementation.

class AnnDataResourceImplementation(genomic_resource: GenomicResource)[source]

Bases: GenomicResourceImplementation, InfoImplementationMixin

AnnData resource implementation.

calc_info_hash() → bytes[source]

Compute the digest of the inputs of the info page.

The page is rendered again only when the digest changes.

Returns:

The digest of everything that get_info depends on.

Return type:

bytes

calc_statistics_hash() → bytes[source]

Compute the digest of the inputs of the statistics build.

grr_manage compares the digest with the stored one to decide whether it must compute the statistics again.

Returns:

The digest of everything that the statistics tasks read.

Return type:

bytes

create_statistics_build_tasks(*, region_size: int = 3000000000, grr: GenomicResourceRepo | None = None) → list[TaskDesc][source]

Create the task graph tasks that compute the statistics.

grr_manage calls every kind with the same two keyword-only arguments. An implementation declares both, even when it ignores them, and declares no other argument.

Parameters:
  • region_size (int) – The longest region that one task covers. A kind that splits its build by genomic region reads it. 0 means do not split: a genomic score then scans the resource in one pass and a reference genome uses one region for each chromosome. A kind that does not split ignores it.

  • grr (GenomicResourceRepo | None) – The repository that holds the resource. None means that the caller names no repository.

Returns:

The tasks of the build. An empty list means that the kind has no statistics to compute.

Return type:

list[TaskDesc]

Raises:

ValueError – If region_size is negative.

property files: set[str]

The names of the resource files that the implementation reads.

get_info(**kwargs: Any) → str[source]

Render the HTML of the info page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

get_statistics_info(**kwargs: Any) → str[source]

Render the HTML of the statistics page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

template_name: ClassVar[str] = 'ann_data.jinja'

gain.genomic_resources.implementations.annotation_pipeline_impl module

class AnnotationPipelineImplementation(resource: GenomicResource)[source]

Bases: GenomicResourceImplementation, InfoImplementationMixin

Resource implementation for annotation pipeline.

calc_info_hash() → bytes[source]

Compute the digest of the inputs of the info page.

The page is rendered again only when the digest changes.

Returns:

The digest of everything that get_info depends on.

Return type:

bytes

calc_statistics_hash() → bytes[source]

Compute the digest of the inputs of the statistics build.

grr_manage compares the digest with the stored one to decide whether it must compute the statistics again.

Returns:

The digest of everything that the statistics tasks read.

Return type:

bytes

create_statistics_build_tasks(*, region_size: int = 3000000000, grr: GenomicResourceRepo | None = None) → list[TaskDesc][source]

Create the task graph tasks that compute the statistics.

grr_manage calls every kind with the same two keyword-only arguments. An implementation declares both, even when it ignores them, and declares no other argument.

Parameters:
  • region_size (int) – The longest region that one task covers. A kind that splits its build by genomic region reads it. 0 means do not split: a genomic score then scans the resource in one pass and a reference genome uses one region for each chromosome. A kind that does not split ignores it.

  • grr (GenomicResourceRepo | None) – The repository that holds the resource. None means that the caller names no repository.

Returns:

The tasks of the build. An empty list means that the kind has no statistics to compute.

Return type:

list[TaskDesc]

Raises:

ValueError – If region_size is negative.

property files: set[str]

The names of the resource files that the implementation reads.

get_info(**kwargs: Any) → str[source]

Render the HTML of the info page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

get_statistics_info(**kwargs: Any) → str[source]

Render the HTML of the statistics page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

template_name: ClassVar[str] = 'annotation_pipeline.jinja'

gain.genomic_resources.implementations.basic_resource_impl module

Provides the catch-all basic resource implementation.

class BasicResourceImplementation(genomic_resource: GenomicResource)[source]

Bases: GenomicResourceImplementation, InfoImplementationMixin

Implementation for resources without a more specific type.

A resource whose config carries no type resolves to the basic type (see GenomicResource.get_type). It has no schema or statistics of its own; it only renders a minimal info page and – crucially – exposes every data file via files so caching covers the whole resource, the same way untyped resources were cached before they had an implementation (gain#78).

calc_info_hash() → bytes[source]

Compute the digest of the inputs of the info page.

The page is rendered again only when the digest changes.

Returns:

The digest of everything that get_info depends on.

Return type:

bytes

calc_statistics_hash() → bytes[source]

Compute the digest of the inputs of the statistics build.

grr_manage compares the digest with the stored one to decide whether it must compute the statistics again.

Returns:

The digest of everything that the statistics tasks read.

Return type:

bytes

create_statistics_build_tasks(*, region_size: int = 3000000000, grr: GenomicResourceRepo | None = None) → list[TaskDesc][source]

Create the task graph tasks that compute the statistics.

grr_manage calls every kind with the same two keyword-only arguments. An implementation declares both, even when it ignores them, and declares no other argument.

Parameters:
  • region_size (int) – The longest region that one task covers. A kind that splits its build by genomic region reads it. 0 means do not split: a genomic score then scans the resource in one pass and a reference genome uses one region for each chromosome. A kind that does not split ignores it.

  • grr (GenomicResourceRepo | None) – The repository that holds the resource. None means that the caller names no repository.

Returns:

The tasks of the build. An empty list means that the kind has no statistics to compute.

Return type:

list[TaskDesc]

Raises:

ValueError – If region_size is negative.

property files: set[str]

The names of the resource files that the implementation reads.

get_info(**kwargs: Any) → str[source]

Render the HTML of the info page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

get_statistics_info(**kwargs: Any) → str[source]

Render the HTML of the statistics page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

template_name: ClassVar[str] = 'basic.jinja'

gain.genomic_resources.implementations.data_frame_resource_impl module

Provides the data_frame resource implementation.

class DataFrameResourceImplementation(genomic_resource: GenomicResource)[source]

Bases: GenomicResourceImplementation, InfoImplementationMixin

DataFrame resource implementation.

calc_info_hash() → bytes[source]

Compute the digest of the inputs of the info page.

The page is rendered again only when the digest changes.

Returns:

The digest of everything that get_info depends on.

Return type:

bytes

calc_statistics_hash() → bytes[source]

Compute the digest of the inputs of the statistics build.

grr_manage compares the digest with the stored one to decide whether it must compute the statistics again.

Returns:

The digest of everything that the statistics tasks read.

Return type:

bytes

create_statistics_build_tasks(*, region_size: int = 3000000000, grr: GenomicResourceRepo | None = None) → list[TaskDesc][source]

Create the task graph tasks that compute the statistics.

grr_manage calls every kind with the same two keyword-only arguments. An implementation declares both, even when it ignores them, and declares no other argument.

Parameters:
  • region_size (int) – The longest region that one task covers. A kind that splits its build by genomic region reads it. 0 means do not split: a genomic score then scans the resource in one pass and a reference genome uses one region for each chromosome. A kind that does not split ignores it.

  • grr (GenomicResourceRepo | None) – The repository that holds the resource. None means that the caller names no repository.

Returns:

The tasks of the build. An empty list means that the kind has no statistics to compute.

Return type:

list[TaskDesc]

Raises:

ValueError – If region_size is negative.

property files: set[str]

The names of the resource files that the implementation reads.

get_info(**kwargs: Any) → str[source]

Render the HTML of the info page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

get_statistics_info(**kwargs: Any) → str[source]

Render the HTML of the statistics page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

template_name: ClassVar[str] = 'data_frame.jinja'

gain.genomic_resources.implementations.gene_models_impl module

class GeneModelsImpl(resource: GenomicResource)[source]

Bases: GenomicResourceImplementation, InfoImplementationMixin

Provides class for gene models.

calc_info_hash() → bytes[source]

Compute the digest of the inputs of the info page.

The page is rendered again only when the digest changes.

Returns:

The digest of everything that get_info depends on.

Return type:

bytes

calc_statistics_hash() → bytes[source]

Compute the digest of the inputs of the statistics build.

grr_manage compares the digest with the stored one to decide whether it must compute the statistics again.

Returns:

The digest of everything that the statistics tasks read.

Return type:

bytes

create_statistics_build_tasks(*, region_size: int = 3000000000, grr: GenomicResourceRepo | None = None) → list[TaskDesc][source]

Create the task graph tasks that compute the statistics.

grr_manage calls every kind with the same two keyword-only arguments. An implementation declares both, even when it ignores them, and declares no other argument.

Parameters:
  • region_size (int) – The longest region that one task covers. A kind that splits its build by genomic region reads it. 0 means do not split: a genomic score then scans the resource in one pass and a reference genome uses one region for each chromosome. A kind that does not split ignores it.

  • grr (GenomicResourceRepo | None) – The repository that holds the resource. None means that the caller names no repository.

Returns:

The tasks of the build. An empty list means that the kind has no statistics to compute.

Return type:

list[TaskDesc]

Raises:

ValueError – If region_size is negative.

property files: set[str]

The names of the resource files that the implementation reads.

get_info(**kwargs: Any) → str[source]

Render the HTML of the info page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

get_statistics() → GeneModelsStatistics | None[source]

Load the statistics of the resource.

Returns:

The statistics. None means that the implementation has none: this base class always returns None.

Return type:

ResourceStatistics | None

get_statistics_info(**kwargs: Any) → str[source]

Render the HTML of the statistics page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

styles_template_name: ClassVar[str] = 'gene_models_styles.jinja'
template_name: ClassVar[str] = 'gene_models.jinja'
class GeneModelsStatistics(resource_id: str, chromosome_count: int, global_statistic: StatisticsData, chrom_statistics: dict[str, StatisticsData])[source]

Bases: ResourceStatistics

Class for accessing reference genome statistics.

static deserialize(data: str) → GeneModelsStatistics[source]

Deserialize gene models statistics.

serialize() → str[source]

Serialize gene models statistics.

class StatisticsData(transcript_number: int, protein_coding_transcript_number: int, gene_number: int, protein_coding_gene_number: int)[source]

Bases: object

Class for storing gene models statistics.

gene_number: int
protein_coding_gene_number: int
protein_coding_transcript_number: int
transcript_number: int

gain.genomic_resources.implementations.liftover_chain_impl module

Provides LiftOver chain resource.

class LiftoverChainImplementation(resource: GenomicResource)[source]

Bases: GenomicResourceImplementation, InfoImplementationMixin

Defines Lift Over chain resource implementation.

calc_info_hash() → bytes[source]

Compute the digest of the inputs of the info page.

The page is rendered again only when the digest changes.

Returns:

The digest of everything that get_info depends on.

Return type:

bytes

calc_statistics_hash() → bytes[source]

Compute the digest of the inputs of the statistics build.

grr_manage compares the digest with the stored one to decide whether it must compute the statistics again.

Returns:

The digest of everything that the statistics tasks read.

Return type:

bytes

create_statistics_build_tasks(*, region_size: int = 3000000000, grr: GenomicResourceRepo | None = None) → list[TaskDesc][source]

Create the task graph tasks that compute the statistics.

grr_manage calls every kind with the same two keyword-only arguments. An implementation declares both, even when it ignores them, and declares no other argument.

Parameters:
  • region_size (int) – The longest region that one task covers. A kind that splits its build by genomic region reads it. 0 means do not split: a genomic score then scans the resource in one pass and a reference genome uses one region for each chromosome. A kind that does not split ignores it.

  • grr (GenomicResourceRepo | None) – The repository that holds the resource. None means that the caller names no repository.

Returns:

The tasks of the build. An empty list means that the kind has no statistics to compute.

Return type:

list[TaskDesc]

Raises:

ValueError – If region_size is negative.

get_info(**kwargs: Any) → str[source]

Render the HTML of the info page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

get_statistics_info(**kwargs: Any) → str[source]

Render the HTML of the statistics page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

template_name: ClassVar[str] = 'liftover_chain.jinja'

gain.genomic_resources.implementations.reference_genome_impl module

class ChromosomeStatistic(chromosome: str, length: int = 0, nucleotide_counts: dict[str, int] | None = None, nucleotide_pair_counts: dict[str, int] | None = None)[source]

Bases: Statistic

Class for individual chromosome statistics.

add_value(value: tuple[str | None, str]) → None[source]
static deserialize(content: str) → ChromosomeStatistic[source]

Create a statistic from serialized data.

finish() → None[source]

Perform final calculations for the statistic.

This step is optional.

This is called when resource iteration is complete.

Can also be used when creating more complex resources via deserialization.

merge(other: ChromosomeStatistic) → None[source]

Add other’s nucleotide and pair counts into this one.

serialize() → str[source]

Return a serialized version of this statistic.

class GenomeStatistic(chromosomes: list[str], length: int = 0, nucleotide_distribution: dict[str, float] | None = None, bi_nucleotide_distribution: dict[str, float] | None = None, chromosome_statistics: dict[str, ChromosomeStatistic] | None = None)[source]

Bases: Statistic

The genome-wide statistic: every chromosome’s counts summed.

add_value(value: Any) → None[source]
property chrom_count: int
static deserialize(content: str) → GenomeStatistic[source]

Create a statistic from serialized data.

finish() → None[source]

Perform final calculations for the statistic.

This step is optional.

This is called when resource iteration is complete.

Can also be used when creating more complex resources via deserialization.

serialize() → str[source]

Return a serialized version of this statistic.

class GenomeStatisticsMixin[source]

Bases: object

Mixin for reference genome statistics access.

static get_chrom_file(chrom: str) → str[source]
static get_global_statistic_file() → str[source]
class ReferenceGenomeImplementation(resource: GenomicResource)[source]

Bases: GenomicResourceImplementation, InfoImplementationMixin

Resource implementation for reference genome.

calc_info_hash() → bytes[source]

Compute the digest of the inputs of the info page.

The page is rendered again only when the digest changes.

Returns:

The digest of everything that get_info depends on.

Return type:

bytes

calc_statistics_hash() → bytes[source]

Compute the digest of the inputs of the statistics build.

grr_manage compares the digest with the stored one to decide whether it must compute the statistics again.

Returns:

The digest of everything that the statistics tasks read.

Return type:

bytes

create_statistics_build_tasks(*, region_size: int = 3000000000, grr: GenomicResourceRepo | None = None) → list[TaskDesc][source]

One task per batch of whole contigs, plus the split ones’.

A contig that fits whole into one region is not given tasks of its own: such contigs are packed into batches no longer than the longest contig (nor than region_size), so the critical path stays one longest contig while a scaffold-heavy assembly – a few thousand contigs – costs a handful of tasks. A contig longer than region_size is counted region by region and merged and saved by one task.

property files: set[str]

The names of the resource files that the implementation reads.

get_info(**kwargs: Any) → str[source]

Render the HTML of the info page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

get_statistics() → ReferenceGenomeStatistics | None[source]

Load the statistics of the resource.

Returns:

The statistics. None means that the implementation has none: this base class always returns None.

Return type:

ResourceStatistics | None

get_statistics_info(**kwargs: Any) → str[source]

Render the HTML of the statistics page of the resource.

Parameters:

**kwargs (Any) – Options of the renderer. The caller defines them.

Returns:

The HTML of the page.

Return type:

str

styles_template_name: ClassVar[str] = 'reference_genome_styles.jinja'
template_name: ClassVar[str] = 'reference_genome.jinja'
class ReferenceGenomeStatistics(resource_id: str, global_statistic: GenomeStatistic, chrom_statistics: dict[str, ChromosomeStatistic])[source]

Bases: ResourceStatistics, GenomeStatisticsMixin

Class for accessing reference genome statistics.

static build_statistics(genomic_resource: GenomicResource) → ReferenceGenomeStatistics | None[source]

Load reference genome statistics.

The global statistic is summed from the per-chromosome ones, as the build does; its stored file supplies only the chromosomes.

Module contents