Example #1
0
    def test_strains_with_uri_and_trailing_strings(self):
        ip_table = test_utils.create_fake_controls_table(1)
        control_type = IntentParserCell()
        control_type.add_paragraph('HIGH_FITC')

        strains = IntentParserCell()
        strains.add_paragraph(
            'MG1655', link='https://hub.sd2e.org/user/sd2e/design/MG1655/1')
        strains.add_paragraph(', MG1655_LPV3,MG1655_RPU_Standard')
        data_row = test_utils.create_control_table_row(
            strains_cell=strains, control_type_cell=control_type)
        ip_table.add_row(data_row)

        control_table_parser = ControlsTable(
            ip_table,
            strain_mapping=self.strain_mappings,
            control_types={'HIGH_FITC'})
        control_table_parser.process_table()
        control_result = control_table_parser.get_intents()
        self.assertEquals(1, len(control_result))

        exp_res = {
            'sbh_uri': 'https://hub.sd2e.org/user/sd2e/design/MG1655/1',
            'label': 'strain1',
            'lab_id': 'name.ip_admin.MG1655'
        }
        expected_result = {
            dc_constants.TYPE: 'HIGH_FITC',
            dc_constants.STRAINS: [exp_res]
        }
        self.assertEqual(expected_result,
                         control_result[0].to_structured_request())
Example #2
0
    def test_table_with_contents(self):
        ip_table = test_utils.create_fake_controls_table(1)
        control_type = IntentParserCell()
        control_type.add_paragraph('HIGH_FITC')

        content = IntentParserCell()
        content.add_paragraph(
            'beta_estradiol',
            link='https://hub.sd2e.org/user/sd2e/design/beta_estradiol/1')
        data_row = test_utils.create_control_table_row(
            contents_cell=content, control_type_cell=control_type)
        ip_table.add_row(data_row)

        control_table_parser = ControlsTable(ip_table,
                                             control_types={'HIGH_FITC'})
        control_table_parser.process_table()
        control_result = control_table_parser.get_intents()

        content = {
            dc_constants.NAME: {
                dc_constants.LABEL:
                'beta_estradiol',
                dc_constants.SBH_URI:
                'https://hub.sd2e.org/user/sd2e/design/beta_estradiol/1'
            }
        }

        expected_result = {
            dc_constants.TYPE: 'HIGH_FITC',
            dc_constants.CONTENTS: [content]
        }
        self.assertEqual(expected_result,
                         control_result[0].to_structured_request())
Example #3
0
    def test_table_with_1_timepoint(self):
        ip_table = test_utils.create_fake_controls_table(1)
        content = IntentParserCell()
        content.add_paragraph('8 hour')

        control_type = IntentParserCell()
        control_type.add_paragraph('HIGH_FITC')

        data_row = test_utils.create_control_table_row(
            timepoint_cell=content, control_type_cell=control_type)
        ip_table.add_row(data_row)

        control_table_parser = ControlsTable(ip_table,
                                             timepoint_units={'hour'},
                                             control_types={'HIGH_FITC'})
        control_table_parser.process_table()
        control_result = control_table_parser.get_intents()
        self.assertEqual(1, len(control_result))
        expected_timepoint = {
            dc_constants.VALUE: 8.0,
            dc_constants.UNIT: 'hour'
        }
        expected_result = {
            dc_constants.TYPE: 'HIGH_FITC',
            dc_constants.TIMEPOINTS: [expected_timepoint]
        }
        self.assertEqual(expected_result,
                         control_result[0].to_structured_request())
Example #4
0
    def test_table_with_control_type(self):
        ip_table = test_utils.create_fake_controls_table(1)
        control_type = IntentParserCell()
        control_type.add_paragraph('HIGH_FITC')
        data_row = test_utils.create_control_table_row(
            control_type_cell=control_type)
        ip_table.add_row(data_row)

        control_table_parser = ControlsTable(ip_table,
                                             control_types={'HIGH_FITC'})
        control_table_parser.process_table()
        control_result = control_table_parser.get_intents()
        self.assertEqual(1, len(control_result))
        expected_result = {dc_constants.TYPE: 'HIGH_FITC'}
        self.assertEqual(expected_result,
                         control_result[0].to_structured_request())
Example #5
0
    def test_table_with_multiple_channels(self):
        ip_table = test_utils.create_fake_controls_table(1)
        control_type = IntentParserCell()
        control_type.add_paragraph('HIGH_FITC')

        channel = IntentParserCell()
        channel.add_paragraph('BL1-A, BL2-A')
        data_row = test_utils.create_control_table_row(
            channel_cell=channel, control_type_cell=control_type)
        ip_table.add_row(data_row)

        control_table_parser = ControlsTable(ip_table,
                                             control_types={'HIGH_FITC'})
        control_table_parser.process_table()
        control_result = control_table_parser.get_intents()
        expected_result = {
            dc_constants.TYPE: 'HIGH_FITC',
            dc_constants.CHANNEL: 'BL1-A'
        }
        self.assertEqual(expected_result,
                         control_result[0].to_structured_request())