def __init__(self, chromosome, start, stop=None, exact=False):
        """
        This class supports single position and range filters.

        By default, the filter will match any record that overlaps with
        the position or range specified. Exact matches must be explicitly
        specified using the `exact` parameter.
        """
        try:
            # Allows start=None to filter items with no position
            if start is not None:
                start = int(start)

            if stop is None:
                stop = start
            else:
                stop = int(stop)
        except ValueError:
            raise ValueError(
                'Start and stop positions must be integers (or None)')

        if exact or start is None:
            # Handle the case where start is None because sometimes
            # a record will have only the chromosome set (no positions).
            f = Filter(**{self.FIELD_START: start, self.FIELD_STOP: stop})
        else:
            f = Filter(**{self.FIELD_START + '__lte': start,
                          self.FIELD_STOP + '__gte': stop})
            if start != stop:
                f = f | Filter(**{self.FIELD_START + '__range':
                                  [start, stop]})
                f = f | Filter(**{self.FIELD_STOP + '__range':
                                  [start, stop]})

        if chromosome is None:
            f = f & Filter(**{self.FIELD_CHR: None})
        else:
            f = f & \
                Filter(**{self.FIELD_CHR: str(chromosome).replace('chr', '')})
        self.filters = f.filters
def __init__ ( self , chromosome , start , stop = None , exact = False ) : try : if start is not None : start = int ( start ) if stop is None : stop = start else : stop = int ( stop ) except ValueError : raise ValueError ( 'Start and stop positions must be integers (or None)' ) if exact or start is None : f = Filter ( ** { self . FIELD_START : start , self . FIELD_STOP : stop } ) else : f = Filter ( ** { self . FIELD_START + '__lte' : start , self . FIELD_STOP + '__gte' : stop } ) if start != stop : f = f | Filter ( ** { self . FIELD_START + '__range' : [ start , stop ] } ) f = f | Filter ( ** { self . FIELD_STOP + '__range' : [ start , stop ] } ) if chromosome is None : f = f & Filter ( ** { self . FIELD_CHR : None } ) else : f = f & Filter ( ** { self . FIELD_CHR : str ( chromosome ) . replace ( 'chr' , '' ) } ) self . filters = f . filters
This class supports single position and range filters.

        By default, the filter will match any record that overlaps with
        the position or range specified. Exact matches must be explicitly
        specified using the `exact` parameter.