Skip to content

Commit

Permalink
Fixed new allele count in AlleleCall stdout. Fixed issue #71.
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm-targa committed Feb 1, 2024
1 parent 43555c6 commit 289c0c5
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 146 deletions.
12 changes: 6 additions & 6 deletions CHEWBBACA/AlleleCall/allele_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -2762,7 +2762,7 @@ def main(input_file, loci_list, schema_directory, output_directory,

# Get list of loci in the schema
schema_loci = fo.pickle_loader(fo.join_paths(schema_directory,
[ct.LOCI_LIST_FILE]))
[ct.GENE_LIST_BASENAME]))
schema_loci_paths = [fo.join_paths(schema_directory, [file])
for file in schema_loci]

Expand Down Expand Up @@ -2847,8 +2847,8 @@ def main(input_file, loci_list, schema_directory, output_directory,
mo.function_helper,
config['CPU cores'],
show_progress=False)
novel_alleles_count = sum(len(v) for v in novel_alleles)
novel_alleles = im.merge_dictionaries(novel_alleles)
novel_alleles_count = sum(len(v) for k, v in novel_alleles.items())
print(f'Assigned identifiers to {novel_alleles_count} new alleles.')

updated_files = {}
Expand Down Expand Up @@ -3009,9 +3009,9 @@ def main(input_file, loci_list, schema_directory, output_directory,
classification_labels)

print(f'Classified a total of {total_cds} CDSs.')
class_counts_header = [f'{c:^8}' for c in ct.ALLELECALL_CLASSIFICATIONS]
class_counts_header = [f'{c:^8}' for c in ct.ALLELECALL_CLASSIFICATIONS[:-1]]
class_counts_header = ' '.join(class_counts_header)
class_counts_values = [f'{global_counts.get(c, 0):^8}' for c in ct.ALLELECALL_CLASSIFICATIONS]
class_counts_values = [f'{global_counts.get(c, 0):^8}' for c in ct.ALLELECALL_CLASSIFICATIONS[:-1]]
class_counts_values = ' '.join(class_counts_values)
print('='*len(class_counts_header))
print(class_counts_header)
Expand All @@ -3020,8 +3020,8 @@ def main(input_file, loci_list, schema_directory, output_directory,
print('='*len(class_counts_header))

if no_inferred is False and config['Mode'] != 1 and len(novel_alleles) > 0:
print('Added {0} novel alleles to the schema.'.format(sum(added2)))
print('Added {0} representative alleles to the schema.'.format(added[1]))
print('Added {0} new alleles to the schema.'.format(sum(added2)))
print('Added {0} new representative alleles to the schema.'.format(added[1]))
elif no_inferred is True:
print('User passed "--no-inferred". No alleles added to the schema.')
elif len(novel_alleles) == 0:
Expand Down
14 changes: 3 additions & 11 deletions CHEWBBACA/CHEWBBACA_NS/download_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,18 +531,10 @@ def main(species_id, schema_id, download_folder, cpu_cores,
fo.remove_files(ns_files)

# Write hidden schema config file
del(schema_params_dict['Schema_lock'])
schema_config = pv.write_schema_config(schema_params_dict['bsr'],
ptf_hash,
schema_params_dict['translation_table'],
schema_params_dict['minimum_locus_length'],
schema_params_dict['ptf_path'] = ptf_hash
schema_params_dict['window_size'] = schema_params_dict.get('window_size', None)
schema_config = pv.write_schema_config(schema_params_dict,
schema_params_dict['chewBBACA_version'],
schema_params_dict['size_threshold'],
schema_params_dict['word_size'],
schema_params_dict.get('window_size', None), # add window size to chewie-NS
schema_params_dict['cluster_sim'],
schema_params_dict['representative_filter'],
schema_params_dict['intraCluster_filter'],
schema_path)

# Create ns_config file
Expand Down
4 changes: 2 additions & 2 deletions CHEWBBACA/CHEWBBACA_NS/synchronize_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ def main(schema_directory, cpu_cores, nomenclature_server,
headers_post_bytes['Authorization'] = token
headers_post_bytes['user_id'] = user_id

schema_params = pv.read_configs(schema_directory, '.schema_config')
schema_params = pv.read_configs(schema_directory, ct.SCHEMA_CONFIG_BASENAME)

# verify that local configs have a single value per parameter
if all([len(schema_params[k]) == 1
Expand Down Expand Up @@ -819,7 +819,7 @@ def main(schema_directory, cpu_cores, nomenclature_server,
''.format(count, len(loci_alleles)))

# Get schema files from genes list file
genes_list = fo.join_paths(schema_directory, ['.genes_list'])
genes_list = fo.join_paths(schema_directory, [ct.GENE_LIST_BASENAME])
genes = fo.pickle_loader(genes_list)

# update loci structure
Expand Down
4 changes: 2 additions & 2 deletions CHEWBBACA/CHEWBBACA_NS/upload_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ def main(schema_directory, species_id, schema_name, loci_prefix,
print('Local schema: {0}'.format(schema_directory))

# Get schema files from genes list file
genes_list = os.path.join(schema_directory, '.genes_list')
genes_list = fo.join_paths(schema_directory, [ct.GENE_LIST_BASENAME])
genes = fo.pickle_loader(genes_list)
fasta_paths = [os.path.join(schema_directory, file) for file in genes]
fasta_paths.sort()
Expand All @@ -993,7 +993,7 @@ def main(schema_directory, species_id, schema_name, loci_prefix,
# Verify schema config
print('Verifying schema configs...')
# Load schema config file
configs = pv.read_configs(schema_directory, '.schema_config')
configs = pv.read_configs(schema_directory, ct.SCHEMA_CONFIG_BASENAME)

# Validate arguments values
schema_ptfs = configs['prodigal_training_file']
Expand Down
2 changes: 1 addition & 1 deletion CHEWBBACA/SchemaEvaluator/evaluate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def main(schema_directory, output_directory, genes_list, annotations,
for file in schema_files}

# Check if the schema was created with chewBBACA
config_file = os.path.join(schema_directory, ".schema_config")
config_file = fo.join_paths(schema_directory, [ct.SCHEMA_CONFIG_BASENAME])
if os.path.exists(config_file):
# get the schema configs
with open(config_file, "rb") as cf:
Expand Down
2 changes: 1 addition & 1 deletion CHEWBBACA/UniprotFinder/annotate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def main(schema_directory, output_directory, genes_list, protein_table,
else:
# Search for annotations through the SPARQL endpoint
print('\nQuerying UniProt\'s SPARQL endpoint...')
config_file = fo.join_paths(schema_directory, ['.schema_config'])
config_file = fo.join_paths(schema_directory, [ct.SCHEMA_CONFIG_BASENAME])
if os.path.isfile(config_file) is True:
config = fo.pickle_loader(config_file)
translation_table = config.get('translation_table', [11])[0]
Expand Down
Loading

0 comments on commit 289c0c5

Please sign in to comment.