def test_get_observations(mocked_config, mocked_responses): constraint = {'type': 'true'} api = TransmartRestClient(mocked_config) response: Hypercube = api.get_observations(constraint) dimension_declaration = response.dimensionDeclarations cells = response.cells dimension_elements = response.dimensionElements assert len(dimension_declaration) == 12 assert len(cells) == 3 assert len(dimension_elements) == 9
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.')