def test_label_search():
= np.array([1,2,3,4,5])
query_frag = np.array([1,2,3,4,5])
query_int = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
label = 0.1
frag_tolerance = False
ppm
assert np.allclose(label_search(query_frag, query_int, label, frag_tolerance, ppm)[0], query_int)
= np.array([1,2,3,4,6])
query_frag = np.array([1,2,3,4,5])
query_int
assert np.allclose(label_search(query_frag, query_int, label, frag_tolerance, ppm)[0], np.array([1,2,3,4,0]))
= np.array([1,2,3,4,6])
query_frag = np.array([5,4,3,2,1])
query_int
assert np.allclose(label_search(query_frag, query_int, label, frag_tolerance, ppm)[0], np.array([5,4,3,2,0]))
= np.array([1.1, 2.2, 3.3, 4.4, 6.6])
query_frag = np.array([1,2,3,4,5])
query_int
= 0.5
frag_tolerance = False
ppm
assert np.allclose(label_search(query_frag, query_int, label, frag_tolerance, ppm)[1], np.array([0.1, 0.2, 0.3, 0.4, 0.0]))
test_label_search()
Label
Label search
The label search is implemented based on the compare_frags from the search. We have a fixed number of reporter channels and check if we find a respective peak within the search tolerance.
Useful resources:
label_search
label_search (query_frag:numpy.ndarray, query_int:numpy.ndarray, label:numpy.ndarray, reporter_frag_tol:float, ppm:bool)
Function to search for a label for a given spectrum.
Args: query_frag (np.ndarray): Array with query fragments. query_int (np.ndarray): Array with query intensities. label (np.ndarray): Array with label masses. reporter_frag_tol (float): Fragment tolerance for search. ppm (bool): Flag to use ppm instead of Dalton.
Returns: np.ndarray: Array with intensities for the respective label channel. np.ndarray: Array with offset masses.
#Example usage
= np.array([127, 128, 129.1, 132])
query_frag = np.array([100, 200, 300, 400, 500])
query_int
= np.array([127.0, 128.0, 129.0, 130.0])
label
= 0.1
frag_tolerance = False
ppm
= label_search(query_frag, query_int, label, frag_tolerance, ppm)
report, offset
print(f'Reported intensities {report}, Offset {offset}')
Reported intensities [100. 200. 300. 0.], Offset [0. 0. 0.1 0. ]
MS2 Search
search_label_on_ms_file
search_label_on_ms_file (file_name:str, label:<class'NamedTuple'>, reporter_frag_tol:float, ppm:bool)
Wrapper function to search labels on an ms_file and write results to the peptide_fdr of the file.
Args: file_name (str): Path to ms_file: label (NamedTuple): Label with channels, mod_name and masses. reporter_frag_tol (float): Fragment tolerance for search. ppm (bool): Flag to use ppm instead of Dalton.
find_labels
find_labels (to_process:dict, callback:<built-infunctioncallable>=None, parallel:bool=False)
Wrapper function to search for labels.
Args: to_process (dict): A dictionary with settings indicating which files are to be processed and how. callback (callable): A function that accepts a float between 0 and 1 as progress. Defaults to None. parallel (bool): If True, process multiple files in parallel. This is not implemented yet! Defaults to False.
Returns: bool: True if and only if the label finding was succesful.