This repository has been archived by the owner on Nov 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 269
/
truncate_fasta_qual_files.py
executable file
·73 lines (56 loc) · 2.63 KB
/
truncate_fasta_qual_files.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
# File created Sept 30, 2010
from __future__ import division
__author__ = "William Walters"
__copyright__ = "Copyright 2011, The QIIME Project"
__credits__ = ["William Walters"]
__license__ = "GPL"
__version__ = "1.7.0"
__maintainer__ = "William Walters"
__email__ = "William.A.Walters@colorado.edu"
__status__ = "Release"
from qiime.util import make_option
from qiime.util import parse_command_line_parameters, get_options_lookup
from qiime.truncate_fasta_qual_files import truncate_fasta_qual
from qiime.util import create_dir
options_lookup = get_options_lookup()
script_info={}
script_info['brief_description']="""Generates filtered fasta and quality score files by truncating at the specified base position."""
script_info['script_description']="""This module is designed to remove regions of poor quality in
454 sequence data. Drops in quality can be visualized with the
quality_scores_plot.py module. The base position specified will
be used as an index to truncate the sequence and quality scores, and
all data at that base position and to the end of the sequence will be
removed in the output filtered files."""
script_info['script_usage']=[]
script_info['script_usage'].append(("""Example:""","""Truncate the input fasta and quality files at base position 100, output to the filtered_seqs directory:""","""%prog -f seqs.fna -q seqs.qual -b 100 -o filtered_seqs/"""))
script_info['output_description']="""Filtered versions of the input fasta and qual file (based on input name with '_filtered' appended) will be generated in the output directory"""
script_info['required_options']= [\
make_option('-f', '--fasta_fp',
type='existing_filepath',
help='Input fasta filepath to be truncated.'),
make_option('-q', '--qual_fp',
type='existing_filepath',
help='Input quality scores filepath to be truncated.'),
make_option('-b', '--base_pos', type='int',
help='Nucleotide position to truncate the fasta and quality score '+\
'files at.')
]
script_info['optional_options']= [\
make_option('-o', '--output_dir',
type = 'new_path',
help='Output directory. Will be created if does not exist. '+\
'[default: %default]', default="."),
]
script_info['version'] = __version__
def main():
option_parser, opts, args =\
parse_command_line_parameters(**script_info)
fasta_fp = opts.fasta_fp
qual_fp = opts.qual_fp
output_dir = opts.output_dir
base_pos = int(opts.base_pos)
create_dir(output_dir)
truncate_fasta_qual(fasta_fp, qual_fp, output_dir, base_pos)
if __name__ == "__main__":
main()