Beispiel #1
0
    def check_random_windows_against_wig(self, strand):
        chrdict = self.chrdict
        chroms = list(self.chrdict)
        chridx = numpy.random.randint(0, high=len(chroms), size=50)
        ga = GenomeArray()

        i = 0

        with open(wigfile) as fin:
            ga.add_from_wiggle(fin, strand)
            while i < 50:
                chrom = chroms[chridx[i]]
                maxlength = chrdict[chrom]
                start = numpy.random.randint(0, high=maxlength - 2000)
                end = numpy.random.randint(start + 10000, high=start + 20000)

                # make sure we don't go off chrom
                while end > maxlength:
                    end = numpy.random.randint(start + 100, high=start + 10000)

                seg = GenomicSegment(chrom, start, end, strand)
                expected = ga[seg]
                # make sure segment has counts in it
                if expected.sum() > 0:
                    i += 1
                    found = self.bw[seg]
                    yield self.check_vals_against_wig, expected, found
Beispiel #2
0
    def check_random_windows_against_wig(self, strand):
        chrdict = self.chrdict
        chroms = list(self.chrdict)
        chridx = numpy.random.randint(0, high=len(chroms), size=50)
        ga = GenomeArray()

        i = 0

        with open(wigfile) as fin:
            ga.add_from_wiggle(fin, strand)
            while i < 50:
                chrom = chroms[chridx[i]]
                maxlength = chrdict[chrom]
                start = numpy.random.randint(0, high=maxlength - 2000)
                end = numpy.random.randint(start + 10000, high=start + 20000)

                # make sure we don't go off chrom
                while end > maxlength:
                    end = numpy.random.randint(start + 100, high=start + 10000)

                seg = GenomicSegment(chrom, start, end, strand)
                expected = ga[seg]
                # make sure segment has counts in it
                if expected.sum() > 0:
                    i += 1
                    found = self.bw[seg]
                    yield self.check_vals_against_wig, expected, found
Beispiel #3
0
 def test_get_chromosome_counts_zero_fill(self):
     ga = GenomeArray()
     with open(wigfile) as fin:
         ga.add_from_wiggle(fin, "+")
         for chrom, length in self.chrdict.items():
             seg = GenomicSegment(chrom, 0, length, "+")
             expected = ga[seg]
             found = self.bw.get_chromosome_counts(chrom)
             yield self.check_vals_against_wig, expected, found
Beispiel #4
0
 def test_get_chromosome_counts_zero_fill(self):
     ga = GenomeArray()
     with open(wigfile) as fin:
         ga.add_from_wiggle(fin, "+")
         for chrom, length in self.chrdict.items():
             seg = GenomicSegment(chrom, 0, length, "+")
             expected = ga[seg]
             found = self.bw.get_chromosome_counts(chrom)
             yield self.check_vals_against_wig, expected, found
Beispiel #5
0
def do_check(argstr, ref_files, test_files):
    """Check that test wiggle files match reference files
    
    Parameters
    ----------
    ref_files : tuple
        Tuple of filenames corresponding to forward and reverse strand wiggles
        for reference dataset
    
    test_files : list
        Tuple of filenames corresponding to forward and reverse strand wiggles
        for test dataset
    """
    err_message = "Unequal output in files %s vs %s, module %s" % (
        ref_files, test_files, test_info["module_name"])
    test_info["test_method"](shlex.split(argstr))
    ref_ga = GenomeArray()
    test_ga = GenomeArray()
    ref_ga.add_from_wiggle(open(ref_files[0]), "+")
    ref_ga.add_from_wiggle(open(ref_files[1]), "-")
    test_ga.add_from_wiggle(open(test_files[0]), "+")
    test_ga.add_from_wiggle(open(test_files[1]), "-")
    nose.tools.assert_true(ref_ga.__eq__(test_ga, tol=1e-8), err_message)
def do_check(argstr,ref_files,test_files):
    """Check that test wiggle files match reference files
    
    Parameters
    ----------
    ref_files : tuple
        Tuple of filenames corresponding to forward and reverse strand wiggles
        for reference dataset
    
    test_files : list
        Tuple of filenames corresponding to forward and reverse strand wiggles
        for test dataset
    """
    err_message = "Unequal output in files %s vs %s, module %s" % (ref_files,test_files,test_info["module_name"])
    test_info["test_method"](shlex.split(argstr))
    ref_ga  = GenomeArray()
    test_ga = GenomeArray()
    ref_ga.add_from_wiggle(open(ref_files[0]),"+")
    ref_ga.add_from_wiggle(open(ref_files[1]),"-")
    test_ga.add_from_wiggle(open(test_files[0]),"+")
    test_ga.add_from_wiggle(open(test_files[1]),"-")
    nose.tools.assert_true(ref_ga.__eq__(test_ga,tol=1e-8),err_message)