-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathprepareSoapFuseTN.pl
More file actions
61 lines (49 loc) · 1.74 KB
/
prepareSoapFuseTN.pl
File metadata and controls
61 lines (49 loc) · 1.74 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env perl
# prepare soapFuse file structure using samples.txt file
# print out soapfuse samples file
use strict;
use warnings;
use File::Path qw/make_path/;
use Getopt::Std;
my %opt;
getopts('h', \%opt);
my $usage = <<ENDL;
Usage: ./prepareSoapFuse.pl [samples_sets.txt]
ENDL
sub HELP_MESSAGE {
print STDERR $usage;
exit(1);
}
HELP_MESSAGE if $opt{h};
sub getReadLength {
my $fqFile = $_[0];
open IN, "zcat $fqFile | head |" or die "Unable to open $fqFile\n";
<IN>;
return length(<IN>);
}
while (my $line = <>) {
chomp $line;
my @sampleSet = split / /, $line;
# last sample is normal
my $normalSample = $sampleSet[$#sampleSet];
for my $tumorSample (@sampleSet[0..($#sampleSet-1)]) {
my $tFq1 = "fastq/$tumorSample.1.fastq.gz";
my $tFq2 = "fastq/$tumorSample.2.fastq.gz";
my $nFq1 = "fastq/$normalSample.1.fastq.gz";
my $nFq2 = "fastq/$normalSample.2.fastq.gz";
die "Cannot find fastq files ($tFq1 and $tFq2)" unless (-e $tFq1 && -e $tFq1);
die "Cannot find fastq files ($nFq1 and $nFq2)" unless (-e $nFq1 && -e $nFq1);
my $tSampleDir = "soapfuse/$sample-T/$sample";
my $nSampleDir = "soapfuse/$sample-N/$sample";
make_path($tSampleDir);
make_path($nSampleDir);
system "ln -f $tFq1 $tSampleDir/${sample}_1.fastq.gz";
system "ln -f $tFq2 $tSampleDir/${sample}_2.fastq.gz";
system "ln -f $nFq1 $nSampleDir/${sample}_1.fastq.gz";
system "ln -f $nFq2 $nSampleDir/${sample}_2.fastq.gz";
my $tReadLength = &getReadLength($tFq1);
my $nReadLength = &getReadLength($nFq1);
print "$sample-T\t$sample\t$sample\t$tReadLength\n";
print "$sample-N\t$sample\t$sample\t$nReadLength\n";
}
}