Skip to content
Snippets Groups Projects
Commit a93c4ac8 authored by Vishruth Mullapudi's avatar Vishruth Mullapudi Committed by Vishruth Mullapudi
Browse files

cleaned up localization with list comprehension

parent faba3df5
1 merge request!1Fix unlocalized peptide mods not adding
......@@ -26,7 +26,7 @@ def main():
localization_col_titles: Dict[str, str] = dict() # Dict containing {fileID: column title}
localized_data: List[FileTuple] = []
use_mod_in_master_prot = False # debug
# use_mod_in_master_prot = False # debug
for ftuple in data:
if use_mod_in_master_prot:
file_headers_tuple: Tuple[FileTuple, Dict[str, str]] = parsemasterlocalizations(ftuple)
......@@ -96,10 +96,8 @@ def parsemasterlocalizations(ftuple: FileTuple) -> Tuple[FileTuple, Dict[str, st
# force everything into string so we can make sure its not empty ("nan")
if not str(mod_string) == "nan":
matches = re.finditer(regex, mod_string)
matched_strs = []
for match_obj in matches:
matched_strs.extend(match_obj.groups())
localizations.append(matched_strs)
localizations.append([int(mod_localization) for match_obj in matches
for mod_localization in match_obj.groups() if mod_localization is not ''])
else:
localizations.append([])
......@@ -128,10 +126,8 @@ def parseprotlocalizations(ftuple: FileTuple, protein_seqrecords: list) -> Tuple
mod_string = row.modifications
if not str(mod_string) == "nan":
matches = re.finditer(regex, mod_string)
matched_strs = []
for match_obj in matches:
matched_strs.extend([int(x) + frag_index_in_prot for x in match_obj.groups() if x is not ''])
prot_localizations.append(matched_strs)
prot_localizations.append([int(mod_localization) + frag_index_in_prot for match_obj in matches for
mod_localization in match_obj.groups() if mod_localization is not ''])
else:
prot_localizations.append([])
else:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment