0
|
1 #!/usr/bin/perl -w
|
|
2 use strict;
|
|
3 use Getopt::Long;
|
|
4
|
|
5 my %opt;
|
|
6
|
|
7
|
|
8 GetOptions(\%opt, "f=s", "b=s", "out=s", "output_path=s","id=s","m=i", "file_type=s", "both", "r=s", "version", "i");
|
|
9
|
|
10 my $cmnd;
|
|
11
|
|
12 if (exists $opt{version}){
|
|
13 $cmnd = "python /usr/local/bin/pyBarcodeFilter.py --version";
|
|
14 }
|
|
15 else{
|
|
16 $cmnd = "python /usr/local/bin/pyBarcodeFilter.py -f $opt{f} -b $opt{b} -m $opt{m} --file_type $opt{file_type}";
|
|
17
|
|
18 if(defined $opt{r}){
|
|
19
|
|
20 $cmnd.= " -r $opt{r}";
|
|
21
|
|
22 if(exists $opt{both}){
|
|
23 $cmnd .= " --both";
|
|
24 }
|
|
25 }
|
|
26
|
|
27 if(exists $opt{i}){
|
|
28 $cmnd .= " -i";
|
|
29 }
|
|
30 }
|
|
31
|
|
32 # Create the output directory (for the multiple output files)
|
|
33 my $output_path = $opt{output_path};
|
|
34
|
|
35 system $cmnd;
|
|
36
|
|
37 open(BC,$opt{b}) || die "Cannot open barcode file";
|
|
38 my %bc;
|
|
39 while(my $line = <BC>){
|
|
40 chomp($line);
|
|
41 my ($barcode,$sample) = (split(/\t/,$line))[0,1];
|
|
42 $bc{$barcode}=$sample;
|
|
43 }
|
|
44
|
|
45 system "mv barcode_statistics.txt $opt{out}";
|
|
46
|
|
47 my $ft = lc($opt{file_type});
|
|
48
|
|
49 foreach my $key(keys %bc){
|
|
50 my @split = (split(/\//,$opt{f}));
|
|
51 my $l = @split;
|
|
52 my $output = $split[$l-1];
|
|
53 $output = (split(/\./,$output))[0];
|
|
54 $output = "$output"."_"."$key"."_"."$bc{$key}"."."."$ft";
|
|
55 my $rename = "$output_path/primary_$opt{id}_$bc{$key}-1"."_visible_"."$ft";
|
|
56 system "mv $output $rename";
|
|
57
|
|
58 if(defined $opt{r}){
|
|
59 my @split2 = (split(/\//,$opt{r}));
|
|
60 $l = @split2;
|
|
61 $output = $split2[$l-1];
|
|
62 $output = (split(/\./,$output))[0];
|
|
63 $output = "$output"."_"."$key"."_"."$bc{$key}"."."."$ft";
|
|
64 $rename = "$output_path/primary_$opt{id}_$bc{$key}-2"."_visible_"."$ft";
|
|
65 system "mv $output $rename";
|
|
66 }
|
|
67 }
|
|
68
|
|
69
|
|
70 close BC;
|
|
71
|