-
Notifications
You must be signed in to change notification settings - Fork 7
/
make-SIFT-db-all-downstream-sift4g.pl
79 lines (59 loc) · 2.42 KB
/
make-SIFT-db-all-downstream-sift4g.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
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
#!/usr/bin/perl -w
# create the SIFT databases, must be run in scripts directory because it's lookin for metadocs
use strict;
#require 'common-utils.pl';
#use Getopt::Std;
use File::Basename;
use Cwd qw(abs_path);
my $directory_of_script = dirname(abs_path(__FILE__));
require $directory_of_script . '/common-utils.pl';
use Getopt::Long qw (GetOptions);
my %options = ();
#getopts ("mhf:", \%options);
my $help = "";
my $ensembl_download = "";
my $metafile = "";
GetOptions ('help|h' => \$help,
'ensembl_download' => \$ensembl_download,
'config=s' => \$metafile );
if ($help || !$metafile || !$metafile) {
print "make-SIFT-db-all.pl\n";
print " -h help\n";
print " -config [required config file]\n";
print " -ensembl_download \n";
}
my $meta_href = readMeta($metafile);
my %meta_hash = %{$meta_href};
make_dir ($meta_hash{"PARENT_DIR"});
make_dir ($meta_hash{"PARENT_DIR"} . "/" . $meta_hash{"ORG_VERSION"});
for my $key (keys %meta_hash) {
my $value = $meta_hash{$key};
# print $value . "\n";
if ($key =~ /_DIR$/ && $key ne "PARENT_DIR") {
# print "making $value\n";
my $dir = $meta_hash{"PARENT_DIR"} . "/" . $value;
if (! -d $dir) { mkdir($dir, 0775) or die $dir . $!; }
}
}
my $siftscore_dir = $meta_hash{"PARENT_DIR"} . "/" . $meta_hash{"SINGLE_REC_WITH_SIFTSCORE_DIR"};
`perl make-sift-scores-db-batch.pl $metafile`;
print "checking the databases\n";
system ("perl check_genes.pl $metafile");
my @chromosomes = getChr ($meta_hash{"PARENT_DIR"} . "/" . $meta_hash{"GENE_DOWNLOAD_DEST"});
foreach my $chr (@chromosomes) {
my $db_file = $meta_hash{"PARENT_DIR"} . "/" . $meta_hash{"SINGLE_REC_WITH_SIFTSCORE_DIR"} . "/" . $chr . "_scores.Srecords.with_dbSNPid.sorted";
my $check_outfile = $meta_hash{"PARENT_DIR"} . "/" . $meta_hash{"ORG_VERSION"} . "/" . $chr . "_SIFTDB_stats.txt";
`python check_SIFTDB.py $db_file $check_outfile`;
}
my $pep_check_file = $meta_hash{"PARENT_DIR"} . "/ENS_peptide_check.txt";
`perl checkENSPep.pl $metafile ENS $pep_check_file`;
my $final_outfolder = $meta_hash{"PARENT_DIR"} ."/". $meta_hash{"ORG_VERSION"};
system ("cp $metafile $final_outfolder");
# make some space
my $zip_dir = $meta_hash{"PARENT_DIR"} . "/" . $meta_hash{"CHR_DOWNLOAD_DEST"} . "/*" ;
print "zipping up $zip_dir\n";
system ("gzip $zip_dir");
my $rm_dir = $meta_hash{"PARENT_DIR"} . "/" . $meta_hash{"SINGLE_REC_WITH_SIFTSCORE_DIR"} . "/*";
system ("rm $rm_dir");
print "All done!\n";
exit (0);