forked from DLWheeler/Pipeliner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
symfiles.pl
executable file
·47 lines (40 loc) · 1.14 KB
/
symfiles.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
#!/usr/bin/perl
#############################################################
##
## Syntax: symfiles [path_to_raw_data] [tab_file] [path_to_work_dir]
##
###############################################################
use strict;
my $dir = $ARGV[0];
my $filetab = $ARGV[1];
my $outd = $ARGV[2];
opendir(DH, $dir) || die "Can not open $dir: $!";
my @files=readdir DH;
close DH;
## mkdir "$dir\/symdata", 0755;
open IN, $filetab or die "no input file";
my ($old, $new, %repl);
while(<IN>){
chomp;
($old, $new) = split /\t/;
$repl{$old} = $new;
}
close IN;
#for my $oldfile (@files){
# for my $oold (keys %repl){
# if (($oldfile =~ /$oold[_|\.]/) && (my ($a,$r) = $oldfile =~ /(\.|_)(R\d)/) && ($oldfile =~ /fastq\.gz/)){
# my $newfile = $repl{$oold} . "." . $r . ".fastq.gz";
# symlink ("$dir\/$oldfile", "$outd\/$newfile");
# last;
# }
# }
#}
for my $oldfile (@files){
for my $oold (keys %repl){
if ($oldfile eq $oold) {
my $newfile = $repl{$oold};
symlink ("$dir\/$oldfile", "$outd\/$newfile");
last;
}
}
}