annotate webapollo.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 d4ae83dedb14
children f9a6e151b3b4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1 import requests
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
2 import json
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
3 import os
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
4 import collections
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
5 try:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
6 import StringIO as io
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
7 except:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
8 import io
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
9 import logging
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
10 import time
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
11 import argparse
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
12 from abc import abstractmethod
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
13 from BCBio import GFF
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
14 from Bio import SeqIO
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
15 logging.getLogger("requests").setLevel(logging.CRITICAL)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
16 log = logging.getLogger()
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
17
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
18
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
19 #############################################
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
20 ###### BEGIN IMPORT OF CACHING LIBRARY ######
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
21 #############################################
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
22 # This code is licensed under the MIT #
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
23 # License and is a copy of code publicly #
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
24 # available in rev. #
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
25 # e27332bc82f4e327aedaec17c9b656ae719322ed #
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
26 # of https://github.com/tkem/cachetools/ #
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
27 #############################################
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
28 class DefaultMapping(collections.MutableMapping):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
29
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
30 __slots__ = ()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
31
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
32 @abstractmethod
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
33 def __contains__(self, key): # pragma: nocover
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
34 return False
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
35
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
36 @abstractmethod
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
37 def __getitem__(self, key): # pragma: nocover
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
38 if hasattr(self.__class__, '__missing__'):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
39 return self.__class__.__missing__(self, key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
40 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
41 raise KeyError(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
42
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
43 def get(self, key, default=None):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
44 if key in self:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
45 return self[key]
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
46 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
47 return default
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
48
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
49 __marker = object()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
50
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
51 def pop(self, key, default=__marker):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
52 if key in self:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
53 value = self[key]
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
54 del self[key]
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
55 elif default is self.__marker:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
56 raise KeyError(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
57 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
58 value = default
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
59 return value
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
60
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
61 def setdefault(self, key, default=None):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
62 if key in self:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
63 value = self[key]
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
64 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
65 self[key] = value = default
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
66 return value
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
67
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
68 DefaultMapping.register(dict)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
69
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
70
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
71 class _DefaultSize(object):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
72 def __getitem__(self, _):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
73 return 1
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
74
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
75 def __setitem__(self, _, value):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
76 assert value == 1
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
77
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
78 def pop(self, _):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
79 return 1
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
80
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
81
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
82 class Cache(DefaultMapping):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
83 """Mutable mapping to serve as a simple cache or cache base class."""
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
84
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
85 __size = _DefaultSize()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
86
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
87 def __init__(self, maxsize, missing=None, getsizeof=None):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
88 if missing:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
89 self.__missing = missing
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
90 if getsizeof:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
91 self.__getsizeof = getsizeof
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
92 self.__size = dict()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
93 self.__data = dict()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
94 self.__currsize = 0
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
95 self.__maxsize = maxsize
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
96
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
97 def __repr__(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
98 return '%s(%r, maxsize=%r, currsize=%r)' % (
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
99 self.__class__.__name__,
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
100 list(self.__data.items()),
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
101 self.__maxsize,
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
102 self.__currsize,
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
103 )
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
104
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
105 def __getitem__(self, key):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
106 try:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
107 return self.__data[key]
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
108 except KeyError:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
109 return self.__missing__(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
110
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
111 def __setitem__(self, key, value):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
112 maxsize = self.__maxsize
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
113 size = self.getsizeof(value)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
114 if size > maxsize:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
115 raise ValueError('value too large')
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
116 if key not in self.__data or self.__size[key] < size:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
117 while self.__currsize + size > maxsize:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
118 self.popitem()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
119 if key in self.__data:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
120 diffsize = size - self.__size[key]
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
121 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
122 diffsize = size
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
123 self.__data[key] = value
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
124 self.__size[key] = size
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
125 self.__currsize += diffsize
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
126
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
127 def __delitem__(self, key):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
128 size = self.__size.pop(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
129 del self.__data[key]
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
130 self.__currsize -= size
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
131
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
132 def __contains__(self, key):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
133 return key in self.__data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
134
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
135 def __missing__(self, key):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
136 value = self.__missing(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
137 try:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
138 self.__setitem__(key, value)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
139 except ValueError:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
140 pass # value too large
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
141 return value
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
142
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
143 def __iter__(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
144 return iter(self.__data)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
145
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
146 def __len__(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
147 return len(self.__data)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
148
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
149 @staticmethod
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
150 def __getsizeof(value):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
151 return 1
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
152
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
153 @staticmethod
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
154 def __missing(key):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
155 raise KeyError(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
156
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
157 @property
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
158 def maxsize(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
159 """The maximum size of the cache."""
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
160 return self.__maxsize
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
161
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
162 @property
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
163 def currsize(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
164 """The current size of the cache."""
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
165 return self.__currsize
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
166
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
167 def getsizeof(self, value):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
168 """Return the size of a cache element's value."""
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
169 return self.__getsizeof(value)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
170
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
171
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
172 class _Link(object):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
173
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
174 __slots__ = ('key', 'expire', 'next', 'prev')
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
175
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
176 def __init__(self, key=None, expire=None):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
177 self.key = key
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
178 self.expire = expire
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
179
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
180 def __reduce__(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
181 return _Link, (self.key, self.expire)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
182
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
183 def unlink(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
184 next = self.next
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
185 prev = self.prev
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
186 prev.next = next
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
187 next.prev = prev
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
188
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
189
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
190 class _Timer(object):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
191
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
192 def __init__(self, timer):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
193 self.__timer = timer
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
194 self.__nesting = 0
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
195
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
196 def __call__(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
197 if self.__nesting == 0:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
198 return self.__timer()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
199 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
200 return self.__time
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
201
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
202 def __enter__(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
203 if self.__nesting == 0:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
204 self.__time = time = self.__timer()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
205 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
206 time = self.__time
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
207 self.__nesting += 1
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
208 return time
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
209
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
210 def __exit__(self, *exc):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
211 self.__nesting -= 1
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
212
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
213 def __reduce__(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
214 return _Timer, (self.__timer,)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
215
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
216 def __getattr__(self, name):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
217 return getattr(self.__timer, name)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
218
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
219
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
220 class TTLCache(Cache):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
221 """LRU Cache implementation with per-item time-to-live (TTL) value."""
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
222
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
223 def __init__(self, maxsize, ttl, timer=time.time, missing=None,
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
224 getsizeof=None):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
225 Cache.__init__(self, maxsize, missing, getsizeof)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
226 self.__root = root = _Link()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
227 root.prev = root.next = root
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
228 self.__links = collections.OrderedDict()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
229 self.__timer = _Timer(timer)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
230 self.__ttl = ttl
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
231
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
232 def __contains__(self, key):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
233 try:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
234 link = self.__links[key] # no reordering
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
235 except KeyError:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
236 return False
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
237 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
238 return not (link.expire < self.__timer())
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
239
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
240 def __getitem__(self, key, cache_getitem=Cache.__getitem__):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
241 try:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
242 link = self.__getlink(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
243 except KeyError:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
244 expired = False
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
245 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
246 expired = link.expire < self.__timer()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
247 if expired:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
248 return self.__missing__(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
249 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
250 return cache_getitem(self, key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
251
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
252 def __setitem__(self, key, value, cache_setitem=Cache.__setitem__):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
253 with self.__timer as time:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
254 self.expire(time)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
255 cache_setitem(self, key, value)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
256 try:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
257 link = self.__getlink(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
258 except KeyError:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
259 self.__links[key] = link = _Link(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
260 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
261 link.unlink()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
262 link.expire = time + self.__ttl
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
263 link.next = root = self.__root
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
264 link.prev = prev = root.prev
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
265 prev.next = root.prev = link
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
266
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
267 def __delitem__(self, key, cache_delitem=Cache.__delitem__):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
268 cache_delitem(self, key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
269 link = self.__links.pop(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
270 link.unlink()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
271 if link.expire < self.__timer():
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
272 raise KeyError(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
273
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
274 def __iter__(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
275 root = self.__root
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
276 curr = root.next
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
277 while curr is not root:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
278 # "freeze" time for iterator access
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
279 with self.__timer as time:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
280 if not (curr.expire < time):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
281 yield curr.key
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
282 curr = curr.next
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
283
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
284 def __len__(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
285 root = self.__root
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
286 curr = root.next
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
287 time = self.__timer()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
288 count = len(self.__links)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
289 while curr is not root and curr.expire < time:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
290 count -= 1
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
291 curr = curr.next
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
292 return count
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
293
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
294 def __setstate__(self, state):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
295 self.__dict__.update(state)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
296 root = self.__root
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
297 root.prev = root.next = root
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
298 for link in sorted(self.__links.values(), key=lambda obj: obj.expire):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
299 link.next = root
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
300 link.prev = prev = root.prev
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
301 prev.next = root.prev = link
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
302 self.expire(self.__timer())
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
303
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
304 def __repr__(self, cache_repr=Cache.__repr__):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
305 with self.__timer as time:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
306 self.expire(time)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
307 return cache_repr(self)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
308
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
309 @property
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
310 def currsize(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
311 with self.__timer as time:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
312 self.expire(time)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
313 return super(TTLCache, self).currsize
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
314
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
315 @property
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
316 def timer(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
317 """The timer function used by the cache."""
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
318 return self.__timer
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
319
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
320 @property
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
321 def ttl(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
322 """The time-to-live value of the cache's items."""
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
323 return self.__ttl
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
324
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
325 def expire(self, time=None):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
326 """Remove expired items from the cache."""
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
327 if time is None:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
328 time = self.__timer()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
329 root = self.__root
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
330 curr = root.next
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
331 links = self.__links
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
332 cache_delitem = Cache.__delitem__
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
333 while curr is not root and curr.expire < time:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
334 cache_delitem(self, curr.key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
335 del links[curr.key]
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
336 next = curr.next
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
337 curr.unlink()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
338 curr = next
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
339
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
340 def clear(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
341 with self.__timer as time:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
342 self.expire(time)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
343 Cache.clear(self)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
344
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
345 def get(self, *args, **kwargs):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
346 with self.__timer:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
347 return Cache.get(self, *args, **kwargs)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
348
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
349 def pop(self, *args, **kwargs):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
350 with self.__timer:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
351 return Cache.pop(self, *args, **kwargs)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
352
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
353 def setdefault(self, *args, **kwargs):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
354 with self.__timer:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
355 return Cache.setdefault(self, *args, **kwargs)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
356
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
357 def popitem(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
358 """Remove and return the `(key, value)` pair least recently used that
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
359 has not already expired.
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
360
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
361 """
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
362 with self.__timer as time:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
363 self.expire(time)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
364 try:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
365 key = next(iter(self.__links))
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
366 except StopIteration:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
367 raise KeyError('%s is empty' % self.__class__.__name__)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
368 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
369 return (key, self.pop(key))
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
370
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
371 if hasattr(collections.OrderedDict, 'move_to_end'):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
372 def __getlink(self, key):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
373 value = self.__links[key]
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
374 self.__links.move_to_end(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
375 return value
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
376 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
377 def __getlink(self, key):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
378 value = self.__links.pop(key)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
379 self.__links[key] = value
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
380 return value
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
381
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
382
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
383 #############################################
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
384 ###### END IMPORT OF CACHING LIBRARY ######
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
385 #############################################
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
386
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
387 cache = TTLCache(
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
388 100, # Up to 100 items
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
389 5 * 60 # 5 minute cache life
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
390 )
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
391 userCache = TTLCache(
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
392 2, # Up to 2 items
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
393 60 # 1 minute cache life
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
394 )
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
395
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
396 class UnknownUserException(Exception):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
397 pass
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
398
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
399 def WAAuth(parser):
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
400 parser.add_argument('apollo', help='Complete Apollo URL')
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
401 parser.add_argument('username', help='WA Username')
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
402 parser.add_argument('password', help='WA Password')
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
403
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
404
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
405 def OrgOrGuess(parser):
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
406 parser.add_argument('--org_json', type=argparse.FileType("r"), help='Apollo JSON output, source for common name')
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
407 parser.add_argument('--org_raw', help='Common Name')
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
408 parser.add_argument('--org_id', help='Organism ID')
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
409
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
410
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
411 def CnOrGuess(parser):
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
412 OrgOrGuess(parser)
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
413 parser.add_argument('--seq_fasta', type=argparse.FileType("r"), help='Fasta file, IDs used as sequence sources')
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
414 parser.add_argument('--seq_raw', nargs='*', help='Sequence Names')
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
415
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
416
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
417 def GuessOrg(args, wa):
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
418 if args.org_json:
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
419 orgs = [x.get('commonName', None)
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
420 for x in json.load(args.org_json)]
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
421 orgs = [x for x in orgs if x is not None]
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
422 return orgs
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
423 elif args.org_raw:
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
424 org = args.org_raw.strip()
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
425 if len(org) > 0:
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
426 return [org]
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
427 else:
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
428 raise Exception("Organism Common Name not provided")
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
429 elif args.org_id:
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
430 return [wa.organisms.findOrganismById(args.org_id).get('commonName', None)]
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
431 else:
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
432 raise Exception("Organism Common Name not provided")
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
433
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
434
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
435 def GuessCn(args, wa):
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
436 org = GuessOrg(args, wa)
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
437 seqs = []
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
438 if args.seq_fasta:
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
439 # If we have a fasta, pull all rec ids from that.
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
440 for rec in SeqIO.parse(args.seq_fasta, 'fasta'):
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
441 seqs.append(rec.id)
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
442 elif args.seq_raw:
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
443 # Otherwise raw list.
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
444 seqs = [x.strip() for x in args.seq_raw if len(x.strip()) > 0]
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
445
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
446 return org, seqs
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
447
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
448
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
449 def AssertUser(user_list):
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
450 if len(user_list) == 0:
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
451 raise UnknownUserException()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
452 elif len(user_list) == 1:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
453 return user_list[0]
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
454 else:
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
455 raise Exception("Too many users!")
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
456
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
457
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
458 def AssertAdmin(user):
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
459 if user.role == 'ADMIN':
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
460 return True
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
461 else:
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
462 raise Exception("User is not an administrator. Permission denied")
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
463
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
464
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
465 class WebApolloInstance(object):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
466
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
467 def __init__(self, url, username, password):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
468 self.apollo_url = url
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
469 self.username = username
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
470 self.password = password
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
471 # TODO: Remove after apollo 2.0.6.
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
472 self.clientToken = time.time()
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
473
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
474 self.annotations = AnnotationsClient(self)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
475 self.groups = GroupsClient(self)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
476 self.io = IOClient(self)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
477 self.organisms = OrganismsClient(self)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
478 self.users = UsersClient(self)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
479 self.metrics = MetricsClient(self)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
480 self.bio = RemoteRecord(self)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
481
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
482 def __str__(self):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
483 return '<WebApolloInstance at %s>' % self.apollo_url
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
484
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
485 def requireUser(self, email):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
486 cacheKey = 'user-list'
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
487 try:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
488 # Get the cached value
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
489 data = userCache[cacheKey]
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
490 except KeyError:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
491 # If we hit a key error above, indicating that
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
492 # we couldn't find the key, we'll simply re-request
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
493 # the data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
494 data = self.users.loadUsers()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
495 userCache[cacheKey] = data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
496
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
497 return AssertUser([x for x in data if x.username == email])
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
498
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
499
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
500 class GroupObj(object):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
501 def __init__(self, **kwargs):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
502 self.name = kwargs['name']
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
503
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
504 if 'id' in kwargs:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
505 self.groupId = kwargs['id']
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
506
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
507
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
508 class UserObj(object):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
509 ROLE_USER = 'USER'
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
510 ROLE_ADMIN = 'ADMIN'
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
511
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
512 def __init__(self, **kwargs):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
513 # Generally expect 'userId', 'firstName', 'lastName', 'username' (email)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
514 for attr in kwargs.keys():
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
515 setattr(self, attr, kwargs[attr])
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
516
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
517 if 'groups' in kwargs:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
518 groups = []
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
519 for groupData in kwargs['groups']:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
520 groups.append(GroupObj(**groupData))
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
521 self.groups = groups
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
522
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
523 self.__props = kwargs.keys()
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
524
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
525 def isAdmin(self):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
526 if hasattr(self, 'role'):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
527 return self.role == self.ROLE_ADMIN
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
528 return False
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
529
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
530 def refresh(self, wa):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
531 # This method requires some sleeping usually.
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
532 newU = wa.users.loadUser(self).toDict()
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
533 for prop in newU:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
534 setattr(self, prop, newU[prop])
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
535
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
536 def toDict(self):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
537 data = {}
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
538 for prop in self.__props:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
539 data[prop] = getattr(self, prop)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
540 return data
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
541
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
542 def __str__(self):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
543 return '<User %s: %s %s <%s>>' % (self.userId, self.firstName,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
544 self.lastName, self.username)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
545
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
546
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
547 class Client(object):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
548
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
549 def __init__(self, webapolloinstance, **requestArgs):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
550 self._wa = webapolloinstance
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
551
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
552 self.__verify = requestArgs.get('verify', True)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
553 self._requestArgs = requestArgs
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
554
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
555 if 'verify' in self._requestArgs:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
556 del self._requestArgs['verify']
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
557
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
558 def request(self, clientMethod, data, post_params={}, isJson=True):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
559 url = self._wa.apollo_url + self.CLIENT_BASE + clientMethod
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
560
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
561 headers = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
562 'Content-Type': 'application/json'
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
563 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
564
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
565 data.update({
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
566 'username': self._wa.username,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
567 'password': self._wa.password,
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
568 'clientToken': self._wa.clientToken,
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
569 })
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
570
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
571 r = requests.post(url, data=json.dumps(data), headers=headers,
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
572 verify=self.__verify, params=post_params, allow_redirects=False, **self._requestArgs)
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
573
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
574 if r.status_code == 200 or r.status_code == 302:
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
575 if isJson:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
576 d = r.json()
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
577 if 'username' in d:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
578 del d['username']
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
579 if 'password' in d:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
580 del d['password']
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
581 return d
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
582 else:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
583 return r.text
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
584
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
585 # @see self.body for HTTP response body
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
586 raise Exception("Unexpected response from apollo %s: %s" %
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
587 (r.status_code, r.text))
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
588
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
589 def get(self, clientMethod, get_params):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
590 url = self._wa.apollo_url + self.CLIENT_BASE + clientMethod
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
591 headers = {}
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
592
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
593 r = requests.get(url, headers=headers, verify=self.__verify,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
594 params=get_params, **self._requestArgs)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
595 if r.status_code == 200:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
596 d = r.json()
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
597 if 'username' in d:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
598 del d['username']
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
599 if 'password' in d:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
600 del d['password']
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
601 return d
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
602 # @see self.body for HTTP response body
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
603 raise Exception("Unexpected response from apollo %s: %s" %
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
604 (r.status_code, r.text))
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
605
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
606
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
607 class MetricsClient(Client):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
608 CLIENT_BASE = '/metrics/'
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
609
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
610 def getServerMetrics(self):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
611 return self.get('metrics', {})
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
612
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
613
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
614 class AnnotationsClient(Client):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
615 CLIENT_BASE = '/annotationEditor/'
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
616
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
617 def _update_data(self, data):
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
618 if not hasattr(self, '_extra_data'):
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
619 raise Exception("Please call setSequence first")
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
620
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
621 data.update(self._extra_data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
622 return data
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
623
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
624 def setSequence(self, sequence, organism):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
625 self._extra_data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
626 'sequence': sequence,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
627 'organism': organism,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
628 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
629
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
630 def setDescription(self, featureDescriptions):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
631 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
632 'features': featureDescriptions,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
633 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
634 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
635 return self.request('setDescription', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
636
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
637 def setName(self, uniquename, name):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
638 # TODO
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
639 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
640 'features': [
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
641 {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
642 'uniquename': uniquename,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
643 'name': name,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
644 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
645 ],
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
646 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
647 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
648 return self.request('setName', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
649
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
650 def setNames(self, features):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
651 # TODO
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
652 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
653 'features': features,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
654 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
655 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
656 return self.request('setName', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
657
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
658 def setStatus(self, statuses):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
659 # TODO
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
660 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
661 'features': statuses,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
662 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
663 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
664 return self.request('setStatus', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
665
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
666 def setSymbol(self, symbols):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
667 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
668 'features': symbols,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
669 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
670 data.update(self._extra_data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
671 return self.request('setSymbol', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
672
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
673 def getComments(self, feature_id):
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
674 data = {
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
675 'features': [{'uniquename': feature_id}],
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
676 }
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
677 data = self._update_data(data)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
678 return self.request('getComments', data)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
679
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
680 def addComments(self, feature_id, comment):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
681 #TODO: This is probably not great and will delete comments, if I had to guess...
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
682 data = {
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
683 'features': [
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
684 {
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
685 'uniquename': feature_id,
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
686 'comments': [comment]
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
687 }
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
688 ],
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
689 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
690 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
691 return self.request('getComments', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
692
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
693 def addAttribute(self, features):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
694 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
695 'features': features,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
696 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
697 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
698 return self.request('addAttribute', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
699
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
700 def getFeatures(self):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
701 data = self._update_data({})
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
702 return self.request('getFeatures', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
703
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
704 def getSequence(self, uniquename):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
705 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
706 'features': [
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
707 {'uniquename': uniquename}
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
708 ]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
709 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
710 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
711 return self.request('getSequence', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
712
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
713 def addFeature(self, feature, trustme=False):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
714 if not trustme:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
715 raise NotImplementedError("Waiting on better docs from project. If you know what you are doing, pass trustme=True to this function.")
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
716
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
717 data = {
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
718 'features': feature,
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
719 }
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
720 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
721 return self.request('addFeature', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
722
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
723 def addTranscript(self, transcript, trustme=False):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
724 if not trustme:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
725 raise NotImplementedError("Waiting on better docs from project. If you know what you are doing, pass trustme=True to this function.")
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
726
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
727 data = {}
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
728 data.update(transcript)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
729 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
730 return self.request('addTranscript', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
731
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
732 # addExon, add/delete/updateComments, addTranscript skipped due to docs
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
733
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
734 def duplicateTranscript(self, transcriptId):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
735 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
736 'features': [{'uniquename': transcriptId}]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
737 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
738
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
739 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
740 return self.request('duplicateTranscript', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
741
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
742 def setTranslationStart(self, uniquename, start):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
743 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
744 'features': [{
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
745 'uniquename': uniquename,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
746 'location': {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
747 'fmin': start
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
748 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
749 }]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
750 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
751 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
752 return self.request('setTranslationStart', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
753
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
754 def setTranslationEnd(self, uniquename, end):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
755 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
756 'features': [{
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
757 'uniquename': uniquename,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
758 'location': {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
759 'fmax': end
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
760 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
761 }]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
762 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
763 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
764 return self.request('setTranslationEnd', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
765
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
766 def setLongestOrf(self, uniquename):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
767 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
768 'features': [{
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
769 'uniquename': uniquename,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
770 }]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
771 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
772 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
773 return self.request('setLongestOrf', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
774
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
775 def setBoundaries(self, uniquename, start, end):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
776 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
777 'features': [{
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
778 'uniquename': uniquename,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
779 'location': {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
780 'fmin': start,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
781 'fmax': end,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
782 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
783 }]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
784 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
785 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
786 return self.request('setBoundaries', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
787
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
788 def getSequenceAlterations(self):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
789 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
790 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
791 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
792 return self.request('getSequenceAlterations', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
793
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
794 def setReadthroughStopCodon(self, uniquename):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
795 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
796 'features': [{
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
797 'uniquename': uniquename,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
798 }]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
799 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
800 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
801 return self.request('setReadthroughStopCodon', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
802
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
803 def deleteSequenceAlteration(self, uniquename):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
804 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
805 'features': [{
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
806 'uniquename': uniquename,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
807 }]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
808 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
809 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
810 return self.request('deleteSequenceAlteration', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
811
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
812 def flipStrand(self, uniquenames):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
813 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
814 'features': [
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
815 {'uniquename': x} for x in uniquenames
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
816 ]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
817 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
818 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
819 return self.request('flipStrand', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
820
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
821 def mergeExons(self, exonA, exonB):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
822 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
823 'features': [
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
824 {'uniquename': exonA},
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
825 {'uniquename': exonB},
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
826 ]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
827 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
828 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
829 return self.request('mergeExons', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
830
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
831 # def splitExon(): pass
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
832
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
833 def deleteFeatures(self, uniquenames):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
834 assert isinstance(uniquenames, collections.Iterable)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
835 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
836 'features': [
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
837 {'uniquename': x} for x in uniquenames
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
838 ]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
839 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
840 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
841 return self.request('deleteFeature', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
842
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
843 # def deleteExon(): pass
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
844
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
845 # def makeIntron(self, uniquename, ): pass
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
846
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
847 def getSequenceSearchTools(self):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
848 return self.get('getSequenceSearchTools', {})
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
849
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
850 def getCannedComments(self):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
851 return self.get('getCannedComments', {})
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
852
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
853 def searchSequence(self, searchTool, sequence, database):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
854 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
855 'key': searchTool,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
856 'residues': sequence,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
857 'database_id': database,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
858 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
859 return self.request('searchSequences', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
860
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
861 def getGff3(self, uniquenames):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
862 assert isinstance(uniquenames, collections.Iterable)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
863 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
864 'features': [
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
865 {'uniquename': x} for x in uniquenames
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
866 ]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
867 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
868 data = self._update_data(data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
869 return self.request('getGff3', data, isJson=False)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
870
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
871
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
872 class GroupsClient(Client):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
873 CLIENT_BASE = '/group/'
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
874
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
875 def createGroup(self, name):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
876 data = {'name': name}
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
877 return self.request('createGroup', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
878
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
879 def getOrganismPermissionsForGroup(self, group):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
880 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
881 'id': group.groupId,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
882 'name': group.name,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
883 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
884 return self.request('getOrganismPermissionsForGroup', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
885
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
886 def loadGroup(self, group):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
887 return self.loadGroupById(group.groupId)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
888
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
889 def loadGroupById(self, groupId):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
890 res = self.request('loadGroups', {'groupId': groupId})
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
891 if isinstance(res, list):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
892 # We can only match one, right?
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
893 return GroupObj(**res[0])
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
894 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
895 return res
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
896
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
897 def loadGroupByName(self, name):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
898 res = self.request('loadGroups', {'name': name})
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
899 if isinstance(res, list):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
900 # We can only match one, right?
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
901 return GroupObj(**res[0])
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
902 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
903 return res
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
904
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
905 def loadGroups(self, group=None):
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
906 res = self.request('loadGroups', {})
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
907 data = [GroupObj(**x) for x in res]
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
908 if group is not None:
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
909 data = [x for x in data if x.name == group]
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
910
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
911 return data
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
912
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
913 def deleteGroup(self, group):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
914 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
915 'id': group.groupId,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
916 'name': group.name,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
917 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
918 return self.request('deleteGroup', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
919
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
920 def updateGroup(self, group, newName):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
921 # TODO: Sure would be nice if modifying ``group.name`` would invoke
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
922 # this?
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
923 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
924 'id': group.groupId,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
925 'name': newName,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
926 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
927 return self.request('updateGroup', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
928
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
929 def updateOrganismPermission(self, group, organismName,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
930 administrate=False, write=False, read=False,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
931 export=False):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
932 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
933 'groupId': group.groupId,
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
934 'organism': organismName,
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
935 'ADMINISTRATE': administrate,
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
936 'WRITE': write,
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
937 'EXPORT': export,
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
938 'READ': read,
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
939 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
940 return self.request('updateOrganismPermission', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
941
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
942 def updateMembership(self, group, users):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
943 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
944 'groupId': group.groupId,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
945 'user': [user.email for user in users]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
946 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
947 return self.request('updateMembership', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
948
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
949
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
950 class IOClient(Client):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
951 CLIENT_BASE = '/IOService/'
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
952
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
953 def write(self, exportType='FASTA', seqType='peptide',
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
954 exportFormat='text', sequences=None, organism=None,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
955 output='text', exportAllSequences=False,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
956 exportGff3Fasta=False):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
957 if exportType not in ('FASTA', 'GFF3'):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
958 raise Exception("exportType must be one of FASTA, GFF3")
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
959
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
960 if seqType not in ('peptide', 'cds', 'cdna', 'genomic'):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
961 raise Exception("seqType must be one of peptide, cds, dna, genomic")
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
962
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
963 if exportFormat not in ('gzip', 'text'):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
964 raise Exception("exportFormat must be one of gzip, text")
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
965
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
966 if output not in ('file', 'text'):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
967 raise Exception("output must be one of file, text")
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
968
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
969 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
970 'type': exportType,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
971 'seqType': seqType,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
972 'format': exportFormat,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
973 'sequences': sequences,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
974 'organism': organism,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
975 'output': output,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
976 'exportAllSequences': exportAllSequences,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
977 'exportGff3Fasta': exportGff3Fasta,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
978 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
979
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
980 return self.request('write', data, isJson=output == 'file')
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
981
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
982 def download(self, uuid, outputFormat='gzip'):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
983
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
984 if outputFormat.lower() not in ('gzip', 'text'):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
985 raise Exception("outputFormat must be one of file, text")
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
986
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
987 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
988 'format': outputFormat,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
989 'uuid': uuid,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
990 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
991 return self.request('write', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
992
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
993
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
994 class OrganismsClient(Client):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
995 CLIENT_BASE = '/organism/'
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
996
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
997 def addOrganism(self, commonName, directory, blatdb=None, species=None,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
998 genus=None, public=False):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
999 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1000 'commonName': commonName,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1001 'directory': directory,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1002 'publicMode': public,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1003 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1004
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1005 if blatdb is not None:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1006 data['blatdb'] = blatdb
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1007 if genus is not None:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1008 data['genus'] = genus
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1009 if species is not None:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1010 data['species'] = species
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1011
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1012 return self.request('addOrganism', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1013
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1014 def findAllOrganisms(self):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1015 return self.request('findAllOrganisms', {})
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1016
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1017 def findOrganismByCn(self, cn):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1018 orgs = self.findAllOrganisms()
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1019 orgs = [x for x in orgs if x['commonName'] == cn]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1020 if len(orgs) == 0:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1021 raise Exception("Unknown common name")
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1022 else:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1023 return orgs[0]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1024
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1025 def findOrganismById(self, id_number):
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1026 orgs = self.findAllOrganisms()
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1027 orgs = [x for x in orgs if str(x['id']) == str(id_number)]
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1028 if len(orgs) == 0:
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1029 raise Exception("Unknown ID")
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1030 else:
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1031 return orgs[0]
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1032
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1033 def deleteOrganism(self, organismId):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1034 return self.request('deleteOrganism', {'id': organismId})
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1035
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1036 def deleteOrganismFeatures(self, organismId):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1037 return self.request('deleteOrganismFeatures', {'id': organismId})
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1038
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1039 def getSequencesForOrganism(self, commonName):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1040 return self.request('getSequencesForOrganism', {'organism': commonName})
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1041
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1042 def updateOrganismInfo(self, organismId, commonName, directory, blatdb=None, species=None, genus=None, public=False):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1043 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1044 'id': organismId,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1045 'name': commonName,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1046 'directory': directory,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1047 'publicMode': public,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1048 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1049
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1050 if blatdb is not None:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1051 data['blatdb'] = blatdb
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1052 if genus is not None:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1053 data['genus'] = genus
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1054 if species is not None:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1055 data['species'] = species
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1056
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1057 return self.request('updateOrganismInfo', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1058
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1059
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1060 class UsersClient(Client):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1061 CLIENT_BASE = '/user/'
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1062
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1063 # Real one
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1064 # def getOrganismPermissionsForUser(self, user):
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1065 # data = {
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1066 # 'userId': user.userId,
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1067 # }
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1068 # return self.request('getOrganismPermissionsForUser', data)
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1069
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1070 # Utter frigging hack
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1071 def getOrganismPermissionsForUser(self, user):
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1072 return self.loadUser(user).organismPermissions
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1073
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1074 def updateOrganismPermission(self, user, organism, administrate=False,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1075 write=False, export=False, read=False):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1076 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1077 'userId': user.userId,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1078 'organism': organism,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1079 'ADMINISTRATE': administrate,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1080 'WRITE': write,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1081 'EXPORT': export,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1082 'READ': read,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1083 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1084 return self.request('updateOrganismPermission', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1085
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1086 def loadUser(self, user):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1087 return self.loadUserById(user.userId)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1088
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1089 def loadUserById(self, userId):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1090 res = self.request('loadUsers', {'userId': userId})
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1091 if isinstance(res, list):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1092 # We can only match one, right?
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1093 return UserObj(**res[0])
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1094 else:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1095 return res
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1096
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1097 def loadUsers(self, email=None):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1098 res = self.request('loadUsers', {})
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1099 data = [UserObj(**x) for x in res]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1100 if email is not None:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1101 data = [x for x in data if x.username == email]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1102
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1103 return data
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1104
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1105 def addUserToGroup(self, group, user):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1106 data = {'group': group.name, 'userId': user.userId}
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1107 return self.request('addUserToGroup', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1108
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1109 def removeUserFromGroup(self, group, user):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1110 data = {'group': group.name, 'userId': user.userId}
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1111 return self.request('removeUserFromGroup', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1112
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1113 def createUser(self, email, firstName, lastName, newPassword, role="user", groups=None):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1114 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1115 'firstName': firstName,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1116 'lastName': lastName,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1117 'email': email,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1118 'role': role,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1119 'groups': [] if groups is None else groups,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1120 # 'availableGroups': [],
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1121 'newPassword': newPassword,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1122 # 'organismPermissions': [],
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1123 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1124 return self.request('createUser', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1125
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1126 def deleteUser(self, user):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1127 return self.request('deleteUser', {'userId': user.userId})
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1128
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1129 def updateUser(self, user, email, firstName, lastName, newPassword):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1130 data = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1131 'userId': user.userId,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1132 'email': email,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1133 'firstName': firstName,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1134 'lastName': lastName,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1135 'newPassword': newPassword,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1136 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1137 return self.request('updateUser', data)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1138
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1139
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1140 class RemoteRecord(Client):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1141 CLIENT_BASE = None
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1142
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1143 def ParseRecord(self, cn):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1144 org = self._wa.organisms.findOrganismByCn(cn)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1145 self._wa.annotations.setSequence(org['commonName'], org['id'])
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1146
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1147 data = io.StringIO(self._wa.io.write(
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1148 exportType='GFF3',
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1149 seqType='genomic',
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1150 exportAllSequences=False,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1151 exportGff3Fasta=True,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1152 output="text",
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1153 exportFormat="text",
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1154 sequences=cn,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1155 ))
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1156 data.seek(0)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1157
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1158 for record in GFF.parse(data):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1159 yield WebApolloSeqRecord(record, self._wa)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1160
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1161
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1162 class WebApolloSeqRecord(object):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1163 def __init__(self, sr, wa):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1164 self._sr = sr
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1165 self._wa = wa
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1166
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1167 def __dir__(self):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1168 return dir(self._sr)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1169
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1170 def __getattr__(self, key):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1171 if key in ('_sr', '_wa'):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1172 return self.__dict__[key]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1173 else:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1174 if key == 'features':
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1175 return (WebApolloSeqFeature(x, self._wa)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1176 for x in self._sr.__dict__[key])
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1177 else:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1178 return self._sr.__dict__[key]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1179
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1180 def __setattr__(self, key, value):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1181 if key in ('_sd', '_wa'):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1182 self.__dict__[key] = value
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1183 else:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1184 self._sr.__dict__[key] = value
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1185 # Methods acting on the SeqRecord object
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1186
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1187
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1188 class WebApolloSeqFeature(object):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1189 def __init__(self, sf, wa):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1190 self._sf = sf
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1191 self._wa = wa
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1192
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1193 def __dir__(self):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1194 return dir(self._sf)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1195
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1196 def __getattr__(self, key):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1197 if key in ('_sf', '_wa'):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1198 return self.__dict__[key]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1199 else:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1200 return self._sf.__dict__[key]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1201
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1202 def __setattr__(self, key, value):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1203 if key in ('_sf', '_wa'):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1204 self.__dict__[key] = value
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1205 else:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1206 # Methods acting on the SeqFeature object
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1207 if key == 'location':
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1208 if value.strand != self._sf.location.strand:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1209 self.wa.annotations.flipStrand(
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1210 self._sf.qualifiers['ID'][0]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1211 )
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1212
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1213 self.wa.annotations.setBoundaries(
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1214 self._sf.qualifiers['ID'][0],
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1215 value.start,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1216 value.end,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1217 )
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1218
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1219 self._sf.__dict__[key] = value
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1220 else:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1221 self._sf.__dict__[key] = value
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1222
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1223
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1224 def _tnType(feature):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1225 if feature.type in ('gene', 'mRNA', 'exon', 'CDS'):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1226 return feature.type
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1227 else:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1228 return 'exon'
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1229
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1230
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1231 def _yieldFeatData(features):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1232 for f in features:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1233 current = {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1234 'location': {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1235 'strand': f.strand,
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1236 'fmin': int(f.location.start),
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1237 'fmax': int(f.location.end),
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1238 },
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1239 'type': {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1240 'name': _tnType(f),
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1241 'cv': {
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1242 'name': 'sequence',
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1243 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1244 },
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1245 }
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1246 if f.type in ('gene', 'mRNA'):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1247 current['name'] = f.qualifiers.get('Name', [f.id])[0]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1248 if hasattr(f, 'sub_features') and len(f.sub_features) > 0:
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1249 current['children'] = [x for x in _yieldFeatData(f.sub_features)]
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1250
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1251 yield current
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1252
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1253
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1254 def featuresToFeatureSchema(features):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1255 compiled = []
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1256 for feature in features:
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1257 # if feature.type != 'gene':
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1258 # log.warn("Not able to handle %s features just yet...", feature.type)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1259 # continue
0
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1260
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1261 for x in _yieldFeatData([feature]):
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1262 compiled.append(x)
6002cc0df04e planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
eric-rasche
parents:
diff changeset
1263 return compiled
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1264
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1265
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1266 def accessible_organisms(user, orgs):
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1267 permissionMap = {
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1268 x['organism']: x['permissions']
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1269 for x in user.organismPermissions
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1270 if 'WRITE' in x['permissions'] or
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1271 'READ' in x['permissions'] or
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1272 'ADMINISTRATE' in x['permissions'] or
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1273 user.role == 'ADMIN'
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1274 }
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1275
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1276 if 'error' in orgs:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1277 raise Exception("Error received from Apollo server: \"%s\"" % orgs['error'])
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1278
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1279 return [
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1280 (org['commonName'], org['id'], False)
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1281 for org in sorted(orgs, key=lambda x: x['commonName'])
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1282 if org['commonName'] in permissionMap
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1283 ]
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1284
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1285
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1286 def galaxy_list_groups(trans, *args, **kwargs):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1287 email = trans.get_user().email
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1288 wa = WebApolloInstance(
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1289 os.environ['GALAXY_WEBAPOLLO_URL'],
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1290 os.environ['GALAXY_WEBAPOLLO_USER'],
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1291 os.environ['GALAXY_WEBAPOLLO_PASSWORD']
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1292 )
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1293 # Assert that the email exists in apollo
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1294 try:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1295 gx_user = wa.requireUser(email)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1296 except UnknownUserException:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1297 return []
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1298
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1299 # Key for cached data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1300 cacheKey = 'groups-' + email
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1301 # We don't want to trust "if key in cache" because between asking and fetch
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1302 # it might through key error.
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1303 if cacheKey not in cache:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1304 # However if it ISN'T there, we know we're safe to fetch + put in
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1305 # there.
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1306 data = _galaxy_list_groups(wa, gx_user, *args, **kwargs)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1307 cache[cacheKey] = data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1308 return data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1309 try:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1310 # The cache key may or may not be in the cache at this point, it
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1311 # /likely/ is. However we take no chances that it wasn't evicted between
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1312 # when we checked above and now, so we reference the object from the
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1313 # cache in preparation to return.
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1314 data = cache[cacheKey]
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1315 return data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1316 except KeyError:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1317 # If access fails due to eviction, we will fail over and can ensure that
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1318 # data is inserted.
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1319 data = _galaxy_list_groups(wa, gx_user, *args, **kwargs)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1320 cache[cacheKey] = data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1321 return data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1322
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1323
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1324 def _galaxy_list_groups(wa, gx_user, *args, **kwargs):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1325 # Fetch the groups.
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1326 group_data = []
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1327 for group in wa.groups.loadGroups():
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1328 # Reformat
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1329 group_data.append((group.name, group.groupId, False))
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1330 return group_data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1331
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1332
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1333 def galaxy_list_orgs(trans, *args, **kwargs):
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1334 email = trans.get_user().email
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1335 wa = WebApolloInstance(
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1336 os.environ['GALAXY_WEBAPOLLO_URL'],
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1337 os.environ['GALAXY_WEBAPOLLO_USER'],
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1338 os.environ['GALAXY_WEBAPOLLO_PASSWORD']
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1339 )
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1340 try:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1341 gx_user = wa.requireUser(email)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1342 except UnknownUserException:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1343 return []
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1344
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1345 # Key for cached data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1346 cacheKey = 'orgs-' + email
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1347 if cacheKey not in cache:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1348 data = _galaxy_list_orgs(wa, gx_user, *args, **kwargs)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1349 cache[cacheKey] = data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1350 return data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1351 try:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1352 data = cache[cacheKey]
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1353 return data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1354 except KeyError:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1355 data = _galaxy_list_orgs(wa, gx_user, *args, **kwargs)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1356 cache[cacheKey] = data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1357 return data
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1358
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1359
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1360 def _galaxy_list_orgs(wa, gx_user, *args, **kwargs):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1361 # Fetch all organisms
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1362 all_orgs = wa.organisms.findAllOrganisms()
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1363 # Figure out which are accessible to the user
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1364 orgs = accessible_organisms(gx_user, all_orgs)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1365 # Return org list
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1366 return orgs
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1367
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1368 ## This is all for implementing the command line interface for testing.
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1369
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1370 class obj(object):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1371 pass
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1372
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1373
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1374 class fakeTrans(object):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1375
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1376 def __init__(self, username):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1377 self.un = username
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1378
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1379 def get_user(self):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1380 o = obj()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1381 o.email = self.un
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1382 return o
3
d4ae83dedb14 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4ac38d0b6dba1183f3e78eb5c224c7051064b4a5
eric-rasche
parents: 0
diff changeset
1383
5
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1384 if __name__ == '__main__':
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1385 parser = argparse.ArgumentParser(description='Test access to apollo server')
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1386 parser.add_argument('email', help='Email of user to test')
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1387 parser.add_argument('--action', choices=['org', 'group'], default='org', help='Data set to test, fetch a list of groups or users known to the requesting user.')
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1388 args = parser.parse_args()
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1389
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1390 trans = fakeTrans(args.email)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1391 if args.action == 'org':
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1392 for f in galaxy_list_orgs(trans):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1393 print(f)
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1394 else:
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1395 for f in galaxy_list_groups(trans):
7610987e0c48 planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 29795b77c0d5c7894219b018a92c5ee7818096c3
eric-rasche
parents: 3
diff changeset
1396 print(f)