def test_io(self): tempfilename = self.tempfilename tempfile = masterslave.open(tempfilename, mode='w') tempfile.write(str(masterslave.rank()) + '\n') tempfile.flush() contents = '' with open(tempfilename) as stillopen: contents = stillopen.read() assert_in(str(masterslave.rank()) + '\n', contents) tempfile.close() with open(tempfilename) as nowclosed: ranks = [int(s.strip()) for s in nowclosed] assert_equal(set(ranks), set(range(masterslave.size()))) tempfile = masterslave.open(tempfilename, 'a') tempfile.write(str(masterslave.rank()) + '\n') tempfile.close() with open(tempfilename) as nowclosed: ranks = [int(s.strip()) for s in nowclosed] assert_equal(len(ranks), masterslave.size() * 2) assert_equal(set(ranks), set(range(masterslave.size()))) if masterslave.size() != 1: masterslave._comm.Barrier()
def func(d1, d2): return d1, d2, masterslave.rank()
def func(dummy): return dummy, masterslave.rank()
def main(): import argparse parser = argparse.ArgumentParser(description='Estimate expected number of \ substitutions under stationary and non-stationary models.') parser.add_argument( '-i', '--input_directory', required=True, type=os.path.expanduser, help='Directory containing .fasta or .fasta.gz alignments') parser.add_argument('-o', '--output_directory', required=True, type=os.path.expanduser, help='Directory in which results will be stored') parser.add_argument('-l', '--log_file', type=os.path.expanduser, help='Defaults to stderr') parser.add_argument('-L', '--log_level', default='INFO', type=str, help='Set logging level') parser.add_argument('-f', '--force_recalculation', action='store_true', help='Force recalculation of existing results') parser.add_argument('-c', '--codon_position', type=int, default=-1, help='Only use this codon position in analysis') parser.add_argument('-g', '--global_optimisation', action='store_true', help='Use global optimisation when fitting models') parser.add_argument('-R', '--num_range', type=lambda x: slice(*eval(x)), default=None, help='Range of files to work on') parser.add_argument('-T', '--triad_file', type=os.path.expanduser, help='Tab delimited list of triads to be processed') parser.add_argument('-u', '--param_limit', type=float, default=20, help='Upper limit for substitution parameters') parser.add_argument('-p', '--pretty_print', action='store_true', help='Pretty print json output') parser.add_argument('-F', '--fitter', type=lambda x: getattr(nest, x), default='seq_fit', help='Nest function to use for fitting') parser.add_argument('-O', '--outgroup', type=str, help='Outgroup to use for clock test fitting') kw_args = vars(parser.parse_args()) setup_logging(**kw_args) if masterslave.rank() == 0: logging.info(kw_args) logging.info(_versions) results = masterslave.imap(partial(process_triad, **kw_args), itriads(**kw_args)) if results: output_results(results, **kw_args) return 0
def main(): import argparse parser = argparse.ArgumentParser(description='Estimate expected number of \ substitutions under stationary and non-stationary models.') parser.add_argument('-o', '--output_directory', required=True, type=os.path.expanduser, help='Directory in which results will be stored') parser.add_argument('-l', '--log_file', type=os.path.expanduser, help='Defaults to stderr') parser.add_argument('-L', '--log_level', default='INFO', help='Set logging level') parser.add_argument('-m', '--mode', default='s', choices='sra', help='Write mode (skip, replace, append)') parser.add_argument('-R', '--num_range', type=lambda x: slice(*eval(x)), default=None, help='Range of files to work on') parser.add_argument('-N', '--num_reps', type=int, default=100, help='Number of G stat samples') parser.add_argument( '-u', '--param_limit', type=float, default=20, help='Upper limit for length and substitution parameters') parser.add_argument('-P', '--model_pos', default=-1, type=int, help='Model for which to produce G statistics') parser.add_argument('-F', '--fitter', type=lambda x: getattr(nest, x), default='seq_fit', help='Nest function to use for fitting') parser.add_argument('-O', '--outgroup', type=str, help='Outgroup to use for clock test fitting') kw_args = vars(parser.parse_args()) setup_logging(**kw_args) if masterslave.rank() == 0: logging.info(kw_args) logging.info(_versions) processor = partial(param_bootstrap, **kw_args) results = masterslave.imap(processor, istats(**kw_args)) if results: output_results(results, **kw_args) return 0