-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_blast.py
36 lines (29 loc) · 1.4 KB
/
run_blast.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
""" Program to run the blast algorithm and
return useful information from it
Creates CLI for blast search and human readable results"""
import sys
import os
import pickle
from termcolor import colored
from blast import blast
def run_blast(args):
""" Application wrapper for blast algorithm """
print(colored("\n\n\n ____ _ _____ _______ \n| _ \| | /\ / ____|__ __|\n| |_) | | / \ | (___ | | \n| _ <| | / /\ \ \___ \ | | \n| |_) | |____ / ____ \ ____) | | | \n|____/|______/_/ \_\_____/ |_| \n", "blue", attrs=['bold']))
print(colored("A python implementation of BLAST (basic local alignment search tool)\n\n\n", 'blue'))
if len(args) < 2:
data_file = input("Enter data file path: ")
dict_file = input("Enter dictionary file path: ")
else:
data_file = os.getcwd() + args[1]
dict_file = os.getcwd() + args[2]
sequence = input("Enter Search sequence: ")
print("Calculating...")
results = blast(sequence, dict_file, data_file)
results.sort(key=lambda x: x[2], reverse=True)
print('\n\nResults:\n')
for result in results[:5]:
print(colored("\nScore: ", "green", attrs=['bold']), result[2])
print(colored("Position: ", "blue", attrs=['bold']), result[1])
print(colored("Sequence", "blue", attrs=['bold']), result[0])
if __name__ == "__main__":
run_blast(sys.argv)