This repository has been archived by the owner on Oct 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFilesystem.pm
102 lines (71 loc) · 2.7 KB
/
Filesystem.pm
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
98
99
100
101
102
package PGXDB::Filesystem;
require Exporter;
use Data::Dumper;
use File::Path qw(make_path);
use Term::ProgressBar;
@ISA = qw(Exporter);
@EXPORT = qw(
pgxdb_check_files_dirs
pgxdb_create_paths
pgxdb_create_log_file_names
);
################################################################################
# utilities ####################################################################
################################################################################
sub pgxdb_check_files_dirs {
my $pgxdb = shift;
my $filekey = shift;
if ($filekey !~ /^[\w\-\.]+?$/) { return $pgxdb }
my $term_bar = "\n".("=" x Term::ProgressBar->new({count => 1, silent => 1})->{term_width})."\n";
if (
(! -e $pgxdb->{parameters}->{$filekey})
||
$pgxdb->{parameters}->{$filekey} !~ /./
) {
print $term_bar.$pgxdb->{config}->{fileerrors}->{$filekey}->{message}.$term_bar;
exit;
}
$pgxdb->{parameters}->{out} =~ s/\/$//;
return $pgxdb;
}
################################################################################
sub pgxdb_create_paths {
my $pgxdb = shift;
$pgxdb->pgxdb_check_files_dirs('out');
foreach (keys %{ $pgxdb->{config}->{directories} }) {
$pgxdb->{paths}->{$_} = $pgxdb->{parameters}->{out}.'/'.$pgxdb->{config}->{directories}->{$_};
make_path($pgxdb->{paths}->{$_});
}
return $pgxdb;
}
################################################################################
sub pgxdb_create_log_file_names {
my $pgxdb = shift;
$pgxdb->{logfiles} = {
gsmDataFile => $pgxdb->{paths}->{logdir}.'/gsminfo.tab',
gsmLogFile => $pgxdb->{paths}->{logdir}.'/gsmlog.tab',
gseDataFile => $pgxdb->{paths}->{logdir}.'/gseinfo.tab',
gsmIdFile => $pgxdb->{paths}->{logdir}.'/gsmids.tab',
pmidAllFile => $pgxdb->{paths}->{logdir}.'/pmid.tab',
pmidMissingFile => $pgxdb->{paths}->{logdir}.'/pmid_missing.tab',
pmidMissingCaFile => $pgxdb->{paths}->{logdir}.'/pmid_missing_cancer.tab',
};
if ( $pgxdb->{parameters}->{randno} > 0 ) {
foreach (keys %{ $pgxdb->{logfiles} }) {
$pgxdb->{logfiles}->{ $_ } =~ s/\.tab$/,randno_$pgxdb->{parameters}->{randno}.tab/;
}}
if ( $pgxdb->{parameters}->{randpf} > 0 ) {
foreach (keys %{ $pgxdb->{logfiles} }) {
$pgxdb->{logfiles}->{ $_ } =~ s/\.tab$/,randpf_$pgxdb->{parameters}->{randpf}.tab/;
}}
if ( $pgxdb->{parameters}->{sel_platforms} =~ /GPL/ ) {
foreach (keys %{ $pgxdb->{logfiles} }) {
$pgxdb->{logfiles}->{ $_ } =~ s/\.tab$/,selpf_$pgxdb->{parameters}->{sel_platforms}.tab/;
}}
if ($pgxdb->{parameters}->{am_samples} =~ /n/i) {
foreach (keys %{ $pgxdb->{logfiles} }) {
$pgxdb->{logfiles}->{ $_ } =~ s/\.tab$/,excluding_arraymap.tab/;
}}
return $pgxdb;
}
1;