Skip to content

Commit

Permalink
Refactor to use helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
mmore500 committed Apr 3, 2021
1 parent 93b68ff commit 48575fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
27 changes: 4 additions & 23 deletions script/make_nopped_op_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from keyname import keyname as kn

from pyhelpers import genome_local_autoload

try:
__, applyto, basedon = sys.argv
except:
Expand All @@ -17,29 +19,8 @@
assert 'ext' in kn.unpack( applyto )
assert 'ext' in kn.unpack( basedon )

def multiloader(target):
if kn.unpack( target )['ext'] == '.json':
with open( target, 'r') as f:
return json.load( f )

elif kn.unpack( target )['ext'] == '.json.gz':
try:
with gzip.open( target, 'rb') as f:
return json.loads( f.read().decode('ascii') )
except Exception:
pass

try:
with gzip.open( target, 'rb') as f:
return json.loads( f.read().decode('utf-8') )
except Exception:
pass

raise ValueError


applytodata = multiloader( applyto )
basedondata = multiloader( basedon )
applytodata = genome_local_autoload( applyto )
basedondata = genome_local_autoload( basedon )

assert (
len( applytodata['value0']['program'] )
Expand Down
4 changes: 1 addition & 3 deletions slurm/genomes/nopoutjob.slurm.sh.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,7 @@ echo "----------------------------------------------------------"
timeout 30s "${REPRO_WORK_DIRECTORY}/dishtiny/script/host_squeue.sh" -j "${SLURM_JOB_ID}" --format \"time: %M, time left: %L\" --noheader || echo "time log failed" &
wait # ignores exit code of time log step
# adapted from https://superuser.com/a/689340
# and https://stackoverflow.com/a/31687663
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 10 -qO- https://raw.githubusercontent.com/mmore500/dishtiny/{{ repo_sha }}/script/make_nopped_op_variants.py | python3 - "${WILDTYPE_GENOME}" "${PHENOTYPE_EQUIVALENT_GENOME}"
"${REPRO_WORK_DIRECTORY}/dishtiny/script/make_nopped_op_variants.py" | python3 - "${WILDTYPE_GENOME}" "${PHENOTYPE_EQUIVALENT_GENOME}"
################################################################################
echo
Expand Down

0 comments on commit 48575fe

Please sign in to comment.