Exemplo n.º 1
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.º 2
0
    def __init__(self, beds_path, chromosome_len_path, dhs_path, bin_size):
        self.beds_path = beds_path
        self.bin_size = bin_size
        self.dhs_path = dhs_path

        with open(chromosome_len_path) as clp:
            self.chromosome_len = read_chromosome_len(clp)
            divide_bed(self.chromosome_len, self.bin_size)

        self.genome_len = 0
        for chromosome in self.chromosome_len:
            self.genome_len += self.chromosome_len[chromosome][0]["end"] + 1
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 setUp(self):
     with open("./utest/test1.len") as tl:
         self.len_obj = read_chromosome_len(tl)
         divide_bed(self.len_obj, 100)
Exemplo n.º 5
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.º 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)