Exemplo n.º 1
0
def mq2_run(session_id, plugin, folder, lod_threshold, session):
    """ Run the scripts to extract the QTLs.

    :arg session_id: the session identifier uniquely identifying the
        MapQTL zip file and the JoinMap map file. The session identifier
        also uniquely identifies the folder in which are the files
        uploaded.
    :arg lod_threshold: the LOD threshold to use to consider a value
        significant for a QTL.
    :arg mapqtl_session: the MapQTL session/run from which to retrieve
        the QTLs.
    """
    upload_folder = os.path.join(UPLOAD_FOLDER, session_id)
    already_done = experiment_done(session_id, lod_threshold, session)
    if already_done is not False:
        return already_done
    exp_id = '%s_s%s_t%s' % (generate_exp_id(), session,
                             lod_threshold)
    exp_folder = os.path.join(upload_folder, exp_id)
    if not os.path.exists(exp_folder):
        os.mkdir(exp_folder)

    try:
        run_mq2(plugin, folder, lod_threshold=lod_threshold,
                session=session, outputfolder=exp_folder)

        (nline, ncol) = get_matrix_dimensions(os.path.join(
            exp_folder, 'qtls_matrix.csv'))
    except MQ2Exception, err:
        shutil.rmtree(exp_folder)
        raise MQ2Exception(err)
Exemplo n.º 2
0
Arquivo: test_csv.py Projeto: 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')))
Exemplo n.º 3
0
def mq2_run(session_id, plugin, folder, lod_threshold, session):
    """ Run the scripts to extract the QTLs.

    :arg session_id: the session identifier uniquely identifying the
        MapQTL zip file and the JoinMap map file. The session identifier
        also uniquely identifies the folder in which are the files
        uploaded.
    :arg lod_threshold: the LOD threshold to use to consider a value
        significant for a QTL.
    :arg mapqtl_session: the MapQTL session/run from which to retrieve
        the QTLs.
    """
    upload_folder = os.path.join(UPLOAD_FOLDER, session_id)
    already_done = experiment_done(session_id, lod_threshold, session)
    if already_done is not False:
        return already_done
    exp_id = '%s_s%s_t%s' % (generate_exp_id(), session, lod_threshold)
    exp_folder = os.path.join(upload_folder, exp_id)
    if not os.path.exists(exp_folder):
        os.mkdir(exp_folder)

    try:
        run_mq2(plugin,
                folder,
                lod_threshold=lod_threshold,
                session=session,
                outputfolder=exp_folder)

        (nline, ncol) = get_matrix_dimensions(
            os.path.join(exp_folder, 'qtls_matrix.csv'))
    except MQ2Exception, err:
        shutil.rmtree(exp_folder)
        raise MQ2Exception(err)
Exemplo n.º 4
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')))
Exemplo n.º 5
0
Arquivo: test_xls.py Projeto: 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')))
Exemplo n.º 6
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')))
Exemplo n.º 7
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')))
Exemplo n.º 8
0
Arquivo: test_csv.py Projeto: 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')))