code: def matches(self, query):
          
          thread_query = 'thread:{tid} AND {subquery}'.format(tid=self._id,
                                                              subquery=query)
          num_matches = self._dbman.count_messages(thread_query)
          return num_matches > 0
docs: Check if this thread matches the given notmuch query.
  
          :param query: The query to check against
          :type query: string
          :returns: True if this thread matches the given query, False otherwise
          :rtype: bool