From 2c1616560bd32a8e48ce3ed657cca98f3342f9e9 Mon Sep 17 00:00:00 2001 From: Lisa M Tuttle Date: Thu, 22 Aug 2024 15:54:25 -0700 Subject: [PATCH] added s_id to filter_df(): ('data_id-time-rep') --- pyhxexpress/hxex_updating.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pyhxexpress/hxex_updating.py b/pyhxexpress/hxex_updating.py index ad29b1e..12548ab 100644 --- a/pyhxexpress/hxex_updating.py +++ b/pyhxexpress/hxex_updating.py @@ -274,7 +274,7 @@ def makelist(thing): return thing def filter_df(metadf=pd.DataFrame(),samples=None,range=None,peptide_ranges=None, - charge=None,index=None,timept=None,timeidx=None,peptides=None,rep=None,data_ids=None,quiet=True): + charge=None,index=None,timept=None,timeidx=None,peptides=None,rep=None,data_ids=None,s_ids=None,quiet=True): ''' Utility function to Filter metadf (or any other dataframe) based on user specified values samples = ['sample1','sample2'] or 'sample1' range = [start,end] @@ -331,6 +331,14 @@ def filter_df(metadf=pd.DataFrame(),samples=None,range=None,peptide_ranges=None, if not filtered.empty and (rep or rep == 0): try: filtered = filtered[filtered['rep'].isin(makelist(rep))] except: print("no column named rep") + + if not filtered.empty and s_ids: + s_ids = makelist(s_ids) + for s_id in s_ids: + d, t, r = [float(s) for s in s_id.split('-')] + try: + filtered = filtered[(filtered['data_id'] == d) & (filtered['time'] == t) & (filtered['rep']==r)] + except: print("no s_id",s_id) if quiet == False: print("Dataframe filtered to",len(filtered),"from",len(metadf),"total entries")