diff options
author | Pjotr Prins | 2016-10-15 10:12:52 +0000 |
---|---|---|
committer | Pjotr Prins | 2016-10-15 10:12:52 +0000 |
commit | a734338acd10c015e35da9574c8ef0b9dee68704 (patch) | |
tree | 91010fe34f473e203d866d4bfd522f583c33c192 | |
parent | 8de38e6b79cde5b1ab52b3ae14f3a736f365e555 (diff) | |
download | genenetwork2-a734338acd10c015e35da9574c8ef0b9dee68704.tar.gz |
Remove all spacing introduced by merge
-rw-r--r-- | wqflask/wqflask/collect.py | 38 | ||||
-rw-r--r-- | wqflask/wqflask/marker_regression/plink_mapping.py | 25 | ||||
-rw-r--r-- | wqflask/wqflask/marker_regression/qtlreaper_mapping.py | 2 | ||||
-rw-r--r-- | wqflask/wqflask/marker_regression/rqtl_mapping.py | 8 |
4 files changed, 32 insertions, 41 deletions
diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index bf465cdc..70ae2a1c 100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -52,10 +52,10 @@ class AnonCollection(object): self.id = None self.created_timestamp = datetime.datetime.utcnow().strftime('%b %d %Y %I:%M%p') self.changed_timestamp = self.created_timestamp #ZS: will be updated when changes are made - + #ZS: Find id and set it if the collection doesn't already exist if Redis.get(self.key) == "None" or Redis.get(self.key) == None: - Redis.set(self.key, None) #ZS: For some reason I get the error "Operation against a key holding the wrong kind of value" if I don't do this + Redis.set(self.key, None) #ZS: For some reason I get the error "Operation against a key holding the wrong kind of value" if I don't do this else: collections_list = json.loads(Redis.get(self.key)) collection_position = 0 #ZS: Position of collection in collection_list, if it exists @@ -66,10 +66,10 @@ class AnonCollection(object): collection_exists = True self.id = collection['id'] break - + if self.id == None: self.id = str(uuid.uuid4()) - + def get_members(self): traits = [] collections_list = json.loads(Redis.get(self.key)) @@ -77,16 +77,16 @@ class AnonCollection(object): if collection['id'] == self.id: traits = collection['members'] return traits - + @property def num_members(self): - num_members = 0 + num_members = 0 collections_list = json.loads(Redis.get(self.key)) for collection in collections_list: if collection['id'] == self.id: num_members = collection['num_members'] return num_members - + def add_traits(self, params): #assert collection_name == "Default", "Unexpected collection name for anonymous user" self.traits = list(process_traits(params['traits'])) @@ -123,7 +123,7 @@ class AnonCollection(object): "num_members" : len(self.traits), "members" : self.traits} collections_list.append(collection_dict) - + Redis.set(self.key, json.dumps(collections_list)) #Redis.sadd(self.key, *list(traits)) #Redis.expire(self.key, 60 * 60 * 24 * 5) @@ -170,14 +170,14 @@ class UserCollection(object): len_before = len(members) traits = process_traits(params['traits']) - + members_now = members for trait in traits: if trait in members: continue else: members_now.append(trait) - + #members_now = list(members | traits) len_now = len(members_now) uc.members = json.dumps(members_now) @@ -204,7 +204,7 @@ def process_traits(unprocessed_traits): assert hmac==user_manager.actual_hmac_creation(data), "Data tampering?" traits.add (str(data)) return traits - + def report_change(len_before, len_now): new_length = len_now - len_before if new_length: @@ -240,7 +240,7 @@ def collections_add(): @app.route("/collections/new") def collections_new(): params = request.args - + if "sign_in" in params: return redirect(url_for('login')) @@ -262,10 +262,10 @@ def collections_new(): def create_new(collection_name): params = request.args - + unprocessed_traits = params['traits'] traits = process_traits(unprocessed_traits) - + if g.user_session.logged_in: uc = model.UserCollection() uc.name = collection_name @@ -278,7 +278,7 @@ def create_new(collection_name): else: current_collections = user_manager.AnonUser().get_collections() ac = AnonCollection(collection_name) - ac.changed_timestamp = datetime.datetime.utcnow().strftime('%b %d %Y %I:%M%p') + ac.changed_timestamp = datetime.datetime.utcnow().strftime('%b %d %Y %I:%M%p') ac.add_traits(params) return redirect(url_for('view_collection', collection_id=ac.id)) @@ -343,7 +343,7 @@ def delete_collection(): else: collection_name = params['collection_name'] user_manager.AnonUser().delete_collection(collection_name) - + flash("We've deleted the collection: {}.".format(collection_name), "alert-info") return redirect(url_for('list_collections')) @@ -367,15 +367,15 @@ def view_collection(): break #this_collection = user_collections[params['collection_id']] traits = this_collection['members'] - + print("in view_collection traits are:", traits) trait_obs = [] json_version = [] for atrait in traits: - name, dataset_name = atrait.split(':') - + name, dataset_name = atrait.split(':') + trait_ob = trait.GeneralTrait(name=name, dataset_name=dataset_name) trait_ob.retrieve_info(get_qtl_info=True) trait_obs.append(trait_ob) diff --git a/wqflask/wqflask/marker_regression/plink_mapping.py b/wqflask/wqflask/marker_regression/plink_mapping.py index c80dc700..b457b9a0 100644 --- a/wqflask/wqflask/marker_regression/plink_mapping.py +++ b/wqflask/wqflask/marker_regression/plink_mapping.py @@ -13,16 +13,10 @@ def run_plink(this_trait, dataset, species, vals, maf): gen_pheno_txt_file_plink(this_trait, dataset, vals, pheno_filename = plink_output_filename) - plink_command = PLINK_COMMAND + ' --noweb --ped %s/%s.ped --no-fid --no-parents --no-sex --no-pheno --map %s/%s.map --pheno %s%s.txt --pheno-name %s --maf %s --missing-phenotype -9999 --out %s%s --assoc ' % (PLINK_PATH, - dataset.group.name, - PLINK_PATH, - dataset.group.name, - TMPDIR, - plink_output_filename, - this_trait.name, - maf, - TMPDIR, - plink_output_filename) + plink_command = PLINK_COMMAND + ' --noweb --ped %s/%s.ped --no-fid --no-parents --no-sex --no-pheno --map %s/%s.map --pheno %s%s.txt --pheno-name %s --maf %s --missing-phenotype -9999 --out %s%s --assoc ' % ( + PLINK_PATH, dataset.group.name, PLINK_PATH, dataset.group.name, + TMPDIR, plink_output_filename, this_trait.name, maf, TMPDIR, + plink_output_filename) logger.debug("plink_command:", plink_command) os.system(plink_command) @@ -36,7 +30,6 @@ def run_plink(this_trait, dataset, species, vals, maf): # #del self.dataset.group.markers.markers[marker] logger.debug("p_values:", pf(p_values)) - dataset.group.markers.add_pvalues(p_values) return dataset.group.markers.markers @@ -74,8 +67,8 @@ def gen_pheno_txt_file_plink(this_trait, dataset, vals, pheno_filename = ''): if new_line: output_file.write(new_line) - output_file.close() - + output_file.close() + # get strain name from ped file in order def get_samples_from_ped_file(dataset): ped_file= open("{}/{}.ped".format(PLINK_PATH, dataset.group.name),"r") @@ -92,7 +85,7 @@ def get_samples_from_ped_file(dataset): line = ped_file.readline() return sample_list - + def parse_plink_output(output_filename, species): plink_results={} @@ -154,7 +147,7 @@ def parse_plink_output(output_filename, species): # min_p_value = 0 return count, p_value_dict - + ###################################################### # input: line: str,one line read from file # function: convert line from str to list; @@ -165,4 +158,4 @@ def build_line_list(line=None): line_list = [item for item in line_list if item <>''] line_list = map(string.strip, line_list) - return line_list
\ No newline at end of file + return line_list diff --git a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py index b072584c..50228b5e 100644 --- a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py +++ b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py @@ -88,6 +88,4 @@ def gen_reaper_results(this_trait, dataset, samples_before, json_data, num_perm, qtl = {"lrs_value": qtl.lrs, "chr":converted_chr, "Mb":reaper_locus.Mb, "cM":reaper_locus.cM, "name":reaper_locus.name, "additive":qtl.additive, "dominance":qtl.dominance} qtl_results.append(qtl) - - return qtl_results, json_data, perm_output, suggestive, significant, bootstrap_results diff --git a/wqflask/wqflask/marker_regression/rqtl_mapping.py b/wqflask/wqflask/marker_regression/rqtl_mapping.py index afd28563..f3694f0b 100644 --- a/wqflask/wqflask/marker_regression/rqtl_mapping.py +++ b/wqflask/wqflask/marker_regression/rqtl_mapping.py @@ -108,7 +108,7 @@ def geno_to_rqtl_function(dataset): # TODO: Need to figure out why some g return(cross) } """ % (dataset.group.name + ".geno")) - + def add_phenotype(cross, pheno_as_string): ro.globalenv["the_cross"] = cross ro.r('the_cross$pheno <- cbind(pull.pheno(the_cross), the_pheno = '+ pheno_as_string +')') @@ -172,7 +172,7 @@ def process_rqtl_perm_results(num_perm, results): significant = np.percentile(np.array(perm_vals), 95) return perm_output, suggestive, significant - + def process_rqtl_results(result): # TODO: how to make this a one liner and not copy the stuff in a loop qtl_results = [] @@ -187,5 +187,5 @@ def process_rqtl_results(result): # TODO: how to make this a one liner an marker['lod_score'] = output[i][2] qtl_results.append(marker) - return qtl_results -
\ No newline at end of file + return qtl_results + |