Example #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))
Example #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
Example #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"