-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#69] Added begging of function for connection all together, decorato…
…r for params and func to get regex which need to be fixed to concatenate lists
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from shmir import cache | ||
from shmir.data import ( | ||
models, | ||
ncbi_api, | ||
) | ||
from shmir.decorators import param | ||
from shmir.designer.validators import calculate_gc_content | ||
|
||
|
||
def create_cache_key(*args): | ||
return ':'.join(args) | ||
|
||
|
||
@param('transcript_name', str, 'Name of transcript', required=True) | ||
@param('min_gc', int, 'Minimum of GC content', default=40) | ||
@param('max_gc', int, 'Maximum of GC content', default=60) | ||
@param('max_offtarget', int, 'Maximum offtarget, minimum is 0', default=10) | ||
@param('mirna_name', str, 'miRNA name of Backbone', default=None) | ||
@param( | ||
'stymulators', bool, 'Bool if immuno stimulators are wanted', default=False | ||
) | ||
def connection( | ||
transcript_name, min_gc, max_gc, max_offtarget, mirna_name, stymulators | ||
): | ||
sequence = '?' | ||
cg_content = calculate_gc_content(sequence) | ||
|
||
cache_key = create_cache_key( | ||
transcript_name, | ||
cg_content, | ||
mirna_name, | ||
max_offtarget, | ||
str(stymulators) | ||
) | ||
|
||
sequence = cache.get(cache_key) # TODO: check if get take cache by key xD | ||
|
||
if not sequence: | ||
sequence = ncbi_api.get_mRNA(transcript_name) | ||
|
||
backbones = models.Backbone.get_mirna(mirna_name) | ||
if not isinstance(backbones, list): | ||
backbones = [backbones] | ||
|
||
all_regex = models.Backbone.get_all_regexp() |