-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfastq2fasta.py
More file actions
executable file
·36 lines (27 loc) · 1.26 KB
/
fastq2fasta.py
File metadata and controls
executable file
·36 lines (27 loc) · 1.26 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
#!/usr/bin/env python
import logging
import argparse
from Bio import SeqIO
def getOptions():
""" Function to pull in arguments """
parser = argparse.ArgumentParser(description="Converts a FASTQ file into a FASTA file.")
parser.add_argument("-i", "--input", dest="fname", action='store', required=True, help="Name of input FASTQ file [Required]")
parser.add_argument("-o", "--out", dest="out", action='store', required=True, help="Name of output FASTA file [Required]")
parser.add_argument("-g", "--log", dest="log", action='store', required=False, help="Log File")
args = parser.parse_args()
return(args)
def setLogger(fname,loglevel):
""" Function to handle error logging """
logging.basicConfig(filename=fname, level=loglevel, format='%(asctime)s - %(levelname)s - %(message)s')
def main():
""" MAIN Function to execute everything """
# Turn on Logging if option -g was given
args = getOptions()
if args.log:
setLogger(args.log,logging.INFO)
logging.info("Converting '%s' to '%s'" % (args.fname,args.out))
SeqIO.convert(args.fname, "fastq", args.out, "fasta")
logging.info("Finished converting '%s' to '%s'" % (args.fname,args.out))
if __name__=='__main__':
main()
logging.info("Script complete.")