diff options
author | BonfaceKilz | 2021-04-30 12:52:55 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-04-30 13:45:15 +0300 |
commit | bd702e59d7a426fe351d34367bf824683c655696 (patch) | |
tree | 95994298c5dc29e527a0646cd99a248c7bbd8a66 /wqflask | |
parent | d1bc52a0d8e1219f377e804c3f27a3543d234fcb (diff) | |
download | genenetwork2-bd702e59d7a426fe351d34367bf824683c655696.tar.gz |
autopep8: Fix W291, W292, W293, W391
Diffstat (limited to 'wqflask')
36 files changed, 98 insertions, 124 deletions
diff --git a/wqflask/base/mrna_assay_tissue_data.py b/wqflask/base/mrna_assay_tissue_data.py index 9bb29664..882ae911 100644 --- a/wqflask/base/mrna_assay_tissue_data.py +++ b/wqflask/base/mrna_assay_tissue_data.py @@ -74,7 +74,7 @@ class MrnaAssayTissueData: def get_symbol_values_pairs(self): id_list = [self.data[symbol].data_id for symbol in self.data] - + symbol_values_dict = {} if len(id_list) > 0: diff --git a/wqflask/maintenance/convert_dryad_to_bimbam.py b/wqflask/maintenance/convert_dryad_to_bimbam.py index e417c280..18fbb8a1 100644 --- a/wqflask/maintenance/convert_dryad_to_bimbam.py +++ b/wqflask/maintenance/convert_dryad_to_bimbam.py @@ -52,7 +52,7 @@ def read_dryad_file(filename): # this_row.append(line.split(" ")[i+2]) # print("row: " + str(i)) # geno_rows.append(this_row) - # + # # return geno_rows diff --git a/wqflask/maintenance/convert_geno_to_bimbam.py b/wqflask/maintenance/convert_geno_to_bimbam.py index a2ede1f9..c5af1ca6 100644 --- a/wqflask/maintenance/convert_geno_to_bimbam.py +++ b/wqflask/maintenance/convert_geno_to_bimbam.py @@ -91,7 +91,7 @@ class ConvertGenoFile: self.markers.append(this_marker.__dict__) - self.write_to_bimbam() + self.write_to_bimbam() def write_to_bimbam(self): with open(self.output_files[0], "w") as geno_fh: @@ -126,7 +126,7 @@ class ConvertGenoFile: self.sample_list = row_contents[3:] else: self.sample_list = row_contents[2:] - + def process_rows(self): for self.latest_row_pos, row in enumerate(self.input_fh): self.latest_row_value = row diff --git a/wqflask/maintenance/generate_kinship_from_bimbam.py b/wqflask/maintenance/generate_kinship_from_bimbam.py index bed634fa..cd39fceb 100644 --- a/wqflask/maintenance/generate_kinship_from_bimbam.py +++ b/wqflask/maintenance/generate_kinship_from_bimbam.py @@ -19,7 +19,7 @@ class GenerateKinshipMatrices: self.group_name = group_name self.geno_file = geno_file self.pheno_file = pheno_file - + def generate_kinship(self): gemma_command = "/gnu/store/xhzgjr0jvakxv6h3blj8z496xjig69b0-profile/bin/gemma -g " + self.geno_file + \ " -p " + self.pheno_file + \ @@ -56,11 +56,11 @@ class GenerateKinshipMatrices: print(" Column is:", convertob.latest_col_value) print(" Row is:", convertob.latest_row_value) break - - + + if __name__ == "__main__": Geno_Directory = """/export/local/home/zas1024/genotype_files/genotype/""" Bimbam_Directory = """/export/local/home/zas1024/genotype_files/genotype/bimbam/""" GenerateKinshipMatrices.process_all(Geno_Directory, Bimbam_Directory) - + # ./gemma -g /home/zas1024/genotype_files/genotype/bimbam/BXD_geno.txt -p /home/zas1024/genotype_files/genotype/bimbam/BXD_pheno.txt -gk 1 -o BXD diff --git a/wqflask/maintenance/geno_to_json.py b/wqflask/maintenance/geno_to_json.py index 76a0fc98..27eb6553 100644 --- a/wqflask/maintenance/geno_to_json.py +++ b/wqflask/maintenance/geno_to_json.py @@ -29,7 +29,7 @@ from pprint import pformat as pf class EmptyConfigurations(Exception): pass - + class Marker: def __init__(self): self.name = None @@ -42,20 +42,20 @@ class Marker: class ConvertGenoFile: def __init__(self, input_file, output_file): - + self.input_file = input_file self.output_file = output_file - + self.mb_exists = False self.cm_exists = False self.markers = [] - + self.latest_row_pos = None self.latest_col_pos = None - + self.latest_row_value = None self.latest_col_value = None - + def convert(self): self.haplotype_notation = { @@ -64,16 +64,16 @@ class ConvertGenoFile: '@het': "0.5", '@unk': "NA" } - + self.configurations = {} #self.skipped_cols = 3 - + # if self.input_file.endswith(".geno.gz"): # print("self.input_file: ", self.input_file) # self.input_fh = gzip.open(self.input_file) # else: self.input_fh = open(self.input_file) - + with open(self.output_file, "w") as self.output_fh: # if self.file_type == "geno": self.process_csv() @@ -105,22 +105,22 @@ class ConvertGenoFile: self.configurations[genotype.upper()]) else: this_marker.genotypes.append("NA") - - #print("this_marker is:", pf(this_marker.__dict__)) + + #print("this_marker is:", pf(this_marker.__dict__)) # if this_marker.chr == "14": self.markers.append(this_marker.__dict__) with open(self.output_file, 'w') as fh: json.dump(self.markers, fh, indent=" ", sort_keys=True) - + # print('configurations:', str(configurations)) #self.latest_col_pos = item_count + self.skipped_cols #self.latest_col_value = item - + # if item_count != 0: # self.output_fh.write(" ") # self.output_fh.write(self.configurations[item.upper()]) - + # self.output_fh.write("\n") def process_rows(self): @@ -176,12 +176,12 @@ class ConvertGenoFile: print(" Column is:", convertob.latest_col_value) print(" Row is:", convertob.latest_row_value) break - + # def process_snps_file(cls, snps_file, new_directory): # output_file = os.path.join(new_directory, "mouse_families.json") # print("%s -> %s" % (snps_file, output_file)) # convertob = ConvertGenoFile(input_file, output_file) - + if __name__ == "__main__": Old_Geno_Directory = """/export/local/home/zas1024/gn2-zach/genotype_files/genotype""" @@ -192,5 +192,5 @@ if __name__ == "__main__": # convertob.convert() ConvertGenoFile.process_all(Old_Geno_Directory, New_Geno_Directory) # ConvertGenoFiles(Geno_Directory) - + #process_csv(Input_File, Output_File) diff --git a/wqflask/tests/unit/wqflask/api/test_correlation.py b/wqflask/tests/unit/wqflask/api/test_correlation.py index bd99838d..34ffa9ef 100644 --- a/wqflask/tests/unit/wqflask/api/test_correlation.py +++ b/wqflask/tests/unit/wqflask/api/test_correlation.py @@ -105,9 +105,9 @@ class TestCorrelations(unittest.TestCase): target_dataset = AttributeSetter({"group": group}) target_vals = [3.4, 6.2, 4.1, 3.4, 1.2, 5.6] - trait_data = {"S1": AttributeSetter({"value": 2.3}), "S2": AttributeSetter({"value": 1.1}), + trait_data = {"S1": AttributeSetter({"value": 2.3}), "S2": AttributeSetter({"value": 1.1}), "S3": AttributeSetter( - {"value": 6.3}), "S4": AttributeSetter({"value": 3.6}), "S5": AttributeSetter({"value": 4.1}), + {"value": 6.3}), "S4": AttributeSetter({"value": 3.6}), "S5": AttributeSetter({"value": 4.1}), "S6": AttributeSetter({"value": 5.0})} this_trait = AttributeSetter({"data": trait_data}) mock_normalize.return_value = ([2.3, 1.1, 6.3, 3.6, 4.1, 5.0], diff --git a/wqflask/tests/unit/wqflask/correlation/test_correlation_functions.py b/wqflask/tests/unit/wqflask/correlation/test_correlation_functions.py index 44d2e0fc..2bbeab1f 100644 --- a/wqflask/tests/unit/wqflask/correlation/test_correlation_functions.py +++ b/wqflask/tests/unit/wqflask/correlation/test_correlation_functions.py @@ -5,7 +5,7 @@ from wqflask.correlation.correlation_functions import cal_zero_order_corr_for_ti class TestCorrelationFunctions(unittest.TestCase): - + @mock.patch("wqflask.correlation.correlation_functions.MrnaAssayTissueData") def test_get_trait_symbol_and_tissue_values(self, mock_class): """test for getting trait symbol and tissue_values""" 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 c762982b..1198740d 100644 --- a/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py +++ b/wqflask/tests/unit/wqflask/marker_regression/test_qtlreaper_mapping.py @@ -8,7 +8,7 @@ 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): + def test_gen_pheno_txt_file(self): vals = ["V1", "x", "V4", "V3","x"] samples = ["S1", "S2", "S3", "S4","S5"] trait_filename = "trait_file" @@ -21,5 +21,3 @@ class TestQtlReaperMapping(unittest.TestCase): 'S1\tS3\tS4\n'), mock.call('T1\t'), mock.call('V1\tV4\tV3')] filehandler.write.assert_has_calls(write_calls) - - 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 6996c275..d69a20d3 100644 --- a/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py +++ b/wqflask/tests/unit/wqflask/marker_regression/test_rqtl_mapping.py @@ -40,10 +40,3 @@ class TestRqtlMapping(unittest.TestCase): expected_sanitized_name = "c('f',NA,'r',NA,NA)" results = sanitize_rqtl_names(vals) self.assertEqual(expected_sanitized_name, results) - - - - - - - diff --git a/wqflask/tests/unit/wqflask/snp_browser/test_snp_browser.py b/wqflask/tests/unit/wqflask/snp_browser/test_snp_browser.py index ce3e7b83..8823e1fc 100644 --- a/wqflask/tests/unit/wqflask/snp_browser/test_snp_browser.py +++ b/wqflask/tests/unit/wqflask/snp_browser/test_snp_browser.py @@ -21,9 +21,9 @@ class TestSnpBrowser(unittest.TestCase): "transcript": "false", "exon": "false", "domain_2": "true", "function": "false", "function_details": "true"} strains = {"mouse": ["S1", "S2", "S3", "S4", "S5"], "rat": []} expected_results = ([['Index', 'SNP ID', 'Chr', 'Mb', 'Alleles', 'ConScore', - 'Domain 1', 'Domain 2', 'Details'], - ['S1', 'S2', 'S3', 'S4', 'S5']], 5, - ['index', 'snp_name', 'chr', 'mb_formatted', 'alleles', + 'Domain 1', 'Domain 2', 'Details'], + ['S1', 'S2', 'S3', 'S4', 'S5']], 5, + ['index', 'snp_name', 'chr', 'mb_formatted', 'alleles', 'conservation_score', 'domain_1', 'domain_2', 'function_details', 'S1', 'S2', 'S3', 'S4', 'S5']) @@ -33,7 +33,7 @@ class TestSnpBrowser(unittest.TestCase): variant_type="InDel", strains=strains, species="rat", empty_columns=[]) expected_results_with_indel = ( ['Index', 'ID', 'Type', 'InDel Chr', 'Mb Start', - 'Mb End', 'Strand', 'Size', 'Sequence', 'Source'], 0, + 'Mb End', 'Strand', 'Size', 'Sequence', 'Source'], 0, ['index', 'indel_name', 'indel_type', 'indel_chr', 'indel_mb_s', 'indel_mb_e', 'indel_strand', 'indel_size', 'indel_sequence', 'source_name']) diff --git a/wqflask/tests/unit/wqflask/test_server_side.py b/wqflask/tests/unit/wqflask/test_server_side.py index 69977146..9d988aea 100644 --- a/wqflask/tests/unit/wqflask/test_server_side.py +++ b/wqflask/tests/unit/wqflask/test_server_side.py @@ -17,8 +17,8 @@ class TestServerSideTableTests(unittest.TestCase): def test_get_page(self): rows_count = 3 table_rows = [ - {'first': 'd', 'second': 4, 'third': 'zz'}, - {'first': 'b', 'second': 2, 'third': 'aa'}, + {'first': 'd', 'second': 4, 'third': 'zz'}, + {'first': 'b', 'second': 2, 'third': 'aa'}, {'first': 'c', 'second': 1, 'third': 'ss'}, ] headers = ['first', 'second', 'third'] diff --git a/wqflask/utility/__init__.py b/wqflask/utility/__init__.py index d540c96e..816bc4df 100644 --- a/wqflask/utility/__init__.py +++ b/wqflask/utility/__init__.py @@ -33,5 +33,3 @@ class Struct: def __repr__(self): return '{%s}' % str(', '.join('%s : %s' % (k, repr(v)) for (k, v) in list(self.__dict__.items()))) - - diff --git a/wqflask/utility/genofile_parser.py b/wqflask/utility/genofile_parser.py index 09100bd9..c0629b5d 100644 --- a/wqflask/utility/genofile_parser.py +++ b/wqflask/utility/genofile_parser.py @@ -98,4 +98,3 @@ class ConvertGenoFile: print("WARNING:", genotype.upper()) this_marker.genotypes.append("NA") self.markers.append(this_marker.__dict__) - diff --git a/wqflask/wqflask/__init__.py b/wqflask/wqflask/__init__.py index 712517a3..a2bf3085 100644 --- a/wqflask/wqflask/__init__.py +++ b/wqflask/wqflask/__init__.py @@ -50,4 +50,4 @@ from wqflask import db_info from wqflask import user_login from wqflask import user_session -import wqflask.views +import wqflask.views diff --git a/wqflask/wqflask/api/mapping.py b/wqflask/wqflask/api/mapping.py index c22b44a9..e4a3fb77 100644 --- a/wqflask/wqflask/api/mapping.py +++ b/wqflask/wqflask/api/mapping.py @@ -140,5 +140,3 @@ def initialize_parameters(start_vars, dataset, this_trait): mapping_params['perm_check'] = False return mapping_params - - diff --git a/wqflask/wqflask/api/router.py b/wqflask/wqflask/api/router.py index e7dfa4e0..f7d52ca3 100644 --- a/wqflask/wqflask/api/router.py +++ b/wqflask/wqflask/api/router.py @@ -59,13 +59,13 @@ def get_species_info(species_name, file_format="json"): WHERE (Name="{0}" OR FullName="{0}" OR SpeciesName="{0}");""".format(species_name)) the_species = results.fetchone() - species_dict = { + species_dict = { "Id": the_species[0], "Name": the_species[1], "FullName": the_species[2], "TaxonomyId": the_species[3] } - + return flask.jsonify(species_dict) @@ -639,7 +639,7 @@ def trait_sample_data(dataset_name, trait_name, file_format="json"): return flask.jsonify(sample_list) else: - return return_error(code=204, source=request.url_rule.rule, title="No Results", details="") + return return_error(code=204, source=request.url_rule.rule, title="No Results", details="") @app.route("/api/v_{}/trait/<path:dataset_name>/<path:trait_name>".format(version)) @@ -685,7 +685,7 @@ def get_trait_info(dataset_name, trait_name, file_format="json"): # ZS: Check if the user input the dataset_name as BXDPublish, etc (which is always going to be the group name + "Publish" if "Publish" in dataset_name: dataset_name = dataset_name.replace("Publish", "") - + group_id = get_group_id(dataset_name) pheno_query = """ SELECT @@ -898,7 +898,7 @@ def get_dataset_trait_ids(dataset_name, start_vars): data_type = "Publish" dataset_name = dataset_name.replace("Publish", "") dataset_id = get_group_id(dataset_name) - + query = """ SELECT PublishXRef.PhenotypeId, PublishXRef.Id, InbredSet.InbredSetCode @@ -949,9 +949,9 @@ def get_samplelist(dataset_name): WHERE StrainXRef.StrainId = Strain.Id AND StrainXRef.InbredSetId = {} """.format(group_id) - + results = g.db.execute(query).fetchall() - + samplelist = [result[0] for result in results] return samplelist diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index 1fcf15f0..9fd89524 100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -239,4 +239,3 @@ def change_collection_name(): g.user_session.change_collection_name(collection_id, new_name) return new_name - diff --git a/wqflask/wqflask/comparison_bar_chart/comparison_bar_chart.py b/wqflask/wqflask/comparison_bar_chart/comparison_bar_chart.py index 0fabb833..d86c8e16 100644 --- a/wqflask/wqflask/comparison_bar_chart/comparison_bar_chart.py +++ b/wqflask/wqflask/comparison_bar_chart/comparison_bar_chart.py @@ -45,7 +45,7 @@ class ComparisonBarChart: # ZS: Getting initial group name before verifying all traits are in the same group in the following loop this_group = self.trait_list[0][1].group.name for trait_db in self.trait_list: - + if trait_db[1].group.name != this_group: self.insufficient_shared_samples = True break @@ -53,7 +53,7 @@ class ComparisonBarChart: this_group = trait_db[1].group.name this_trait = trait_db[0] self.traits.append(this_trait) - + this_sample_data = this_trait.data for sample in this_sample_data: @@ -79,7 +79,7 @@ class ComparisonBarChart: self.js_data = dict(traits=[trait.name for trait in self.traits], samples=self.all_sample_list, sample_data=self.sample_data,) - + def get_trait_db_obs(self, trait_db_list): self.trait_list = [] @@ -95,4 +95,3 @@ class ComparisonBarChart: self.trait_list.append((trait_ob, dataset_ob)) #print("trait_list:", self.trait_list) - diff --git a/wqflask/wqflask/correlation/corr_scatter_plot.py b/wqflask/wqflask/correlation/corr_scatter_plot.py index f9a0ea11..4f756f58 100644 --- a/wqflask/wqflask/correlation/corr_scatter_plot.py +++ b/wqflask/wqflask/correlation/corr_scatter_plot.py @@ -68,7 +68,7 @@ class CorrScatterPlot: slope_string = '%.3E' % slope else: slope_string = '%.3f' % slope - + x_buffer = (max(vals_1) - min(vals_1)) * 0.1 y_buffer = (max(vals_2) - min(vals_2)) * 0.1 @@ -82,7 +82,7 @@ class CorrScatterPlot: ry = stats.rankdata(vals_2) self.rdata = [] self.rdata.append(rx.tolist()) - self.rdata.append(ry.tolist()) + self.rdata.append(ry.tolist()) srslope, srintercept, srr_value, srp_value, srstd_err = stats.linregress( rx, ry) diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index e75c4a85..8ee24246 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -680,4 +680,3 @@ def get_header_fields(data_type, corr_method): 'Sample p(r)'] return header_fields - diff --git a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py index aefb4453..59469428 100644 --- a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py +++ b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py @@ -324,7 +324,7 @@ def sortEigenVectors(vector): A.append(item[0]) B.append(item[1]) sum = reduce(lambda x, y: x + y, A, 0.0) - A = [x * 100.0 / sum for x in A] + A = [x * 100.0 / sum for x in A] return [A, B] except: return [] diff --git a/wqflask/wqflask/ctl/ctl_analysis.py b/wqflask/wqflask/ctl/ctl_analysis.py index 48a82435..f4eafbe7 100644 --- a/wqflask/wqflask/ctl/ctl_analysis.py +++ b/wqflask/wqflask/ctl/ctl_analysis.py @@ -66,7 +66,7 @@ class CTL: def addNode(self, gt): node_dict = {'data': {'id': str(gt.name) + ":" + str(gt.dataset.name), - 'sid': str(gt.name), + 'sid': str(gt.name), 'dataset': str(gt.dataset.name), 'label': gt.name, 'symbol': gt.symbol, @@ -238,4 +238,3 @@ class CTL: self.render_image(self.results) sys.stdout.flush() return(dict(template_vars)) - diff --git a/wqflask/wqflask/db_info.py b/wqflask/wqflask/db_info.py index c7558ed8..8d28fef0 100644 --- a/wqflask/wqflask/db_info.py +++ b/wqflask/wqflask/db_info.py @@ -135,5 +135,3 @@ def process_query_results(results): } return info_ob - - diff --git a/wqflask/wqflask/docs.py b/wqflask/wqflask/docs.py index fc93248a..0a1a597d 100644 --- a/wqflask/wqflask/docs.py +++ b/wqflask/wqflask/docs.py @@ -20,7 +20,7 @@ class Docs: self.title = self.entry.capitalize() self.content = "" else: - + self.title = result[0] self.content = result[1].decode("utf-8") diff --git a/wqflask/wqflask/export_traits.py b/wqflask/wqflask/export_traits.py index 5bd54f9d..2c180d49 100644 --- a/wqflask/wqflask/export_traits.py +++ b/wqflask/wqflask/export_traits.py @@ -1,6 +1,6 @@ import csv import xlsxwriter -import io +import io import datetime import itertools @@ -20,7 +20,7 @@ def export_search_results_csv(targs): table_data = json.loads(targs['export_data']) table_rows = table_data['rows'] - + now = datetime.datetime.now() time_str = now.strftime('%H:%M_%d%B%Y') if 'file_name' in targs: diff --git a/wqflask/wqflask/external_tools/send_to_webgestalt.py b/wqflask/wqflask/external_tools/send_to_webgestalt.py index fd12562f..fcd943ba 100644 --- a/wqflask/wqflask/external_tools/send_to_webgestalt.py +++ b/wqflask/wqflask/external_tools/send_to_webgestalt.py @@ -48,7 +48,7 @@ class SendToWebGestalt: id_type = "entrezgene" - self.hidden_vars = { + self.hidden_vars = { 'gene_list': "\n".join(gene_id_list), 'id_type': "entrezgene", 'ref_set': "genome", diff --git a/wqflask/wqflask/heatmap/heatmap.py b/wqflask/wqflask/heatmap/heatmap.py index aa11caa8..02eb66e5 100644 --- a/wqflask/wqflask/heatmap/heatmap.py +++ b/wqflask/wqflask/heatmap/heatmap.py @@ -125,7 +125,7 @@ class Heatmap: webqtlConfig.GENERATED_IMAGE_DIR, output_filename) - os.system(reaper_command) + os.system(reaper_command) reaper_results = parse_reaper_output(output_filename) diff --git a/wqflask/wqflask/interval_analyst/GeneUtil.py b/wqflask/wqflask/interval_analyst/GeneUtil.py index cadff080..e624a146 100644 --- a/wqflask/wqflask/interval_analyst/GeneUtil.py +++ b/wqflask/wqflask/interval_analyst/GeneUtil.py @@ -10,7 +10,7 @@ def loadGenes(chrName, diffCol, startMb, endMb, species='mouse'): fetchFields = ['SpeciesId', 'Id', 'GeneSymbol', 'GeneDescription', 'Chromosome', 'TxStart', 'TxEnd', 'Strand', 'GeneID', 'NM_ID', 'kgID', 'GenBankID', 'UnigenID', 'ProteinID', 'AlignID', 'exonCount', 'exonStarts', 'exonEnds', 'cdsStart', 'cdsEnd'] - + # List All Species in the Gene Table speciesDict = {} results = g.db.execute(""" @@ -21,7 +21,7 @@ def loadGenes(chrName, diffCol, startMb, endMb, species='mouse'): for item in results: speciesDict[item[0]] = item[1] - + # List current Species and other Species speciesId = speciesDict[species] otherSpecies = [[X, speciesDict[X]] for X in list(speciesDict.keys())] @@ -45,7 +45,7 @@ def loadGenes(chrName, diffCol, startMb, endMb, species='mouse'): newdict = {} for j, item in enumerate(fetchFields): newdict[item] = result[j] - # count SNPs if possible + # count SNPs if possible if diffCol and species == 'mouse': newdict["snpCount"] = g.db.execute(""" SELECT count(*) @@ -58,17 +58,17 @@ def loadGenes(chrName, diffCol, startMb, endMb, species='mouse'): (newdict["TxEnd"] - newdict["TxStart"]) / 1000.0 else: newdict["snpDensity"] = newdict["snpCount"] = 0 - + try: newdict['GeneLength'] = 1000.0 * (newdict['TxEnd'] - newdict['TxStart']) except: pass - + # load gene from other Species by the same name for item in otherSpecies: othSpec, othSpecId = item newdict2 = {} - + resultsOther = g.db.execute("SELECT %s FROM GeneList WHERE SpeciesId = %d AND geneSymbol= '%s' LIMIT 1" % (", ".join(fetchFields), othSpecId, newdict["GeneSymbol"])).fetchone() @@ -76,8 +76,8 @@ def loadGenes(chrName, diffCol, startMb, endMb, species='mouse'): if resultsOther: for j, item in enumerate(fetchFields): newdict2[item] = resultsOther[j] - - # count SNPs if possible, could be a separate function + + # count SNPs if possible, could be a separate function if diffCol and othSpec == 'mouse': newdict2["snpCount"] = g.db.execute(""" SELECT count(*) @@ -91,17 +91,15 @@ def loadGenes(chrName, diffCol, startMb, endMb, species='mouse'): (newdict2["TxEnd"] - newdict2["TxStart"]) / 1000.0 else: newdict2["snpDensity"] = newdict2["snpCount"] = 0 - + try: newdict2['GeneLength'] = 1000.0 * \ (newdict2['TxEnd'] - newdict2['TxStart']) except: pass - + newdict['%sGene' % othSpec] = newdict2 - + GeneList.append(newdict) return GeneList - - diff --git a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py index f932498f..c51b7a9a 100644 --- a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py +++ b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py @@ -34,7 +34,7 @@ def run_reaper(this_trait, this_dataset, samples, vals, json_data, num_perm, boo opt_list = [] if boot_check and num_bootstrap > 0: - bootstrap_filename = (f"{this_dataset.group.name}_BOOTSTRAP_" + + bootstrap_filename = (f"{this_dataset.group.name}_BOOTSTRAP_" + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) ) @@ -44,8 +44,8 @@ def run_reaper(this_trait, this_dataset, samples, vals, json_data, num_perm, boo opt_list.append( f"--bootstrap_output {webqtlConfig.GENERATED_IMAGE_DIR}{bootstrap_filename}.txt") if num_perm > 0: - permu_filename = ("{this_dataset.group.name}_PERM_" + - ''.join(random.choice(string.ascii_uppercase + + 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)) @@ -56,7 +56,7 @@ def run_reaper(this_trait, this_dataset, samples, vals, json_data, num_perm, boo if manhattan_plot != True: opt_list.append("--interval 1") - reaper_command = (REAPER_COMMAND + + reaper_command = (REAPER_COMMAND + ' --geno {0}/{1}.geno --traits {2}/gn2/{3}.txt {4} -o {5}{6}.txt'.format(flat_files('genotype'), genofile_name, @@ -81,7 +81,7 @@ def run_reaper(this_trait, this_dataset, samples, vals, json_data, num_perm, boo suggestive = permu_vals[int(num_perm * 0.37 - 1)] significant = permu_vals[int(num_perm * 0.95 - 1)] - return (marker_obs, permu_vals, suggestive, significant, bootstrap_vals, + return (marker_obs, permu_vals, suggestive, significant, bootstrap_vals, [output_filename, permu_filename, bootstrap_filename]) diff --git a/wqflask/wqflask/marker_regression/rqtl_mapping.py b/wqflask/wqflask/marker_regression/rqtl_mapping.py index 741d6c23..b3c9fddf 100644 --- a/wqflask/wqflask/marker_regression/rqtl_mapping.py +++ b/wqflask/wqflask/marker_regression/rqtl_mapping.py @@ -300,7 +300,7 @@ def add_categorical_covar(cross, covar_as_string, i): ro.r('the_cross$pheno <- cbind(pheno, ' + \ col_name + ' = newcovar[,' + str(x) + '])') col_names.append(col_name) - #logger.info("loop" + str(x) + "done"); + #logger.info("loop" + str(x) + "done"); logger.info("returning from add_categorical_covar") return ro.r["the_cross"], col_names diff --git a/wqflask/wqflask/resource_manager.py b/wqflask/wqflask/resource_manager.py index 36d4cd61..61f3b202 100644 --- a/wqflask/wqflask/resource_manager.py +++ b/wqflask/wqflask/resource_manager.py @@ -142,5 +142,5 @@ def get_group_names(group_masks): group_name = get_group_info(group_id)['name'] this_mask['name'] = group_name group_masks_with_names[group_id] = this_mask - + return group_masks_with_names diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index 273a97a4..0d2fb2f8 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -343,4 +343,3 @@ def get_aliases(symbol_list, species): search_terms.append(the_search_term) return search_terms - diff --git a/wqflask/wqflask/server_side.py b/wqflask/wqflask/server_side.py index 8b3a4faa..8ca3a9eb 100644 --- a/wqflask/wqflask/server_side.py +++ b/wqflask/wqflask/server_side.py @@ -30,7 +30,7 @@ class ServerSideTable: self.rows_count = rows_count self.table_rows = table_rows self.header_data_names = header_data_names - + self.sort_rows() self.paginate_rows() diff --git a/wqflask/wqflask/snp_browser/snp_browser.py b/wqflask/wqflask/snp_browser/snp_browser.py index e98cfb71..5b7a663c 100644 --- a/wqflask/wqflask/snp_browser/snp_browser.py +++ b/wqflask/wqflask/snp_browser/snp_browser.py @@ -494,10 +494,10 @@ class SnpBrowser: function_details = function_details + ", Coding Region Unknown" self.empty_columns['function_details'] = "true" - + #[snp_href, chr, mb_formatted, alleles, snp_source_cell, conservation_score, gene_name_cell, transcript_href, exon, domain_1, domain_2, function, function_details] - base_color_dict = {"A": "#C33232", "C": "#1569C7", "T": "#CFCF32", "G": "#32C332", + base_color_dict = {"A": "#C33232", "C": "#1569C7", "T": "#CFCF32", "G": "#32C332", "t": "#FF6", "c": "#5CB3FF", "a": "#F66", "g": "#CF9", ":": "#FFFFFF", "-": "#FFFFFF", "?": "#FFFFFF"} the_bases = [] @@ -735,7 +735,7 @@ def get_header_list(variant_type, strains, species=None, empty_columns=None): if empty_columns['function_details'] == "false": empty_field_count += 1 header_fields[0].remove('Details') - + for col in empty_columns.keys(): if empty_columns[col] == "false": header_data_names.remove(col) @@ -952,4 +952,3 @@ def check_if_in_gene(species_id, chr, mb): return [result[0], result[1]] else: return "" - diff --git a/wqflask/wqflask/user_login.py b/wqflask/wqflask/user_login.py index 708d43d2..bfaed9c2 100644 --- a/wqflask/wqflask/user_login.py +++ b/wqflask/wqflask/user_login.py @@ -45,10 +45,10 @@ def encode_password(pass_gen_fields, unencrypted_password): salt = pass_gen_fields['salt'] else: salt = bytes(pass_gen_fields['salt'], "utf-8") - encrypted_password = pbkdf2.pbkdf2_hex(str(unencrypted_password), + encrypted_password = pbkdf2.pbkdf2_hex(str(unencrypted_password), salt, - pass_gen_fields['iterations'], - pass_gen_fields['keylength'], + pass_gen_fields['iterations'], + pass_gen_fields['keylength'], pass_gen_fields['hashfunc']) pass_gen_fields.pop("unencrypted_password", None) @@ -111,7 +111,7 @@ def get_signed_session_id(user): key = UserSession.user_cookie_name + ":" + session_id Redis.hmset(key, session) Redis.expire(key, THREE_DAYS) - + return session_id_signed @@ -207,7 +207,7 @@ def login(): UserSession.user_cookie_name, session_id_signed, max_age=None) else: flash("Something went unexpectedly wrong.", "alert-danger") - response = make_response(redirect(url_for('index_page'))) + response = make_response(redirect(url_for('index_page'))) return response else: user_details = get_user_by_unique_column( @@ -276,13 +276,13 @@ 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") if github_user["name"] else "None", + "user_id": str(uuid.uuid4()), + "name": github_user["name"].encode("utf-8") if github_user["name"] else "None", "github_id": github_user["id"], - "user_url": github_user["html_url"].encode("utf-8"), - "login_type": "github", - "organization": "", - "active": 1, + "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"]) @@ -308,8 +308,8 @@ def orcid_oauth2(): url = "/n/login" if code: data = { - "client_id": ORCID_CLIENT_ID, - "client_secret": ORCID_CLIENT_SECRET, + "client_id": ORCID_CLIENT_ID, + "client_secret": ORCID_CLIENT_SECRET, "grant_type": "authorization_code", "redirect_uri": GN2_BRANCH_URL + "n/login/orcid_oauth2", "code": code @@ -321,13 +321,13 @@ def orcid_oauth2(): user_details = get_user_by_unique_column("orcid", result_dict["orcid"]) if user_details == None: 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, + "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 } save_user(user_details, user_details["user_id"]) @@ -374,7 +374,7 @@ def send_forgot_password_email(verification_email): key_prefix = "forgot_password_code" subject = "GeneNetwork password reset" fromaddr = "no-reply@genenetwork.org" - + verification_code = str(uuid.uuid4()) key = key_prefix + ":" + verification_code diff --git a/wqflask/wqflask/user_session.py b/wqflask/wqflask/user_session.py index 6ccb2e80..963288b3 100644 --- a/wqflask/wqflask/user_session.py +++ b/wqflask/wqflask/user_session.py @@ -318,5 +318,3 @@ class UserSession: # And more importantly delete the redis record Redis.delete(self.redis_key) self.logged_in = False - - |