diff delete_organism.py @ 5:7610987e0c48 draft

planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
author eric-rasche
date Wed, 01 Mar 2017 22:39:58 -0500
parents
children f9a6e151b3b4
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/delete_organism.py	Wed Mar 01 22:39:58 2017 -0500
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+import argparse
+from webapollo import WebApolloInstance
+from webapollo import WAAuth, OrgOrGuess, GuessOrg, AssertUser
+import logging
+logging.basicConfig(level=logging.INFO)
+log = logging.getLogger(__name__)
+
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser(description='Sample script to completely delete an organism')
+    WAAuth(parser)
+    parser.add_argument('email', help='User Email')
+    OrgOrGuess(parser)
+
+    args = parser.parse_args()
+
+    wa = WebApolloInstance(args.apollo, args.username, args.password)
+    # User must have an account
+    gx_user = AssertUser(wa.users.loadUsers(email=args.email))
+
+    # Get organism
+    org_cn = GuessOrg(args, wa)
+    if isinstance(org_cn, list):
+        org_cn = org_cn[0]
+
+    # TODO: Check user perms on org.
+    org = wa.organisms.findOrganismByCn(org_cn)
+
+    # Call setSequence to tell apollo which organism we're working with
+    wa.annotations.setSequence(org['commonName'], org['id'])
+    # Then get a list of features.
+    features = wa.annotations.getFeatures()
+    # For each feature in the features
+    for feature in features['features']:
+        # We see that deleteFeatures wants a uniqueName, and so we pass
+        # is the uniquename field in the feature.
+        print(wa.annotations.deleteFeatures([feature['uniquename']]))
+