LeeBergstrand / BackBLAST_Reciprocal_BLAST

This repository contains a reciprocal BLAST program for filtering down BLAST results to best bidirectional hits. It also contains a toolkit for finding and visualizing BLAST hits for gene clusters within multiple bacterial genomes.
MIT License
14 stars 8 forks source link

Check all input pathways before calling BLASTp (search.py) #61

Open LeeBergstrand opened 2 years ago

LeeBergstrand commented 2 years ago

Problem Description

If one puts in the wrong FASTA file paths for search.py, then the error is only caught when BLAST fails as a subprocess.

e.g.

Command line argument error: Argument "query". File is not accessible:  `../Reference_Genes/reference_genes_n47.faa'
Traceback (most recent call last):
  File "/home/lee/miniconda3/envs/backblast/share/backblast/scripts/search.py", line 308, in <module>
    main(cli_args)
  File "/home/lee/miniconda3/envs/backblast/share/backblast/scripts/search.py", line 213, in main
    forward_blast_high_scoring_pairs = get_blast_hight_scoring_pairs(query_gene_cluster_path=query_gene_cluster_path,
  File "/home/lee/miniconda3/envs/backblast/share/backblast/scripts/search.py", line 45, in get_blast_hight_scoring_pairs
    return filter_blast_csv(run_blastp(query_gene_cluster_path,
  File "/home/lee/miniconda3/envs/backblast/share/backblast/scripts/search.py", line 62, in run_blastp
    blast_out = subprocess.check_output(
  File "/home/lee/miniconda3/envs/backblast/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/home/lee/miniconda3/envs/backblast/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['blastp', '-query', '../Reference_Genes/reference_genes_n47.faa', '-subject', './deltaproteobacterium_NaphS2.faa', '-evalue', '1e-25', '-soft_masking', 'true', '-seg', 'yes', '-outfmt', '10 qseqid sseqid pident evalue qcovhsp bitscore']' returned non-zero exit status 1.

Problem Solution

Check if the input files are there in Python and error out with a clear message before calling BLASTp.

jmtsuji commented 2 years ago

@LeeBergstrand Good find. This should be an easy fix, but my time is super limited right now. Would you be willing to make a PR for this? Otherwise, we could add it to a longer-term list of minor improvements to make to the code (e.g., https://github.com/LeeBergstrand/BackBLAST_Reciprocal_BLAST/issues/35)

LeeBergstrand commented 2 years ago

@jmtsuji I'll do a pull request for this eventually. Leaving open.

jmtsuji commented 2 years ago

@LeeBergstrand Sounds good, thanks.