text stringlengths 18 773k |
|---|
def calculate_hex(hex_string):
"""Credit for conversion to itsnotlupus/vesync_wsproxy"""
hex_conv = hex_string.split(':')
converted_hex = (int(hex_conv[0], 16) + int(hex_conv[1], 16))/8192
return converted_hex |
def resolve_updates(orig_list, updated_list):
"""Merges changes from one list of devices against another"""
if updated_list is not None and updated_list:
if orig_list is None:
orig_list = updated_list
else:
# Add new devices not in list but found ... |
def main (args):
"""Usage: create_sedml output-filename
"""
if (len(args) != 2):
print(main.__doc__)
sys.exit(1);
# create the document
doc = libsedml.SedDocument();
doc.setLevel(1);
doc.setVersion(1);
# create a first model referencing an sbml file
model = doc.createModel();
model.setId("... |
def get_profiles(adapter, vcf_file):
"""Given a vcf, get a profile string for each sample in the vcf
based on the profile variants in the database
Args:
adapter(MongoAdapter): Adapter to mongodb
vcf_file(str): Path to vcf file
Returns:
profiles (dict(str)): The profiles (given... |
def profile_match(adapter, profiles, hard_threshold=0.95, soft_threshold=0.9):
"""
given a dict of profiles, searches through all the samples in the DB
for a match. If a matching sample is found an exception is raised,
and the variants will not be loaded into the database.
Args:
... |
def compare_profiles(profile1, profile2):
"""
Given two profiles, determine the ratio of similarity, i.e.
the hamming distance between the strings.
Args:
profile1/2 (str): profile string
Returns:
similarity_ratio (float): the ratio of similiarity (0-1)
"... |
def update_profiles(adapter):
"""
For all cases having vcf_path, update the profile string for the samples
Args:
adapter (MongoAdapter): Adapter to mongodb
"""
for case in adapter.cases():
#If the case has a vcf_path, get the profiles and update the
#case with new profil... |
def profile_stats(adapter, threshold = 0.9):
"""
Compares the pairwise hamming distances for all the sample profiles in
the database. Returns a table of the number of distances within given
ranges.
Args:
adapter (MongoAdapter): Adapter to mongodb
threshold (... |
def purity(labels, true_labels):
"""
Calculates the purity score for the given labels.
Args:
labels (array): 1D array of integers
true_labels (array): 1D array of integers - true labels
Returns:
purity score - a float bewteen 0 and 1. Closer to 1 is better.
"""
purity =... |
def nne(dim_red, true_labels):
"""
Calculates the nearest neighbor accuracy (basically leave-one-out cross
validation with a 1NN classifier).
Args:
dim_red (array): dimensions (k, cells)
true_labels (array): 1d array of integers
Returns:
Nearest neighbor accuracy - fraction... |
def mdl(ll, k, data):
"""
Returns the minimum description length score of the model given its
log-likelihood and k, the number of cell types.
a lower cost is better...
"""
"""
N - no. of genes
n - no. of cells
k - no. of cell types
R - sum(Dataset) i.e. total no. of reads
... |
def find_nb_genes(data):
"""
Finds the indices of all genes in the dataset that have
a mean < 0.9 variance. Returns an array of booleans.
"""
data_means = data.mean(1)
data_vars = data.var(1)
nb_indices = data_means < 0.9*data_vars
return nb_indices |
def log_ncr(a, b):
"""
Returns log(nCr(a,b)), given that b<a. Does not assume that a and b
are integers (uses log-gamma).
"""
val = gammaln(a+1) - gammaln(a-b+1) - gammaln(b+1)
return val |
def nb_ll(data, P, R):
"""
Returns the negative binomial log-likelihood of the data.
Args:
data (array): genes x cells
P (array): NB success probability param - genes x clusters
R (array): NB stopping param - genes x clusters
Returns:
cells x clusters array of log-likel... |
def zinb_ll(data, P, R, Z):
"""
Returns the zero-inflated negative binomial log-likelihood of the data.
"""
lls = nb_ll(data, P, R)
clusters = P.shape[1]
for c in range(clusters):
pass
return lls |
def nb_ll_row(params, data_row):
"""
returns the negative LL of a single row.
Args:
params (array) - [p, r]
data_row (array) - 1d array of data
Returns:
LL of row
"""
p = params[0]
r = params[1]
n = len(data_row)
ll = np.sum(gammaln(data_row + r)) - np.sum(g... |
def nb_r_deriv(r, data_row):
"""
Derivative of log-likelihood wrt r (formula from wikipedia)
Args:
r (float): the R paramemter in the NB distribution
data_row (array): 1d array of length cells
"""
n = len(data_row)
d = sum(digamma(data_row + r)) - n*digamma(r) + n*np.log(r/(r+np... |
def nb_fit(data, P_init=None, R_init=None, epsilon=1e-8, max_iters=100):
"""
Fits the NB distribution to data using method of moments.
Args:
data (array): genes x cells
P_init (array, optional): NB success prob param - genes x 1
R_init (array, optional): NB stopping param - genes x ... |
def nb_cluster(data, k, P_init=None, R_init=None, assignments=None, means=None, max_iters=10):
"""
Performs negative binomial clustering on the given data. If some genes have mean > variance, then these genes are fitted to a Poisson distribution.
Args:
data (array): genes x cells
k (int): n... |
def fit_cluster(data, assignments, k, P_init, R_init, means):
"""
Fits NB/poisson params to a cluster.
"""
for c in range(k):
if data[:,assignments==c].shape[1] == 0:
_, assignments = kmeans_pp(data, k)
genes, cells = data.shape
nb_gene_indices = np.array([True for i in range... |
def zip_ll(data, means, M):
"""
Calculates the zero-inflated Poisson log-likelihood.
Args:
data (array): genes x cells
means (array): genes x k
M (array): genes x k - this is the zero-inflation parameter.
Returns:
cells x k array of log-likelihood for each cell/cluster ... |
def zip_ll_row(params, data_row):
"""
Returns the negative log-likelihood of a row given ZIP data.
Args:
params (list): [lambda zero-inf]
data_row (array): 1d array
Returns:
negative log-likelihood
"""
l = params[0]
pi = params[1]
d0 = (data_row==0)
likeliho... |
def migrate_database(adapter):
"""Migrate an old loqusdb instance to 1.0
Args:
adapter
Returns:
nr_updated(int): Number of variants that where updated
"""
all_variants = adapter.get_variants()
nr_variants = all_variants.count()
nr_updated = 0
with progressb... |
def main (args):
"""Usage: create_sedml2 output-filename
"""
if (len(args) != 2):
print(main.__doc__)
sys.exit(1);
# create the document
doc = libsedml.SedDocument();
doc.setLevel(1);
doc.setVersion(3);
# create a data description
ddesc = doc.createDataDescription()
ddesc.setId('data1')... |
def preproc_data(data, gene_subset=False, **kwargs):
"""
basic data preprocessing before running gap score
Assumes that data is a matrix of shape (genes, cells).
Returns a matrix of shape (cells, 8), using the first 8 SVD
components. Why 8? It's an arbitrary selection...
"""
import uncurl
... |
def calculate_bounding_box(data):
"""
Returns a 2 x m array indicating the min and max along each
dimension.
"""
mins = data.min(0)
maxes = data.max(0)
return mins, maxes |
def calculate_gap(data, clustering, km, B=50, **kwargs):
"""
See: https://datasciencelab.wordpress.com/2013/12/27/finding-the-k-in-k-means-clustering/
https://web.stanford.edu/~hastie/Papers/gap.pdf
Returns two results: the gap score, and s_k.
"""
k = len(set(clustering))
Wk = km.inertia_
... |
def run_gap_k_selection(data, k_min=1, k_max=50, B=5,
skip=5, **kwargs):
"""
Runs gap score for all k from k_min to k_max.
"""
if k_min == k_max:
return k_min
gap_vals = []
sk_vals = []
k_range = list(range(k_min, k_max, skip))
min_k = 0
min_i = 0
for i, k in enum... |
async def _request(
self,
method: str,
url: str,
*,
headers: dict = None,
params: dict = None,
json: dict = None) -> dict:
"""Make a request against the RainMachine device."""
if not headers:
headers = {}
... |
def get_devices(self) -> list:
"""Return list of VeSync devices"""
if not self.enabled:
return None
self.in_process = True
response, _ = helpers.call_api(
'/cloud/v1/deviceManaged/devices',
'post',
headers=helpers.req_headers(self),
... |
def login(self) -> bool:
"""Return True if log in request succeeds"""
user_check = isinstance(self.username, str) and len(self.username) > 0
pass_check = isinstance(self.password, str) and len(self.password) > 0
if user_check and pass_check:
response, _ = helpers.call_api(
... |
def update(self):
"""Fetch updated information about devices"""
if self.device_time_check():
if not self.in_process:
outlets, switches, fans = self.get_devices()
self.outlets = helpers.resolve_updates(self.outlets, outlets)
self.switches = h... |
def update_energy(self, bypass_check=False):
"""Fetch updated energy information about devices"""
for outlet in self.outlets:
outlet.update_energy(bypass_check) |
def DistFitDataset(Dat):
"""
Given a data matrix, this returns the per-gene fit error for the
Poisson, Normal, and Log-Normal distributions.
Args:
Dat (array): numpy array with shape (genes, cells)
Returns:
d (dict): 'poiss', 'norm', 'lognorm' give the fit error for each distributi... |
def delete(adapter, case_obj, update=False, existing_case=False):
"""Delete a case and all of it's variants from the database.
Args:
adapter: Connection to database
case_obj(models.Case)
update(bool): If we are in the middle of an update
existing_case(models.Case): If someth... |
def delete_variants(adapter, vcf_obj, case_obj, case_id=None):
"""Delete variants for a case in the database
Args:
adapter(loqusdb.plugins.Adapter)
vcf_obj(iterable(dict))
ind_positions(dict)
case_id(str)
Returns:
nr_deleted (int): Number of deleted variants... |
def annotate(ctx, variant_file, sv):
"""Annotate the variants in a VCF
"""
adapter = ctx.obj['adapter']
variant_path = os.path.abspath(variant_file)
expected_type = 'snv'
if sv:
expected_type = 'sv'
if 'sv':
nr_cases = adapter.nr_cases(sv_cases=True)
else:
nr_... |
async def find(self, *tracking_numbers: str) -> list:
"""Get tracking info for one or more tracking numbers."""
data = {'data': [{'num': num} for num in tracking_numbers]}
tracking_resp = await self._request('post', API_URL_TRACK, json=data)
print(tracking_resp)
if not tracking... |
def cli(ctx, database, username, password, authdb, port, host, uri, verbose, config, test):
"""loqusdb: manage a local variant count database."""
loglevel = "INFO"
if verbose:
loglevel = "DEBUG"
coloredlogs.install(level=loglevel)
LOG.info("Running loqusdb version %s", __version__)
conf... |
def binarize(qualitative):
"""
binarizes an expression dataset.
"""
thresholds = qualitative.min(1) + (qualitative.max(1) - qualitative.min(1))/2.0
binarized = qualitative > thresholds.reshape((len(thresholds), 1)).repeat(8,1)
return binarized.astype(int) |
def qualNorm_filter_genes(data, qualitative, pval_threshold=0.05, smoothing=1e-5, eps=1e-5):
"""
Does qualNorm but returns a filtered gene set, based on a p-value threshold.
"""
genes, cells = data.shape
clusters = qualitative.shape[1]
output = np.zeros((genes, clusters))
missing_indices = [... |
def qualNorm(data, qualitative):
"""
Generates starting points using binarized data. If qualitative data is missing for a given gene, all of its entries should be -1 in the qualitative matrix.
Args:
data (array): 2d array of genes x cells
qualitative (array): 2d array of numerical data - ge... |
def qualNormGaussian(data, qualitative):
"""
Generates starting points using binarized data. If qualitative data is missing for a given gene, all of its entries should be -1 in the qualitative matrix.
Args:
data (array): 2d array of genes x cells
qualitative (array): 2d array of numerical d... |
def script_dir(pyobject, follow_symlinks=True):
"""Get current script's directory
Args:
pyobject (Any): Any Python object in the script
follow_symlinks (Optional[bool]): Follow symlinks or not. Defaults to True.
Returns:
str: Current script's directory
"""
if getattr(sys, '... |
def script_dir_plus_file(filename, pyobject, follow_symlinks=True):
"""Get current script's directory and then append a filename
Args:
filename (str): Filename to append to directory path
pyobject (Any): Any Python object in the script
follow_symlinks (Optional[bool]): Follow symlinks o... |
def identity(ctx, variant_id):
"""Check how well SVs are working in the database
"""
if not variant_id:
LOG.warning("Please provide a variant id")
ctx.abort()
adapter = ctx.obj['adapter']
version = ctx.obj['version']
LOG.info("Search variants {0}".format(adapter))
... |
def registration_authority_entity_id(self):
"""
Some entities return the register entity id,
but other do not. Unsure if this is a bug or
inconsistently registered data.
"""
if ATTR_ENTITY_REGISTRATION_AUTHORITY in self.raw:
try:
return self.r... |
def legal_form(self):
"""In some cases, the legal form is stored in the JSON-data.
In other cases, an ELF-code, consisting of mix of exactly
four letters and numbers are stored. This ELF-code
can be looked up in a registry where a code maps to
a organizational type. ELF-codes are... |
def valid_child_records(self):
child_lei = list()
"""Loop through data to find a valid record. Return list of LEI."""
for d in self.raw['data']:
# We're not very greedy here, but it seems some records have
# lapsed even through the issuer is active
if d['att... |
def annotate_variant(variant, var_obj=None):
"""Annotate a cyvcf variant with observations
Args:
variant(cyvcf2.variant)
var_obj(dict)
Returns:
variant(cyvcf2.variant): Annotated variant
"""
if var_obj:
variant.INFO['Obs'] = var_obj['observations']
... |
def annotate_snv(adpter, variant):
"""Annotate an SNV/INDEL variant
Args:
adapter(loqusdb.plugin.adapter)
variant(cyvcf2.Variant)
"""
variant_id = get_variant_id(variant)
variant_obj = adapter.get_variant(variant={'_id':variant_id})
annotated_variant = annotated_variant... |
def annotate_svs(adapter, vcf_obj):
"""Annotate all SV variants in a VCF
Args:
adapter(loqusdb.plugin.adapter)
vcf_obj(cyvcf2.VCF)
Yields:
variant(cyvcf2.Variant)
"""
for nr_variants, variant in enumerate(vcf_obj, 1):
variant_info = get_coords(variant)
... |
def annotate_snvs(adapter, vcf_obj):
"""Annotate all variants in a VCF
Args:
adapter(loqusdb.plugin.adapter)
vcf_obj(cyvcf2.VCF)
Yields:
variant(cyvcf2.Variant): Annotated variant
"""
variants = {}
for nr_variants, variant in enumerate(vcf_obj, 1):
... |
def from_geojson(geojson, srid=4326):
"""
Create a Geometry from a GeoJSON. The SRID can be overridden from the
expected 4326.
"""
type_ = geojson["type"].lower()
if type_ == "geometrycollection":
geometries = []
for geometry in geojson["geometries... |
def from_shapely(sgeom, srid=None):
"""
Create a Geometry from a Shapely geometry and the specified SRID.
The Shapely geometry will not be modified.
"""
if SHAPELY:
WKBWriter.defaults["include_srid"] = True
if srid:
lgeos.GEOSSetSRID(sgeom... |
def wkb(self):
"""
Get the geometry as an (E)WKB.
"""
return self._to_wkb(use_srid=True, dimz=self.dimz, dimm=self.dimm) |
def postgis_type(self):
"""
Get the type of the geometry in PostGIS format, including additional
dimensions and SRID if they exist.
"""
dimz = "Z" if self.dimz else ""
dimm = "M" if self.dimm else ""
if self.srid:
return "geometry({}{}{},{})".format(se... |
def poisson_ll(data, means):
"""
Calculates the Poisson log-likelihood.
Args:
data (array): 2d numpy array of genes x cells
means (array): 2d numpy array of genes x k
Returns:
cells x k array of log-likelihood for each cell/cluster pair
"""
if sparse.issparse(data):
... |
def poisson_ll_2(p1, p2):
"""
Calculates Poisson LL(p1|p2).
"""
p1_1 = p1 + eps
p2_1 = p2 + eps
return np.sum(-p2_1 + p1_1*np.log(p2_1)) |
def poisson_dist(p1, p2):
"""
Calculates the Poisson distance between two vectors.
p1 can be a sparse matrix, while p2 has to be a dense matrix.
"""
# ugh...
p1_ = p1 + eps
p2_ = p2 + eps
return np.dot(p1_-p2_, np.log(p1_/p2_)) |
def delete(ctx, family_file, family_type, case_id):
"""Delete the variants of a case."""
if not (family_file or case_id):
LOG.error("Please provide a family file")
ctx.abort()
adapter = ctx.obj['adapter']
# Get a ped_parser.Family object from family file
family = None
family_id... |
def update_energy(self, bypass_check: bool = False):
"""Builds weekly, monthly and yearly dictionaries"""
if bypass_check or (not bypass_check and self.update_time_check):
self.get_weekly_energy()
if 'week' in self.energy:
self.get_monthly_energy()
... |
def turn_on_nightlight(self):
"""Turn on nightlight"""
body = helpers.req_body(self.manager, 'devicestatus')
body['uuid'] = self.uuid
body['mode'] = 'auto'
response, _ = helpers.call_api(
'/15a/v1/device/nightlightstatus',
'put',
headers=helpe... |
def main (args):
"""Usage: echo_sedml input-filename output-filename
"""
if len(args) != 3:
print(main.__doc__)
sys.exit(1)
d = libsedml.readSedML(args[1]);
if ( d.getErrorLog().getNumFailsWithSeverity(libsedml.LIBSEDML_SEV_ERROR) > 0):
print (d.getErrorLog().toString());
else:
libsedml.wri... |
async def main() -> None:
"""Create the aiohttp session and run the example."""
logging.basicConfig(level=logging.INFO)
async with ClientSession() as websession:
try:
client = Client(websession)
await client.profile.login('<EMAIL>', '<PASSWORD>')
_LOGGER.info('A... |
def my_import(name):
""" dynamic importing """
module, attr = name.rsplit('.', 1)
mod = __import__(module, fromlist=[attr])
klass = getattr(mod, attr)
return klass() |
def like_button_js_tag(context):
""" This tag will check to see if they have the FACEBOOK_LIKE_APP_ID setup
correctly in the django settings, if so then it will pass the data
along to the intercom_tag template to be displayed.
If something isn't perfect we will return False, which will then... |
def like_button_tag(context):
""" This tag will check to see if they have the FACEBOOK_APP_ID setup
correctly in the django settings, if so then it will pass the data
along to the intercom_tag template to be displayed.
If something isn't perfect we will return False, which will then not
... |
def add_structural_variant(self, variant, max_window = 3000):
"""Add a variant to the structural variants collection
The process of adding an SV variant differs quite a bit from the
more straight forward case of SNV/INDEL.
Variants are represented in the database by cl... |
def get_structural_variant(self, variant):
"""Check if there are any overlapping sv clusters
Search the sv variants with chrom start end_chrom end and sv_type
Args:
variant (dict): A variant dictionary
Returns:
variant (dict): A variant dictionary
"""
... |
def get_sv_variants(self, chromosome=None, end_chromosome=None, sv_type=None,
pos=None, end=None):
"""Return all structural variants in the database
Args:
chromosome (str)
end_chromosome (str)
sv_type (str)
pos (int): Left positio... |
def get_clusters(self, variant_id):
"""Search what clusters a variant belongs to
Args:
variant_id(str): From ID column in vcf
Returns:
clusters()
"""
query = {'variant_id':variant_id}
identities = self.db.identity.find(query)
... |
def run_state_estimation(data, clusters, dist='Poiss', reps=1, **kwargs):
"""
Runs state estimation for multiple initializations, returning the result with the highest log-likelihood. All the arguments are passed to the underlying state estimation functions (poisson_estimate_state, nb_estimate_state, zip_estima... |
def get_details(self):
"""Build details dictionary"""
body = helpers.req_body(self.manager, 'devicedetail')
head = helpers.req_headers(self.manager)
r, _ = helpers.call_api('/131airpurifier/v1/device/deviceDetail',
method='post', headers=head, json=body)
... |
def turn_on(self):
"""Turn Air Purifier on"""
if self.device_status != 'on':
body = helpers.req_body(self.manager, 'devicestatus')
body['uuid'] = self.uuid
body['status'] = 'on'
head = helpers.req_headers(self.manager)
r, _ = helpers.call_api(... |
def fan_speed(self, speed: int = None) -> bool:
"""Adjust Fan Speed by Specifying 1,2,3 as argument or cycle
through speeds increasing by one"""
body = helpers.req_body(self.manager, 'devicestatus')
body['uuid'] = self.uuid
head = helpers.req_headers(self.manager)
if ... |
def mode_toggle(self, mode: str) -> bool:
"""Set mode to manual, auto or sleep"""
head = helpers.req_headers(self.manager)
body = helpers.req_body(self.manager, 'devicestatus')
body['uuid'] = self.uuid
if mode != body['mode'] and mode in ['sleep', 'auto', 'manual']:
b... |
def fourier_series(x, *a):
"""
Arbitrary dimensionality fourier series.
The first parameter is a_0, and the second parameter is the interval/scale
parameter.
The parameters are altering sin and cos paramters.
n = (len(a)-2)/2
"""
output = 0
output += a[0]/2
w = a[1]
for n ... |
def graph_distances(start, edges, distances):
"""
Given an undirected adjacency list and a pairwise distance matrix between
all nodes: calculates distances along graph from start node.
Args:
start (int): start node
edges (list): adjacency list of tuples
distances (array): 2d arr... |
def poly_curve(x, *a):
"""
Arbitrary dimension polynomial.
"""
output = 0.0
for n in range(0, len(a)):
output += a[n]*x**n
return output |
def run_lineage(means, weights, curve_function='poly', curve_dimensions=6):
"""
Lineage graph produced by minimum spanning tree
Args:
means (array): genes x clusters - output of state estimation
weights (array): clusters x cells - output of state estimation
curve_function (string): ... |
def pseudotime(starting_node, edges, fitted_vals):
"""
Args:
starting_node (int): index of the starting node
edges (list): list of tuples (node1, node2)
fitted_vals (array): output of lineage (2 x cells)
Returns:
A 1d array containing the pseudotime value of each cell.
"... |
def _add_countriesdata(cls, iso3, country):
# type: (str, hxl.Row) -> None
"""
Set up countries data from data in form provided by UNStats and World Bank
Args:
iso3 (str): ISO3 code for country
country (hxl.Row): Country information
Returns:
... |
def set_countriesdata(cls, countries):
# type: (str) -> None
"""
Set up countries data from data in form provided by UNStats and World Bank
Args:
countries (str): Countries data in HTML format provided by UNStats
Returns:
None
"""
cls._co... |
def countriesdata(cls, use_live=True):
# type: (bool) -> List[Dict[Dict]]
"""
Read countries data from OCHA countries feed (falling back to file)
Args:
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
Returns:
... |
def set_ocha_url(cls, url=None):
# type: (str) -> None
"""
Set World Bank url from which to retrieve countries data
Args:
url (str): World Bank url from which to retrieve countries data. Defaults to internal value.
Returns:
None
"""
if ur... |
def get_country_info_from_iso3(cls, iso3, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[Dict[str]]
"""Get country information from ISO3 code
Args:
iso3 (str): ISO3 code for which to get country information
use_live (bool):... |
def get_country_name_from_iso3(cls, iso3, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get country name from ISO3 code
Args:
iso3 (str): ISO3 code for which to get country name
use_live (bool): Try to get use late... |
def get_iso2_from_iso3(cls, iso3, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get ISO2 from ISO3 code
Args:
iso3 (str): ISO3 code for which to get ISO2 code
use_live (bool): Try to get use latest data from web ra... |
def get_country_info_from_iso2(cls, iso2, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[Dict[str]]
"""Get country name from ISO2 code
Args:
iso2 (str): ISO2 code for which to get country information
use_live (bool): Try to... |
def get_country_name_from_iso2(cls, iso2, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get country name from ISO2 code
Args:
iso2 (str): ISO2 code for which to get country name
use_live (bool): Try to get use late... |
def get_m49_from_iso3(cls, iso3, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[int]
"""Get M49 from ISO3 code
Args:
iso3 (str): ISO3 code for which to get M49 code
use_live (bool): Try to get use latest data from web rathe... |
def get_country_info_from_m49(cls, m49, use_live=True, exception=None):
# type: (int, bool, Optional[ExceptionUpperBound]) -> Optional[Dict[str]]
"""Get country name from M49 code
Args:
m49 (int): M49 numeric code for which to get country information
use_live (bool): Try... |
def get_country_name_from_m49(cls, m49, use_live=True, exception=None):
# type: (int, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get country name from M49 code
Args:
m49 (int): M49 numeric code for which to get country name
use_live (bool): Try to get use l... |
def expand_countryname_abbrevs(cls, country):
# type: (str) -> List[str]
"""Expands abbreviation(s) in country name in various ways (eg. FED -> FEDERATED, FEDERAL etc.)
Args:
country (str): Country with abbreviation(s)to expand
Returns:
List[str]: Uppercase coun... |
def simplify_countryname(cls, country):
# type: (str) -> (str, List[str])
"""Simplifies country name by removing descriptive text eg. DEMOCRATIC, REPUBLIC OF etc.
Args:
country (str): Country name to simplify
Returns:
Tuple[str, List[str]]: Uppercase simplified ... |
def get_iso3_country_code(cls, country, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get ISO3 code for cls. Only exact matches or None are returned.
Args:
country (str): Country for which to get ISO3 code
use_live... |
def get_iso3_country_code_fuzzy(cls, country, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Tuple[[Optional[str], bool]]
"""Get ISO3 code for cls. A tuple is returned with the first value being the ISO3 code and the second
showing if the match is exact or ... |
def get_countries_in_region(cls, region, use_live=True, exception=None):
# type: (Union[int,str], bool, Optional[ExceptionUpperBound]) -> List[str]
"""Get countries (ISO3 codes) in region
Args:
region (Union[int,str]): Three digit UNStats M49 region code or region name
u... |
def load_profile(ctx, variant_file, update, stats, profile_threshold):
"""
Command for profiling of samples. User may upload variants used in profiling
from a vcf, update the profiles for all samples, and get some stats
from the profiles in the database.
Profiling is used to monito... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.