Exemple #1
0
    def test_clean_and_reformat_mapping_allpgp(self):
        """Exercise the reformat mapping code, verify expected results"""
        out = StringIO()
        reformat_mapping_testdata.seek(0)
        clean_and_reformat_mapping(reformat_mapping_testdata, out, 'body_site',
                                   'test')
        out.seek(0)

        # verify the resulting header structure
        test_mapping = [l.strip().split('\t') for l in out]
        test_header = test_mapping[0]
        self.assertEqual(test_header[-4:], ['SIMPLE_BODY_SITE',
                                            'TITLE_ACRONYM', 'TITLE_BODY_SITE',
                                            'HMP_SITE'])

        self.assertEqual(test_mapping[1][:], ['A', 'w00t', '43.0',
                                              'UBERON_mucosa_of_tongue', '5',
                                              'ORAL', 'test', 'test-ORAL',
                                              'ORAL'])
        self.assertEqual(test_mapping[2][:], ['B', 'left', '51.0',
                                              'UBERON:FECES', '10',
                                              'FECAL', 'test', 'test-FECAL',
                                              'FECAL'])
        self.assertEqual(test_mapping[3][:], ['C', 'right', '12.0',
                                              'UBERON_FECES', '15',
                                              'FECAL', 'test', 'test-FECAL',
                                              'FECAL'])
        self.assertEqual(test_mapping[4][:], ['E', 'stuff', '56.0',
                                              'UBERON:SKIN', '37',
                                              'SKIN', 'test', 'test-SKIN',
                                              'SKIN'])
Exemple #2
0
    def test_clean_and_reformat_mapping_allpgp(self):
        """Exercise the reformat mapping code, verify expected results"""
        out = StringIO()
        reformat_mapping_testdata.seek(0)
        clean_and_reformat_mapping(reformat_mapping_testdata, out, 'body_site',
                                   'test')
        out.seek(0)

        # verify the resulting header structure
        test_mapping = [l.strip().split('\t') for l in out]
        test_header = test_mapping[0]
        self.assertEqual(test_header[-4:], [
            'SIMPLE_BODY_SITE', 'TITLE_ACRONYM', 'TITLE_BODY_SITE', 'HMP_SITE'
        ])

        self.assertEqual(test_mapping[1][:], [
            'A', 'w00t', '43.0', 'UBERON_mucosa_of_tongue', '5', 'ORAL',
            'test', 'test-ORAL', 'ORAL'
        ])
        self.assertEqual(test_mapping[2][:], [
            'B', 'left', '51.0', 'UBERON:FECES', '10', 'FECAL', 'test',
            'test-FECAL', 'FECAL'
        ])
        self.assertEqual(test_mapping[3][:], [
            'C', 'right', '12.0', 'UBERON_FECES', '15', 'FECAL', 'test',
            'test-FECAL', 'FECAL'
        ])
        self.assertEqual(test_mapping[4][:], [
            'E', 'stuff', '56.0', 'UBERON:SKIN', '37', 'SKIN', 'test',
            'test-SKIN', 'SKIN'
        ])