Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@staticmethod
def _string_to_params(s):
"""
Return a tuple (N, p_mut_coeff, choose_or_rand, sick_or_not, off_v_last)
obtained by parsing the string `s`.
"""
p_mut_coeff, N, choose_or_rand, sick_or_not, off_v_last = s.split('__')
return (GMhcCoevScript._parse_N(N),
GMhcCoevScript._parse_p_mut_coeff(p_mut_coeff),
GMhcCoevScript._parse_choose_or_rand(choose_or_rand),
GMhcCoevScript._parse_sick_or_not(sick_or_not),
GMhcCoevScript._parse_off_v_last(off_v_last))
@staticmethod
def _string_to_params(s):
"""
Return a tuple (N, p_mut_coeff, choose_or_rand, sick_or_not, off_v_last)
obtained by parsing the string `s`.
"""
p_mut_coeff, N, choose_or_rand, sick_or_not, off_v_last = s.split('__')
return (GMhcCoevScript._parse_N(N),
GMhcCoevScript._parse_p_mut_coeff(p_mut_coeff),
GMhcCoevScript._parse_choose_or_rand(choose_or_rand),
GMhcCoevScript._parse_sick_or_not(sick_or_not),
GMhcCoevScript._parse_off_v_last(off_v_last))
@staticmethod
def _string_to_params(s):
"""
Return a tuple (N, p_mut_coeff, choose_or_rand, sick_or_not, off_v_last)
obtained by parsing the string `s`.
"""
p_mut_coeff, N, choose_or_rand, sick_or_not, off_v_last = s.split('__')
return (GMhcCoevScript._parse_N(N),
GMhcCoevScript._parse_p_mut_coeff(p_mut_coeff),
GMhcCoevScript._parse_choose_or_rand(choose_or_rand),
GMhcCoevScript._parse_sick_or_not(sick_or_not),
GMhcCoevScript._parse_off_v_last(off_v_last))
# summary of user-visible changes
__changelog__ = """
2011-07-22:
* Use the ``APPS/BIO/MHC_COEV-040711`` run time tag to select execution sites.
2011-06-15:
* Initial release, forked off the ``ggamess`` sources.
"""
__author__ = 'Riccardo Murri '
__docformat__ = 'reStructuredText'
# run script, but allow GC3Pie persistence module to access classes defined here;
# for details, see: http://code.google.com/p/gc3pie/issues/detail?id=95
if __name__ == '__main__':
import gmhc_coev
gmhc_coev.GMhcCoevScript().run()
# std module imports
import csv
import glob
import math
import os
import re
import shutil
import sys
import time
# gc3 library imports
import gc3libs
from gc3libs import Application, Run, Task
from gc3libs.cmdline import SessionBasedScript
@staticmethod
def _params_to_str(N, p_mut_coeff, choose_or_rand, sick_or_not, off_v_last):
return str.join('__', [
GMhcCoevScript._p_mut_coeff_to_str(p_mut_coeff),
GMhcCoevScript._N_to_str(N),
GMhcCoevScript._choose_or_rand_to_str(choose_or_rand),
GMhcCoevScript._sick_or_not_to_str(sick_or_not),
GMhcCoevScript._off_v_last_to_str(off_v_last),
])
@staticmethod
def _params_to_str(N, p_mut_coeff, choose_or_rand, sick_or_not, off_v_last):
return str.join('__', [
GMhcCoevScript._p_mut_coeff_to_str(p_mut_coeff),
GMhcCoevScript._N_to_str(N),
GMhcCoevScript._choose_or_rand_to_str(choose_or_rand),
GMhcCoevScript._sick_or_not_to_str(sick_or_not),
GMhcCoevScript._off_v_last_to_str(off_v_last),
])
@staticmethod
def _parse_N(N_str):
try:
return int(N_str)
except ValueError:
match = GMhcCoevScript._N_RE.match(N_str)
if not match:
raise ValueError("Cannot parse N expression '%s'" % N_str)
return int(match.group('N'))
@staticmethod
def _params_to_str(N, p_mut_coeff, choose_or_rand, sick_or_not, off_v_last):
return str.join('__', [
GMhcCoevScript._p_mut_coeff_to_str(p_mut_coeff),
GMhcCoevScript._N_to_str(N),
GMhcCoevScript._choose_or_rand_to_str(choose_or_rand),
GMhcCoevScript._sick_or_not_to_str(sick_or_not),
GMhcCoevScript._off_v_last_to_str(off_v_last),
])
@staticmethod
def _params_to_str(N, p_mut_coeff, choose_or_rand, sick_or_not, off_v_last):
return str.join('__', [
GMhcCoevScript._p_mut_coeff_to_str(p_mut_coeff),
GMhcCoevScript._N_to_str(N),
GMhcCoevScript._choose_or_rand_to_str(choose_or_rand),
GMhcCoevScript._sick_or_not_to_str(sick_or_not),
GMhcCoevScript._off_v_last_to_str(off_v_last),
])
lineno+1, path, len(row), str.join(',', (str(x) for x in row)))
continue # with next `row`
# extract parameter values
try:
iterno = int(iterno)
N = GMhcCoevScript._parse_N(N_str)
p_mut_coeff = GMhcCoevScript._parse_p_mut_coeff(p_mut_coeff_str)
choose_or_rand = GMhcCoevScript._parse_choose_or_rand(choose_or_rand_str)
sick_or_not = GMhcCoevScript._parse_sick_or_not(sick_or_not_str)
off_v_last = GMhcCoevScript._parse_off_v_last(off_v_last_str)
except ValueError, ex:
self.log.warning("Ignoring line '%s' in input file '%s': %s",
str.join(',', row), path, str(ex))
continue
basename = ('MHC_coev_' +
GMhcCoevScript._params_to_str(
N, p_mut_coeff, choose_or_rand,
sick_or_not, off_v_last))
# prepare job(s) to submit
if (iterno > iters[basename]):
self.log.info(
"Requested %d iterations for %s: %d already in session, preparing %d more",
iterno, basename, iters[basename], iterno - iters[basename])
for iter in range(iters[basename]+1, iterno+1):
kwargs = extra.copy()
base_output_dir = kwargs.pop('output_dir', self.params.output)
yield GMhcCoevTask(
self.params.walltime, # single_run_duration
self.params.generations,
N,
p_mut_coeff,