alphaviz.utils

Functions:

calculate_mass(mono_mz, charge)

Calculate the precursor mass from mono mz and charge.

calculate_mz(prec_mass, charge)

Calculate the precursor mono mz from mass and charge.

check_analysis_file(file)

check_github_version([silent])

Checks and logs the current version of AlphaViz. Check if the local version equals the AlphaViz GitHub master branch. This is only possible with an active internet connection and if no credentials are required for GitHub. :param silent: Use the logger to display the obtained conclusion. Default is False. :type silent: str.

get_frag_dict(parsed_pep, mass_dict)

Calculate the masses of the fragment ions :param parsed_pep: the list of amino acids and modified amono acids.

get_fragmass(parsed_pep, mass_dict)

Calculate the masses of the fragment ions :param parsed_pep: the list of amino acids and modified amono acids.

get_mass_dict([modfile, aasfile, verbose])

Function to create a mass dict based on tsv files.

get_precmass(parsed_pep, mass_dict)

Calculate the mass of the neutral precursor :param parsed_pep: the list of amino acids and modified amono acids.

parse(peptide)

Parser to parse peptide strings :param peptide: modified peptide sequence.

alphaviz.utils.calculate_mass(mono_mz: float, charge: int) float[source]

Calculate the precursor mass from mono mz and charge. :param mono_mz: mono m/z. :type mono_mz: float :param charge: charge. :type charge: int

Returns

precursor mass.

Return type

float

alphaviz.utils.calculate_mz(prec_mass: float, charge: int) float[source]

Calculate the precursor mono mz from mass and charge. :param prec_mass: precursor mass. :type prec_mass: float :param charge: charge. :type charge: int

Returns

mono m/z.

Return type

float

alphaviz.utils.check_analysis_file(file)[source]
alphaviz.utils.check_github_version(silent=False) str[source]

Checks and logs the current version of AlphaViz. Check if the local version equals the AlphaViz GitHub master branch. This is only possible with an active internet connection and if no credentials are required for GitHub. :param silent: Use the logger to display the obtained conclusion.

Default is False.

Returns

The version on the AlphaViz GitHub master branch. “” if no version can be found on GitHub

Return type

str

alphaviz.utils.get_frag_dict(parsed_pep: list, mass_dict: dict) dict[source]

Calculate the masses of the fragment ions :param parsed_pep: the list of amino acids and modified amono acids. :type parsed_pep: list or numba.typed.List of str :param mass_dict: key is the amino acid or the modified amino acid, and the value is the mass. :type mass_dict: numba.typed.Dict

Returns

float}: key is the fragment type (b1, b2, …, y1, y2, …), value is fragment mass.

Return type

dict{str

alphaviz.utils.get_fragmass(parsed_pep: list, mass_dict: Dict) tuple[source]

Calculate the masses of the fragment ions :param parsed_pep: the list of amino acids and modified amono acids. :type parsed_pep: numba.typed.List of str :param mass_dict: key is the amino acid or the modified amino acid, and the value is the mass. :type mass_dict: numba.typed.Dict

Returns

the fragment masses and the fragment types (represented as np.int8). For a fragment type, positive value means the b-ion, the value indicates the position (b1, b2, b3…); the negative value means the y-ion, the absolute value indicates the position (y1, y2, …).

Return type

Tuple[np.ndarray(np.float64), np.ndarray(np.int8)]

alphaviz.utils.get_mass_dict(modfile: str = 'data/modifications.tsv', aasfile: str = 'data/amino_acids.tsv', verbose: bool = True)[source]

Function to create a mass dict based on tsv files. This is used to create the hardcoded dict in the constants notebook. The dict needs to be hardcoded because of importing restrictions when using numba. More specifically, a global needs to be typed at runtime. :param modfile: Filename of modifications file. :type modfile: str :param aasfile: Filename of AAs file. :type aasfile: str :param verbose: Flag to print dict. :type verbose: bool, optional

Returns

Returns a numba compatible dictionary with masses.

Raises

FileNotFoundError – If files are not found.

alphaviz.utils.get_precmass(parsed_pep: list, mass_dict: Dict) float[source]

Calculate the mass of the neutral precursor :param parsed_pep: the list of amino acids and modified amono acids. :type parsed_pep: list or numba.typed.List of str :param mass_dict: key is the amino acid or the modified amino acid, and the value is the mass. :type mass_dict: numba.typed.Dict

Returns

the peptide neutral mass.

Return type

float

alphaviz.utils.parse(peptide: str) List[source]

Parser to parse peptide strings :param peptide: modified peptide sequence. :type peptide: str

Returns

a list of animo acids and modified amono acids

Return type

List (numba.typed.List)