def _check_metric(self, value): easydev.check_param_in_list(value, ['braycurtis', 'canberra', 'chebyshev', 'cityblock', 'correlation', 'cosine', 'dice', 'euclidean', 'hamming', 'jaccard', 'kulsinski', 'mahalanobis', 'matching', 'minkowski', 'rogerstanimoto', 'russellrao', 'seuclidean', 'kalmichener', 'sokalsneath', 'sqeuclidean', 'yule'])
def check_method(self, value): # None is possible # in R, in addition to single, complete, average, centroid, # median and ward # there are ward.D, wardD2 and mcquitty # default is complete easydev.check_param_in_list(str(value), self.methods)
def _check_metric(self, value): easydev.check_param_in_list(value, [ 'braycurtis', 'canberra', 'chebyshev', 'cityblock', 'correlation', 'cosine', 'dice', 'euclidean', 'hamming', 'jaccard', 'kulsinski', 'mahalanobis', 'matching', 'minkowski', 'rogerstanimoto', 'russellrao', 'seuclidean', 'kalmichener', 'sokalsneath', 'sqeuclidean', 'yule' ])
def check_method(self, value): # None is possible # in R, in addition to single, complete, average, centroid, # median and ward # there are ward.D, wardD2 and mcquitty # default is complete return from biokit.viz.commons import valid_methods easydev.check_param_in_list(str(value), valid_methods)
def check_param_in_list(self, param, valid_values): """ transforms valid_values into list (e.g., convenient if an iterator) """ param = self.tolist(param) for name in param: easydev.check_param_in_list(name, list(valid_values))
def _check_method(self, value): # None is possible # in R, in addition to single, complete, average, centroid, median and ward # there are ward.D, wardD2 and mcquitty # default is complete easydev.check_param_in_list(str(value), ['linkage', 'single', 'complete', 'None', 'average',' weighted', 'centroid', 'median', 'ward'])
def _check_method(self, value): # None is possible # in R, in addition to single, complete, average, centroid, median and ward # there are ward.D, wardD2 and mcquitty # default is complete easydev.check_param_in_list(str(value), [ 'linkage', 'single', 'complete', 'None', 'average', ' weighted', 'centroid', 'median', 'ward' ])
def search(self, database_or_query=None, query=None, frmt='json'): """Search a searchable field (database) for a pattern The search request is more powerful than fetch for querying the database, but search will only returns the fields hgnc_id, symbol and score. This is because this tool is mainly intended to query the server to find possible entries of interest or to check data (such as your own symbols) rather than to fetch information about the genes. If you want to retrieve all the data for a set of genes from the search result, the user could use the hgnc_id returned by search to then fire off a fetch request by hgnc_id. :param database: if not provided, search all databases. :: # Search all searchable fields for the tern BRAF h.search('BRAF') # Return all records that have symbols that start with ZNF h.search('symbol', 'ZNF*') # Return all records that have symbols that start with ZNF # followed by one and only one character (e.g. ZNF3) # Nov 2015 does not work neither here nor in within in the # official documentation h.search('symbol', 'ZNF?') # search for symbols starting with ZNF that have been approved # by HGNC h.search('symbol', 'ZNF*+AND+status:Approved') # return ZNF3 and ZNF12 h.search('symbol', 'ZNF3+OR+ZNF12') # Return all records that have symbols that start with ZNF which # are not approved (ie entry withdrawn) h.search('symbol', 'ZNF*+NOT+status:Approved') """ if database_or_query is None and query is None: raise ValueError('you must provide at least one parameter') elif database_or_query is not None and query is None: # presumably user wants to search all databases query = database_or_query url = 'search/{0}'.format(query) else: database = database_or_query easydev.check_param_in_list(database, self.searchable_fields) url = 'search/{0}/{1}'.format(database, query) headers = self.get_headers(content=frmt) res = self.http_get(url, frmt=frmt, headers=headers) return res
def setup(): argv = sys.argv # default mode is INSTALL if len(argv) == 1: mode = 'INSTALL' elif len(argv) == 2: easydev.check_param_in_list(argv[1], ['install', 'build']) mode = argv[1] for package in ['CellNOptR', 'CNORdt', 'CNORfuzzy', 'CNORfeeder', 'CNORode']: if mode == 'install': cmd = 'INSTALL' elif mode == 'build': cmd = 'build' cmd = 'R CMD %s packages' % cmd + os.sep + package print cmd os.system(cmd)
def fetch(self, database, query, frmt='json'): """Retrieve particular records from a searchable fields Returned object is a json object with fields as in :attr:`stored_field`, which is returned from :meth:`get_info` method. Only one query at a time. No wild cards are accepted. :: >>> h = HGNC() >>> h.fetch('symbol', 'ZNF3') >>> h.fetch('alias_name', 'A-kinase anchor protein, 350kDa') """ easydev.check_param_in_list(database, self.searchable_fields) url = 'fetch/{0}/{1}'.format(database, query) headers = self.get_headers(content=frmt) res = self.http_get(url, frmt=frmt, headers=headers) return res
def _check_subname(self, subname): from easydev import check_param_in_list check_param_in_list(subname, self.sub_challenges)
def check_metric(self, value): return from biokit.viz.commons import valid_metrics easydev.check_param_in_list(value, valid_metrics)
def _set_method(self, method): easydev.check_param_in_list(method, self.valid_methods) if method == 'fdr': method = 'fdr_bh' self._method = method
def check_param_in_list(self, param, valid_values): easydev.check_param_in_list(param, valid_values)
def check_metric(self, value): easydev.check_param_in_list(value, self.metrics)
def _set_mode(self, mode): easydev.check_param_in_list(mode, ["time", "control"]) self._mode = mode
def from_bool(self, value): check_param_in_list(value, [True, False]) if value is True: return "T" if value is False: return "F"