Ejemplo n.º 1
0
    def test_get_plugin_and_folder_with_folder(self):
        """ Test the get_plugin_and_folder function with too many inputs
        """
        plugin, folder = mq2.get_plugin_and_folder(inputzip=TEST_INPUT_PASSED)

        plugin2, folder2 = mq2.get_plugin_and_folder(inputdir=folder)
        self.assertEqual(plugin, plugin2)
        self.assertEqual(folder, folder2)
Ejemplo n.º 2
0
Archivo: test.py Proyecto: PBR/MQ2
    def test_get_plugin_and_folder_with_folder(self):
        """ Test the get_plugin_and_folder function with too many inputs
        """
        plugin, folder = mq2.get_plugin_and_folder(
            inputzip=TEST_INPUT_PASSED)

        plugin2, folder2 = mq2.get_plugin_and_folder(
            inputdir=folder)
        self.assertEqual(plugin, plugin2)
        self.assertEqual(folder, folder2)
Ejemplo n.º 3
0
 def test_plugin_get_files(self):
     """ Test the get_files method of the plugin.
     """
     plugin, folder = mq2.get_plugin_and_folder(inputzip=TEST_INPUT_PASSED)
     self.assertEqual(len(plugin.get_files(folder)), 1)
     self.assertTrue(plugin.get_files(folder)[0].endswith('/rqtl_out.csv'))
     self.assertEqual(plugin.get_files(None), [])
Ejemplo n.º 4
0
Archivo: test_csv.py Proyecto: PBR/MQ2
 def test_run_mq2_from_file(self):
     """ Test the run_mq2 function from a file.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputfile=TEST_INPUT_FILE)
     mq2.run_mq2(plugin,
                 folder=TEST_INPUT_FILE,
                 lod_threshold=3)
     self.assertEqual(read_file('qtls.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'csv', 'qtls.exp')))
     self.assertEqual(read_file('map.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'csv', 'map.exp')))
     self.assertEqual(read_file('map_with_qtls.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'csv', 'map_with_qtls.exp')))
     self.assertEqual(read_file('qtls_matrix.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'csv', 'qtls_matrix.exp')))
     self.assertEqual(read_file('qtls_with_mk.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'csv', 'qtls_with_mk.exp')))
     self.assertEqual(read_file('MapChart.map'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'csv', 'MapChart.exp')))
Ejemplo n.º 5
0
Archivo: test_csv.py Proyecto: PBR/MQ2
 def test_plugin_get_files(self):
     """ Test the get_files method of the plugin.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_PASSED)
     self.assertEqual(len(plugin.get_files(folder)), 1)
     self.assertTrue(plugin.get_files(folder)[0].endswith('/rqtl_out.csv'))
     self.assertEqual(plugin.get_files(None), [])
Ejemplo n.º 6
0
 def test_plugin_get_session_identifiers(self):
     """ Test the get_session_identifiers method of the plugin.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_PASSED)
     self.assertEqual(len(plugin.get_session_identifiers(folder)), 1)
     self.assertEqual(plugin.get_session_identifiers(folder), ['2'])
     self.assertEqual(plugin.get_session_identifiers(None), [])
Ejemplo n.º 7
0
 def test_plugin_get_session_identifiers_failed(self):
     """ Test the get_session_identifiers method of the plugin.
     """
     plugin, folder = mq2.get_plugin_and_folder(inputzip=TEST_INPUT_PASSED)
     self.assertRaises(MQ2.MQ2Exception,
                       plugin.get_session_identifiers,
                       folder=os.path.join(TEST_FOLDER, 'fake.xls'),
                       inputfile=folder)
Ejemplo n.º 8
0
Archivo: test_csv.py Proyecto: PBR/MQ2
 def test_plugin_valid_file(self):
     """ Test the valid_file method of the plugin.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_PASSED)
     self.assertFalse(plugin.valid_file(TEST_INPUT_PASSED))
     self.assertTrue(plugin.valid_file(
         os.path.join(folder, 'rqtl_output', 'rqtl_out.csv')))
Ejemplo n.º 9
0
 def test_plugin_valid_file(self):
     """ Test the valid_file method of the plugin.
     """
     plugin, folder = mq2.get_plugin_and_folder(inputzip=TEST_INPUT_PASSED)
     self.assertFalse(plugin.valid_file(TEST_INPUT_PASSED))
     self.assertTrue(
         plugin.valid_file(
             os.path.join(folder, 'rqtl_output', 'rqtl_out.csv')))
Ejemplo n.º 10
0
 def test_run_mq2_invalid_input(self):
     """ Test the run_mq2 function with an invalid MapQTL zip input.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_FAILED)
     self.assertRaises(
         MQ2.MQ2NoMatrixException,
         mq2.run_mq2,
         plugin, folder, lod_threshold=3, session=2)
Ejemplo n.º 11
0
def session(session_id):
    """ Shows the session page.
    This page shows the different experiments ran on this session.
    A session being a MapQTL output zip file and a JoinMap map file,
    experiments are defined by the parameters used to find the QTLs
    within this MapQTL output.

    @param session_id the session identifier uniquely identifying the
    MapQTL zip file and the JoinMap map file.
    """
    print 'mq2 %s -- %s -- %s' % (datetime.datetime.now(), request.remote_addr,
                                  request.url)

    if session_id == CONFIG.get('mq2', 'sample_session'):
        global UPLOAD_FOLDER
        UPLOAD_FOLDER = os.path.join(os.path.abspath(__file__),
                                     APP.static_folder)
    upload_folder = os.path.join(UPLOAD_FOLDER, session_id)

    try:
        plugin, folder = get_plugin_and_folder(
            inputzip=os.path.join(upload_folder, 'input.zip'))
    except IOError:
        flash('Could not extract the zip archive.', 'errors')
        return redirect(url_for('index'))

    if plugin.session_name:
        form = InputFormSession(sessions=sorted(
            plugin.get_session_identifiers(folder)),
                                sessions_label=plugin.session_name)
    else:
        form = InputForm()
    if not (session_id in os.listdir(UPLOAD_FOLDER)
            or session_id in os.listdir(APP.static_folder)):
        flash('This session does not exists')
        return redirect(url_for('index'))

    if form.validate_on_submit():
        lod_threshold = form.lod_threshold.data
        session = None
        if plugin.session_name:
            session = form.session.data
        output = None
        try:
            output = mq2_run(session_id,
                             plugin,
                             folder,
                             lod_threshold=lod_threshold,
                             session=session)
        except MQ2Exception, err:
            form.errors['MQ2'] = err
        if output:
            flash("Experiment already run in experiment: <a href='%s'>"
                  "%s</a>" %
                  (url_for('results', session_id=session_id,
                           exp_id=output), output))
Ejemplo n.º 12
0
 def test_run_mq2_invalid_session(self):
     """ Test the run_mq2 function with MapQTL zip input and the
     wrong session identifier.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_PASSED)
     self.assertRaises(
         MQ2.MQ2NoSuchSessionException,
         mq2.run_mq2,
         plugin, folder, lod_threshold=3, session=1)
Ejemplo n.º 13
0
 def test_run_mq2_invalid_lod(self):
     """ Test the run_mq2 function with MapQTL zip input and an
     invalid LOD threshold.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_PASSED)
     self.assertRaises(
         MQ2.MQ2Exception,
         mq2.run_mq2,
         plugin, folder=folder, lod_threshold='a', session=2)
Ejemplo n.º 14
0
 def test_run_mq2_no_folder(self):
     """ Test the run_mq2 function with MapQTL zip input and without
     folder.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_PASSED)
     self.assertRaises(
         MQ2.MQ2Exception,
         mq2.run_mq2,
         plugin, folder=None, lod_threshold=3, session=2)
Ejemplo n.º 15
0
 def test_run_mq2_kw(self):
     """ Test the run_mq2 function with MapQTL zip input of a Kruskal-Wallis
     analysis.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_KW)
     self.assertRaises(
         MQ2.MQ2Exception,
         mq2.run_mq2,
         plugin, folder, lod_threshold=3, session=2)
Ejemplo n.º 16
0
Archivo: test_xls.py Proyecto: PBR/MQ2
 def test_plugin_get_session_identifiers_failed(self):
     """ Test the get_session_identifiers method of the plugin.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_PASSED)
     self.assertRaises(
         MQ2.MQ2Exception,
         plugin.get_session_identifiers,
         folder=os.path.join(TEST_FOLDER, 'fake.xls'),
         inputfile=folder)
Ejemplo n.º 17
0
Archivo: test_csv.py Proyecto: PBR/MQ2
 def test_run_mq2_no_folder(self):
     """ Test the run_mq2 function with MapQTL zip input and without
     folder.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_PASSED)
     self.assertRaises(
         MQ2.MQ2Exception,
         mq2.run_mq2,
         plugin, folder=None, lod_threshold=3, session=2)
Ejemplo n.º 18
0
    def test_plugin_valid_file(self):
        """ Test the valid_file method of the plugin.
        """
        plugin, folder = mq2.get_plugin_and_folder(inputzip=TEST_INPUT_PASSED)
        self.assertFalse(plugin.valid_file(TEST_INPUT_PASSED))
        self.assertTrue(
            plugin.valid_file(os.path.join(folder,
                                           os.listdir(folder)[0])))

        self.assertFalse(plugin.valid_file(TEST_FAKE_INPUT_FILE))
Ejemplo n.º 19
0
Archivo: test_csv.py Proyecto: PBR/MQ2
 def test_run_mq2_invalid_lod(self):
     """ Test the run_mq2 function with MapQTL zip input and an
     invalid LOD threshold.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_PASSED)
     self.assertRaises(
         MQ2.MQ2Exception,
         mq2.run_mq2,
         plugin, folder=folder, lod_threshold='a', session=2)
Ejemplo n.º 20
0
 def test_plugin_get_files(self):
     """ Test the get_files method of the plugin.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_PASSED)
     self.assertEqual(len(plugin.get_files(folder)), 2)
     self.assertTrue(
         plugin.get_files(folder)[0].endswith(
             '/Session 2 (IM)_A_trait01.mqo'))
     self.assertEqual(plugin.get_files(None), [])
Ejemplo n.º 21
0
 def test_get_plugin_and_folder(self):
     """ Test the get_plugin_and_folder function with MapQTL zip
     input.
     """
     plugin, folder = mq2.get_plugin_and_folder(inputzip=TEST_INPUT_PASSED)
     self.assertTrue(
         os.path.basename(folder).startswith(
             date.today().strftime('%Y%m%d')))
     self.assertEqual(plugin.name, 'CSV plugin')
     self.assertEqual(plugin.session_name, None)
Ejemplo n.º 22
0
Archivo: test_csv.py Proyecto: PBR/MQ2
 def test_get_plugin_and_folder(self):
     """ Test the get_plugin_and_folder function with MapQTL zip
     input.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_PASSED)
     self.assertTrue(os.path.basename(
         folder).startswith(date.today().strftime('%Y%m%d')))
     self.assertEqual(plugin.name, 'CSV plugin')
     self.assertEqual(plugin.session_name, None)
Ejemplo n.º 23
0
Archivo: test_xls.py Proyecto: PBR/MQ2
    def test_plugin_valid_file(self):
        """ Test the valid_file method of the plugin.
        """
        plugin, folder = mq2.get_plugin_and_folder(
            inputzip=TEST_INPUT_PASSED)
        self.assertFalse(plugin.valid_file(TEST_INPUT_PASSED))
        self.assertTrue(plugin.valid_file(
            os.path.join(folder,os.listdir(folder)[0])))

        self.assertFalse(plugin.valid_file(
            TEST_FAKE_INPUT_FILE))
Ejemplo n.º 24
0
def session(session_id):
    """ Shows the session page.
    This page shows the different experiments ran on this session.
    A session being a MapQTL output zip file and a JoinMap map file,
    experiments are defined by the parameters used to find the QTLs
    within this MapQTL output.

    @param session_id the session identifier uniquely identifying the
    MapQTL zip file and the JoinMap map file.
    """
    print 'mq2 %s -- %s -- %s' % (datetime.datetime.now(),
                                  request.remote_addr, request.url)

    if session_id == CONFIG.get('mq2', 'sample_session'):
        global UPLOAD_FOLDER
        UPLOAD_FOLDER = os.path.join(os.path.abspath(__file__),
                                     APP.static_folder)
    upload_folder = os.path.join(UPLOAD_FOLDER, session_id)

    try:
        plugin, folder = get_plugin_and_folder(
            inputzip=os.path.join(upload_folder, 'input.zip'))
    except IOError:
        flash('Could not extract the zip archive.', 'errors')
        return redirect(url_for('index'))

    if plugin.session_name:
        form = InputFormSession(
            sessions=sorted(plugin.get_session_identifiers(folder)),
            sessions_label=plugin.session_name)
    else:
        form = InputForm()
    if not (session_id in os.listdir(UPLOAD_FOLDER) or
            session_id in os.listdir(APP.static_folder)):
        flash('This session does not exists')
        return redirect(url_for('index'))

    if form.validate_on_submit():
        lod_threshold = form.lod_threshold.data
        session = None
        if plugin.session_name:
            session = form.session.data
        output = None
        try:
            output = mq2_run(session_id, plugin, folder,
                             lod_threshold=lod_threshold, session=session)
        except MQ2Exception, err:
            form.errors['MQ2'] = err
        if output:
            flash("Experiment already run in experiment: <a href='%s'>"
                  "%s</a>" % (url_for('results', session_id=session_id,
                  exp_id=output), output))
Ejemplo n.º 25
0
    def test_plugin_get_session_identifiers(self):
        """ Test the get_session_identifiers method of the plugin.
        """
        plugin, folder = mq2.get_plugin_and_folder(inputzip=TEST_INPUT_PASSED)
        self.assertEqual(len(plugin.get_session_identifiers(folder)), 1)
        self.assertEqual(plugin.get_session_identifiers(folder), ['Sheet1'])
        self.assertEqual(plugin.get_session_identifiers(None), [])

        self.assertEqual(
            plugin.get_session_identifiers(
                folder=os.path.join(TEST_FOLDER, 'fake.xls')), [])

        self.assertEqual(plugin.get_session_identifiers(inputfile=folder), [])
Ejemplo n.º 26
0
Archivo: test_xls.py Proyecto: PBR/MQ2
    def test_plugin_get_session_identifiers(self):
        """ Test the get_session_identifiers method of the plugin.
        """
        plugin, folder = mq2.get_plugin_and_folder(
            inputzip=TEST_INPUT_PASSED)
        self.assertEqual(len(plugin.get_session_identifiers(folder)), 1)
        self.assertEqual(plugin.get_session_identifiers(folder), ['Sheet1'])
        self.assertEqual(plugin.get_session_identifiers(None), [])

        self.assertEqual(plugin.get_session_identifiers(
            folder=os.path.join(TEST_FOLDER, 'fake.xls')), [])

        self.assertEqual(plugin.get_session_identifiers(
            inputfile=folder), [])
Ejemplo n.º 27
0
 def test_run_mq2(self):
     """ Test the run_mq2 function from a zip archive.
     """
     plugin, folder = mq2.get_plugin_and_folder(inputzip=TEST_INPUT_PASSED)
     mq2.run_mq2(plugin, folder, lod_threshold=3, session='Sheet1')
     self.assertEqual(
         read_file('qtls.csv'),
         read_file(os.path.join(TEST_FOLDER, 'xls', 'qtls.exp')))
     self.assertEqual(
         read_file('map.csv'),
         read_file(os.path.join(TEST_FOLDER, 'xls', 'map.exp')))
     self.assertEqual(
         read_file('map_with_qtls.csv'),
         read_file(os.path.join(TEST_FOLDER, 'xls', 'map_with_qtls.exp')))
     self.assertEqual(
         read_file('qtls_with_mk.csv'),
         read_file(os.path.join(TEST_FOLDER, 'xls', 'qtls_with_mk.exp')))
Ejemplo n.º 28
0
Archivo: test_xls.py Proyecto: PBR/MQ2
 def test_run_mq2(self):
     """ Test the run_mq2 function from a zip archive.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_PASSED)
     mq2.run_mq2(plugin, folder, lod_threshold=3, session='Sheet1')
     self.assertEqual(read_file('qtls.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'xls', 'qtls.exp')))
     self.assertEqual(read_file('map.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'xls', 'map.exp')))
     self.assertEqual(read_file('map_with_qtls.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'xls', 'map_with_qtls.exp')))
     self.assertEqual(read_file('qtls_with_mk.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'xls', 'qtls_with_mk.exp')))
Ejemplo n.º 29
0
 def test_run_mq2_from_file(self):
     """ Test the run_mq2 function from a file.
     """
     plugin, folder = mq2.get_plugin_and_folder(inputfile=TEST_INPUT_FILE)
     mq2.run_mq2(plugin, folder=TEST_INPUT_FILE, lod_threshold=3)
     self.assertEqual(
         read_file('qtls.csv'),
         read_file(os.path.join(TEST_FOLDER, 'csv', 'qtls.exp')))
     self.assertEqual(
         read_file('map.csv'),
         read_file(os.path.join(TEST_FOLDER, 'csv', 'map.exp')))
     self.assertEqual(
         read_file('map_with_qtls.csv'),
         read_file(os.path.join(TEST_FOLDER, 'csv', 'map_with_qtls.exp')))
     self.assertEqual(
         read_file('qtls_matrix.csv'),
         read_file(os.path.join(TEST_FOLDER, 'csv', 'qtls_matrix.exp')))
     self.assertEqual(
         read_file('qtls_with_mk.csv'),
         read_file(os.path.join(TEST_FOLDER, 'csv', 'qtls_with_mk.exp')))
     self.assertEqual(
         read_file('MapChart.map'),
         read_file(os.path.join(TEST_FOLDER, 'csv', 'MapChart.exp')))
Ejemplo n.º 30
0
 def test_run_mq2(self):
     """ Test the run_mq2 function with MapQTL zip input.
     """
     plugin, folder = mq2.get_plugin_and_folder(inputzip=TEST_INPUT_PASSED)
     mq2.run_mq2(plugin, folder, lod_threshold=3, session=2)
     self.assertEqual(
         read_file('qtls.csv'),
         read_file(os.path.join(TEST_FOLDER, 'csv', 'qtls.exp')))
     self.assertEqual(
         read_file('map.csv'),
         read_file(os.path.join(TEST_FOLDER, 'csv', 'map.exp')))
     self.assertEqual(
         read_file('map_with_qtls.csv'),
         read_file(os.path.join(TEST_FOLDER, 'csv', 'map_with_qtls.exp')))
     self.assertEqual(
         read_file('qtls_matrix.csv'),
         read_file(os.path.join(TEST_FOLDER, 'csv', 'qtls_matrix.exp')))
     self.assertEqual(
         read_file('qtls_with_mk.csv'),
         read_file(os.path.join(TEST_FOLDER, 'csv', 'qtls_with_mk.exp')))
     self.assertEqual(
         read_file('MapChart.map'),
         read_file(os.path.join(TEST_FOLDER, 'csv', 'MapChart.exp')))
Ejemplo n.º 31
0
Archivo: test_csv.py Proyecto: PBR/MQ2
 def test_run_mq2(self):
     """ Test the run_mq2 function with MapQTL zip input.
     """
     plugin, folder = mq2.get_plugin_and_folder(
         inputzip=TEST_INPUT_PASSED)
     mq2.run_mq2(plugin, folder, lod_threshold=3, session=2)
     self.assertEqual(read_file('qtls.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'csv', 'qtls.exp')))
     self.assertEqual(read_file('map.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'csv', 'map.exp')))
     self.assertEqual(read_file('map_with_qtls.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'csv', 'map_with_qtls.exp')))
     self.assertEqual(read_file('qtls_matrix.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'csv', 'qtls_matrix.exp')))
     self.assertEqual(read_file('qtls_with_mk.csv'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'csv', 'qtls_with_mk.exp')))
     self.assertEqual(read_file('MapChart.map'),
                      read_file(os.path.join(
                         TEST_FOLDER, 'csv', 'MapChart.exp')))