view test/test_query_mass_repos.py @ 29:0d534bce8e84

small fix
author pieter.lukasse@wur.nl
date Fri, 09 May 2014 17:11:11 +0200
parents 637830ac8bcd
children
line wrap: on
line source

'''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 = "mass (Da)"
        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()