Skip to content

Instantly share code, notes, and snippets.

@23jodys
Created December 9, 2014 19:38
Show Gist options
  • Save 23jodys/c640dcdd93f52073df89 to your computer and use it in GitHub Desktop.
Save 23jodys/c640dcdd93f52073df89 to your computer and use it in GitHub Desktop.
def Integer(obj):
if obj["min"] < obj["value"] < obj["max"]:
return True
else:
raise ValueError("value out of range")
min_tile_size = {"type": Integer,
"min": 10,
"max": 20,
"value": 15,
"where": ["target", "search"]}
max_awful_primers = {"type": Integer,
"min": 5,
"max": 15,
"where": ["pair_filter"],
"help": "Maximum number of completely, atrocious, most awful primers to include"}
parameters = [min_tile_size]
for param in parameters:
if param["type"](param):
return True
else:
return False
design_relationships =
rnafusion_relationships = [ (check_blah, (arg1, arg2), msg) ]
for function, args, msg in itertools.chain(design_relationships, rnafusion_relationships):
if not function(*args):
blah += msg
return blah
class RNAFusion(Params):
def __init__(self, *kwargs):
self.val = kwargs.get('name', None)up
data_objects = {
'min_tile_size': {},
}
relationships = [ check_lte, (min_tile_size, max_tile_size, "Minimum tile size must be less than or equal to maximum tile size", ),
check_between, (max_awful_primers, "Awful primers must be between {}, {}") ]
def get_dict(group=None):
if group is not None:
def validate(self):
validate_fields
parent_class_validate(relationships)
# Now I'm in the backend
>>> target_params = LoadJson("/path/to/json", "target")
ValidationError("Not valid search")
>>> params.min_tile_size
38
>>> params["min_tile_size"]
38
>>> params.get_dict('target')
{'min_tile_size': 38,
...}
>>> params.get_dict_searching()
{'primer_size_min': 18,
...}
>>> search_params = LoadJson("/path/to/json", "search")5
# In the frontend
>>> params = RNAFusion()
>>> params.min_tile_size = "A"
ValueError("Parameter not correct")
>>> msg = params.bulk_set({})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment