'Converts a dataset to the target_type and returns a message indicating
status of the conversion. None is returned to indicate that dataset
was converted successfully.'

def convert_dataset(self, trans, target_type):

    try:
        converted_dataset = self.get_converted_dataset(trans, target_type)
    except NoConverterException:
        return self.conversion_messages.NO_CONVERTER
    except ConverterDependencyException as dep_error:
        return {'kind': self.conversion_messages.ERROR, 'message': dep_error.value}
    msg = None
    if (converted_dataset and (converted_dataset.state == Dataset.states.ERROR)):
        job_id = trans.sa_session.query(JobToOutputDatasetAssociation).filter_by(dataset_id=converted_dataset.id).first().job_id
        job = trans.sa_session.query(Job).get(job_id)
        msg = {'kind': self.conversion_messages.ERROR, 'message': job.stderr}
    elif ((not converted_dataset) or (converted_dataset.state != Dataset.states.OK)):
        msg = self.conversion_messages.PENDING
    return msg
