def setup(self): api = TransmartRestClient(self.mocked_config) constraint = {'type': 'true'} test_query_result = QueryResults(api.get_observations(constraint), api.get_tree_nodes(), api.get_dimensions(), api.get_studies(), api.get_relation_types(), api.get_relations()) mapper = TransmartLoaderMapper() self.qr_collection = mapper.map_query_results(test_query_result)
def copy_slice(self, constraint: Dict, output_dir: Path) -> None: """ Reads data from a TranSMART instance using the input constraint and writes transmart-copy staging files to the output directory. :param constraint the constraint to use when reading data :param output_dir the directory to write staging files to """ Console.info('Reading data from tranSMART...') transmart_client = TransmartRestClient(self.config) query_results = QueryResults( transmart_client.get_observations(constraint), transmart_client.get_tree_nodes(depth=0, tags=True), transmart_client.get_dimensions(), transmart_client.get_studies(), transmart_client.get_relation_types(), transmart_client.get_relations()) collection: DataCollection = TransmartLoaderMapper().map_query_results( query_results) Console.info('Writing files to {}'.format(output_dir)) copy_writer = TransmartCopyWriter(str(output_dir)) copy_writer.write_collection(collection) Console.info('Done.')
def test_get_relations(mocked_config, mocked_responses): api = TransmartRestClient(mocked_config) response: Relations = api.get_relations() assert len(response.relations) == 1