Skip to content

Commit ecf49e7

Browse files
committed
Merge branch 'master' of github.com:mwang87/MassQueryLanguage
2 parents 15ab833 + 746954b commit ecf49e7

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

massql/msql.ebnf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,14 @@ function: functionscannum
103103
| functionscanrangesum
104104
| functionscanmz
105105
| functionscaninfo
106+
| functionscanmaxint
106107

107108
functionscannum: "scannum"
108109
functionscansum: "scansum"
109110
functionscanrangesum: "scanrangesum"
110111
functionscanmz: "scanmz"
111112
functionscaninfo: "scaninfo"
113+
functionscanmaxint: "scanmaxint"
112114

113115
booleanandconjunction: "AND"
114116
| "and"

massql/msql_engine.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,4 +688,28 @@ def _executecollate_query(parsed_dict, ms1_df, ms2_df):
688688

689689
return ms2_df
690690

691+
if parsed_dict["querytype"]["function"] == "functionscanmaxint":
692+
# This is the biggest peak in the spectrum
693+
694+
if parsed_dict["querytype"]["datatype"] == "datams1data":
695+
if len(ms1_df) == 0:
696+
return ms1_df
697+
698+
ms1sum_df = ms1_df.groupby("scan").max().reset_index()
699+
700+
ms1_df = ms1_df.groupby("scan").first().reset_index()
701+
ms1_df["i"] = ms1sum_df["i"]
702+
703+
return ms1_df
704+
if parsed_dict["querytype"]["datatype"] == "datams2data":
705+
if len(ms2_df) == 0:
706+
return ms2_df
707+
708+
ms2sum_df = ms2_df.groupby("scan").max().reset_index()
709+
710+
ms2_df = ms2_df.groupby("scan").first().reset_index()
711+
ms2_df["i"] = ms2sum_df["i"]
712+
713+
return ms2_df
714+
691715
print("APPLYING FUNCTION")

tests/test_query.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,15 @@ def test_waters_query():
648648

649649
results_df = msql_engine.process_query(query, "tests/data/MMSRG_027.mzML")
650650

651+
def test_scanmaxint_query():
652+
query = """
653+
QUERY scanmaxint(MS2DATA)
654+
"""
655+
656+
results_df = msql_engine.process_query(query, "tests/data/GNPS00002_A3_p.mzML")
657+
658+
print(results_df)
659+
651660
def main():
652661
#msql_engine.init_ray()
653662

@@ -718,7 +727,8 @@ def main():
718727
#test_ms2_mobility_variable2()
719728
#test_massdefect_ANY_query()
720729
#test_advanced_filters()
721-
test_advanced_filters2()
730+
#test_advanced_filters2()
731+
test_scanmaxint_query()
722732

723733

724734
if __name__ == "__main__":

0 commit comments

Comments
 (0)