def result_path_iter(self, observed_index, prior_index): true_model = self.observed_index_to_prior_index[observed_index] out_dir = self.get_result_dir(observed_index, prior_index) if not os.path.isdir(out_dir): raise Exception('expected result direcory {0!r} does not ' 'exist'.format(out_dir)) observed_stream, close = process_file_arg( self.observed_index_to_path[observed_index]) header = parsing.parse_header(observed_stream, sep = '\t', strict = True, seek = False) parameter_indices = functions.get_indices_of_patterns(header, parsing.PARAMETER_PATTERNS) for i, line in enumerate(observed_stream): l = line.strip().split() true_params = dict(zip([header[x] for x in parameter_indices], [l[x] for x in parameter_indices])) true_params['PRI.model'] = str(true_model) result_prefix = '{0}{1}-'.format(self.get_result_path_prefix( observed_index, prior_index, i + 1), self.final_result_index) summary_path = result_prefix + 'posterior-summary.txt' psi_path = result_prefix + 'psi-results.txt' omega_path = result_prefix + 'omega-results.txt' cv_path = result_prefix + 'cv-results.txt' div_model_path = result_prefix + 'div-model-results.txt' model_path = result_prefix + 'model-results.txt' paths = {'summary': summary_path, 'psi': psi_path, 'omega': omega_path, 'cv': cv_path, 'div-model': div_model_path, 'model': model_path} yield true_params, paths observed_stream.close()
def __init__(self, div_model_results_path, inclusion_threshold=None): self.path = div_model_results_path self.inclusion_threshold = inclusion_threshold self.models = [] self.n = 0 self.cumulative_prob = 0.0 header = parsing.parse_header(self.path) if 'div_model_with_conditional_age_estimates' in header: self._parse_results_file() else: self._parse_posterior_file()
def __init__(self, div_model_results_path, inclusion_threshold = None): self.path = div_model_results_path self.inclusion_threshold = inclusion_threshold self.models = [] self.n = 0 self.cumulative_prob = 0.0 header = parsing.parse_header(self.path) if 'div_model_with_conditional_age_estimates' in header: self._parse_results_file() else: self._parse_posterior_file()
def result_path_iter(self, observed_index, prior_index): true_model = self.observed_index_to_prior_index[observed_index] out_dir = self.get_result_dir(observed_index, prior_index) if not os.path.isdir(out_dir): raise Exception('expected result direcory {0!r} does not ' 'exist'.format(out_dir)) observed_stream, close = process_file_arg( self.observed_index_to_path[observed_index]) header = parsing.parse_header(observed_stream, sep='\t', strict=True, seek=False) parameter_indices = functions.get_indices_of_patterns( header, parsing.PARAMETER_PATTERNS) for i, line in enumerate(observed_stream): l = line.strip().split() true_params = dict( zip([header[x] for x in parameter_indices], [l[x] for x in parameter_indices])) true_params['PRI.model'] = str(true_model) result_prefix = '{0}{1}-'.format( self.get_result_path_prefix(observed_index, prior_index, i + 1), self.final_result_index) summary_path = result_prefix + 'posterior-summary.txt' psi_path = result_prefix + 'psi-results.txt' omega_path = result_prefix + 'omega-results.txt' cv_path = result_prefix + 'cv-results.txt' div_model_path = result_prefix + 'div-model-results.txt' model_path = result_prefix + 'model-results.txt' paths = { 'summary': summary_path, 'psi': psi_path, 'omega': omega_path, 'cv': cv_path, 'div-model': div_model_path, 'model': model_path } yield true_params, paths observed_stream.close()