forked from LangilleLab/microbiome_helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_fastq_to_fasta.pl
executable file
·98 lines (63 loc) · 2.15 KB
/
run_fastq_to_fasta.pl
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/perl
use warnings;
use strict;
use File::Basename;
use Getopt::Long;
use Pod::Usage;
use Parallel::ForkManager;
my ($parallel,$help);
my $out_dir='./';
my $res = GetOptions("out_dir=s" => \$out_dir,
"parallel:i"=>\$parallel,
"help"=>\$help,
)or pod2usage(2);
pod2usage(-verbose=>2) if $help;
my @files=@ARGV;
pod2usage($0.': You must provide a list of fastq files to be converted.') unless @files;
#make output directory
system("mkdir -p $out_dir");
my $cpu_count=0;
#if the option is set
if(defined($parallel)){
#option is set but with no value then use the max number of proccessors
if($parallel ==0){
#load this module dynamically
eval("use Sys::CPU;");
$cpu_count=Sys::CPU::cpu_count();
}else{
$cpu_count=$parallel;
}
}
my $pm = new Parallel::ForkManager($cpu_count);
foreach my $file (@files){
my $pid = $pm->start and next;
my ($file_name,$dir)=fileparse($file, qr/\.[^.]*/);
my $out_file=$out_dir.'/'.$file_name.'.fasta';
my $cmd="fastq_to_fasta -i $file -o $out_file";
print $cmd,"\n";
system($cmd);
$pm->finish;
}
$pm->wait_all_children;
__END__
=head1 Name
run_fastq_to_fasta.pl - A wrapper of the FASTX-Toolkit command "fastq_to_fasta"
=head1 USAGE
run_fastq_to_fasta [-p [<# proc>] -o <out_dir> -h] <list of fastq files>
=head1 OPTIONS
=over 4
=item B<-o, --out_dir <file>>
The name of the output directory to place all FASTA output files.
=item B<-p, --parallel [<# of proc>]>
Using this option without a value will use all CPUs on machine, while giving it a value will limit to that many CPUs. Without option only one CPU is used.
=item B<-h, --help>
Displays the entire help documentation.
=back
=head1 DESCRIPTION
B<run_fastq_to_fasta.pl> This script simplifies running the FASTX-Toolkit "fastq_to_fasta" command by allowing multiple FASTQs to be converted with 1 command.
Make sure that the FASTX-Toolkit command "fastq_to_fasta" is in your PATH before running this script.
FASTX-Toolkit website: http://hannonlab.cshl.edu/fastx_toolkit/
=head1 AUTHOR
Morgan Langille, E<lt>morgan.g.i.langille@gmail.comE<gt>
Minor updates by Gavin Douglas (gavin.douglas@dal.ca)
=cut