Repository: mwang87/MassQueryLanguage (language: python)

Issue:
Advanced parse testing with reference parses



Discussion / hints:

Fix patch:
diff --git a/msql.ebnf b/msql.ebnf
index 8626729..427b117 100644
--- a/msql.ebnf
+++ b/msql.ebnf
@@ -46,7 +46,7 @@ positivepolarity: "POSITIVE"
     | "Positive"
 negativepolarity: "NEGATIVE"
     | "negative"
-    | "negative"
+    | "Negative"
 
 conditionfields: ms2productcondition
     | ms2precursorcondition
diff --git a/proteosafe/msql-nf/Makefile b/proteosafe/msql-nf/Makefile
index 7fc2cf1..44e5c4f 100644
--- a/proteosafe/msql-nf/Makefile
+++ b/proteosafe/msql-nf/Makefile
@@ -3,5 +3,5 @@ include ../Makefile.deploytemplate
 
 WORKFLOW_NAME=msql-nf
 TOOL_FOLDER_NAME=msql-nf
-WORKFLOW_VERSION=release_29.10
+WORKFLOW_VERSION=release_29.11
 WORKFLOW_DESCRIPTION="MSQL NF - <a href='https://mwang87.github.io/MassQueryLanguage_Documentation/'>Documentation Link</a>. Currently Supports v1.0 of MassQL" 
\ No newline at end of file
diff --git a/workflow/workflow.nf b/workflow/workflow.nf
index 16f004d..9f80719 100644
--- a/workflow/workflow.nf
+++ b/workflow/workflow.nf
@@ -104,7 +104,7 @@ if(params.extract == "YES"){
         extracted.json \
         extracted.tsv 
         """
-    }    
+    }
 }
 
 
@@ -127,22 +127,23 @@ process summarizeResults {
     """
 }
 
-
-process summarizeExtracted {
-    publishDir "$params.publishdir/summary", mode: 'copy'
-    cache false
-    echo true
-    errorStrategy 'ignore'
+// process summarizeExtracted {
+//     publishDir "$params.publishdir/summary", mode: 'copy'
+//     cache false
+//     echo true
+//     errorStrategy 'ignore'
     
-    input:
-    file(extracted_json) from _extracted_json_ch
+//     input:
+//     file(extracted_json) from _extracted_json_ch
+
+//     output:
+//     file "summary_extracted.html" optional true
+
+//     """
+//     $params.PYTHONRUNTIME $TOOL_FOLDER/summarize_extracted.py \
+//     $extracted_json \
+//     summary_extracted.html
+//     """
+// }
 
-    output:
-    file "summary_extracted.html" optional true
 
-    """
-    $params.PYTHONRUNTIME $TOOL_FOLDER/summarize_extracted.py \
-    $extracted_json \
-    summary_extracted.html
-    """
-}
\ No newline at end of file


Test patch:
diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml
index e2c7d6a..943587d 100644
--- a/.github/workflows/test-unit.yml
+++ b/.github/workflows/test-unit.yml
@@ -27,6 +27,7 @@ jobs:
         if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
     - name: Parsing Testing
       run: |
+        if [ -f requirements.txt ]; then pip install -r requirements_test.txt; fi
         #pytest --capture=tee-sys -vv test.py::test_parse
         pytest -vv test_parse.py::test_parse
     - name: Query Testing
diff --git a/requirements_test.txt b/requirements_test.txt
new file mode 100644
index 0000000..e4da24c
--- /dev/null
+++ b/requirements_test.txt
@@ -0,0 +1,2 @@
+pytest
+pathvalidate
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_MS2DATA_WHERE_MS2PROD_226.18TOLERANCEPPM_5___e52fbecfe84d774889d7b5f536a3363e.json b/test/reference_parses/QUERY_MS2DATA_WHERE_MS2PROD_226.18TOLERANCEPPM_5___e52fbecfe84d774889d7b5f536a3363e.json
new file mode 100644
index 0000000..b51147a
--- /dev/null
+++ b/test/reference_parses/QUERY_MS2DATA_WHERE_MS2PROD_226.18TOLERANCEPPM_5___e52fbecfe84d774889d7b5f536a3363e.json
@@ -0,0 +1,23 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierppmtolerance": {
+                    "name": "qualifierppmtolerance",
+                    "unit": "ppm",
+                    "value": 5.0
+                },
+                "type": "qualifier"
+            },
+            "type": "ms2productcondition",
+            "value": [
+                226.18
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": null
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_MS2DATA_WHERE_MS2PROD_226.18_AND_MS2PREC_226___7a3ae5ca424175eb968641a06e191be8.json b/test/reference_parses/QUERY_MS2DATA_WHERE_MS2PROD_226.18_AND_MS2PREC_226___7a3ae5ca424175eb968641a06e191be8.json
new file mode 100644
index 0000000..ad649c5
--- /dev/null
+++ b/test/reference_parses/QUERY_MS2DATA_WHERE_MS2PROD_226.18_AND_MS2PREC_226___7a3ae5ca424175eb968641a06e191be8.json
@@ -0,0 +1,22 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "type": "ms2productcondition",
+            "value": [
+                226.18
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "type": "ms2precursorcondition",
+            "value": [
+                226.1797
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": null
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_MS2DATA_WHERE_MS2PROD_226.18___ba59129fc3ca9db0a463480fd413f880.json b/test/reference_parses/QUERY_MS2DATA_WHERE_MS2PROD_226.18___ba59129fc3ca9db0a463480fd413f880.json
new file mode 100644
index 0000000..1f2e048
--- /dev/null
+++ b/test/reference_parses/QUERY_MS2DATA_WHERE_MS2PROD_226.18___ba59129fc3ca9db0a463480fd413f880.json
@@ -0,0 +1,15 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "type": "ms2productcondition",
+            "value": [
+                226.18
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": null
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS1MZ_425.2898TOLERA___106d511f8de4ae41364fbece4838e2c8.json b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS1MZ_425.2898TOLERA___106d511f8de4ae41364fbece4838e2c8.json
new file mode 100644
index 0000000..668579b
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS1MZ_425.2898TOLERA___106d511f8de4ae41364fbece4838e2c8.json
@@ -0,0 +1,27 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitypercent": {
+                    "name": "qualifierintensitypercent",
+                    "value": 0.1
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms1mzcondition",
+            "value": [
+                425.2898
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams1data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS1MZ_425.2898TOLERA___1f23674928bf7c61db1bede091d016ac.json b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS1MZ_425.2898TOLERA___1f23674928bf7c61db1bede091d016ac.json
new file mode 100644
index 0000000..cc7d7da
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS1MZ_425.2898TOLERA___1f23674928bf7c61db1bede091d016ac.json
@@ -0,0 +1,27 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitypercent": {
+                    "name": "qualifierintensitypercent",
+                    "value": 1.0
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms1mzcondition",
+            "value": [
+                425.2898
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams1data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS1MZ_XTOLERANCEMZ_0___10cc51d88921a4f32ca1f0a38ea3b4f2.json b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS1MZ_XTOLERANCEMZ_0___10cc51d88921a4f32ca1f0a38ea3b4f2.json
new file mode 100644
index 0000000..045a99e
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS1MZ_XTOLERANCEMZ_0___10cc51d88921a4f32ca1f0a38ea3b4f2.json
@@ -0,0 +1,71 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitymatch": {
+                    "name": "qualifierintensitymatch",
+                    "value": "Y"
+                },
+                "qualifierintensitypercent": {
+                    "name": "qualifierintensitypercent",
+                    "value": 25.0
+                },
+                "qualifierintensityreference": {
+                    "name": "qualifierintensityreference"
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms1mzcondition",
+            "value": [
+                "X"
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitymatch": {
+                    "name": "qualifierintensitymatch",
+                    "value": "Y*0.33"
+                },
+                "qualifierintensitytolpercent": {
+                    "name": "qualifierintensitytolpercent",
+                    "value": 30.0
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms1mzcondition",
+            "value": [
+                "X+2"
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "type": "ms2precursorcondition",
+            "value": [
+                "X"
+            ]
+        },
+        {
+            "conditiontype": "filter",
+            "type": "ms1mzcondition",
+            "value": [
+                "X"
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams1data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS1MZ_XTOLERANCEMZ_0___9008f814f26ce5a1835e900d1e9c659f.json b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS1MZ_XTOLERANCEMZ_0___9008f814f26ce5a1835e900d1e9c659f.json
new file mode 100644
index 0000000..419fe7c
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS1MZ_XTOLERANCEMZ_0___9008f814f26ce5a1835e900d1e9c659f.json
@@ -0,0 +1,140 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitymatch": {
+                    "name": "qualifierintensitymatch",
+                    "value": "Y"
+                },
+                "qualifierintensitypercent": {
+                    "name": "qualifierintensitypercent",
+                    "value": 25.0
+                },
+                "qualifierintensityreference": {
+                    "name": "qualifierintensityreference"
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms1mzcondition",
+            "value": [
+                "X"
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitymatch": {
+                    "name": "qualifierintensitymatch",
+                    "value": "Y*0.66"
+                },
+                "qualifierintensitytolpercent": {
+                    "name": "qualifierintensitytolpercent",
+                    "value": 30.0
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms1mzcondition",
+            "value": [
+                "X+2"
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitymatch": {
+                    "name": "qualifierintensitymatch",
+                    "value": "Y*0.66"
+                },
+                "qualifierintensitytolpercent": {
+                    "name": "qualifierintensitytolpercent",
+                    "value": 30.0
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms1mzcondition",
+            "value": [
+                "X-2"
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitymatch": {
+                    "name": "qualifierintensitymatch",
+                    "value": "Y*0.17"
+                },
+                "qualifierintensitytolpercent": {
+                    "name": "qualifierintensitytolpercent",
+                    "value": 40.0
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.2
+                },
+                "type": "qualifier"
+            },
+            "type": "ms1mzcondition",
+            "value": [
+                "X+4"
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitymatch": {
+                    "name": "qualifierintensitymatch",
+                    "value": "Y*0.17"
+                },
+                "qualifierintensitytolpercent": {
+                    "name": "qualifierintensitytolpercent",
+                    "value": 40.0
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.2
+                },
+                "type": "qualifier"
+            },
+            "type": "ms1mzcondition",
+            "value": [
+                "X-4"
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "type": "ms2precursorcondition",
+            "value": [
+                "X"
+            ]
+        },
+        {
+            "conditiontype": "filter",
+            "type": "ms1mzcondition",
+            "value": [
+                "X"
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams1data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS2PROD_309.2TOLERAN___ca35f95cb92bd1fbd9a06d74463ecc45.json b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS2PROD_309.2TOLERAN___ca35f95cb92bd1fbd9a06d74463ecc45.json
new file mode 100644
index 0000000..a440a0b
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_MS2PROD_309.2TOLERAN___ca35f95cb92bd1fbd9a06d74463ecc45.json
@@ -0,0 +1,27 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensityticpercent": {
+                    "name": "qualifierintensityticpercent",
+                    "value": 10.0
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms2productcondition",
+            "value": [
+                309.2
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams1data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_POLARITY_Negative___856798678fb46ad031afbf6c1c18a9e3.json b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_POLARITY_Negative___856798678fb46ad031afbf6c1c18a9e3.json
new file mode 100644
index 0000000..eb62049
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_POLARITY_Negative___856798678fb46ad031afbf6c1c18a9e3.json
@@ -0,0 +1,15 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "type": "polaritycondition",
+            "value": [
+                "negativepolarity"
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams1data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_POLARITY_Positive___0db9167846d408f02e831cf233b8b563.json b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_POLARITY_Positive___0db9167846d408f02e831cf233b8b563.json
new file mode 100644
index 0000000..5a39618
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_POLARITY_Positive___0db9167846d408f02e831cf233b8b563.json
@@ -0,0 +1,15 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "type": "polaritycondition",
+            "value": [
+                "positivepolarity"
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams1data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_RTMIN_50___ea275091f8beb5dc52e5013e2a0b38bd.json b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_RTMIN_50___ea275091f8beb5dc52e5013e2a0b38bd.json
new file mode 100644
index 0000000..10b5ed6
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_RTMIN_50___ea275091f8beb5dc52e5013e2a0b38bd.json
@@ -0,0 +1,15 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "type": "rtmincondition",
+            "value": [
+                50.0
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams1data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_SCANMIN_100_AND_SCAN___d83553d176ee4bac735b23927f3477fe.json b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_SCANMIN_100_AND_SCAN___d83553d176ee4bac735b23927f3477fe.json
new file mode 100644
index 0000000..5c23b60
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS1DATA__WHERE_SCANMIN_100_AND_SCAN___d83553d176ee4bac735b23927f3477fe.json
@@ -0,0 +1,22 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "type": "scanmincondition",
+            "value": [
+                100.0
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "type": "scanmaxcondition",
+            "value": [
+                105.0
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams1data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_CHARGE_1___c3f3cfbd42a396813e18b743b41ffa23.json b/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_CHARGE_1___c3f3cfbd42a396813e18b743b41ffa23.json
new file mode 100644
index 0000000..6e2fd0d
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_CHARGE_1___c3f3cfbd42a396813e18b743b41ffa23.json
@@ -0,0 +1,15 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "type": "chargecondition",
+            "value": [
+                1.0
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_157.0857+10___18bc388c403057bfcdaf4429d31c4bbe.json b/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_157.0857+10___18bc388c403057bfcdaf4429d31c4bbe.json
new file mode 100644
index 0000000..7d1f085
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_157.0857+10___18bc388c403057bfcdaf4429d31c4bbe.json
@@ -0,0 +1,15 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "type": "ms2productcondition",
+            "value": [
+                167.0857
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_167.0857TOLE___17c6443350bc76ae1462d4e492139426.json b/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_167.0857TOLE___17c6443350bc76ae1462d4e492139426.json
new file mode 100644
index 0000000..6f63287
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_167.0857TOLE___17c6443350bc76ae1462d4e492139426.json
@@ -0,0 +1,38 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierppmtolerance": {
+                    "name": "qualifierppmtolerance",
+                    "unit": "ppm",
+                    "value": 5.0
+                },
+                "type": "qualifier"
+            },
+            "type": "ms2productcondition",
+            "value": [
+                167.0857
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierppmtolerance": {
+                    "name": "qualifierppmtolerance",
+                    "unit": "ppm",
+                    "value": 5.0
+                },
+                "type": "qualifier"
+            },
+            "type": "ms2neutrallosscondition",
+            "value": [
+                176.0321
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_226.18TOLERA___183ad9892736b0d8642ccec4aa131c40.json b/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_226.18TOLERA___183ad9892736b0d8642ccec4aa131c40.json
new file mode 100644
index 0000000..1d762da
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_226.18TOLERA___183ad9892736b0d8642ccec4aa131c40.json
@@ -0,0 +1,23 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierppmtolerance": {
+                    "name": "qualifierppmtolerance",
+                    "unit": "ppm",
+                    "value": 5.0
+                },
+                "type": "qualifier"
+            },
+            "type": "ms2productcondition",
+            "value": [
+                226.18
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_X_TOLERANCEM___a5ce05df2b600cc86a0a76d43dd61ff6.json b/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_X_TOLERANCEM___a5ce05df2b600cc86a0a76d43dd61ff6.json
new file mode 100644
index 0000000..58be22e
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_X_TOLERANCEM___a5ce05df2b600cc86a0a76d43dd61ff6.json
@@ -0,0 +1,65 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitypercent": {
+                    "name": "qualifierintensitypercent",
+                    "value": 5.0
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms2productcondition",
+            "value": [
+                "X"
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitypercent": {
+                    "name": "qualifierintensitypercent",
+                    "value": 5.0
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms2productcondition",
+            "value": [
+                "X+164.9"
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitypercent": {
+                    "name": "qualifierintensitypercent",
+                    "value": 5.0
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms2productcondition",
+            "value": [
+                "X+329.8"
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_X_TOLERANCEM___de1efdec2d9f13fba1556258838fc30f.json b/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_X_TOLERANCEM___de1efdec2d9f13fba1556258838fc30f.json
new file mode 100644
index 0000000..743b86d
--- /dev/null
+++ b/test/reference_parses/QUERY_scaninfo_MS2DATA__WHERE_MS2PROD_X_TOLERANCEM___de1efdec2d9f13fba1556258838fc30f.json
@@ -0,0 +1,46 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitypercent": {
+                    "name": "qualifierintensitypercent",
+                    "value": 5.0
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms2productcondition",
+            "value": [
+                "X"
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitypercent": {
+                    "name": "qualifierintensitypercent",
+                    "value": 5.0
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms2productcondition",
+            "value": [
+                "X+119.1"
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": "functionscaninfo"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scanmz_MS2DATA__WHERE_MS2PROD_226.18___1be0b3783ef46849f8be2a041dc7a3f8.json b/test/reference_parses/QUERY_scanmz_MS2DATA__WHERE_MS2PROD_226.18___1be0b3783ef46849f8be2a041dc7a3f8.json
new file mode 100644
index 0000000..99e0b25
--- /dev/null
+++ b/test/reference_parses/QUERY_scanmz_MS2DATA__WHERE_MS2PROD_226.18___1be0b3783ef46849f8be2a041dc7a3f8.json
@@ -0,0 +1,15 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "type": "ms2productcondition",
+            "value": [
+                226.18
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": "functionscanmz"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scannum_MS2DATA__WHERE_MS2NL_163___4c06210393d721e52082566c4910e179.json b/test/reference_parses/QUERY_scannum_MS2DATA__WHERE_MS2NL_163___4c06210393d721e52082566c4910e179.json
new file mode 100644
index 0000000..c90d03e
--- /dev/null
+++ b/test/reference_parses/QUERY_scannum_MS2DATA__WHERE_MS2NL_163___4c06210393d721e52082566c4910e179.json
@@ -0,0 +1,15 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "type": "ms2neutrallosscondition",
+            "value": [
+                163.0
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": "functionscannum"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scannum_MS2DATA__WHERE_MS2PREC_85.0282TOLERA___134f5926097a502b8c1ed113d63bce43.json b/test/reference_parses/QUERY_scannum_MS2DATA__WHERE_MS2PREC_85.0282TOLERA___134f5926097a502b8c1ed113d63bce43.json
new file mode 100644
index 0000000..4d2750d
--- /dev/null
+++ b/test/reference_parses/QUERY_scannum_MS2DATA__WHERE_MS2PREC_85.0282TOLERA___134f5926097a502b8c1ed113d63bce43.json
@@ -0,0 +1,23 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms2precursorcondition",
+            "value": [
+                85.0282
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": "functionscannum"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scannum_MS2DATA__WHERE_MS2PROD_88TOLERANCEMZ___6d988b4f5914b1ec60cff898439e7816.json b/test/reference_parses/QUERY_scannum_MS2DATA__WHERE_MS2PROD_88TOLERANCEMZ___6d988b4f5914b1ec60cff898439e7816.json
new file mode 100644
index 0000000..39bb23b
--- /dev/null
+++ b/test/reference_parses/QUERY_scannum_MS2DATA__WHERE_MS2PROD_88TOLERANCEMZ___6d988b4f5914b1ec60cff898439e7816.json
@@ -0,0 +1,34 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifierintensitypercent": {
+                    "name": "qualifierintensitypercent",
+                    "value": 10.0
+                },
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms2productcondition",
+            "value": [
+                88.0
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "type": "ms2precursorcondition",
+            "value": [
+                600.0
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": "functionscannum"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scansum_MS1DATA__WHERE_MS1MZ_100TOLERANCEMZ____ba08671aada7c435d266b095c78c7443.json b/test/reference_parses/QUERY_scansum_MS1DATA__WHERE_MS1MZ_100TOLERANCEMZ____ba08671aada7c435d266b095c78c7443.json
new file mode 100644
index 0000000..065998d
--- /dev/null
+++ b/test/reference_parses/QUERY_scansum_MS1DATA__WHERE_MS1MZ_100TOLERANCEMZ____ba08671aada7c435d266b095c78c7443.json
@@ -0,0 +1,23 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "qualifiers": {
+                "qualifiermztolerance": {
+                    "name": "qualifiermztolerance",
+                    "unit": "mz",
+                    "value": 0.1
+                },
+                "type": "qualifier"
+            },
+            "type": "ms1mzcondition",
+            "value": [
+                100.0
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams1data",
+        "function": "functionscansum"
+    }
+}
\ No newline at end of file
diff --git a/test/reference_parses/QUERY_scansum_MS2DATA__WHERE_MS2PROD_271_AND_MS2PR___0aa157e0adeb2407305cfe3cb431eba3.json b/test/reference_parses/QUERY_scansum_MS2DATA__WHERE_MS2PROD_271_AND_MS2PR___0aa157e0adeb2407305cfe3cb431eba3.json
new file mode 100644
index 0000000..21291ab
--- /dev/null
+++ b/test/reference_parses/QUERY_scansum_MS2DATA__WHERE_MS2PROD_271_AND_MS2PR___0aa157e0adeb2407305cfe3cb431eba3.json
@@ -0,0 +1,22 @@
+{
+    "conditions": [
+        {
+            "conditiontype": "where",
+            "type": "ms2productcondition",
+            "value": [
+                271.0
+            ]
+        },
+        {
+            "conditiontype": "where",
+            "type": "ms2precursorcondition",
+            "value": [
+                500.0
+            ]
+        }
+    ],
+    "querytype": {
+        "datatype": "datams2data",
+        "function": "functionscansum"
+    }
+}
\ No newline at end of file
diff --git a/test/test_parses/placeholder.txt b/test/test_parses/placeholder.txt
new file mode 100644
index 0000000..e69de29
diff --git a/test_parse.py b/test_parse.py
index af256e5..cc300c4 100644
--- a/test_parse.py
+++ b/test_parse.py
@@ -6,11 +6,34 @@
 import json
 import pytest
 
-def test_parse():        
+def test_parse():
+    # This test not only performs a parse, but also tries to compare it against a reference parse
+
+    from pathvalidate import sanitize_filename
+    import os
+    import hashlib
+
+    # Writing out the queries and comparing
     for line in open("test_queries.txt"):
         test_query = line.rstrip()
         print(test_query)
-        msql_parser.parse_msql(test_query)
+        output_parse = msql_parser.parse_msql(test_query)
+
+        hash_object = hashlib.md5(test_query.encode("ascii"))
+        hash_output = hash_object.hexdigest()
+
+        json_filename = sanitize_filename(test_query).replace(" ", "_").replace("=", "_").replace("(", "_").replace(")", "_")[:50] + "___" +  hash_output + ".json"
+
+        output_filename = os.path.join("test/test_parses", json_filename)
+        output_json_str = json.dumps(output_parse, sort_keys=True, indent=4)
+
+        with open(output_filename, "w") as o:
+            o.write(output_json_str)
+
+        reference_filename = os.path.join("test/reference_parses", json_filename)
+        reference_string = open(reference_filename).read()
+
+        assert(output_json_str == reference_string)
 
 def test_comment_parse():
     query = """
@@ -70,6 +93,7 @@ def test_variable_formula_parse():
     parsed_output = msql_parser.parse_msql(query)
 
 def main():
+    test_parse()
     #test_comment_parse()
     #test_number_expression_parse()
     #test_formula_expression_parse()
diff --git a/test_queries.txt b/test_queries.txt
index 6176c7d..6cbfc1e 100644
--- a/test_queries.txt
+++ b/test_queries.txt
@@ -20,4 +20,5 @@ QUERY scaninfo(MS2DATA) WHERE MS2PROD=X :TOLERANCEMZ=0.1:INTENSITYPERCENT=5 AND
 QUERY scaninfo(MS1DATA) WHERE MS1MZ=X:TOLERANCEMZ=0.1:INTENSITYPERCENT=25:INTENSITYMATCH=Y:INTENSITYMATCHREFERENCE AND MS1MZ=X+2:TOLERANCEMZ=0.1:INTENSITYMATCH=Y*0.66:INTENSITYMATCHPERCENT=30 AND MS1MZ=X-2:TOLERANCEMZ=0.1:INTENSITYMATCH=Y*0.66:INTENSITYMATCHPERCENT=30 AND MS1MZ=X+4:TOLERANCEMZ=0.2:INTENSITYMATCH=Y*0.17:INTENSITYMATCHPERCENT=40 AND MS1MZ=X-4:TOLERANCEMZ=0.2:INTENSITYMATCH=Y*0.17:INTENSITYMATCHPERCENT=40 AND MS2PREC=X FILTER MS1MZ=X
 QUERY scaninfo(MS1DATA) WHERE MS1MZ=X:TOLERANCEMZ=0.1:INTENSITYPERCENT=25:INTENSITYMATCH=Y:INTENSITYMATCHREFERENCE AND MS1MZ=X+2:TOLERANCEMZ=0.1:INTENSITYMATCH=Y*0.33:INTENSITYMATCHPERCENT=30 AND MS2PREC=X FILTER MS1MZ=X
 QUERY scaninfo(MS2DATA) WHERE MS2PROD=167.0857:TOLERANCEPPM=5 AND MS2NL=176.0321:TOLERANCEPPM=5
-QUERY scaninfo(MS2DATA) WHERE MS2PROD=157.0857+10
\ No newline at end of file
+QUERY scaninfo(MS2DATA) WHERE MS2PROD=157.0857+10
+QUERY scaninfo(MS1DATA) WHERE POLARITY=Negative
\ No newline at end of file