forked from igordot/sns
-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-settings
executable file
·67 lines (48 loc) · 1.5 KB
/
generate-settings
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
#!/usr/bin/env perl
use strict;
use warnings;
use File::Basename;
my $HELP = <<HELP;
Generate the initial settings.txt file for a specified genome.
usage: generate-settings genome
* genome = name (hg19, mm10, etc.) or exact dir (contains genome.fa and genes.gtf)
HELP
if (!$ARGV[0]) {
die $HELP;
}
main();
# main subroutine
sub main {
my $genome_arg = $ARGV[0];
# pipeline directory (the directory that this file is in)
my $pipeline_dir = dirname(__FILE__);
# settings file
my $settings_file = "settings.txt";
# check if the settings file already exists
if ( -e $settings_file ) {
die "\n\n ERROR: FILE $settings_file ALREADY EXISTS (DELETE IT TO GENERATE A NEW ONE) \n\n";
}
# set genome setting
my $genome_dir_setting;
if ($genome_arg =~ m/\//) {
# use directory if given
$genome_dir_setting = "GENOME-DIR|${genome_arg}\n";
}
else {
# use /gpfs/data/igorlab/ref if genome name is provided
$genome_dir_setting = "GENOME-DIR|/gpfs/data/igorlab/ref/${genome_arg}\n";
}
# save genome setting
open(my $fh, ">", $settings_file);
# print $fh $genome_setting;
print $fh $genome_dir_setting;
close $fh;
# get values to make sure they were set properly
my $settings_genome = `bash ${pipeline_dir}/scripts/get-set-setting.sh $settings_file GENOME-DIR`;
my $settings_fasta = `bash ${pipeline_dir}/scripts/get-set-setting.sh $settings_file REF-FASTA`;
# print values
print STDERR "\n";
print STDERR " REF DIR : $settings_genome \n";
print STDERR " REF FASTA : $settings_fasta \n";
}
# end