-
Notifications
You must be signed in to change notification settings - Fork 1
/
bam2fastq
32 lines (31 loc) · 935 Bytes
/
bam2fastq
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
#!/usr/bin/perl -w
# Transfer Bam to Fastq with samtools command
# Run the script to the Bam directory
# Contact: Shicheng Guo
# Version 1.3
# Update: 2016-02-19
use strict;
use Cwd;
my $dir=getcwd;
chdir $dir;
my @file=glob("*.bam");
mkdir "../fastq" if ! -e "../fastq";
foreach my $file(@file){
my ($sample,undef)=split /\./,$file;
open OUT,">$file.bam2fq.job";
print OUT "#!/bin/csh\n";
print OUT "#PBS -n $file.bam2fastq.job\n";
print OUT "#PBS -q glean\n"; # glean,condo,hotel
print OUT "#PBS -l nodes=1:ppn=1\n";
print OUT "#PBS -l walltime=7:00:00\n";
print OUT "#PBS -o ".$file.".bam2fastq.log\n";
print OUT "#PBS -e ".$file.".bam2fastq.err\n";
print OUT "#PBS -V\n";
print OUT "#PBS -M shihcheng.guo\@gmail.com \n";
print OUT "#PBS -m abe\n";
print OUT "#PBS -A k4zhang-group\n";
print OUT "cd $dir\n";
print OUT "samtools fastq -0 -n $file > ../fastq/$sample.fastq";
close OUT;
system("qsub $file.job");
}