예제 #1
0
    def test_export_wsp(self):
        wsp_path = "examples/data/8_color_data_set/8_color_ICS.wsp"
        sample_grp = 'DEN'

        # use a leaf gate to test if the new WSP session is created correctly
        gate_name = 'TNFa+'
        gate_path = ('root', 'Time', 'Singlets', 'aAmine-', 'CD3+', 'CD4+')

        fks = Session(copy.deepcopy(test_samples_8c_full_set))
        fks.import_flowjo_workspace(wsp_path, ignore_missing_files=True)

        out_file = BytesIO()
        fks.export_wsp(out_file, sample_grp)
        out_file.seek(0)

        fks_out = Session(copy.deepcopy(test_samples_8c_full_set))
        fks_out.import_flowjo_workspace(out_file, ignore_missing_files=True)

        self.assertIsInstance(fks_out, Session)

        fks_gate = fks.get_gate(sample_grp, gate_name, gate_path)
        fks_out_gate = fks_out.get_gate(sample_grp, gate_name, gate_path)

        self.assertIsInstance(fks_gate, gates.RectangleGate)
        self.assertIsInstance(fks_out_gate, gates.RectangleGate)

        self.assertEqual(fks_gate.gate_name, gate_name)
        self.assertEqual(fks_out_gate.gate_name, gate_name)
예제 #2
0
    def test_wsp_export_simple_poly50(self):
        wsp_path = "examples/data/simple_line_example/simple_poly_and_rect_v2_poly50.wsp"
        fcs_path = "examples/data/simple_line_example/data_set_simple_line_100.fcs"
        sample_group = 'my_group'
        sample_id = 'data_set_simple_line_100.fcs'

        fks = Session(fcs_path)
        fks.import_flowjo_workspace(wsp_path)

        with BytesIO() as fh_out:
            fks.export_wsp(fh_out, sample_group)
            fh_out.seek(0)

            fks2 = Session(fcs_path)
            fks2.import_flowjo_workspace(fh_out)

        fks.analyze_samples(sample_group)
        fks_results = fks.get_gating_results(sample_group, sample_id)

        fks2.analyze_samples(sample_group)
        fks2_results = fks2.get_gating_results(sample_group, sample_id)

        gate_refs = fks.get_gate_ids(sample_group)

        self.assertEqual(len(gate_refs), 2)

        fks_rect1_count = fks_results.get_gate_count('rect1')
        fks2_rect1_count = fks2_results.get_gate_count('rect1')
        fks_poly1_count = fks_results.get_gate_count('poly1')
        fks2_poly1_count = fks2_results.get_gate_count('poly1')

        self.assertEqual(fks_rect1_count, 0)
        self.assertEqual(fks2_rect1_count, 0)
        self.assertEqual(fks_poly1_count, 50)
        self.assertEqual(fks2_poly1_count, 50)