pyproteonet.data.molecule_set.MoleculeSet
- class pyproteonet.data.molecule_set.MoleculeSet(molecules: Dict[str, DataFrame], mappings: Dict[str, DataFrame | MoleculeMapping])
A set of molecules and their relations/mapping. E.g. a set of proteins and peptides with every peptide belonging to one or many proteins
- __init__(molecules: Dict[str, DataFrame], mappings: Dict[str, DataFrame | MoleculeMapping])
A set of molecules and their relations/mapping.
- Parameters:
molecules (Dict[str, pd.DataFrame]) – Relevant molecules as dictionay of molecule name and dataframe containing at least the molecule indices
mappings (Dict[str, pd.DataFrame]) – Every mapping has a multi-index, where every item consists of the ids of the two molecues that are mapped
Methods
__init__(molecules, mappings)A set of molecules and their relations/mapping.
add_mapping_pairs(name, pairs[, ...])add_molecules(molecule, df)clear_cache()copy([molecule_ids])drop_mapping(mapping)drop_molecule_data(columns[, molecule, inplace])get_mapped(mapping[, molecule, ...])get_mapped_pairs(mapping[, molecule_a, ...])get_mapping(mapping_name[, molecule, ...])get_mapping_degrees(molecule, mapping[, ...])Returns the node degrees for the given molecule type according to the given mapping.
get_mapping_partner(molecule, mapping)Infer the partner molecule type for a molecule type and mapping
get_mapping_unique_molecules(molecule[, ...])get_node_values_for_graph(graph[, ...])infer_mapping(molecule, mapping)Infer a mapping name from a molecule type and a mapping string.
infer_mapping_name(molecule, mapping_name)load(path)number_molecules(molecule)rename_mapping(mapping, new_name)rename_molecule(molecule, new_name)Rename a molecule type.
rename_molecule_data(columns[, molecule, ...])save(path[, overwrite])set_molecule_data(molecule, column, data[, ...])Attributes
molecule_names- get_mapping_degrees(molecule: str, mapping: str, result_column: str | None = None, partner_molecule: str | None = None, only_unique: bool = False) Series
- Returns the node degrees for the given molecule type according to the given mapping.
E.g. can be used to get the number of peptides per protein.
- Parameters:
molecule (str) – The molecule type to get the degrees for.
mapping (str) – The mapping to use to generate the graph for the degree calculation.
result_column (Optional[str], optional) – If given stores the results as a molecule column in the molecule set. Defaults to None.
partner_molecule (str, optional) – _description_. Defaults to None.
only_unique (bool, optional) – _description_. Defaults to False.
- Raises:
AttributeError – _description_
- Returns:
_description_
- Return type:
pd.Series
- get_mapping_partner(molecule: str, mapping: str) str
Infer the partner molecule type for a molecule type and mapping
- Parameters:
molecule (str) – The one molecule type of the mapping
mapping (str) – The mapping name.
- Returns:
The other molecule type of the mapping.
- Return type:
str
- infer_mapping(molecule: str, mapping: str) Tuple[str, str, str]
Infer a mapping name from a molecule type and a mapping string.
- Parameters:
molecule (str) – Molecule type like protein, peptide …
mapping (str) – If the name of a molecule type is given it is tried to infer the mapping name connecting both molecule types. If a mapping name is given it is returned as is.
- Returns:
The from molecule type, the mapping name, and the to molecule type.
- Return type:
Tuple[str, str, str]
- rename_molecule(molecule: str, new_name: str)
Rename a molecule type.
- Parameters:
molecule (str) – The current name.
new_name (str) – The new name.
- Raises:
KeyError – Raised when the new name already exists.