当前位置: 首页>>代码示例>>Python>>正文


Python data.RawData类代码示例

本文整理汇总了Python中qiita_db.data.RawData的典型用法代码示例。如果您正苦于以下问题:Python RawData类的具体用法?Python RawData怎么用?Python RawData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RawData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: render

    def render(self, raw_data_id, prep_template, study, files):
        rd = RawData(raw_data_id)
        raw_data_files = [(basename(fp), fp_type[4:])
                          for _, fp, fp_type in rd.get_filepaths()]
        filetype = rd.filetype
        fp_types = fp_type_by_ft[filetype]
        raw_data_link_status = rd.link_filepaths_status

        show_buttons = rd.status(study) == 'sandbox'
        link_msg = ""
        if show_buttons:
            # Define the message for the link status
            if raw_data_link_status == 'linking':
                link_msg = "Linking files..."
                show_buttons = False
            elif raw_data_link_status == 'unlinking':
                link_msg = "Unlinking files..."
                show_buttons = False
            elif raw_data_link_status.startswith('failed'):
                link_msg = "Error (un)linking files: %s" % raw_data_link_status

        link_msg = convert_text_html(link_msg)
        return self.render_string(
            "study_description_templates/raw_data_info.html",
            rd_id=raw_data_id,
            rd_filetype=rd.filetype,
            raw_data_files=raw_data_files,
            prep_template_id=prep_template.id,
            files=files,
            filepath_types=fp_types,
            filetype=filetype,
            link_msg=link_msg,
            show_buttons=show_buttons)
开发者ID:MarkBruns,项目名称:qiita,代码行数:33,代码来源:prep_template_tab.py

示例2: delete_raw_data

    def delete_raw_data(self, study, user, callback):
        """Delete the selected raw data

        Parameters
        ----------
        study : Study
            The current study object
        user : User
            The current user object
        callback : function
            The callback function to call with the results once the processing
            is done
        """
        raw_data_id = int(self.get_argument('raw_data_id'))
        prep_template_id = int(self.get_argument('prep_template_id'))

        try:
            RawData.delete(raw_data_id, prep_template_id)
            msg = ("Raw data %d has been deleted from prep_template %d"
                   % (raw_data_id, prep_template_id))
            msg_level = "success"
        except Exception as e:
            msg = "Couldn't remove raw data %d: %s" % (raw_data_id, str(e))
            msg_level = "danger"

        callback((msg, msg_level, "prep_template_tab", prep_template_id, None))
开发者ID:adamrp,项目名称:qiita,代码行数:26,代码来源:description_handlers.py

示例3: test_status_error

    def test_status_error(self):
        # Let's create a new study, so we can check that the error is raised
        # because the new study does not have access to the raw data
        info = {
            "timeseries_type_id": 1,
            "metadata_complete": True,
            "mixs_compliant": True,
            "number_samples_collected": 25,
            "number_samples_promised": 28,
            "portal_type_id": 3,
            "study_alias": "FCM",
            "study_description": "Microbiome of people who eat nothing but "
                                 "fried chicken",
            "study_abstract": "Exploring how a high fat diet changes the "
                              "gut microbiome",
            "emp_person_id": StudyPerson(2),
            "principal_investigator_id": StudyPerson(3),
            "lab_person_id": StudyPerson(1)
        }
        s = Study.create(User('[email protected]'), "Fried chicken microbiome",
                         [1], info)
        rd = RawData(1)

        with self.assertRaises(QiitaDBStatusError):
            rd.status(s)
开发者ID:zonca,项目名称:qiita,代码行数:25,代码来源:test_data.py

示例4: delete_raw_data

    def delete_raw_data(self, study, user, callback):
        """Delete the selected raw data

        Parameters
        ----------
        study : Study
            The current study object
        user : User
            The current user object
        callback : function
            The callback function to call with the results once the processing
            is done
        """
        raw_data_id = int(self.get_argument('raw_data_id'))

        try:
            RawData.delete(raw_data_id, study.id)
            msg = ("Raw data %d has been deleted from study: "
                   "<b><i>%s</i></b>" % (raw_data_id, study.title))
            msg_level = "success"
            tab = 'study_information_tab'
            tab_id = None
        except Exception as e:
            msg = "Couldn't remove %d raw data: %s" % (raw_data_id, str(e))
            msg_level = "danger"
            tab = 'raw_data_tab'
            tab_id = raw_data_id

        callback((msg, msg_level, tab, tab_id, None))
开发者ID:RNAer,项目名称:qiita,代码行数:29,代码来源:description_handlers.py

示例5: unlink_all_files

def unlink_all_files(raw_data_id):
    """Removes all files from raw data

    Needs to be dispachable because it does I/O and a lot of DB calls
    """
    rd = RawData(raw_data_id)
    rd.clear_filepaths()
开发者ID:jwdebelius,项目名称:qiita,代码行数:7,代码来源:dispatchable.py

示例6: add_files_to_raw_data

def add_files_to_raw_data(raw_data_id, filepaths):
    """Add files to raw data

    Needs to be dispachable because it moves large files
    """
    rd = RawData(raw_data_id)
    rd.add_filepaths(filepaths)
开发者ID:jwdebelius,项目名称:qiita,代码行数:7,代码来源:dispatchable.py

示例7: test_get_filepaths

 def test_get_filepaths(self):
     """Correctly returns the filepaths to the raw files"""
     rd = RawData(1)
     obs = rd.get_filepaths()
     exp = [
         (join(self.db_test_raw_dir, '1_s_G1_L001_sequences.fastq.gz'), 1),
         (join(self.db_test_raw_dir,
               '1_s_G1_L001_sequences_barcodes.fastq.gz'), 2)]
     self.assertEqual(obs, exp)
开发者ID:teravest,项目名称:qiita,代码行数:9,代码来源:test_data.py

示例8: QiitaBaseTest

class QiitaBaseTest(TestCase):
    """Tests that the base class functions act correctly"""

    def setUp(self):
        # We need an actual subclass in order to test the equality functions
        self.tester = RawData(1)

    def test_init_base_error(self):
        """Raises an error when instantiating a base class directly"""
        with self.assertRaises(IncompetentQiitaDeveloperError):
            QiitaObject(1)

    def test_init_error_inexistent(self):
        """Raises an error when instantiating an object that does not exists"""
        with self.assertRaises(QiitaDBUnknownIDError):
            RawData(10)

    def test_check_subclass(self):
        """Nothing happens if check_subclass called from a subclass"""
        self.tester._check_subclass()

    def test_check_subclass_error(self):
        """check_subclass raises an error if called from a base class"""
        # Checked through the __init__ call
        with self.assertRaises(IncompetentQiitaDeveloperError):
            QiitaObject(1)
        with self.assertRaises(IncompetentQiitaDeveloperError):
            QiitaStatusObject(1)

    def test_check_id(self):
        """Correctly checks if an id exists on the database"""
        self.assertTrue(self.tester._check_id(1))
        self.assertFalse(self.tester._check_id(100))

    def test_equal_self(self):
        """Equality works with the same object"""
        self.assertEqual(self.tester, self.tester)

    def test_equal(self):
        """Equality works with two objects pointing to the same instance"""
        new = RawData(1)
        self.assertEqual(self.tester, new)

    def test_not_equal(self):
        """Not equals works with object of the same type"""
        new = RawData(2)
        self.assertNotEqual(self.tester, new)

    def test_not_equal_type(self):
        """Not equals works with object of different type"""
        new = Study(1)
        self.assertNotEqual(self.tester, new)
开发者ID:BrindhaBioinfo,项目名称:qiita,代码行数:52,代码来源:test_base.py

示例9: test_get_preprocess_fastq_cmd_per_sample_FASTQ_failure

    def test_get_preprocess_fastq_cmd_per_sample_FASTQ_failure(self):
        metadata_dict = {
            'SKB8.640193': {'run_prefix': "sample1_failure", 'primer': 'A',
                            'barcode': 'A', 'center_name': 'ANL',
                            'platform': 'ILLUMINA',
                            'library_construction_protocol': 'A',
                            'experiment_design_description': 'A'}}
        md_template = pd.DataFrame.from_dict(metadata_dict, orient='index')
        prep_template = PrepTemplate.create(md_template, Study(1), '16S')

        # This part should fail
        fp1 = self.path_builder('sample1_failure.fastq')
        with open(fp1, 'w') as f:
            f.write('\n')
        self.files_to_remove.append(fp1)
        fp2 = self.path_builder('sample1_failure.barcodes.fastq.gz')
        with open(fp2, 'w') as f:
            f.write('\n')
        self.files_to_remove.append(fp2)
        forward_filepath_id = convert_to_id('raw_forward_seqs',
                                            'filepath_type')
        barcode_filepath_id = convert_to_id('raw_barcodes', 'filepath_type')

        fps = [(fp1, forward_filepath_id), (fp2, barcode_filepath_id)]

        filetype_id = get_filetypes()['per_sample_FASTQ']
        raw_data = RawData.create(filetype_id, [prep_template], fps)
        params = [p for p in list(PreprocessedIlluminaParams.iter())
                  if p.name == 'per sample FASTQ defaults'][0]

        with self.assertRaises(ValueError):
            _get_preprocess_fastq_cmd(raw_data, prep_template, params)
开发者ID:MarkBruns,项目名称:qiita,代码行数:32,代码来源:test_processing_pipeline.py

示例10: test_status

    def test_status(self):
        rd = RawData(1)
        s = Study(1)
        self.assertEqual(rd.status(s), 'private')

        # Since the status is inferred from the processed data, change the
        # status of the processed data so we can check how it changes in the
        # preprocessed data
        pd = ProcessedData(1)
        pd.status = 'public'
        self.assertEqual(rd.status(s), 'public')

        # Check that new raw data has sandbox as status since no
        # processed data exists for them
        rd = RawData.create(self.filetype, self.studies, self.filepaths)
        self.assertEqual(rd.status(s), 'sandbox')
开发者ID:zonca,项目名称:qiita,代码行数:16,代码来源:test_data.py

示例11: test_move_filepaths_to_upload_folder

    def test_move_filepaths_to_upload_folder(self):
        # setting up test, done here as this is the only test that uses these
        # files
        fd, seqs_fp = mkstemp(suffix='_seqs.fastq')
        close(fd)
        study_id = 1

        rd = RawData.create(2, [Study(study_id)], [(seqs_fp, 1)])
        filepaths = rd.get_filepaths()
        # deleting reference so we can directly call
        # move_filepaths_to_upload_folder
        for fid, _, _ in filepaths:
            self.conn_handler.execute(
                "DELETE FROM qiita.raw_filepath WHERE filepath_id=%s", (fid,))

        # moving filepaths
        move_filepaths_to_upload_folder(study_id, filepaths, self.conn_handler)

        # check that they do not exist in the old path but do in the new one
        path_for_removal = join(get_mountpoint("uploads")[0][1], str(study_id))
        for _, fp, _ in filepaths:
            self.assertFalse(exists(fp))
            new_fp = join(path_for_removal, basename(fp).split('_', 1)[1])
            self.assertTrue(exists(new_fp))

            self.files_to_remove.append(new_fp)
开发者ID:jwdebelius,项目名称:qiita,代码行数:26,代码来源:test_util.py

示例12: test_clear_filepaths

 def test_clear_filepaths(self):
     rd = RawData.create(self.filetype, self.studies, self.filepaths)
     self.assertTrue(self.conn_handler.execute_fetchone(
         "SELECT EXISTS(SELECT * FROM qiita.raw_filepath "
         "WHERE raw_data_id=%s)", (rd.id,))[0])
     rd.clear_filepaths()
     self.assertFalse(self.conn_handler.execute_fetchone(
         "SELECT EXISTS(SELECT * FROM qiita.raw_filepath "
         "WHERE raw_data_id=%s)", (rd.id,))[0])
开发者ID:BrindhaBioinfo,项目名称:qiita,代码行数:9,代码来源:test_data.py

示例13: test_remove_filepath

 def test_remove_filepath(self):
     rd = RawData.create(self.filetype, self.studies, self.filepaths)
     fp = join(self.db_test_raw_dir, "3_%s" % basename(self.seqs_fp))
     rd.remove_filepath(fp)
     self.assertFalse(self.conn_handler.execute_fetchone(
         "SELECT EXISTS(SELECT * FROM qiita.raw_filepath "
         "WHERE filepath_id=17)")[0])
     self.assertTrue(self.conn_handler.execute_fetchone(
         "SELECT EXISTS(SELECT * FROM qiita.raw_filepath "
         "WHERE filepath_id=18)")[0])
开发者ID:BrindhaBioinfo,项目名称:qiita,代码行数:10,代码来源:test_data.py

示例14: test_link_filepaths_status_setter

 def test_link_filepaths_status_setter(self):
     rd = RawData(1)
     self.assertEqual(rd.link_filepaths_status, 'idle')
     rd._set_link_filepaths_status('linking')
     self.assertEqual(rd.link_filepaths_status, 'linking')
     rd._set_link_filepaths_status('unlinking')
     self.assertEqual(rd.link_filepaths_status, 'unlinking')
     rd._set_link_filepaths_status('failed: error')
     self.assertEqual(rd.link_filepaths_status, 'failed: error')
开发者ID:BrindhaBioinfo,项目名称:qiita,代码行数:9,代码来源:test_data.py

示例15: test_create

    def test_create(self):
        """Correctly creates all the rows in the DB for the raw data"""
        # Check that the returned object has the correct id
        exp_id = get_count("qiita.raw_data") + 1
        obs = RawData.create(self.filetype, self.prep_templates,
                             self.filepaths)
        self.assertEqual(obs.id, exp_id)

        # Check that the raw data have been correctly added to the DB
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.raw_data WHERE raw_data_id=%d" % exp_id)
        # raw_data_id, filetype, link_filepaths_status
        self.assertEqual(obs, [[exp_id, 2, 'idle']])

        # Check that the raw data has been correctly linked with the prep
        # templates
        sql = """SELECT prep_template_id
                 FROM qiita.prep_template
                 WHERE raw_data_id = %s
                 ORDER BY prep_template_id"""
        obs = self.conn_handler.execute_fetchall(sql, (exp_id,))
        self.assertEqual(obs, [[self.pt1.id], [self.pt2.id]])

        # Check that the files have been copied to right location
        exp_seqs_fp = join(self.db_test_raw_dir,
                           "%d_%s" % (exp_id, basename(self.seqs_fp)))
        self.assertTrue(exists(exp_seqs_fp))
        self._clean_up_files.append(exp_seqs_fp)

        exp_bc_fp = join(self.db_test_raw_dir,
                         "%d_%s" % (exp_id, basename(self.barcodes_fp)))
        self.assertTrue(exists(exp_bc_fp))
        self._clean_up_files.append(exp_bc_fp)

        # Check that the filepaths have been correctly added to the DB
        top_id = self.conn_handler.execute_fetchone(
            "SELECT count(1) FROM qiita.filepath")[0]
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.filepath WHERE filepath_id=%d or "
            "filepath_id=%d" % (top_id - 1, top_id))
        exp_seqs_fp = "%d_%s" % (exp_id, basename(self.seqs_fp))
        exp_bc_fp = "%d_%s" % (exp_id, basename(self.barcodes_fp))
        # filepath_id, path, filepath_type_id
        exp = [[top_id - 1, exp_seqs_fp, 1, '852952723', 1, 5],
               [top_id, exp_bc_fp, 2, '852952723', 1, 5]]
        self.assertEqual(obs, exp)

        # Check that the raw data have been correctly linked with the filepaths
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.raw_filepath WHERE raw_data_id=%d" % exp_id)
        # raw_data_id, filepath_id
        self.assertEqual(obs, [[exp_id, top_id - 1], [exp_id, top_id]])
开发者ID:MarkBruns,项目名称:qiita,代码行数:52,代码来源:test_data.py


注:本文中的qiita_db.data.RawData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。