<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def query(self, query, output_path=None, file_name="query", output="tab"):
 """ Execute a GMQL textual query on the remote server. :param query: the string containing the query :param output_path (optional):
 where to store the results locally. If specified the results are downloaded locally :param file_name (optional):
 the name of the query :param output (optional):
 how to save the results. It can be "tab" or "gtf" :return: a pandas dataframe with the dictionary ids of the results """

        header = self.__check_authentication()
        header['Content-Type'] = "text/plain"
        output = output.lower()
        if output not in ['tab', 'gtf']:
            raise ValueError("output must be 'tab' or 'gtf'")
        url = self.address + "/queries/run/" + file_name + '/' + output
        response = requests.post(url, data=query, headers=header)
        if response.status_code != 200:
            raise ValueError("Code {}. {}".format(response.status_code, response.json().get("error")))
        response = response.json()
        jobid = response.get("id")
        self.logger.debug("JobId: {}. Waiting for the result".format(jobid))

        status_resp = self._wait_for_result(jobid)

        datasets = status_resp.get("datasets")
        return self.__process_result_datasets(datasets, output_path)