from typing import Dict
from typing import Optional
from typing import List
from typing import Tuple


def prepare_individual_spectra_for_pySPLASH(
    spectra_dict: Dict, mslevel: Optional[int] = -1
) -> List[Tuple[float, float]]:
    """ This function takes a mzmlripper spectra and returns a list
    formatted to be sent to through the pySPLASH splash functions
    to return a SPLASH

    Args:
        spectra_dict (Dict): Spectra information
        mslevel (int, optional): MS level to look at. Defautls to -1.

    Returns:
        List[Tuple[float, float]]: List of mass and intensity values
    """

    ion_list = []  # This list will contain tuples of (mass, intensity)
    # Get the masses from the ripper dictionary
    masses = spectra_dict["mass_list"]

    # Run through the masses to get intensities
    for mass in masses:
        # Get the intensity for this mass
        intensity = spectra_dict[f"{mass:.4f}"]
        # Add a dictionary that maps mass to the mass and intensity to intensity
        ion_list.append((mass, intensity))

    # return the formatted data
    return ion_list