Exemple #1
0
    def test_validate_num_rows(self):
        file = self.exampleFile(filename)
        dataframe = read_bed(file)

        with open(file, "r") as ins:
            lines = []
            for line in ins:
                lines.append(line)
            assert (len(lines) == len(dataframe.index))
Exemple #2
0
    def test_to_json(self):
        dataframe = read_bed(self.exampleFile(filename))

        def is_valid_json(string):
            try:
                json_object = json.loads(string)
            except ValueError:
                return False
            return True

        assert (type(dataframe._mango_to_json) == str)
        assert (is_valid_json(dataframe._mango_to_json) == True)
Exemple #3
0
    def test_column_type(self):
        dataframe = read_bed(self.exampleFile("chr17.582500-594500.bed"))

        chromosomes = list(dataframe["chrom"])
        chromStart = list(dataframe["chromStart"])
        chromEnd = list(dataframe["chromEnd"])

        for i in range(len(chromStart)):
            assert (type(chromStart[i] == int))

        for i in range(len(chromEnd)):
            assert (type(chromEnd[i] == int))

        for i in range(len(chromosomes)):
            assert (type(chromosomes[i] == int))
Exemple #4
0
    def test_visualization(self):
        dataframe = read_bed(self.exampleFile(filename))

        assert (dataframe._pileup_visualization == "featureJson")
        tracks = [
            Track(viz="features",
                  label="my features",
                  source=pileup.sources.DataFrameSource(dataframe))
        ]
        reads = pileup.PileupViewer(chrom="chr22",
                                    start=10436,
                                    stop=10564,
                                    reference="hg19",
                                    tracks=tracks)
        assert (str(
            type(reads)
        ) == '<class \'bdgenomics.mango.pileup.pileupViewer.PileupViewer\'>')
        assert (reads.chrom == 'chr22')
Exemple #5
0
 def test_required_columns(self):
     dataframe = read_bed(self.exampleFile(filename))
     dataframe_columns = list(dataframe.columns)
     for name in ("chrom", "chromStart", "chromEnd"):
         assert (name in dataframe_columns)