diff options
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/maintenance/convert_geno_to_bimbam.py | 3 | ||||
-rw-r--r-- | wqflask/maintenance/geno_to_json.py | 3 | ||||
-rw-r--r-- | wqflask/utility/Plot.py | 2 | ||||
-rw-r--r-- | wqflask/utility/tools.py | 3 | ||||
-rw-r--r-- | wqflask/wqflask/marker_regression/display_mapping_results.py | 25 | ||||
-rw-r--r-- | wqflask/wqflask/marker_regression/rqtl_mapping.py | 66 | ||||
-rw-r--r-- | wqflask/wqflask/snp_browser/snp_browser.py | 4 | ||||
-rw-r--r-- | wqflask/wqflask/user_manager.py | 4 |
8 files changed, 59 insertions, 51 deletions
diff --git a/wqflask/maintenance/convert_geno_to_bimbam.py b/wqflask/maintenance/convert_geno_to_bimbam.py index a1712500..a2ede1f9 100644 --- a/wqflask/maintenance/convert_geno_to_bimbam.py +++ b/wqflask/maintenance/convert_geno_to_bimbam.py @@ -21,7 +21,8 @@ import simplejson as json from pprint import pformat as pf -class EmptyConfigurations(Exception): pass +class EmptyConfigurations(Exception): + pass class Marker: diff --git a/wqflask/maintenance/geno_to_json.py b/wqflask/maintenance/geno_to_json.py index 7bdf2b53..76a0fc98 100644 --- a/wqflask/maintenance/geno_to_json.py +++ b/wqflask/maintenance/geno_to_json.py @@ -26,7 +26,8 @@ from pprint import pformat as pf #from utility.tools import flat_files -class EmptyConfigurations(Exception): pass +class EmptyConfigurations(Exception): + pass class Marker: diff --git a/wqflask/utility/Plot.py b/wqflask/utility/Plot.py index 4f5691c1..00658d10 100644 --- a/wqflask/utility/Plot.py +++ b/wqflask/utility/Plot.py @@ -319,7 +319,7 @@ def colorSpectrum(n=100): ImageColor.getrgb("rgb(0%,100%,0%)"), ImageColor.getrgb("rgb(0%,0%,100%)")] N = n * multiple - out = [None] * N; + out = [None] * N for i in range(N): x = float(i) / N out[i] = ImageColor.getrgb("rgb({}%,{}%,{}%".format( diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index 263c3948..d82e478d 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -198,7 +198,8 @@ def locate(name, subdir=None): return lookfor else: raise Exception("Can not locate " + lookfor) - if subdir: sys.stderr.write(subdir) + if subdir: + sys.stderr.write(subdir) raise Exception("Can not locate " + name + " in " + base) diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py index cde822e8..8d0134d8 100644 --- a/wqflask/wqflask/marker_regression/display_mapping_results.py +++ b/wqflask/wqflask/marker_regression/display_mapping_results.py @@ -1343,13 +1343,13 @@ class DisplayMappingResults: (float(txEnd) - startMb) # at least one pixel if (geneEndPix < xLeftOffset): - return; # this gene is not on the screen + return # this gene is not on the screen elif (geneEndPix > xLeftOffset + plotWidth): - geneEndPix = xLeftOffset + plotWidth; # clip the last in-range gene + geneEndPix = xLeftOffset + plotWidth # clip the last in-range gene if (geneStartPix > xLeftOffset + plotWidth): - return; # we are outside the valid on-screen range, so stop drawing genes + return # we are outside the valid on-screen range, so stop drawing genes elif (geneStartPix < xLeftOffset): - geneStartPix = xLeftOffset; # clip the first in-range gene + geneStartPix = xLeftOffset # clip the first in-range gene # color the gene based on SNP density # found earlier, needs to be recomputed as snps are added @@ -1397,13 +1397,13 @@ class DisplayMappingResults: (float(txEnd) - startMb) # at least one pixel if (geneEndPix < xLeftOffset): - return; # this gene is not on the screen + return # this gene is not on the screen elif (geneEndPix > xLeftOffset + plotWidth): - geneEndPix = xLeftOffset + plotWidth; # clip the last in-range gene + geneEndPix = xLeftOffset + plotWidth # clip the last in-range gene if (geneStartPix > xLeftOffset + plotWidth): - return; # we are outside the valid on-screen range, so stop drawing genes + return # we are outside the valid on-screen range, so stop drawing genes elif (geneStartPix < xLeftOffset): - geneStartPix = xLeftOffset; # clip the first in-range gene + geneStartPix = xLeftOffset # clip the first in-range gene outlineColor = DARKBLUE fillColor = DARKBLUE @@ -1603,9 +1603,9 @@ class DisplayMappingResults: drawit = 1 if (geneStartPix < xLeftOffset): - drawit = 0; + drawit = 0 if (geneStartPix > xLeftOffset + plotWidth): - drawit = 0; + drawit = 0 if drawit == 1: if _chr[i].name != " - ": @@ -1755,7 +1755,7 @@ class DisplayMappingResults: geneYLocation + 17 + 2*maxind*self.EACH_GENE_HEIGHT*zoom), fill=BLACK, angle=-90) - oldgeneEndPix = geneEndPix; + oldgeneEndPix = geneEndPix oldgeno = _chr[j].genotype firstGene = 0 else: @@ -3208,5 +3208,6 @@ class DisplayMappingResults: if lCorr: lCorr = lCorr[0] break - except: raise # lCorr = None + except: + raise # lCorr = None return lCorr diff --git a/wqflask/wqflask/marker_regression/rqtl_mapping.py b/wqflask/wqflask/marker_regression/rqtl_mapping.py index c2b165a4..741d6c23 100644 --- a/wqflask/wqflask/marker_regression/rqtl_mapping.py +++ b/wqflask/wqflask/marker_regression/rqtl_mapping.py @@ -19,24 +19,24 @@ logger = utility.logger.getLogger(__name__) def get_trait_data_type(trait_db_string): - logger.info("get_trait_data_type"); + logger.info("get_trait_data_type") the_query = "SELECT value FROM TraitMetadata WHERE type='trait_data_type'" - logger.info("the_query done"); + logger.info("the_query done") results_json = g.db.execute(the_query).fetchone() - logger.info("the_query executed"); + logger.info("the_query executed") results_ob = json.loads(results_json[0]) - logger.info("json results loaded"); + logger.info("json results loaded") if trait_db_string in results_ob: - logger.info("found"); + logger.info("found") return results_ob[trait_db_string] else: - logger.info("not found"); + logger.info("not found") return "numeric" # Run qtl mapping using R/qtl def run_rqtl_geno(vals, samples, dataset, mapping_scale, method, model, permCheck, num_perm, perm_strata_list, do_control, control_marker, manhattan_plot, pair_scan, cofactors): - logger.info("Start run_rqtl_geno"); + logger.info("Start run_rqtl_geno") # Get pointers to some common R functions r_library = ro.r["library"] # Map the library function r_c = ro.r["c"] # Map the c function @@ -46,7 +46,7 @@ def run_rqtl_geno(vals, samples, dataset, mapping_scale, method, model, permChec print((r_library("qtl"))) # Load R/qtl - logger.info("QTL library loaded"); + logger.info("QTL library loaded") # Get pointers to some R/qtl functions scanone = ro.r["scanone"] # Map the scanone function @@ -75,29 +75,29 @@ def run_rqtl_geno(vals, samples, dataset, mapping_scale, method, model, permChec genofilelocation = locate(dataset.group.genofile, "genotype") else: genofilelocation = locate(dataset.group.name + ".geno", "genotype") - logger.info("Going to create a cross from geno"); + logger.info("Going to create a cross from geno") # TODO: Add the SEX if that is available cross_object = GENOtoCSVR(genofilelocation, crossfilelocation) - logger.info("before calc_genoprob"); + logger.info("before calc_genoprob") if manhattan_plot: cross_object = calc_genoprob(cross_object) else: cross_object = calc_genoprob(cross_object, step=5, stepwidth="max") - logger.info("after calc_genoprob"); + logger.info("after calc_genoprob") pheno_string = sanitize_rqtl_phenotype(vals) - logger.info("phenostring done"); + logger.info("phenostring done") names_string = sanitize_rqtl_names(samples) - logger.info("sanitized pheno and names"); + logger.info("sanitized pheno and names") # Add the phenotype cross_object = add_phenotype(cross_object, pheno_string, "the_pheno") # Add the phenotype cross_object = add_names(cross_object, names_string, "the_names") - logger.info("Added pheno and names"); + logger.info("Added pheno and names") # Create the additive covariate markers marker_covars = create_marker_covariates(control_marker, cross_object) - logger.info("Marker covars done"); + logger.info("Marker covars done") if cofactors != "": - logger.info("Cofactors: " + cofactors); + logger.info("Cofactors: " + cofactors) # Create the covariates from selected traits cross_object, trait_covars = add_cofactors( cross_object, dataset, cofactors, samples) @@ -108,10 +108,12 @@ def run_rqtl_geno(vals, samples, dataset, mapping_scale, method, model, permChec # DEBUG to save the session object to file if pair_scan: if do_control == "true": - logger.info("Using covariate"); result_data_frame = scantwo( + logger.info("Using covariate") + result_data_frame = scantwo( cross_object, pheno="the_pheno", addcovar=covars, model=model, method=method, n_cluster = 16) else: - logger.info("No covariates"); result_data_frame = scantwo( + logger.info("No covariates") + result_data_frame = scantwo( cross_object, pheno="the_pheno", model=model, method=method, n_cluster=16) pair_scan_filename = webqtlUtil.genRandStr("scantwo_") + ".png" @@ -122,11 +124,13 @@ def run_rqtl_geno(vals, samples, dataset, mapping_scale, method, model, permChec return process_pair_scan_results(result_data_frame) else: if do_control == "true" or cofactors != "": - logger.info("Using covariate"); result_data_frame = scanone( + logger.info("Using covariate") + result_data_frame = scanone( cross_object, pheno="the_pheno", addcovar=covars, model=model, method=method) ro.r('save.image(file = "/home/zas1024/gn2-zach/itp_cofactor_test.RData")') else: - logger.info("No covariates"); result_data_frame = scanone( + logger.info("No covariates") + result_data_frame = scanone( cross_object, pheno="the_pheno", model=model, method=method) # Do permutation (if requested by user) @@ -275,18 +279,18 @@ def add_phenotype(cross, pheno_as_string, col_name): def add_categorical_covar(cross, covar_as_string, i): ro.globalenv["the_cross"] = cross - logger.info("cross set"); + logger.info("cross set") ro.r('covar <- as.factor(' + covar_as_string + ')') - logger.info("covar set"); + logger.info("covar set") ro.r('newcovar <- model.matrix(~covar-1)') - logger.info("model.matrix finished"); + logger.info("model.matrix finished") ro.r('cat("new covar columns", ncol(newcovar), "\n")') nCol = ro.r('ncol(newcovar)') - logger.info("ncol covar done: " + str(nCol[0])); + logger.info("ncol covar done: " + str(nCol[0])) ro.r('pheno <- data.frame(pull.pheno(the_cross))') - logger.info("pheno pulled from cross"); + logger.info("pheno pulled from cross") nCol = int(nCol[0]) - logger.info("nCol python int:" + str(nCol)); + logger.info("nCol python int:" + str(nCol)) col_names = [] # logger.info("loop") for x in range(1, (nCol + 1)): @@ -298,7 +302,7 @@ def add_categorical_covar(cross, covar_as_string, i): col_names.append(col_name) #logger.info("loop" + str(x) + "done"); - logger.info("returning from add_categorical_covar"); + logger.info("returning from add_categorical_covar") return ro.r["the_cross"], col_names @@ -323,7 +327,7 @@ def add_cofactors(cross, this_dataset, covariates, samples): covariate_list = covariates.split(",") covar_name_string = "c(" for i, covariate in enumerate(covariate_list): - logger.info("Covariate: " + covariate); + logger.info("Covariate: " + covariate) this_covar_data = [] covar_as_string = "c(" trait_name = covariate.split(":")[0] @@ -352,12 +356,12 @@ def add_cofactors(cross, this_dataset, covariates, samples): covar_as_string += ")" datatype = get_trait_data_type(covariate) - logger.info("Covariate: " + covariate + " is of type: " + datatype); + logger.info("Covariate: " + covariate + " is of type: " + datatype) if(datatype == "categorical"): # Cat variable - logger.info("call of add_categorical_covar"); + logger.info("call of add_categorical_covar") cross, col_names = add_categorical_covar( cross, covar_as_string, i) # Expand and add it to the cross - logger.info("add_categorical_covar returned"); + logger.info("add_categorical_covar returned") # Go through the additional covar names for z, col_name in enumerate(col_names): if i < (len(covariate_list) - 1): diff --git a/wqflask/wqflask/snp_browser/snp_browser.py b/wqflask/wqflask/snp_browser/snp_browser.py index 7fcbe984..e98cfb71 100644 --- a/wqflask/wqflask/snp_browser/snp_browser.py +++ b/wqflask/wqflask/snp_browser/snp_browser.py @@ -673,13 +673,13 @@ def get_browser_sample_lists(species_id=1): strain_lists = {} mouse_strain_list = [] query = "SHOW COLUMNS FROM SnpPattern;" - results = g.db.execute(query).fetchall(); + results = g.db.execute(query).fetchall() for result in results[1:]: mouse_strain_list.append(result[0]) rat_strain_list = [] query = "SHOW COLUMNS FROM RatSnpPattern;" - results = g.db.execute(query).fetchall(); + results = g.db.execute(query).fetchall() for result in results[2:]: rat_strain_list.append(result[0]) diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py index 5610833b..9ebec405 100644 --- a/wqflask/wqflask/user_manager.py +++ b/wqflask/wqflask/user_manager.py @@ -765,10 +765,10 @@ class LoginUser: user = None valid = None if user_details: - user = model.User(); + user = model.User() for key in user_details: user.__dict__[key] = user_details[key] - valid = False; + valid = False submitted_password = params['password'] pwfields = Struct(json.loads(user.password)) |