-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCL_Interface.py
More file actions
42 lines (35 loc) · 2.31 KB
/
Copy pathCL_Interface.py
File metadata and controls
42 lines (35 loc) · 2.31 KB
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
37
38
39
40
41
42
from CrisprOpenDB.CrisprOpenDB_HostID import PhageHostFinder
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--input", help="Input file in FASTA format.", type=str, required=True)
parser.add_argument("-m", "--mismatch", help="Number of mismatches. Value must be between 0 and 5. If not specified, default value is 2.", type=int, default=2)
parser.add_argument("-a", "--aligner", help="Alignement tool to use. blast or fasta36", type=str, default="blast")
parser.add_argument("-r", "--report", help="Show report of host identification.", action="store_true")
parser.add_argument("-t", "--table", help="Show full result table in separate csv file.", action="store_true")
parser.add_argument("-b", "--blastdb", help="Blast database to use for alignment.", type=str, default=None)
parser.add_argument("-f", "--fastadb", help="Fasta database to use for alignment.", type=str, default=None)
parser.add_argument("-u", "--unknown", help="Keep spacers with unknown genus for prediction. False if not specified.", action="store_true")
parser.add_argument("-n", "--num_threads", help="Number of threads (>=1) to use for the alignment. Default is 1.", type=int, default=1)
args = parser.parse_args()
if args.mismatch < 0 or args.mismatch > 5:
parser.print_help()
exit()
if args.aligner not in ["blast", "fasta36"]:
parser.print_help()
exit()
if args.unknown:
print("**Warning**\nKeeping spacers with unknown genus (option -u, --unknown) can lead to incorrect prediction. If you choose to use this option, we stongly recommend that you use the report of host identification to keep track of the identification process and avoid any bias (option -r, --report).")
if args.num_threads < 1:
parser.print_help()
exit()
if (args.blastdb != None and args.fastadb != None):
print("Please use only one of the following options:\n-b, --blastdb\n-f, --fastadb")
exit()
elif args.blastdb:
phf = PhageHostFinder(args.blastdb, None)
elif args.fastadb:
phf = PhageHostFinder(None, args.fastadb)
else:
phf = PhageHostFinder()
results = phf.identify(args.input, args.mismatch, args.aligner, args.report, args.table, args.unknown, args.num_threads)