예제 #1
0
 def test_read_channels(self):
     cols = pd.MultiIndex.from_tuples(
         list(zip(self.short_channels, self.long_channels)),
         names=["short", "long"],
     )
     df = DataFrame(self.data, columns=cols)
     s3_file_path = f"s3://{self.bucket_name}/test.fcs"
     df.to_fcs(s3_file_path)
     assert read_channels(s3_file_path, "short") == self.short_channels
     assert read_channels(s3_file_path, "long") == self.long_channels
     np.testing.assert_array_equal(read_channels(s3_file_path, "multi"),
                                   cols)
예제 #2
0
파일: test_apis.py 프로젝트: nehcgnay/fcsy
    def test_read_channels(self):
        with TmpDir() as dir_:
            filename = os.path.join(dir_, "test.fcs")
            cols = pd.MultiIndex.from_tuples(
                list(zip(self.short_channels, self.long_channels)),
                names=["short", "long"],
            )
            df = DataFrame(self.data, columns=cols)
            df.to_fcs(filename)

            assert read_channels(filename, "short") == self.short_channels
            assert read_channels(filename, "long") == self.long_channels
            np.testing.assert_array_equal(read_channels(filename, "multi"),
                                          cols)
예제 #3
0
파일: test_apis.py 프로젝트: nehcgnay/fcsy
    def test_read_channels(self):
        with TmpDir() as dir_:
            filename = os.path.join(dir_, self.name)
            df = DataFrame(self.data, columns=self.short_channels)
            write_fcs(df, filename, long_names=self.long_channels)

            assert read_channels(filename, "short") == self.short_channels
            assert read_channels(filename, "long") == self.long_channels
            np.testing.assert_array_equal(
                read_channels(filename, "multi"),
                pd.MultiIndex.from_tuples(
                    zip(self.short_channels, self.long_channels),
                    names=["short", "long"],
                ),
            )
예제 #4
0
    def test_rename_channels(self):
        cols = pd.MultiIndex.from_tuples(
            list(zip(self.short_channels, self.long_channels)),
            names=["short", "long"],
        )
        df = DataFrame(self.data, columns=cols)
        s3_file_path = f"s3://{self.bucket_name}/test.fcs"
        df.to_fcs(s3_file_path)

        rename_channels(s3_file_path, {
            "a": "a_1",
            "d": "d_1"
        },
                        "short",
                        allow_rewrite=True)

        dfr = DataFrame.from_fcs(s3_file_path, channel_type="multi")

        np.testing.assert_array_equal(
            ["a_1", "b", "c", "d_1"],
            dfr.columns.get_level_values("short").values,
        )
        np.testing.assert_array_equal(
            list("ABCD"),
            dfr.columns.get_level_values("long").values,
        )

        ln = ""
        for i in range(30):
            ln = ln + str(i)
        rename_channels(s3_file_path, {"C": ln}, "long", allow_rewrite=True)
        assert ["A", "B", ln, "D"] == read_channels(s3_file_path, "long")
예제 #5
0
파일: test_apis.py 프로젝트: nehcgnay/fcsy
    def test_rename_channels(self):
        with TmpDir() as dir_:
            filename = os.path.join(dir_, "test.fcs")
            cols = pd.MultiIndex.from_tuples(
                list(zip(self.short_channels, self.long_channels)),
                names=["short", "long"],
            )
            df = DataFrame(self.data, columns=cols)
            df.to_fcs(filename)

            with open(filename, "rb+") as fp:
                rename_channels(fp, dict(zip(self.short_channels,
                                             list("wxyz"))), "short")

            with open(filename, "rb+") as fp:
                rename_channels(fp, dict(zip(self.long_channels,
                                             list("WXYZ"))), "long")

            assert read_channels(filename, "short") == list("wxyz")
            assert read_channels(filename, "long") == list("WXYZ")
예제 #6
0
파일: test_apis.py 프로젝트: nehcgnay/fcsy
    def test_rename_channels(self):
        with TmpDir() as dir_:
            df = DataFrame(
                self.data,
                columns=pd.MultiIndex.from_tuples(
                    zip(self.short_channels, self.long_channels),
                    names=["short", "long"],
                ),
            )
            filename = os.path.join(dir_, self.name)
            df.to_fcs(filename)
            rename_channels(filename,
                            dict(zip(self.short_channels, list("abcd"))),
                            "short")
            short_channels = read_channels(filename, "short")
            assert short_channels == list("abcd")

            rename_channels(filename,
                            dict(zip(self.long_channels, list("ABCD"))),
                            "long")
            long_channels = read_channels(filename, "long")
            assert long_channels == list("ABCD")

            data = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]
            columns = pd.MultiIndex.from_tuples(list(zip("abc", "ABC")),
                                                names=["short", "long"])
            df = DataFrame(data, columns=columns)
            filename = os.path.join(dir_, self.name)
            df.to_fcs(filename)
            rename_channels(filename, {
                "a": "a_1",
                "b": "b_1",
                "c": "c_1"
            },
                            channel_type="short")
            short_channels = read_channels(filename, "short")
            long_channels = read_channels(filename, "long")
            assert short_channels == ["a_1", "b_1", "c_1"]
            assert long_channels == list("ABC")