Spot#
- class panorama.region.Spot(spot_id)#
Bases:
SpotRepresents a spot in a pangenome.
- __delitem__(name)#
Delete the region for the given name
- Parameters:
name – Name of the wanted region
- Raises:
KeyError – Name does not exist in the spot
TypeError – Name is not a string
- __getitem__(name)#
Get the region with the given name
- Parameters:
name – Name of the wanted region
- Return type:
Region- Returns:
Region in the spot for the given name
- Raises:
KeyError – Name does not exist in the spot
TypeError – Name is not a string
- __init__(spot_id)#
Constructor method.
- Parameters:
spot_id (
int) – The identifier of the spot.
- __len__()#
Get the number of regions in the spot
- Return type:
int
- __repr__()#
Spot representation
- Return type:
str
- __setitem__(name, region)#
Set the region belonging to the spot
- Parameters:
name (
str) – Name of the regionregion (
Region) – Region to add in the spot
- Raises:
KeyError – Name of the region is already in the spot for a different region
- __str__()#
String representation of the spot
- _get_content()#
Creates the _uniqContent object if it was never computed.
- Return type:
Dict[Region,Set[Region]]- Returns:
RGP groups that have identical gene content
- _get_ordered_set()#
Creates the _uniqSyn object if it was never computed. Return it in any case
- Return type:
Dict[Region,Set[Region]]- Returns:
RGP groups that have an identical synteny
- _mk_uniq_content()#
cluster RGP into groups that have identical gene content
- _mk_uniq_ordered_set_obj()#
cluster RGP into groups that have an identical synteny
- add(region)#
Add a region to the spot. Alias more readable for setitem
- Parameters:
region (
Region) – Region to add in the spot- Raises:
TypeError – Region is not an instance Region
- add_metadata(metadata, metadata_id=None)#
Add metadata to metadata getter
- Parameters:
metadata (
Metadata) – metadata value to add for the sourcemetadata_id (
int) – metadata identifier
- Raises:
AssertionError – Source or metadata is not with the correct type
- Return type:
None
- borders(set_size, multigenics)#
Extracts all the borders of all RGPs belonging to the spot
- Parameters:
set_size – Number of genes to get
multigenics – pangenome graph multigenic persistent families
- Returns:
Families that bordering spot
- property conserved: bool#
Check if the spot is conserved between pangenomes.
- Returns:
bool – True if the spot is conserved, False otherwise.
- count_uniq_content()#
Get a counter of uniq RGP and number of identical RGP (in terms of gene family content)
- Return type:
dict- Returns:
Dictionary with a representative rgp as the key and number of identical rgp as value
- count_uniq_ordered_set()#
Get a counter of uniq RGP and number of identical RGP (in terms of synteny content)
- Returns:
Dictionary with a representative rgp as the key and number of identical rgp as value
- del_metadata_by_attribute(**kwargs)#
Remove a source from the feature
- del_metadata_by_source(source)#
Remove a source from the feature
- Parameters:
source (
str) – Name of the source to delete- Raises:
AssertionError – Source is not with the correct type
KeyError – Source does not belong in the MetaFeature
- property families: Generator[GeneFamily, None, None]#
Get the gene families in the RGP
- Returns:
Family in the spot
- formatted_metadata_dict()#
Format metadata by combining source and field values.
Given an object with metadata, this function creates a new dictionary where the keys are formatted as ‘source_field’.
- Return type:
Dict[str,List[str]]- Returns:
A dictionary with formatted metadata.
- formatted_metadata_dict_to_string(separator='|')#
Format metadata by combining source and field values.
Given an object with metadata, this function creates a new dictionary where the keys are formatted as ‘source_field’. In some cases, it is possible to have multiple values for the same field, in this situation, values are concatenated with the specified separator.
- Parameters:
separator (
str) – The separator used to join multiple values for the same field (default is ‘|’).- Return type:
Dict[str,str]- Returns:
A dictionary with formatted metadata.
- get(name)#
Get a region by its name. Alias more readable for getitem
- Parameters:
name (
str) – Name of the region- Return type:
Region- Returns:
Wanted region
- get_metadata(source, metadata_id=None)#
Get metadata from metadata getter by its source and identifier
- Parameters:
source (
str) – source of the metadatametadata_id (
int) – metadata identifier
- Raises:
KeyError – No metadata with ID or source is found
- Return type:
Metadata
- get_metadata_by_attribute(**kwargs)#
Get metadata by one or more attribute
- Return type:
Generator[Metadata,None,None]- Returns:
Metadata searched
- get_metadata_by_source(source)#
Get all the metadata feature corresponding to the source
- Parameters:
source (
str) – Name of the source to get- Return type:
Optional[Dict[int,Metadata]]- Returns:
List of metadata corresponding to the source
- Raises:
AssertionError – Source is not with the correct type
- get_uniq_content()#
Get an Iterable of all the unique rgp (in terms of gene family content) in the spot
- Return type:
Set[Region]- Returns:
Iterable of all the unique rgp (in terms of gene family content) in the spot
- get_uniq_ordered_set()#
Get an Iterable of all the unique syntenies in the spot
- Return type:
Set[Region]- Returns:
Iterable of all the unique syntenies in the spot
- get_uniq_to_rgp()#
Get dictionary with a representing RGP as the key, and all identical RGPs as value
- Return type:
Dict[Region,Set[Region]]- Returns:
Dictionary with a representing RGP as the key, and set of identical RGPs as value
- has_metadata()#
Does the feature has some metadata associated.
- Return type:
bool- Returns:
True if it has metadata else False
- has_source(source)#
Check if the source is in the metadata feature
- Parameters:
source (
str) – name of the source- Return type:
bool- Returns:
True if the source is in the metadata feature else False
- max_metadata_by_source()#
Get the maximum number of metadata for one source
- Return type:
Tuple[str,int]- Returns:
Name of the source with the maximum annotation and the number of metadata corresponding
- property metadata: Generator[Metadata, None, None]#
Generate metadata in gene families
- Returns:
Metadata from all sources
- property number_of_families: int#
Get the number of different families in the spot
- Returns:
Number of families
- property number_of_metadata: int#
Get the number of metadata associated to feature
- property number_of_organisms#
Get the number of organisms that contain the spot.
- Returns:
int – The number of organisms.
- property organisms: Generator[Organism, None, None]#
Generator of the organisms that contain the spot.
- Yields:
Organism – The next organism that contains the spot.
- property regions: Generator[Region, None, None]#
Generates the regions in the spot
- Returns:
Regions in the spot
- remove(name)#
Remove a region by its name. Alias more readable for delitem
- Parameters:
name (
str) – Name of the region
- property sources: Generator[str, None, None]#
Get all metadata source in gene family
- Returns:
Metadata source
- spot_2_families()#
Add to Gene Families a link to spot