def search(args): """ Return features within a chromosomal region in JBrowse JSON format """ q = args['q'] chrom = None if 'chr' not in args \ else args['chr'] start = None if 'start' not in args \ else args['start'] end = None if 'end' not in args \ else args['end'] if start >= end: tools.fail('End coordinate must be greater than start') strand = None if 'strand' not in args \ else args['strand'] featuretype = 'mRNA' if 'featuretype' not in args \ else args['featuretype'] completely_within = False if 'completely_within' not in args \ else args['completely_within'] level = 1 if 'level' not in args \ else args['level'] imfeatureclass = tools.to_camel_case(featuretype) if q == 'features': data = utils.get_features(refseq=chrom, start=start, \ end=end, strand=strand, featuretype=imfeatureclass, completely_within=completely_within, level=level) if not data: return tools.fail('Failed to retrieve feature data in JSON') elif q == 'globalStats': data = utils.get_global_stats(featuretype=imfeatureclass) elif q == 'regionStats': data = utils.get_region_stats(refseq=chrom, start=start, \ end=end, featuretype=imfeatureclass) elif q == 'regionFeatureDensities': data = utils.get_region_feature_densities(refseq=chrom, start=start, \ end=end, featuretype=imfeatureclass) return 'application/json', json.dumps(data)
def search(args): """ Return features within a chromosomal region in JBrowse JSON format """ q = args['q'] chrom = args['chr'] start = args['start'] end = args['end'] if start >= end: tools.fail('End coordinate must be greater than start') strand = None if 'strand' not in args \ else args['strand'] featuretype = 'mRNA' if 'featuretype' not in args \ else args['featuretype'] level = 1 if 'level' not in args \ else args['level'] completely_within = False if 'completely_within' not in args \ else args['completely_within'] interbase = True if 'interbase' not in args \ else args['interbase'] if q == 'features': data = utils.parse_gff(gff_file, chrom=chrom, start=start, \ end=end, strand=strand, featuretype=featuretype, level=level, \ completely_within=completely_within, interbase=interbase) if not data: return tools.fail('Failed to parse gff') elif q == 'globalStats': data = { 'scoreMin': -1, 'scoreMax': 1 } elif q == 'regionStats': raise Exception('Not implemented yet') elif q == 'regionFeatureDensities': raise Exception('Not implemented yet') return 'application/json', json.dumps(data)