Exemplo n.º 1
0
    def __init__( self, IP_file, BG_file, map_file=None ) :
        self.data       = {}
        self.filtered   = {}
        self.load_data( IP_file, BG_file )
        
        # load genome map file, if provided
        if map_file :
            
            gff = fileIO.loadGFF( map_file )
            
            region_contigs = []
            for region in gff['regions'] :
                contig = region['contig']
                if not self.data.has_key( contig ) :
                    raise PiqueDataException( 'Map file contains unknown contig : ' + contig )
                if not region_contigs.__contains__( contig ) :
                    region_contigs.append( contig )

            # remove default regions from mapped contigs
            for contig in region_contigs :
                self.del_analysis_region( contig, 0, self.data[contig]['length'] )
        
            for region in gff['regions'] :
                contig = region['contig']
                start  = region['start']
                stop   = region['stop']
                self.add_analysis_region( contig, start, stop )
            
            # add masks
            for mask in gff['masks'] :
                contig = mask['contig']
                start  = mask['start']
                stop   = mask['stop']
                self.add_mask( contig, start, stop )
Exemplo n.º 2
0
    def __init__( self, IP_file, BG_file, map_file=None, name='' ) :
        self.data       = {}
        self.filtered   = {}
        self.name       = name
        
        # check the map file for errors now before loading the data
        if map_file :
            gff = fileIO.loadGFF( map_file )

            types = []
            err = 'Overlapping analysis regions : '
            rvs = 'Reversed coodinates in analysis region : '
            types.append( ('regions', err, rvs) )
            err = 'Overlapping masking regions : '
            rvs = 'Reversed coodinates in masking region : '  
            types.append( ('masks', err, rvs) )
            err = 'Overlapping normalization regions : '
            rvs = 'Reversed coodinates in normalization region : '
            types.append( ('norms', err, rvs) )

            for t,err,rvs in types :
                for region in gff[t] :
                    contig = region['contig']
                    start  = region['start']
                    stop   = region['stop']
                    if start > stop :
                        coord = str(start) + ':' + str(stop)
                        raise PiqueDataException( rvs + contig + coord )
                    for r in gff[t] :
                        if r['contig'] == contig :
                            if r['start'] > start and r['start'] < stop or  \
                               r['stop']  > start and r['stop']  < stop :
                                first  = str(start)      + ':' + str(stop)
                                second = str(r['start']) + ':' + str(r['stop'])
                                raise PiqueDataException( err + contig + ' ' + first + '::' + second )
           
        # load the track data 
        self.load_data( IP_file, BG_file )
        
        # load genome map file, if provided
        if map_file :
            
            region_contigs = []
            for region in gff['regions'] :
                contig = region['contig']
                if not self.data.has_key( contig ) :
                    raise PiqueDataException( 'Map file contains unknown contig : ' + contig )
                if not region_contigs.__contains__( contig ) :
                    region_contigs.append( contig )
            
            # remove default regions from mapped contigs
            for contig in region_contigs :
                self.del_analysis_region( contig, 0, self.data[contig]['length'] )
        
            for region in gff['regions'] :
                contig = region['contig']
                start  = region['start']
                stop   = region['stop']
                self.add_analysis_region( contig, start, stop )
            
            # add masks
            for mask in gff['masks'] :
                contig = mask['contig']
                start  = mask['start']
                stop   = mask['stop']
                self.add_mask( contig, start, stop )
            
            # add normalization regions
            for norm in gff['norms'] :
                contig = norm['contig']
                start  = norm['start']
                stop   = norm['stop']
                self.add_norm( contig, start, stop )
Exemplo n.º 3
0
    def __init__(self, IP_file, BG_file, map_file=None, name=''):
        self.data = {}
        self.filtered = {}
        self.name = name

        # check the map file for errors now before loading the data
        if map_file:
            gff = fileIO.loadGFF(map_file)

            types = []
            err = 'Overlapping analysis regions : '
            rvs = 'Reversed coodinates in analysis region : '
            types.append(('regions', err, rvs))
            err = 'Overlapping masking regions : '
            rvs = 'Reversed coodinates in masking region : '
            types.append(('masks', err, rvs))
            err = 'Overlapping normalization regions : '
            rvs = 'Reversed coodinates in normalization region : '
            types.append(('norms', err, rvs))

            for t, err, rvs in types:
                for region in gff[t]:
                    contig = region['contig']
                    start = region['start']
                    stop = region['stop']
                    if start > stop:
                        coord = str(start) + ':' + str(stop)
                        raise PiqueDataException(rvs + contig + coord)
                    for r in gff[t]:
                        if r['contig'] == contig:
                            if r['start'] > start and r['start'] < stop or  \
                               r['stop']  > start and r['stop']  < stop :
                                first = str(start) + ':' + str(stop)
                                second = str(r['start']) + ':' + str(r['stop'])
                                raise PiqueDataException(err + contig + ' ' +
                                                         first + '::' + second)

        # load the track data
        self.load_data(IP_file, BG_file)

        # load genome map file, if provided
        if map_file:

            region_contigs = []
            for region in gff['regions']:
                contig = region['contig']
                if not self.data.has_key(contig):
                    raise PiqueDataException(
                        'Map file contains unknown contig : ' + contig)
                if not region_contigs.__contains__(contig):
                    region_contigs.append(contig)

            # remove default regions from mapped contigs
            for contig in region_contigs:
                self.del_analysis_region(contig, 0,
                                         self.data[contig]['length'])

            for region in gff['regions']:
                contig = region['contig']
                start = region['start']
                stop = region['stop']
                self.add_analysis_region(contig, start, stop)

            # add masks
            for mask in gff['masks']:
                contig = mask['contig']
                start = mask['start']
                stop = mask['stop']
                self.add_mask(contig, start, stop)

            # add normalization regions
            for norm in gff['norms']:
                contig = norm['contig']
                start = norm['start']
                stop = norm['stop']
                self.add_norm(contig, start, stop)