def test_get_default_config(self): # Initialization cc = ConfigClient() cbc = CellBaseClient(cc) assert cc.get_default_configuration() == cbc.get_default_configuration( )
def test_get(self): """"Checks generic fetcher for RESTful service""" # Initialization cc = ConfigClient() cbc = CellBaseClient(cc) res = cbc.get('feature', 'gene', 'protein', 'BRCA1') assert res[0]['result'][0]['name'][0] == 'BRCA1_HUMAN'
def test_change_config(self): """Checks configuration customization""" # Initialization cc = ConfigClient() cbc = CellBaseClient(cc) # Checking some default config params assert cbc.get_config()['species'] == 'hsapiens' assert cbc.get_config()['version'] == 'v4' # Checking some setters for config params cc.species = 'mmusculus' assert cbc.get_config()['species'] == 'mmusculus' cc.version = 'v3' assert cbc.get_config()['version'] == 'v3'
def test_change_config(self): """Checks configuration customization""" # Initialization cc = ConfigClient() cbc = CellBaseClient(cc) # Checking some default config params assert cbc.get_config()['species'] == 'hsapiens' assert cbc.get_config()['version'] == 'latest' # Checking some setters for config params cc.species = 'mmusculus' assert cbc.get_config()['species'] == 'mmusculus' cc.version = 'v4' assert cbc.get_config()['version'] == 'v4'
def main(): """The main function""" # Getting args args = _parse_arguments() # Check arguments args = _check_arguments(args) # Setting up logging system _set_logger(args.verbosity) # Setting up PyCellBase clients cc = ConfigClient({ "species": _DEFAULT_SPECIES, "version": _DEFAULT_API_VERSION, "rest": { "hosts": [_DEFAULT_HOST] } }) # Overriding config if args.config is not None: cc = ConfigClient(args.config) if args.species is not None: cc.species = args.species if args.api_version is not None: cc.version = args.api_version if args.host is not None: cc.host = args.host if args.assembly is not None: assembly = args.assembly else: assembly = _DEFAULT_ASSEMBLY cbc = CellBaseClient(cc) if args.which == 'xref': # Getting available databases databases = _get_databases_list(cbc, assembly) # Filtering databases with include and exclude include = args.include.split(',') if args.include is not None else None exclude = args.exclude.split(',') if args.exclude is not None else None databases = _filter_databases(databases, include=include, exclude=exclude) # Converting IDs convert_ids(input_fpath=args.input_fpath, output_fpath=args.output_fpath, cellbase_client=cbc, assembly=assembly, databases=databases) if args.which == 'hgvs': calculate_hgvs(input_data=args.input, output_fpath=args.output_fpath, cbc=cbc, ref_seq_type=args.ref_seq_type, assembly=assembly) if args.which == 'annotate': # Getting the list of annotations to add include = get_include_annots(args.include, args.exclude) include = list(set(include).intersection(_ANNOT.keys())) # Annotate VCF annotate_vcf(cellbase_client=cbc, input_fpath=args.input_fpath, output_fpath=args.output_fpath, include=include, assembly=assembly)
#!/usr/bin/env python2 # coding: utf-8 import re from os import listdir from os.path import isfile, join from pycellbase.cbclient import CellBaseClient cbc = CellBaseClient() cbcregion = cbc.get_genomic_region_client() def GetConservation(region): query = str(region[0]) + ":" + str(region[1]) + "-" + str(region[2]) conservation = cbcregion.get_conservation(query, assembly="GRCh38") for result in conservation[0]['result']: if 'phastCons' in result['source']: phastCons = result['values'] if 'phylop' in result['source']: phylop = result['values'] positions = [str(i) for i in range(region[1], region[2], 1)] phastCons_coverage = float(len(phastCons)) / float(len(positions)) phylop_coverage = float(len(phylop)) / float(len(positions)) return phastCons, phylop, phastCons_coverage, phylop_coverage def GetPhastCons_old(region, PhastConscores): positions = [ str(region[0]) + '_' + str(i) for i in range(region[1], region[2], 1) ] scores = [ float(PhastConscores[position]) for position in positions