diff options
author | BonfaceKilz | 2021-04-30 13:15:10 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-04-30 13:45:15 +0300 |
commit | 99f8bdbb70e4e00df6671c3f20db4857ffa96d6f (patch) | |
tree | b2e672d66ff5e43e1a2162b62493ceed7a158818 | |
parent | 4e65b73a0f903834f8dbd02d11c49b75d7c935c7 (diff) | |
download | genenetwork2-99f8bdbb70e4e00df6671c3f20db4857ffa96d6f.tar.gz |
autopep8: Run autopep8 100 times with target rules
Rules used are:
E20,E211,E22,E224,E224,E225,E226,E227,E228,E231,E241,E242,
E251,E252,E26,E265,E266,E27,E301,E302,E303,E304,E305,E306,
E401,E501,E70,E701,W291,W292,W293,W391,W504,E101,E11,E121,
E122,E123,E124,E125,E126,E127,E128,E129,E131,E133
28 files changed, 172 insertions, 164 deletions
diff --git a/wqflask/base/webqtlConfig.py b/wqflask/base/webqtlConfig.py index 872b52eb..39947158 100644 --- a/wqflask/base/webqtlConfig.py +++ b/wqflask/base/webqtlConfig.py @@ -15,7 +15,7 @@ from utility.tools import valid_path, mk_dir, assert_dir, assert_writable_dir, f DEBUG = 1 # USER privilege -USERDICT = {'guest': 1, 'user': 2, 'admin': 3, 'root':4} +USERDICT = {'guest': 1, 'user': 2, 'admin': 3, 'root': 4} # Set privileges SUPER_PRIVILEGES = {'data': 'edit', 'metadata': 'edit', 'admin': 'edit-admins'} diff --git a/wqflask/maintenance/quantile_normalize.py b/wqflask/maintenance/quantile_normalize.py index 88bb2cb5..0cc963e5 100644 --- a/wqflask/maintenance/quantile_normalize.py +++ b/wqflask/maintenance/quantile_normalize.py @@ -123,7 +123,7 @@ if __name__ == '__main__': success, _ = bulk(es, set_data(sys.argv[1])) response = es.search( - index="traits", doc_type="trait", body = { + index="traits", doc_type="trait", body={ "query": {"match": {"name": "ENSMUSG00000028982"}} } ) diff --git a/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py b/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py index 93848a84..8b4337ec 100644 --- a/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py +++ b/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py @@ -9,13 +9,14 @@ from wqflask.marker_regression.qtlreaper_mapping import gen_pheno_txt_file class TestQtlReaperMapping(unittest.TestCase): @mock.patch("wqflask.marker_regression.qtlreaper_mapping.TEMPDIR", "/home/user/data") def test_gen_pheno_txt_file(self): - vals = ["V1", "x", "V4", "V3","x"] - samples = ["S1", "S2", "S3", "S4","S5"] + vals = ["V1", "x", "V4", "V3", "x"] + samples = ["S1", "S2", "S3", "S4", "S5"] trait_filename = "trait_file" with mock.patch("builtins.open", mock.mock_open())as mock_open: gen_pheno_txt_file(samples=samples, vals=vals, trait_filename=trait_filename) - mock_open.assert_called_once_with("/home/user/data/gn2/trait_file.txt", "w") + mock_open.assert_called_once_with( + "/home/user/data/gn2/trait_file.txt", "w") filehandler = mock_open() write_calls = [mock.call('Trait\t'), mock.call( 'S1\tS3\tS4\n'), mock.call('T1\t'), mock.call('V1\tV4\tV3')] diff --git a/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py b/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py index 68686e27..91d2c587 100644 --- a/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py +++ b/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py @@ -28,7 +28,7 @@ class TestRqtlMapping(unittest.TestCase): def test_sanitize_rqtl_phenotype(self): """test for sanitizing rqtl phenotype""" - vals = ['f', "x", "r", "x","x"] + vals = ['f', "x", "r", "x", "x"] results = sanitize_rqtl_phenotype(vals) expected_phenotype_string = 'c(f,NA,r,NA,NA)' @@ -36,7 +36,7 @@ class TestRqtlMapping(unittest.TestCase): def test_sanitize_rqtl_names(self): """test for sanitzing rqtl names""" - vals = ['f', "x", "r", "x","x"] + vals = ['f', "x", "r", "x", "x"] expected_sanitized_name = "c('f',NA,'r',NA,NA)" results = sanitize_rqtl_names(vals) self.assertEqual(expected_sanitized_name, results) diff --git a/wqflask/utility/Plot.py b/wqflask/utility/Plot.py index 37a8a1a5..9b2c6735 100644 --- a/wqflask/utility/Plot.py +++ b/wqflask/utility/Plot.py @@ -188,7 +188,8 @@ def plotBar(canvas, data, barColor=BLUE, axesColor=BLACK, labelColor=BLACK, XLab for i in range(int(stepX) + 1): xc = xLeftOffset + (x - xLow) * xScale im_drawer.line( - xy=((xc, yTopOffset + plotHeight), (xc, yTopOffset + plotHeight + 5)), + xy=((xc, yTopOffset + plotHeight), + (xc, yTopOffset + plotHeight + 5)), fill=axesColor) strX = cformat(d=x, rank=0) im_drawer.text( @@ -217,7 +218,7 @@ def plotBar(canvas, data, barColor=BLUE, axesColor=BLACK, labelColor=BLACK, XLab text=XLabel, xy=(xLeftOffset + ( plotWidth - im_drawer.textsize(XLabel, font=labelFont)[0]) / 2.0, - yTopOffset + plotHeight + yBottomOffset-10), + yTopOffset + plotHeight + yBottomOffset - 10), font=labelFont, fill=labelColor) if YLabel: diff --git a/wqflask/utility/elasticsearch_tools.py b/wqflask/utility/elasticsearch_tools.py index e56c22eb..eae3ba03 100644 --- a/wqflask/utility/elasticsearch_tools.py +++ b/wqflask/utility/elasticsearch_tools.py @@ -105,7 +105,7 @@ def get_item_by_unique_column(es, column_name, column_value, index, doc_type): item_details = None try: response = es.search( - index=index, doc_type=doc_type, body = { + index=index, doc_type=doc_type, body={ "query": {"match": {column_name: column_value}} }) if len(response["hits"]["hits"]) > 0: diff --git a/wqflask/utility/svg.py b/wqflask/utility/svg.py index bc3bc833..eddb97da 100644 --- a/wqflask/utility/svg.py +++ b/wqflask/utility/svg.py @@ -229,13 +229,13 @@ class pathdata: def bezier(self, x1, y1, x2, y2, x, y): """bezier with xy1 and xy2 to xy absolut""" - self.path.append('C' + str(x1) + ','+str(y1)+' '+str(x2) - + ',' + str(y2) + ' '+str(x)+','+str(y)) + self.path.append('C' + str(x1) + ',' + str(y1) + ' ' + str(x2) + + ',' + str(y2) + ' ' + str(x) + ',' + str(y)) def relbezier(self, x1, y1, x2, y2, x, y): """bezier with xy1 and xy2 to xy relative""" - self.path.append('c' + str(x1) + ','+str(y1)+' '+str(x2) - + ',' + str(y2) + ' '+str(x)+','+str(y)) + self.path.append('c' + str(x1) + ',' + str(y1) + ' ' + str(x2) + + ',' + str(y2) + ' ' + str(x) + ',' + str(y)) def smbezier(self, x2, y2, x, y): """smooth bezier with xy2 to xy absolut""" @@ -267,13 +267,13 @@ class pathdata: def ellarc(self, rx, ry, xrot, laf, sf, x, y): """elliptival arc with rx and ry rotating with xrot using large-arc-flag and sweep-flag to xy absolut""" - self.path.append('A' + str(rx) + ','+str(ry)+' '+str(xrot) - + ' ' + str(laf) + ' '+str(sf)+' '+str(x)+' '+str(y)) + self.path.append('A' + str(rx) + ',' + str(ry) + ' ' + str(xrot) + + ' ' + str(laf) + ' ' + str(sf) + ' ' + str(x) + ' ' + str(y)) def relellarc(self, rx, ry, xrot, laf, sf, x, y): """elliptival arc with rx and ry rotating with xrot using large-arc-flag and sweep-flag to xy relative""" - self.path.append('a' + str(rx) + ','+str(ry)+' '+str(xrot) - + ' ' + str(laf) + ' '+str(sf)+' '+str(x)+' '+str(y)) + self.path.append('a' + str(rx) + ',' + str(ry) + ' ' + str(xrot) + + ' ' + str(laf) + ' ' + str(sf) + ' ' + str(x) + ' ' + str(y)) def __repr__(self): return ' '.join(self.path) @@ -471,7 +471,7 @@ class ellipse(SVGelement): an ellipse is defined as a center and a x and y radius. """ - def __init__(self, cx=None, cy=None, rx=None, ry=None,fill=None,stroke=None,stroke_width=None,**args): + def __init__(self, cx=None, cy=None, rx=None, ry=None, fill=None, stroke=None, stroke_width=None, **args): if rx == None or ry == None: raise ValueError('both rx and ry are required') @@ -494,7 +494,7 @@ class circle(SVGelement): The circle creates an element using a x, y and radius values eg """ - def __init__(self, cx=None, cy=None, r=None, fill=None,stroke=None,stroke_width=None,**args): + def __init__(self, cx=None, cy=None, r=None, fill=None, stroke=None, stroke_width=None, **args): if r == None: raise ValueError('r is required') SVGelement.__init__(self, 'circle', {'r': r}, **args) @@ -527,7 +527,7 @@ class line(SVGelement): A line is defined by a begin x,y pair and an end x,y pair """ - def __init__(self, x1=None, y1=None, x2=None, y2=None,stroke=None,stroke_width=None,**args): + def __init__(self, x1=None, y1=None, x2=None, y2=None, stroke=None, stroke_width=None, **args): SVGelement.__init__(self, 'line', **args) if x1 != None: self.attributes['x1'] = x1 @@ -549,7 +549,7 @@ class polyline(SVGelement): a polyline is defined by a list of xy pairs """ - def __init__(self, points, fill=None, stroke=None, stroke_width=None,**args): + def __init__(self, points, fill=None, stroke=None, stroke_width=None, **args): SVGelement.__init__(self, 'polyline', { 'points': _xypointlist(points)}, **args) if fill != None: @@ -566,7 +566,7 @@ class polygon(SVGelement): a polygon is defined by a list of xy pairs """ - def __init__(self, points, fill=None, stroke=None, stroke_width=None,**args): + def __init__(self, points, fill=None, stroke=None, stroke_width=None, **args): SVGelement.__init__( self, 'polygon', {'points': _xypointlist(points)}, **args) if fill != None: @@ -583,7 +583,7 @@ class path(SVGelement): a path is defined by a path object and optional width, stroke and fillcolor """ - def __init__(self, pathdata, fill=None, stroke=None, stroke_width=None,id=None,**args): + def __init__(self, pathdata, fill=None, stroke=None, stroke_width=None, id=None, **args): SVGelement.__init__(self, 'path', {'d': str(pathdata)}, **args) if stroke != None: self.attributes['stroke'] = stroke @@ -601,7 +601,7 @@ class text(SVGelement): a text element can bge used for displaying text on the screen """ - def __init__(self, x=None, y=None, text=None, font_size=None,font_family=None,text_anchor=None,**args): + def __init__(self, x=None, y=None, text=None, font_size=None, font_family=None, text_anchor=None, **args): SVGelement.__init__(self, 'text', **args) if x != None: self.attributes['x'] = x @@ -637,7 +637,7 @@ class pattern(SVGelement): in x and y to cover the areas to be painted. """ - def __init__(self, x=None, y=None, width=None, height=None,patternUnits=None,**args): + def __init__(self, x=None, y=None, width=None, height=None, patternUnits=None, **args): SVGelement.__init__(self, 'pattern', **args) if x != None: self.attributes['x'] = x @@ -684,7 +684,7 @@ class lineargradient(SVGelement): stop elements van be added to define the gradient colors. """ - def __init__(self, x1=None, y1=None, x2=None, y2=None,id=None,**args): + def __init__(self, x1=None, y1=None, x2=None, y2=None, id=None, **args): SVGelement.__init__(self, 'linearGradient', **args) if x1 != None: self.attributes['x1'] = x1 @@ -705,7 +705,7 @@ class radialgradient(SVGelement): stop elements van be added to define the gradient colors. """ - def __init__(self, cx=None, cy=None, r=None, fx=None,fy=None,id=None,**args): + def __init__(self, cx=None, cy=None, r=None, fx=None, fy=None, id=None, **args): SVGelement.__init__(self, 'radialGradient', **args) if cx != None: self.attributes['cx'] = cx @@ -749,11 +749,11 @@ class image(SVGelement): adds an image to the drawing. Supported formats are .png, .jpg and .svg. """ - def __init__(self, url, x=None, y=None, width=None,height=None,**args): + def __init__(self, url, x=None, y=None, width=None, height=None, **args): if width == None or height == None: raise ValueError('both height and width are required') SVGelement.__init__( - self, 'image', {'xlink:href': url, 'width': width, 'height':height}, **args) + self, 'image', {'xlink:href': url, 'width': width, 'height': height}, **args) if x != None: self.attributes['x'] = x if y != None: @@ -777,7 +777,7 @@ class marker(SVGelement): add an element to it which should be used as a marker. """ - def __init__(self, id=None, viewBox=None, refx=None, refy=None,markerWidth=None,markerHeight=None,**args): + def __init__(self, id=None, viewBox=None, refx=None, refy=None, markerWidth=None, markerHeight=None, **args): SVGelement.__init__(self, 'marker', **args) if id != None: self.attributes['id'] = id @@ -851,7 +851,7 @@ class use(SVGelement): references a symbol by linking to its id and its position, height and width """ - def __init__(self, link, x=None, y=None, width=None,height=None,**args): + def __init__(self, link, x=None, y=None, width=None, height=None, **args): SVGelement.__init__(self, 'use', {'xlink:href': link}, **args) if x != None: self.attributes['x'] = x @@ -904,7 +904,7 @@ class animate(SVGelement): animates an attribute. """ - def __init__(self, attribute, fr=None, to=None, dur=None,**args): + def __init__(self, attribute, fr=None, to=None, dur=None, **args): SVGelement.__init__( self, 'animate', {'attributeName': attribute}, **args) if fr != None: @@ -935,7 +935,7 @@ class animateTransform(SVGelement): transform an element from and to a value. """ - def __init__(self, type=None, fr=None, to=None, dur=None,**args): + def __init__(self, type=None, fr=None, to=None, dur=None, **args): SVGelement.__init__(self, 'animateTransform', { 'attributeName': 'transform'}, **args) # As far as I know the attributeName is always transform @@ -955,7 +955,7 @@ class animateColor(SVGelement): Animates the color of a element """ - def __init__(self, attribute, type=None, fr=None, to=None,dur=None,**args): + def __init__(self, attribute, type=None, fr=None, to=None, dur=None, **args): SVGelement.__init__(self, 'animateColor', { 'attributeName': attribute}, **args) if type != None: diff --git a/wqflask/wqflask/api/mapping.py b/wqflask/wqflask/api/mapping.py index cbef96eb..f8b0d8bd 100644 --- a/wqflask/wqflask/api/mapping.py +++ b/wqflask/wqflask/api/mapping.py @@ -53,7 +53,8 @@ def do_mapping_for_api(start_vars): header_row = ["name", "chr", "cM", "lod_score"] if mapping_params['num_perm'] > 0: _sperm_output, _suggestive, _significant, result_markers = rqtl_mapping.run_rqtl_geno(vals, dataset, mapping_params['rqtl_method'], mapping_params['rqtl_model'], - mapping_params['perm_check'], mapping_params['num_perm'], + mapping_params['perm_check'], mapping_params[ + 'num_perm'], mapping_params['do_control'], mapping_params[ 'control_marker'], mapping_params['manhattan_plot'], mapping_params['pair_scan']) diff --git a/wqflask/wqflask/api/router.py b/wqflask/wqflask/api/router.py index 9d3446db..aec74c9e 100644 --- a/wqflask/wqflask/api/router.py +++ b/wqflask/wqflask/api/router.py @@ -98,8 +98,8 @@ def get_groups_list(species_name=None): "Name": group[3], "FullName": group[4], "public": group[5], - "MappingMethodId": group[6], - "GeneticType": group[7] + "MappingMethodId": group[6], + "GeneticType": group[7] } groups_list.append(group_dict) @@ -143,8 +143,8 @@ def get_group_info(group_name, species_name=None, file_format="json"): "Name": group[3], "FullName": group[4], "public": group[5], - "MappingMethodId": group[6], - "GeneticType": group[7] + "MappingMethodId": group[6], + "GeneticType": group[7] } return flask.jsonify(group_dict) @@ -192,11 +192,11 @@ def get_datasets_for_group(group_name, species_name=None): "Short_Abbreviation": dataset[3], "Long_Abbreviation": dataset[4], "FullName": dataset[5], - "ShortName": dataset[6], - "CreateTime": dataset[7], - "public": dataset[8], - "confidentiality": dataset[9], - "DataScale": dataset[10] + "ShortName": dataset[6], + "CreateTime": dataset[7], + "public": dataset[8], + "confidentiality": dataset[9], + "DataScale": dataset[10] } datasets_list.append(dataset_dict) @@ -249,10 +249,10 @@ def get_dataset_info(dataset_name, group_name=None, file_format="json"): "full_name": dataset[2], "short_name": dataset[3], "data_scale": dataset[4], - "tissue_id": dataset[5], - "tissue": dataset[6], - "public": dataset[7], - "confidential": dataset[8] + "tissue_id": dataset[5], + "tissue": dataset[6], + "public": dataset[7], + "confidential": dataset[8] } datasets_list.append(dataset_dict) @@ -286,7 +286,7 @@ def get_dataset_info(dataset_name, group_name=None, file_format="json"): "description": dataset[2], "pubmed_id": dataset[5], "title": dataset[6], - "year": dataset[7] + "year": dataset[7] } elif dataset[4]: dataset_dict = { @@ -777,7 +777,7 @@ def get_genotypes(group_name, file_format="csv", dataset_name=None): i += 1 csv_writer = csv.writer( - si, delimiter="\t", escapechar="\\", quoting = csv.QUOTE_NONE) + si, delimiter="\t", escapechar="\\", quoting=csv.QUOTE_NONE) else: return return_error(code=204, source=request.url_rule.rule, title="No Results", details="") elif file_format == "rqtl2": diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index 58518639..01274ba9 100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -77,13 +77,13 @@ def collections_add(): return render_template("collections/add.html", traits=traits, collections=collections, - ) + ) else: hash = request.args['hash'] return render_template("collections/add.html", hash=hash, collections=collections, - ) + ) @app.route("/collections/new") @@ -147,7 +147,7 @@ def list_collections(): return render_template("collections/list.html", params=params, collections=user_collections, - ) + ) @app.route("/collections/remove", methods=('POST',)) @@ -226,7 +226,7 @@ def view_collection(): else: return render_template("collections/view.html", **collection_info - ) + ) @app.route("/collections/change_name", methods=('POST',)) diff --git a/wqflask/wqflask/correlation/corr_scatter_plot.py b/wqflask/wqflask/correlation/corr_scatter_plot.py index 4f756f58..cafb9265 100644 --- a/wqflask/wqflask/correlation/corr_scatter_plot.py +++ b/wqflask/wqflask/correlation/corr_scatter_plot.py @@ -18,12 +18,12 @@ class CorrScatterPlot: def __init__(self, params): if "Temp" in params['dataset_1']: self.dataset_1 = data_set.create_dataset( - dataset_name="Temp", dataset_type="Temp", group_name = params['dataset_1'].split("_")[1]) + dataset_name="Temp", dataset_type="Temp", group_name=params['dataset_1'].split("_")[1]) else: self.dataset_1 = data_set.create_dataset(params['dataset_1']) if "Temp" in params['dataset_2']: self.dataset_2 = data_set.create_dataset( - dataset_name="Temp", dataset_type="Temp", group_name = params['dataset_2'].split("_")[1]) + dataset_name="Temp", dataset_type="Temp", group_name=params['dataset_2'].split("_")[1]) else: self.dataset_2 = data_set.create_dataset(params['dataset_2']) diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index aa39bc5c..9b0b6118 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -79,7 +79,7 @@ class CorrelationResults: with Bench("Doing correlations"): if start_vars['dataset'] == "Temp": self.dataset = data_set.create_dataset( - dataset_name="Temp", dataset_type="Temp", group_name = start_vars['group']) + dataset_name="Temp", dataset_type="Temp", group_name=start_vars['group']) self.trait_id = start_vars['trait_id'] self.this_trait = create_trait(dataset=self.dataset, name=self.trait_id, @@ -609,14 +609,14 @@ def get_header_fields(data_type, corr_method): 'Location', 'Mean', 'Sample rho', - 'N', - 'Sample p(rho)', - 'Lit rho', - 'Tissue rho', - 'Tissue p(rho)', - 'Max LRS', - 'Max LRS Location', - 'Additive Effect'] + 'N', + 'Sample p(rho)', + 'Lit rho', + 'Tissue rho', + 'Tissue p(rho)', + 'Max LRS', + 'Max LRS Location', + 'Additive Effect'] else: header_fields = ['Index', 'Record', @@ -625,14 +625,14 @@ def get_header_fields(data_type, corr_method): 'Location', 'Mean', 'Sample r', - 'N', - 'Sample p(r)', - 'Lit r', - 'Tissue r', - 'Tissue p(r)', - 'Max LRS', - 'Max LRS Location', - 'Additive Effect'] + 'N', + 'Sample p(r)', + 'Lit r', + 'Tissue r', + 'Tissue p(r)', + 'Max LRS', + 'Max LRS Location', + 'Additive Effect'] elif data_type == "Publish": if corr_method == "spearman": header_fields = ['Index', diff --git a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py index c1bf3daa..3a54a218 100644 --- a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py +++ b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py @@ -211,7 +211,7 @@ class CorrelationMatrix: this_group_name = self.trait_list[0][1].group.name temp_dataset = data_set.create_dataset( - dataset_name="Temp", dataset_type="Temp", group_name = this_group_name) + dataset_name="Temp", dataset_type="Temp", group_name=this_group_name) temp_dataset.group.get_samplelist() for i, pca_trait in enumerate(pca_traits): trait_id = "PCA" + str(i + 1) + "_" + temp_dataset.group.species + "_" + \ diff --git a/wqflask/wqflask/ctl/ctl_analysis.py b/wqflask/wqflask/ctl/ctl_analysis.py index a0fb34d8..bb928ec5 100644 --- a/wqflask/wqflask/ctl/ctl_analysis.py +++ b/wqflask/wqflask/ctl/ctl_analysis.py @@ -154,7 +154,7 @@ class CTL: # Perform the CTL scan res = self.r_CTLscan(rGeno, rPheno, strategy=strategy, - nperm=nperm, parametric = parametric, nthreads=6) + nperm=nperm, parametric=parametric, nthreads=6) # Get significant interactions significant = self.r_CTLsignificant(res, significance=significance) diff --git a/wqflask/wqflask/group_manager.py b/wqflask/wqflask/group_manager.py index b7e7e38a..04a100ba 100644 --- a/wqflask/wqflask/group_manager.py +++ b/wqflask/wqflask/group_manager.py @@ -120,14 +120,16 @@ def add_or_edit_group(): if "admin_emails_to_add" in params: admin_emails = params['admin_emails_to_add'].split(",") for email in admin_emails: - user_details = get_user_by_unique_column("email_address", email) + user_details = get_user_by_unique_column( + "email_address", email) if user_details: admin_user_ids.add(user_details['user_id']) #send_group_invites(params['group_id'], user_email_list = admin_emails, user_type="admins") if "member_emails_to_add" in params: member_emails = params['member_emails_to_add'].split(",") for email in member_emails: - user_details = get_user_by_unique_column("email_address", email) + user_details = get_user_by_unique_column( + "email_address", email) if user_details: member_user_ids.add(user_details['user_id']) #send_group_invites(params['group_id'], user_email_list = user_emails, user_type="members") @@ -156,7 +158,7 @@ def send_group_invites(group_id, user_email_list=[], user_type="members"): continue else: send_verification_email(user_details, template_name="email/group_verification.txt", - key_prefix="verification_code", subject = "You've been invited to join a GeneNetwork user group") + key_prefix="verification_code", subject="You've been invited to join a GeneNetwork user group") else: temp_password = ''.join(random.choice( string.ascii_uppercase + string.digits) for _ in range(6)) diff --git a/wqflask/wqflask/interval_analyst/GeneUtil.py b/wqflask/wqflask/interval_analyst/GeneUtil.py index 04980281..5e86ae31 100644 --- a/wqflask/wqflask/interval_analyst/GeneUtil.py +++ b/wqflask/wqflask/interval_analyst/GeneUtil.py @@ -60,7 +60,8 @@ def loadGenes(chrName, diffCol, startMb, endMb, species='mouse'): newdict["snpDensity"] = newdict["snpCount"] = 0 try: - newdict['GeneLength'] = 1000.0 * (newdict['TxEnd'] - newdict['TxStart']) + newdict['GeneLength'] = 1000.0 * \ + (newdict['TxEnd'] - newdict['TxStart']) except: pass diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py index f3b1b1fc..5bf8822a 100644 --- a/wqflask/wqflask/marker_regression/display_mapping_results.py +++ b/wqflask/wqflask/marker_regression/display_mapping_results.py @@ -591,7 +591,7 @@ class DisplayMappingResults: intCanvas = Image.new("RGBA", size=(self.graphWidth, self.graphHeight)) with Bench("Drawing Plot"): gifmap = self.plotIntMapping( - intCanvas, startMb=self.startMb, endMb=self.endMb, showLocusForm= showLocusForm) + intCanvas, startMb=self.startMb, endMb=self.endMb, showLocusForm=showLocusForm) self.gifmap = gifmap.__str__() @@ -610,7 +610,7 @@ class DisplayMappingResults: intCanvasX2 = Image.new("RGBA", size=( self.graphWidth * 2, self.graphHeight * 2)) gifmapX2 = self.plotIntMapping( - intCanvasX2, startMb=self.startMb, endMb=self.endMb, showLocusForm= showLocusForm, zoom=2) + intCanvasX2, startMb=self.startMb, endMb=self.endMb, showLocusForm=showLocusForm, zoom=2) intCanvasX2.save( "{}.png".format( os.path.join(webqtlConfig.GENERATED_IMAGE_DIR, @@ -628,8 +628,8 @@ class DisplayMappingResults: name=showLocusForm, submit=HtmlGenWrapper.create_input_tag(type_='hidden')) - hddn = {'FormID': 'showDatabase', 'ProbeSetID': '_', 'database': fd.RISet+ \ - "Geno",'CellID':'_', 'RISet':fd.RISet, 'incparentsf1':'ON'} + hddn = {'FormID': 'showDatabase', 'ProbeSetID': '_', 'database': fd.RISet + \ + "Geno", 'CellID': '_', 'RISet': fd.RISet, 'incparentsf1': 'ON'} for key in hddn.keys(): showLocusForm.append(HtmlGenWrapper.create_input_tag( name=key, value=hddn[key], type_='hidden')) @@ -651,7 +651,7 @@ class DisplayMappingResults: btminfo.append( 'Mapping using genotype data as a trait will result in infinity LRS at one locus. In order to display the result properly, all LRSs higher than 100 are capped at 100.') - def plotIntMapping(self, canvas, offset=(80, 120, 90, 100), zoom=1, startMb= None, endMb = None, showLocusForm = ""): + def plotIntMapping(self, canvas, offset=(80, 120, 90, 100), zoom=1, startMb=None, endMb=None, showLocusForm=""): im_drawer = ImageDraw.Draw(canvas) # calculating margins xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset @@ -730,7 +730,7 @@ class DisplayMappingResults: zoom=zoom, startMb=startMb, endMb=endMb) if self.SNPChecked: self.drawSNPTrackNew( - canvas, offset=newoffset, zoom=2 * zoom, startMb=startMb, endMb = endMb) + canvas, offset=newoffset, zoom=2 * zoom, startMb=startMb, endMb=endMb) # BEGIN HaplotypeAnalyst if self.haplotypeAnalystChecked: self.drawHaplotypeBand( @@ -758,7 +758,7 @@ class DisplayMappingResults: return gifmap - def drawBootStrapResult(self, canvas, nboot, drawAreaHeight, plotXScale, offset=(40, 120, 80, 10), zoom=1, startMb= None, endMb = None): + def drawBootStrapResult(self, canvas, nboot, drawAreaHeight, plotXScale, offset=(40, 120, 80, 10), zoom=1, startMb=None, endMb=None): im_drawer = ImageDraw.Draw(canvas) xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset plotWidth = canvas.size[0] - xLeftOffset - xRightOffset @@ -873,14 +873,14 @@ class DisplayMappingResults: font=VERDANA_FILE, size=13 * fontZoom) im_drawer.rectangle( xy=((canvas.size[0] - bootOffset, yZero - bootHeightThresh), - (canvas.size[0] - bootOffset - 15*zoom, yZero)), + (canvas.size[0] - bootOffset - 15 * zoom, yZero)), fill=YELLOW, outline=BLACK) im_drawer.line( xy=((canvas.size[0] - bootOffset + 4, yZero), (canvas.size[0] - bootOffset, yZero)), fill=BLACK) TEXT_Y_DISPLACEMENT = -8 - im_drawer.text(xy=(canvas.size[0] - bootOffset + 10, yZero+TEXT_Y_DISPLACEMENT), text='0%', + im_drawer.text(xy=(canvas.size[0] - bootOffset + 10, yZero + TEXT_Y_DISPLACEMENT), text='0%', font=bootScaleFont, fill=BLACK) for item in bootScale: @@ -891,7 +891,7 @@ class DisplayMappingResults: xy=((canvas.size[0] - bootOffset + 4, bootY), (canvas.size[0] - bootOffset, bootY)), fill=BLACK) - im_drawer.text(xy=(canvas.size[0] - bootOffset + 10, bootY+TEXT_Y_DISPLACEMENT), + im_drawer.text(xy=(canvas.size[0] - bootOffset + 10, bootY + TEXT_Y_DISPLACEMENT), text='%2.1f' % item, font=bootScaleFont, fill=BLACK) if self.legendChecked: @@ -910,7 +910,7 @@ class DisplayMappingResults: text='Frequency of the Peak LRS', font=smallLabelFont, fill=BLACK) - def drawProbeSetPosition(self, canvas, plotXScale, offset=(40, 120, 80, 10), zoom=1, startMb= None, endMb = None): + def drawProbeSetPosition(self, canvas, plotXScale, offset=(40, 120, 80, 10), zoom=1, startMb=None, endMb=None): im_drawer = ImageDraw.Draw(canvas) if len(self.traitList) != 1: return @@ -987,7 +987,7 @@ class DisplayMappingResults: draw_open_polygon(canvas, xy=traitPixel, outline=BLACK, fill=self.TRANSCRIPT_LOCATION_COLOR) - def drawSNPTrackNew(self, canvas, offset=(40, 120, 80, 10), zoom=1, startMb= None, endMb = None): + def drawSNPTrackNew(self, canvas, offset=(40, 120, 80, 10), zoom=1, startMb=None, endMb=None): im_drawer = ImageDraw.Draw(canvas) if self.plotScale != 'physic' or self.selectedChr == -1 or not self.diffCol: return @@ -1059,7 +1059,7 @@ class DisplayMappingResults: im_drawer.rectangle( xy=((rightShift, yPaddingTop + kstep * 15), - (rectWidth + rightShift, yPaddingTop + 10+kstep*15)), + (rectWidth + rightShift, yPaddingTop + 10 + kstep * 15)), fill=thisLRSColor, outline=BLACK) im_drawer.text( text=name, xy=(rectWidth + 2 + rightShift, @@ -1303,7 +1303,7 @@ class DisplayMappingResults: text=string4, xy=(xLeftOffset, y_constant * fontZoom), font=labelFont, fill=labelColor) - def drawGeneBand(self, canvas, gifmap, plotXScale, offset=(40, 120, 80, 10), zoom=1, startMb= None, endMb = None): + def drawGeneBand(self, canvas, gifmap, plotXScale, offset=(40, 120, 80, 10), zoom=1, startMb=None, endMb=None): im_drawer = ImageDraw.Draw(canvas) if self.plotScale != 'physic' or self.selectedChr == -1 or not self.geneCol: return @@ -1434,7 +1434,7 @@ class DisplayMappingResults: xy=( (geneStartPix, geneYLocation + \ self.EACH_GENE_HEIGHT / 2 * zoom), - (geneEndPix, geneYLocation + self.EACH_GENE_HEIGHT / 2 *zoom)), + (geneEndPix, geneYLocation + self.EACH_GENE_HEIGHT / 2 * zoom)), fill=outlineColor, width=1) # draw the arrows @@ -1558,7 +1558,7 @@ class DisplayMappingResults: target="_blank")) # BEGIN HaplotypeAnalyst - def drawHaplotypeBand(self, canvas, gifmap, plotXScale, offset=(40, 120, 80, 10), zoom=1, startMb= None, endMb = None): + def drawHaplotypeBand(self, canvas, gifmap, plotXScale, offset=(40, 120, 80, 10), zoom=1, startMb=None, endMb=None): if self.plotScale != 'physic' or self.selectedChr == -1 or not self.geneCol: return @@ -1630,7 +1630,7 @@ class DisplayMappingResults: geneStartPix = xLeftOffset + plotXScale * \ (float(txStart) - startMb) - 0 geneEndPix = xLeftOffset + plotXScale * \ - (float(txEnd) - startMb) + 0 + (float(txEnd) - startMb) + 0 if oldgeneEndPix >= xLeftOffset: drawStart = oldgeneEndPix + 4 @@ -1707,19 +1707,19 @@ class DisplayMappingResults: im_drawer.line( xy=((drawStart, - geneYLocation + 7 + 2*ind*self.EACH_GENE_HEIGHT*zoom), + geneYLocation + 7 + 2 * ind * self.EACH_GENE_HEIGHT * zoom), (drawEnd, - geneYLocation + 7 + 2*ind*self.EACH_GENE_HEIGHT*zoom)), - fill= mylineColor, width=zoom * (self.EACH_GENE_HEIGHT + 2)) + geneYLocation + 7 + 2 * ind * self.EACH_GENE_HEIGHT * zoom)), + fill=mylineColor, width=zoom * (self.EACH_GENE_HEIGHT + 2)) fillColor = BLACK outlineColor = BLACK if lastGene == 0: im_drawer.rectangle( xy=((geneStartPix, - geneYLocation + 2 * ind*self.EACH_GENE_HEIGHT*zoom), + geneYLocation + 2 * ind * self.EACH_GENE_HEIGHT * zoom), (geneEndPix, - geneYLocation + 2 *ind*self.EACH_GENE_HEIGHT + 2*self.EACH_GENE_HEIGHT*zoom)), + geneYLocation + 2 * ind * self.EACH_GENE_HEIGHT + 2 * self.EACH_GENE_HEIGHT * zoom)), outline=outlineColor, fill=fillColor) COORDS = "%d, %d, %d, %d" % ( @@ -1741,10 +1741,10 @@ class DisplayMappingResults: mylineColor = self.HAPLOTYPE_RECOMBINATION im_drawer.line( xy=((plotRight, - geneYLocation + 7 + 2*ind*self.EACH_GENE_HEIGHT*zoom), + geneYLocation + 7 + 2 * ind * self.EACH_GENE_HEIGHT * zoom), (drawEnd, - geneYLocation + 7 + 2*ind*self.EACH_GENE_HEIGHT*zoom)), - fill= mylineColor, width=zoom * (self.EACH_GENE_HEIGHT + 2)) + geneYLocation + 7 + 2 * ind * self.EACH_GENE_HEIGHT * zoom)), + fill=mylineColor, width=zoom * (self.EACH_GENE_HEIGHT + 2)) if lastGene == 0: draw_rotated_text( @@ -1752,7 +1752,7 @@ class DisplayMappingResults: font=ImageFont.truetype(font=VERDANA_FILE, size=12), xy=(geneStartPix, - geneYLocation + 17 + 2*maxind*self.EACH_GENE_HEIGHT*zoom), + geneYLocation + 17 + 2 * maxind * self.EACH_GENE_HEIGHT * zoom), fill=BLACK, angle=-90) oldgeneEndPix = geneEndPix @@ -1778,21 +1778,21 @@ class DisplayMappingResults: im_drawer.text( text="%s" % (samplelist[j]), xy=((xLeftOffset + plotWidth + 10), - geneYLocation + 11 + 2*ind*self.EACH_GENE_HEIGHT*zoom), + geneYLocation + 11 + 2 * ind * self.EACH_GENE_HEIGHT * zoom), font=ImageFont.truetype( font=VERDANA_FILE, size=12), fill=BLACK) im_drawer.text( text="%2.2f" % (expr), xy=((xLeftOffset + plotWidth + 60), - geneYLocation + 11 + 2*ind*self.EACH_GENE_HEIGHT*zoom), + geneYLocation + 11 + 2 * ind * self.EACH_GENE_HEIGHT * zoom), font=ImageFont.truetype( font=VERDANA_FILE, size=12), fill=BLACK) # END HaplotypeAnalyst - def drawClickBand(self, canvas, gifmap, plotXScale, offset=(40, 120, 80, 10), zoom=1, startMb= None, endMb = None): + def drawClickBand(self, canvas, gifmap, plotXScale, offset=(40, 120, 80, 10), zoom=1, startMb=None, endMb=None): im_drawer = ImageDraw.Draw(canvas) if self.plotScale != 'physic' or self.selectedChr == -1: return @@ -1817,8 +1817,8 @@ class DisplayMappingResults: numBasesCurrentlyOnScreen = self.kONE_MILLION * \ abs(startMb - endMb) # Number of bases on screen now - flankingWidthInBases = int ( - min((float(numBasesCurrentlyOnScreen) / 2.0), (5*self.kONE_MILLION))) + flankingWidthInBases = int( + min((float(numBasesCurrentlyOnScreen) / 2.0), (5 * self.kONE_MILLION))) webqtlZoomWidth = numBasesCurrentlyOnScreen / 16.0 # Flanking width should be such that we either zoom in to a 10 million base region, or we show the clicked region at the same scale as we are currently seeing. @@ -1990,7 +1990,7 @@ class DisplayMappingResults: # end of drawBrowserClickableRegions pass - def drawXAxis(self, canvas, drawAreaHeight, gifmap, plotXScale, showLocusForm, offset=(40, 120, 80, 10), zoom=1, startMb= None, endMb = None): + def drawXAxis(self, canvas, drawAreaHeight, gifmap, plotXScale, showLocusForm, offset=(40, 120, 80, 10), zoom=1, startMb=None, endMb=None): im_drawer = ImageDraw.Draw(canvas) xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset plotWidth = canvas.size[0] - xLeftOffset - xRightOffset @@ -2087,7 +2087,7 @@ class DisplayMappingResults: xy=( xLeftOffset + (plotWidth - im_drawer.textsize( "Megabases", font=megabaseLabelFont)[0]) / 2, - strYLoc + MBLabelFont.font.height + 10*(zoom%2)), + strYLoc + MBLabelFont.font.height + 10 * (zoom % 2)), font=megabaseLabelFont, fill=BLACK) pass else: @@ -2110,7 +2110,7 @@ class DisplayMappingResults: thisChr.append( [_locus.name, _locus.cM - Locus0CM]) else: - for j in (0, nLoci / 4, nLoci / 2, nLoci*3/4, -1): + for j in (0, nLoci / 4, nLoci / 2, nLoci * 3 / 4, -1): while _chr[j].name == ' - ': j += 1 if _chr[j].cM != preLpos: @@ -2162,23 +2162,23 @@ class DisplayMappingResults: yZero + 25)), fill=lineColor) im_drawer.line( - xy=((xLeftOffset + offsetA, yZero + 25), (xLeftOffset+offsetA,\ - yZero + 40 + Zorder*(LRectWidth+3))), + xy=((xLeftOffset + offsetA, yZero + 25), (xLeftOffset + offsetA,\ + yZero + 40 + Zorder * (LRectWidth + 3))), fill=lineColor) rectColor = ORANGE else: im_drawer.line( - xy=((xLeftOffset + offsetA, yZero + 40+Zorder*(LRectWidth+3)-3), (\ - xLeftOffset + offsetA, yZero + 40+Zorder*(LRectWidth+3))), + xy=((xLeftOffset + offsetA, yZero + 40 + Zorder * (LRectWidth + 3) - 3), (\ + xLeftOffset + offsetA, yZero + 40 + Zorder * (LRectWidth + 3))), fill=lineColor) rectColor = DEEPPINK im_drawer.rectangle( - xy=((xLeftOffset + offsetA, yZero + 40+Zorder*(LRectWidth+3)), + xy=((xLeftOffset + offsetA, yZero + 40 + Zorder * (LRectWidth + 3)), (xLeftOffset + offsetA - LRectHeight, - yZero + 40 + Zorder*(LRectWidth+3)+LRectWidth)), + yZero + 40 + Zorder * (LRectWidth + 3) + LRectWidth)), outline=rectColor, fill=rectColor, width=0) - COORDS = "%d,%d,%d,%d" % (xLeftOffset+offsetA-LRectHeight, yZero+40+Zorder*(LRectWidth+3),\ - xLeftOffset + offsetA, yZero +40+Zorder*(LRectWidth+3)+LRectWidth) + COORDS = "%d,%d,%d,%d" % (xLeftOffset + offsetA - LRectHeight, yZero + 40 + Zorder * (LRectWidth + 3),\ + xLeftOffset + offsetA, yZero + 40 + Zorder * (LRectWidth + 3) + LRectWidth) HREF = "/show_trait?trait_id=%s&dataset=%s" % ( Lname, self.dataset.group.name + "Geno") #HREF="javascript:showDatabase3('%s','%s','%s','');" % (showLocusForm,fd.RISet+"Geno", Lname) @@ -2203,13 +2203,13 @@ class DisplayMappingResults: text="Centimorgans", xy=(xLeftOffset + (plotWidth - im_drawer.textsize( "Centimorgans", font=centimorganLabelFont)[0]) / 2, - strYLoc + MBLabelFont.font.height + 10 * (zoom %2)), + strYLoc + MBLabelFont.font.height + 10 * (zoom % 2)), font=centimorganLabelFont, fill=BLACK) im_drawer.line(xy=((xLeftOffset, yZero), (xLeftOffset + plotWidth, yZero)), fill=BLACK, width=X_AXIS_THICKNESS) # Draw the X axis itself - def drawQTL(self, canvas, drawAreaHeight, gifmap, plotXScale, offset=(40, 120, 80, 10), zoom=1, startMb= None, endMb = None): + def drawQTL(self, canvas, drawAreaHeight, gifmap, plotXScale, offset=(40, 120, 80, 10), zoom=1, startMb=None, endMb=None): im_drawer = ImageDraw.Draw(canvas) xLeftOffset, xRightOffset, yTopOffset, yBottomOffset = offset plotWidth = canvas.size[0] - xLeftOffset - xRightOffset @@ -2364,7 +2364,7 @@ class DisplayMappingResults: TEXT_Y_DISPLACEMENT = -10 im_drawer.text( text=scaleStr, - xy=(xLeftOffset - 4 - im_drawer.textsize(scaleStr, font=LRSScaleFont)[0]-5, + xy=(xLeftOffset - 4 - im_drawer.textsize(scaleStr, font=LRSScaleFont)[0] - 5, yLRS + TEXT_Y_DISPLACEMENT), font=LRSScaleFont, fill=self.LRS_COLOR) @@ -2479,7 +2479,7 @@ class DisplayMappingResults: if k > 0: Xc0, Yc0 = AdditiveCoordXY[k - 1] Xc, Yc = aPoint - if (Yc0 - yZero) * (Yc-yZero) < 0: + if (Yc0 - yZero) * (Yc - yZero) < 0: if Xc == Xc0: # genotype , locus distance is 0 Xcm = Xc else: @@ -2509,7 +2509,7 @@ class DisplayMappingResults: fill=plusColor, width=lineWidth # , clipX=(xLeftOffset, xLeftOffset + plotWidth) ) - elif (Yc0 - yZero) * (Yc-yZero) > 0: + elif (Yc0 - yZero) * (Yc - yZero) > 0: if Yc < yZero: im_drawer.line( xy=((Xc0, Yc0), (Xc, Yc)), @@ -2660,7 +2660,7 @@ class DisplayMappingResults: if k > 0: Xc0, Yc0 = AdditiveCoordXY[k - 1] Xc, Yc = aPoint - if (Yc0 - yZero) * (Yc-yZero) < 0: + if (Yc0 - yZero) * (Yc - yZero) < 0: if Xc == Xc0: # genotype , locus distance is 0 Xcm = Xc else: @@ -2689,7 +2689,7 @@ class DisplayMappingResults: fill=plusColor, width=lineWidth # , clipX=(xLeftOffset, xLeftOffset + plotWidth) ) - elif (Yc0 - yZero) * (Yc-yZero) > 0: + elif (Yc0 - yZero) * (Yc - yZero) > 0: if Yc < yZero: im_drawer.line( xy=((Xc0, Yc0), (Xc, Yc)), fill=plusColor, @@ -2726,7 +2726,7 @@ class DisplayMappingResults: if k > 0: Xc0, Yc0 = DominanceCoordXY[k - 1] Xc, Yc = aPoint - if (Yc0 - yZero) * (Yc-yZero) < 0: + if (Yc0 - yZero) * (Yc - yZero) < 0: if Xc == Xc0: # genotype , locus distance is 0 Xcm = Xc else: @@ -2754,7 +2754,7 @@ class DisplayMappingResults: fill=plusColor, width=lineWidth # , clipX=(xLeftOffset, xLeftOffset + plotWidth) ) - elif (Yc0 - yZero) * (Yc-yZero) > 0: + elif (Yc0 - yZero) * (Yc - yZero) > 0: if Yc < yZero: im_drawer.line( xy=((Xc0, Yc0), (Xc, Yc)), @@ -2805,8 +2805,8 @@ class DisplayMappingResults: scaleStr = "%2.3f" % item im_drawer.text( text=scaleStr, - xy= (xLeftOffset + plotWidth + 6, - additiveY + TEXT_Y_DISPLACEMENT), + xy=(xLeftOffset + plotWidth + 6, + additiveY + TEXT_Y_DISPLACEMENT), font=additiveScaleFont, fill=self.ADDITIVE_COLOR_POSITIVE) im_drawer.line( @@ -2818,7 +2818,7 @@ class DisplayMappingResults: xy=((xLeftOffset, yZero), (xLeftOffset, yTopOffset + 30 * (zoom - 1))), fill=self.LRS_COLOR, width=1 * zoom) # the blue line running up the y axis - def drawGraphBackground(self, canvas, gifmap, offset=(80, 120, 80, 50), zoom=1, startMb= None, endMb = None): + def drawGraphBackground(self, canvas, gifmap, offset=(80, 120, 80, 50), zoom=1, startMb=None, endMb=None): # conditions # multiple Chromosome view # single Chromosome Physical @@ -2953,10 +2953,10 @@ class DisplayMappingResults: "SNP Count", "SNP Density", "Avg Expr", - "Human Chr", - "Mb Start (hg19)", - "Literature Correlation", - "Gene Description"] + "Human Chr", + "Mb Start (hg19)", + "Literature Correlation", + "Gene Description"] else: gene_table_header_list = ["", "Index", @@ -3073,12 +3073,12 @@ class DisplayMappingResults: geneIdString, theGO["GeneSymbol"], target="_blank") - ), + ), str(HtmlGenWrapper.create_link_tag( mouseStartString, "{:.6f}".format(txStart), target="_blank") - ), + ), str(HtmlGenWrapper.create_link_tag( "javascript:rangeView('{}', {:f}, {:f})".format( str(chr_as_int), diff --git a/wqflask/wqflask/marker_regression/gemma_mapping.py b/wqflask/wqflask/marker_regression/gemma_mapping.py index 289f1d5c..f88c5ac8 100644 --- a/wqflask/wqflask/marker_regression/gemma_mapping.py +++ b/wqflask/wqflask/marker_regression/gemma_mapping.py @@ -150,7 +150,7 @@ def gen_covariates_file(this_dataset, covariates, samples): if dataset_name == "Temp": temp_group = trait_name.split("_")[2] dataset_ob = create_dataset( - dataset_name="Temp", dataset_type="Temp", group_name = temp_group) + dataset_name="Temp", dataset_type="Temp", group_name=temp_group) else: dataset_ob = create_dataset(covariate.split(":")[1]) trait_ob = create_trait(dataset=dataset_ob, diff --git a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py index 5d16abde..4d6715ba 100644 --- a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py +++ b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py @@ -2,7 +2,8 @@ import os import math import string import random -import json, re +import json +import re from base import webqtlConfig from base.trait import GeneralTrait @@ -28,7 +29,7 @@ def run_reaper(this_trait, this_dataset, samples, vals, json_data, num_perm, boo output_filename = (f"{this_dataset.group.name}_GWA_" + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) - ) + ) bootstrap_filename = None permu_filename = None @@ -37,7 +38,7 @@ def run_reaper(this_trait, this_dataset, samples, vals, json_data, num_perm, boo bootstrap_filename = (f"{this_dataset.group.name}_BOOTSTRAP_" + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) - ) + ) opt_list.append("-b") opt_list.append(f"--n_bootstrap {str(num_bootstrap)}") @@ -47,7 +48,7 @@ def run_reaper(this_trait, this_dataset, samples, vals, json_data, num_perm, boo permu_filename = ("{this_dataset.group.name}_PERM_" + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) - ) + ) opt_list.append("-n " + str(num_perm)) opt_list.append( "--permu_output " + webqtlConfig.GENERATED_IMAGE_DIR + permu_filename + ".txt") diff --git a/wqflask/wqflask/marker_regression/rqtl_mapping.py b/wqflask/wqflask/marker_regression/rqtl_mapping.py index cf8cf514..1fa3dffe 100644 --- a/wqflask/wqflask/marker_regression/rqtl_mapping.py +++ b/wqflask/wqflask/marker_regression/rqtl_mapping.py @@ -110,7 +110,7 @@ def run_rqtl_geno(vals, samples, dataset, mapping_scale, method, model, permChec if do_control == "true": logger.info("Using covariate") result_data_frame = scantwo( - cross_object, pheno="the_pheno", addcovar=covars, model=model, method=method, n_cluster = 16) + cross_object, pheno="the_pheno", addcovar=covars, model=model, method=method, n_cluster=16) else: logger.info("No covariates") result_data_frame = scantwo( @@ -140,14 +140,14 @@ def run_rqtl_geno(vals, samples, dataset, mapping_scale, method, model, permChec cross_object, strata_ob = add_perm_strata( cross_object, perm_strata_list) if do_control == "true" or cofactors != "": - perm_data_frame = scanone(cross_object, pheno_col="the_pheno", addcovar=covars, n_perm = int( - num_perm), perm_strata = strata_ob, model=model, method=method) + perm_data_frame = scanone(cross_object, pheno_col="the_pheno", addcovar=covars, n_perm=int( + num_perm), perm_strata=strata_ob, model=model, method=method) else: perm_data_frame = scanone( - cross_object, pheno_col="the_pheno", n_perm=num_perm, perm_strata = strata_ob, model=model, method=method) + cross_object, pheno_col="the_pheno", n_perm=num_perm, perm_strata=strata_ob, model=model, method=method) else: if do_control == "true" or cofactors != "": - perm_data_frame = scanone(cross_object, pheno_col="the_pheno", addcovar=covars, n_perm = int( + perm_data_frame = scanone(cross_object, pheno_col="the_pheno", addcovar=covars, n_perm=int( num_perm), model=model, method=method) else: perm_data_frame = scanone( diff --git a/wqflask/wqflask/marker_regression/run_mapping.py b/wqflask/wqflask/marker_regression/run_mapping.py index 81e0a03f..32ccec48 100644 --- a/wqflask/wqflask/marker_regression/run_mapping.py +++ b/wqflask/wqflask/marker_regression/run_mapping.py @@ -67,7 +67,8 @@ class RunMapping: if 'genofile' in start_vars: if start_vars['genofile'] != "": self.genofile_string = start_vars['genofile'] - self.dataset.group.genofile = self.genofile_string.split(":")[0] + self.dataset.group.genofile = self.genofile_string.split(":")[ + 0] genofile_samplelist = get_genofile_samplelist(self.dataset) all_samples_ordered = self.dataset.group.all_samples_ordered() diff --git a/wqflask/wqflask/model.py b/wqflask/wqflask/model.py index 822900cc..a222b87c 100644 --- a/wqflask/wqflask/model.py +++ b/wqflask/wqflask/model.py @@ -36,7 +36,7 @@ class User(Base): # json detailing when they became a superuser, otherwise empty superuser = Column(Text) - # if not superuser + # if not superuser logins = relationship("Login", order_by="desc(Login.timestamp)", @@ -47,7 +47,7 @@ class User(Base): user_collections = relationship("UserCollection", order_by="asc(UserCollection.name)", lazy='dynamic', - ) + ) def display_num_collections(self): """ diff --git a/wqflask/wqflask/resource_manager.py b/wqflask/wqflask/resource_manager.py index 61f3b202..b28c1b04 100644 --- a/wqflask/wqflask/resource_manager.py +++ b/wqflask/wqflask/resource_manager.py @@ -116,7 +116,7 @@ def add_group_to_resource(): group_id = request.form['selected_group'] resource_info = get_resource_info(resource_id) default_privileges = resource_info['default_mask'] - return render_template("admin/set_group_privileges.html", resource_id=resource_id, group_id=group_id, default_privileges = default_privileges) + return render_template("admin/set_group_privileges.html", resource_id=resource_id, group_id=group_id, default_privileges=default_privileges) elif all(key in request.form for key in ('data_privilege', 'metadata_privilege', 'admin_privilege')): group_id = request.form['group_id'] group_name = get_group_info(group_id)['name'] diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index fc48959e..3cbda3dd 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -276,7 +276,7 @@ class SearchResultPage: search_operator, self.dataset, search_type['key'] - ) + ) return the_search else: return None diff --git a/wqflask/wqflask/snp_browser/snp_browser.py b/wqflask/wqflask/snp_browser/snp_browser.py index 42fe339e..c4d0e135 100644 --- a/wqflask/wqflask/snp_browser/snp_browser.py +++ b/wqflask/wqflask/snp_browser/snp_browser.py @@ -28,10 +28,10 @@ class SnpBrowser: if self.limit_strains == "true": self.header_fields, self.empty_field_count, self.header_data_names = get_header_list( - variant_type=self.variant_type, strains=self.chosen_strains, empty_columns = self.empty_columns) + variant_type=self.variant_type, strains=self.chosen_strains, empty_columns=self.empty_columns) else: self.header_fields, self.empty_field_count, self.header_data_names = get_header_list( - variant_type=self.variant_type, strains=self.strain_lists, species = self.species_name, empty_columns = self.empty_columns) + variant_type=self.variant_type, strains=self.strain_lists, species=self.species_name, empty_columns=self.empty_columns) def initialize_parameters(self, start_vars): if 'first_run' in start_vars: diff --git a/wqflask/wqflask/user_login.py b/wqflask/wqflask/user_login.py index 0d5f1f3e..ff77982f 100644 --- a/wqflask/wqflask/user_login.py +++ b/wqflask/wqflask/user_login.py @@ -65,7 +65,7 @@ def set_password(password): "salt": base64.b64encode(os.urandom(32)), "iterations": 100000, "keylength": 32, - "created_timestamp": timestamp() + "created_timestamp": timestamp() } assert len(password) >= 6, "Password shouldn't be shorter than 6 characters" @@ -132,7 +132,7 @@ def send_email(toaddr, msg, fromaddr="no-reply@genenetwork.org"): logger.info("Successfully sent email to " + toaddr) -def send_verification_email(user_details, template_name="email/user_verification.txt", key_prefix="verification_code", subject = "GeneNetwork e-mail verification"): +def send_verification_email(user_details, template_name="email/user_verification.txt", key_prefix="verification_code", subject="GeneNetwork e-mail verification"): verification_code = str(uuid.uuid4()) key = key_prefix + ":" + verification_code @@ -147,7 +147,7 @@ def send_verification_email(user_details, template_name="email/user_verification return {"recipient": recipient, "subject": subject, "body": body} -def send_invitation_email(user_email, temp_password, template_name="email/user_invitation.txt", subject= "You've been added to a GeneNetwork user group"): +def send_invitation_email(user_email, temp_password, template_name="email/user_invitation.txt", subject="You've been added to a GeneNetwork user group"): recipient = user_email body = render_template(template_name, temp_password) send_email(recipient, subject, body) diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py index fb26bfb1..cf84ea73 100644 --- a/wqflask/wqflask/user_manager.py +++ b/wqflask/wqflask/user_manager.py @@ -476,7 +476,7 @@ def set_password(password, user): user.password = json.dumps(pwfields.__dict__, sort_keys=True, - ) + ) class VerificationEmail: @@ -677,7 +677,7 @@ def github_oauth2(): user_details = get_user_by_unique_column("github_id", github_user["id"]) if user_details == None: user_details = { - "user_id": str(uuid.uuid4()), "name": github_user["name"].encode("utf-8"), "github_id": github_user["id"], "user_url": github_user["html_url"].encode("utf-8") , "login_type": "github" , "organization": "" , "active": 1 , "confirmed": 1 + "user_id": str(uuid.uuid4()), "name": github_user["name"].encode("utf-8"), "github_id": github_user["id"], "user_url": github_user["html_url"].encode("utf-8"), "login_type": "github", "organization": "", "active": 1, "confirmed": 1 } save_user(user_details, user_details["user_id"]) @@ -705,7 +705,7 @@ def orcid_oauth2(): user_details = { "user_id": str(uuid4()), "name": result_dict["name"], "orcid": result_dict["orcid"], "user_url": "%s/%s" % ( "/".join(ORCID_AUTH_URL.split("/")[:-2]), - result_dict["orcid"]), "login_type": "orcid", "organization": "", "active": 1 , "confirmed": 1 + result_dict["orcid"]), "login_type": "orcid", "organization": "", "active": 1, "confirmed": 1 } save_user(user_details, user_details["user_id"]) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index f75209ff..f9b8f310 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -141,7 +141,7 @@ def handle_bad_request(e): now = datetime.datetime.utcnow() time_str = now.strftime('%l:%M%p UTC %b %d, %Y') formatted_lines = [request.url - + " (" + time_str + ")"]+traceback.format_exc().splitlines() + + " (" + time_str + ")"] + traceback.format_exc().splitlines() # Handle random animations # Use a cookie to have one animation on refresh |