Skip to content

Commit

Permalink
Fixed pytest small error with test_emtpy_BLAST_antigen_hits
Browse files Browse the repository at this point in the history
  • Loading branch information
kbessonov1984 committed Jul 30, 2024
1 parent 22b6a98 commit 4ef8526
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ectyper/ectyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def run_program():
# Add empty rows for genomes without a blast result or non-E.coli samples that did not undergo typing
final_predictions = predictionFunctions.add_non_predicted(
raw_genome_files, predictions_dict, other_genomes_dict, filesnotfound_dict, ecoli_genomes_dict)
print(final_predictions)


for sample in final_predictions.keys():
final_predictions[sample]["database"] = "v"+ectyperdb_dict["version"] + " (" + ectyperdb_dict["date"] + ")"
Expand Down
12 changes: 9 additions & 3 deletions ectyper/predictionFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,17 @@ def predict_pathotype_and_shiga_toxin_subtype(ecoli_genome_files_dict, other_gen
"-out", f"{temp_dir}/blast_pathotype_result.txt",
"-outfmt", "6 qseqid qlen sseqid length pident sstart send sframe slen qcovhsp bitscore sseq"
]
LOG.debug(f"BLASTN results on pathotype database written to {temp_dir}/blast_pathotype_result.txt ...")
cmd_status = subprocess_util.run_subprocess(cmd)

cmd_status = subprocess_util.run_subprocess(cmd)
if cmd_status.returncode == 0:
LOG.info(f"BLASTN on pathotype database for {g} was successful and results written to {temp_dir}/blast_pathotype_result.txt ...")
else:
LOG.critical(f"BLASTn against pathotype database failed with error code {cmd_status.returncode} and pathotype results for {g} would NOT be available. Skipping pathotyping ...")
continue


if os.stat(f'{temp_dir}/blast_pathotype_result.txt').st_size == 0:
LOG.warning(f"No pathotype signatures found for sample {g} as pathotype BLAST results file {temp_dir}/blast_pathotype_result.txt is empty. Skipping ...")
LOG.warning(f"No pathotype signatures found for sample {g} as pathotype BLAST results file {temp_dir}/blast_pathotype_result.txt is empty. Skipping pathotyping...")
predictions_pathotype_dict[g]={field:'-' for field in definitions.PATHOTYPE_TOXIN_FIELDS}
predictions_pathotype_dict[g]['pathotype']= ['ND']
continue
Expand Down
2 changes: 1 addition & 1 deletion test/test_complex_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_emtpy_BLAST_antigen_hits(tmpdir):
with open(file=ectyper.definitions.SEROTYPE_ALLELE_JSON) as fp:
ectyperdb_dict = json.load(fp)
alleles_fasta_file = ectyper.create_alleles_fasta_file(tmpdir, ectyperdb_dict)
db_prediction_dict = ectyper.genome_group_prediction([args.input], alleles_fasta_file, args, tmpdir, ectyperdb_dict)
db_prediction_dict = ectyper.genome_group_prediction(args.input, alleles_fasta_file, args, tmpdir, ectyperdb_dict)
assert db_prediction_dict == {}

def test_invalid_fasta():
Expand Down

0 comments on commit 4ef8526

Please sign in to comment.