Alternative content
from Bio.Blast.Applications import NcbiblastnCommandline
import os
import sys
def perform_local_blast(query_file, subject_file, output_file):
# Set up the BLAST command with format 6 (tab-delimited)
blastn_cline = NcbiblastnCommandline(query=query_file, subject=subject_file, out=output_file, outfmt=6,
word_size=16, perc_identity=100)
# Run BLAST
stdout, stderr = blastn_cline()
# Check for errors
if stderr:
print("Error running BLAST:")
print(stderr)
def parse_blast_results(output_file):
# Parse BLAST results
with open(output_file, "r") as result_handle:
for line in result_handle:
fields = line.strip().split('\t')
qseq = fields[0] # Extract the aligned query sequence (qseq)
#print("Aligned Query Sequence:", qseq)
# Print other relevant information if needed
def main():
if len(sys.argv) != 4:
print("Usage: python script.py query.fasta subject.fasta output.txt")
sys.exit(1)
query_file = sys.argv[1]
subject_file = sys.argv[2]
output_file = sys.argv[3]
# Perform local BLAST
perform_local_blast(query_file, subject_file, output_file)
# Parse and print BLAST results
#parse_blast_results(output_file)
if __name__ == "__main__":
main()