def filter_line(self, route):
    """Mark unusual trips for the given route."""
    if self._route_type is not None and self._route_type != route.route_type:
      self.info('Skipping route %s due to different route_type value (%s)' %
                (route['route_id'], route['route_type']))
      return
    self.info('Filtering infrequent trips for route %s.' % route.route_id)
    trip_count = len(route.trips)
    for pattern_id, pattern in route.GetPatternIdTripDict().items():
      ratio = float(1.0 * len(pattern) / trip_count)
      if not self._force:
        if (ratio < self._threshold):
          self.info("\t%d trips on route %s with headsign '%s' recognized "
                    "as unusual (ratio %f)" %
                    (len(pattern),
                    route['route_short_name'],
                    pattern[0]['trip_headsign'],
                    ratio))
          for trip in pattern:
            trip.trip_type = 1 # special
            self.info("\t\tsetting trip_type of trip %s as special" %
                      trip.trip_id)
      else:
        self.info("\t%d trips on route %s with headsign '%s' recognized "
                  "as %s (ratio %f)" %
                  (len(pattern),
                   route['route_short_name'],
                   pattern[0]['trip_headsign'],
                   ('regular', 'unusual')[ratio < self._threshold],
                   ratio))
        for trip in pattern:
          trip.trip_type = ('0','1')[ratio < self._threshold]
          self.info("\t\tsetting trip_type of trip %s as %s" %
                    (trip.trip_id,
                     ('regular', 'unusual')[ratio < self._threshold]))
Mark unusual trips for the given route.