Exemplo n.º 1
0
 def gen_testVector(self, bed, vec):
     with open(bed) as md:
         bed_obj = read_bed(md)
     with open(vec) as dmv:
         vector_dmv = array(read_vector(dmv), "int8")
     self.vec_obj = bed2vector(bed_obj, self.len_obj)
     print "\nestimate\t", vector_dmv
     print "result\t\t", self.vec_obj
     self.assertTrue(alltrue(self.vec_obj == vector_dmv))
Exemplo n.º 2
0
 def _get_vector(self, bp):
     bed = read_bed(bp)
     divide_bed(bed, self.bin_size)
     merge_bed(bed)
     try:
         vector = bed2vector(bed, self.chromosome_len)
     except:
         print bp
         raise
     return vector
Exemplo n.º 3
0
    def init_dhs_extraction(self):
        with open(self.dhs_path) as dp:
            dhs = read_bed(dp)
            divide_bed(dhs, self.bin_size)
            merge_bed(dhs)
            self.dhs_vector = bed2vector(dhs, self.chromosome_len)
            coverage = len(nonzero(self.dhs_vector)[0])
            print coverage,"coverage"

        ret = empty((coverage, len(self.beds_path)), dtype="int8")

        current_col = 0
        for bed_path in self.beds_path:
            with open(bed_path) as bp:
                ret[:,current_col] = self._bed2extracted_vector(bp)
                current_col += 1
        self.sparse = csr_matrix(ret,dtype="int16")
        print "init DHS extraction finished"
Exemplo n.º 4
0
 def testMerge2(self):
     divide_bed(self.bed_obj, 100)
     merge_bed(self.bed_obj)
     with open("./utest/test1_divided_merged.bed") as dmd:
         self.bed_dmer = read_bed(dmd)
     self.assertEqual(self.bed_obj, self.bed_dmer)
Exemplo n.º 5
0
 def testMerge(self):
     merge_bed(self.bed_obj)
     with open("./utest/test1_merged.bed") as md:
         self.bed_mer = read_bed(md)
     self.assertEqual(self.bed_obj, self.bed_mer)
Exemplo n.º 6
0
 def testDivide(self):
     divide_bed(self.bed_obj, 100)
     with open("./utest/test1_divided.bed") as dd:
         self.bed_div = read_bed(dd)
     self.assertEqual(self.bed_div, self.bed_obj)
Exemplo n.º 7
0
 def setUp(self):
     with open("./utest/test1.bed") as tb:
         self.bed_obj = read_bed(tb)
     self.maxDiff = None