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)
def test_load_wsp_single_poly(self): wsp_path = "examples/simple_line_example/simple_poly_and_rect.wsp" fcs_path = "examples/simple_line_example/data_set_simple_line_100.fcs" fks = Session(fcs_samples=fcs_path) fks.import_flowjo_workspace(wsp_path) self.assertIsInstance( fks.get_gate('my_group', 'data_set_simple_line_100.fcs', 'poly1'), gates.PolygonGate) gate_ids = {'rect1', 'poly1'} self.assertSetEqual(set(fks.get_gate_ids('my_group')), gate_ids)
def test_parse_wsp_reused_gate_with_child(self): wsp_path = "examples/data/8_color_data_set/reused_quad_gate_with_child.wsp" fks = Session(copy.deepcopy(test_samples_8c_full_set)) fks.import_flowjo_workspace(wsp_path, ignore_missing_files=True) group_name = 'All Samples' gate_name = 'some_child_gate' gate_ids = fks.get_gate_ids(group_name) gate_id_1 = (gate_name, ('root', 'good cells', 'cd4+', 'Q2: CD107a+, IL2+')) gate_id_2 = (gate_name, ('root', 'good cells', 'cd8+', 'Q2: CD107a+, IL2+')) self.assertIn(gate_id_1, gate_ids) self.assertIn(gate_id_2, gate_ids)
def test_load_wsp_single_poly(self): wsp_path = "examples/data/simple_line_example/simple_poly_and_rect.wsp" fcs_path = "examples/data/simple_line_example/data_set_simple_line_100.fcs" fks = Session(fcs_samples=fcs_path) fks.import_flowjo_workspace(wsp_path) self.assertIsInstance( fks.get_gate('my_group', 'poly1', sample_id='data_set_simple_line_100.fcs'), gates.PolygonGate) gate_names = {'rect1', 'poly1'} wsp_gates_tuple = fks.get_gate_ids('my_group') wsp_gate_names = set([g[0] for g in wsp_gates_tuple]) self.assertSetEqual(wsp_gate_names, gate_names)