diff test/test_query_mass_repos.py @ 23:85fd05d0d16c

New tool to Query multiple public repositories for elemental compositions from accurate mass values detected by high-resolution mass spectrometers
author pieter.lukasse@wur.nl
date Thu, 03 Apr 2014 16:44:11 +0200
parents
children 637830ac8bcd
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/test_query_mass_repos.py	Thu Apr 03 16:44:11 2014 +0200
@@ -0,0 +1,62 @@
+'''Integration tests for the GCMS project'''
+
+from pkg_resources import resource_filename  # @UnresolvedImport # pylint: disable=E0611
+from MS import query_mass_repos
+import os.path
+import sys
+import unittest
+
+
+class IntegrationTest(unittest.TestCase):
+
+       
+        
+
+    def test_simple(self):
+        '''
+        Simple initial test
+        '''
+        # Create out folder
+        outdir = "output/query_mass_repos/"
+        if not os.path.exists(outdir):
+            os.makedirs(outdir)
+
+        #Build up arguments and run
+        
+        #     input_file = sys.argv[1]
+        #     molecular_mass_col = sys.argv[2]
+        #     repository_file = sys.argv[3]
+        #     mass_tolerance = float(sys.argv[4])
+        #     output_result = sys.argv[5]
+        
+        input_file = resource_filename(__name__, "data/service_query_tabular.txt")
+
+        molecular_mass_col = "MM"
+        dblink_file = resource_filename(__name__, "data/MFSearcher ExactMassDB service.txt")
+        output_result = resource_filename(__name__, outdir + "metexp_query_results_added.txt")
+    
+     
+
+    
+        sys.argv = ['test',
+                    input_file,
+                    molecular_mass_col,
+                    dblink_file, 
+                    '0.001',
+                    'ms',
+                    output_result]
+        
+        # Execute main function with arguments provided through sys.argv
+        query_mass_repos.main()
+        
+       
+        
+   
+
+def _read_file(filename):
+    '''
+    Helper method to quickly read a file
+    @param filename:
+    '''
+    with open(filename) as handle:
+        return handle.read()