aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base
diff options
context:
space:
mode:
authorZachary Sloan2014-02-28 00:02:13 +0000
committerZachary Sloan2014-02-28 00:02:13 +0000
commitf29bfd7bb55b542c864cbada92eebf2454fa9aac (patch)
tree3864cb83dd3981b64a234afb9049ba583c7a6c31 /wqflask/base
parentdd6e828ca3b205fefcae833aec53139961f9575f (diff)
downloadgenenetwork2-f29bfd7bb55b542c864cbada92eebf2454fa9aac.tar.gz
Made some changes/comments to Lei's load_genotypes.py file
Diffstat (limited to 'wqflask/base')
-rw-r--r--wqflask/base/trait_collection.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/wqflask/base/trait_collection.py b/wqflask/base/trait_collection.py
index 797a4d63..49b0eaea 100644
--- a/wqflask/base/trait_collection.py
+++ b/wqflask/base/trait_collection.py
@@ -22,6 +22,45 @@ from sqlalchemy import (Column, Integer, String, Table, ForeignKey, Unicode, Boo
Text, Index)
from sqlalchemy.orm import relationship, backref
+#from redis import StrictRedis
+import redis
+Redis = redis.StrictRedis()
+
from wqflask.database import Base, init_db
class TraitCollection(object):
+
+
+class AnonCollection(TraitCollection):
+
+ def __init__(self, anon_id)
+ self.anon_id = anon_id
+ self.collection_members = Redis.smembers(self.anon_id)
+ print("self.collection_members is:", self.collection_members)
+ self.num_members = len(self.collection_members)
+
+
+ @app.route("/collections/remove", methods=('POST',))
+ def remove_traits(traits_to_remove):
+ print("traits_to_remove:", traits_to_remove)
+ for trait in traits_to_remove:
+ Redis.srem(self.anon_id, trait)
+ members_now = self.collection_members - traits_to_remove
+ print("members_now:", members_now)
+ print("Went from {} to {} members in set.".format(len(self.collection_members), len(members_now)))
+
+ # We need to return something so we'll return this...maybe in the future
+ # we can use it to check the results
+ return str(len(members_now))
+
+ @property
+ def num_members(self):
+ print("members are:", json.loads(self.members))
+ return len(json.loads(self.members))
+
+ #@property
+ #def display_num_members(self):
+ # return display_collapsible(self.num_members)
+
+ def members_as_set(self):
+ return set(json.loads(self.members)) \ No newline at end of file