comparison old_version/optimizer.pl @ 3:221db2eb3c8e draft default tip

Uploaded
author elixir-it
date Wed, 22 Jul 2020 19:23:14 +0000
parents 6e4eb4856874
children
comparison
equal deleted inserted replaced
2:6e4eb4856874 3:221db2eb3c8e
1 #!/usr/bin/perl -w
2 use Cwd;
3
4 %arguments=
5 (
6 "fileR"=>"", #file: vcf file of affected individuals
7 "fileC"=>"", #file: vcf file of unaffected individuals
8 "ofile"=>"", #name: name of the output files
9 "AD"=>"T",
10 "XL"=>"F", #
11 "disease_clinvar"=>[4,6], #numeric mandadory, multiple values
12 "score_AF"=>[2,4], #numeric mandatory, multiple values
13 "score_functional"=>[4,6], #numeric mandatory, multiple values
14 "score_NS"=>[2,4], #numeric mandatory, multiple values
15 "score_nIND"=>[2,4], #numeric mandatory, multiple values
16 "scoreeQTL"=>[2,4], #numeric mandatory, multiple values
17 "scoreG"=>[3,5], #numeric mandatory, multiple values
18 "scoreI"=>[1..3],
19 "disease"=>"", #name optional
20 "similarD"=>"", #file optional
21 "lgenes"=>"", #file optional
22 "leQTL"=>"qfile", #file mandatory, but default value
23 "keywords"=>"kfile", #file mandatory, but default value
24 "effects"=>"efile", #file mandatory, but default value
25 "ifile"=>"inter_Hs.file"
26 "nind"=>5,
27 "AF"=>0.0001
28 );
29
30 @arguments=@ARGV;
31 for ($i=0;$i<=$#ARGV;$i+=2)
32 {
33 $act=$ARGV[$i];
34 $act=~s/-//g;
35 $val=$ARGV[$i+1];
36 if (exists $arguments{$act})
37 {
38 unless ($val=~/\:/)
39 {
40 $arguments{$act}=$val;
41 }else{
42 ($s,$e)=(split(/\:/,$val));
43 @vls=();
44 print "$s $e\n";
45 for ($I=$s;$I<=$e;$I++)
46 {
47 push(@vls,$I);
48 }
49 print "@vls\n";
50 $arguments{$act}=\@vls;
51 }
52 }else{
53 warn("$act: unknown argument\n");
54 @valid=keys %arguments;
55 warn("Valid arguments are @valid\n");
56 die("All those moments will be lost in time, like tears in rain.\n Time to die!\n");
57 }
58 #print "$act $val\n";
59 }
60
61 %compose_ARG=
62 (
63 "disease"=>1, #name optional
64 "similarD"=>1, #file optional
65 "lgenes"=>1, #file optional
66 "leQTL"=>1, #file mandatory, but default value
67 "keywords"=>1, #file mandatory, but default value
68 "effects"=>1, #file
69 "AF"=>1,
70 "nind"=>1,
71 "AD"=>1,
72 "XL"=>1,
73 "ifile"=>1
74
75 );
76
77 $dir=getcwd();
78 print "$dir\n";
79 $add_string=" ";
80
81 foreach $a (keys %compose_ARG)
82 {
83 $add_string.="-$a $arguments{$a} " if $arguments{$a} ne "";
84 }
85
86 #print "$add_string";
87
88
89 @DC=@{$arguments{"disease_clinvar"}}; #=>[2..8], #numeric mandadory, but default value
90 @AF=@{$arguments{"score_AF"}}; #numeric mandatory, but default value
91 @FUN=@{$arguments{"score_functional"}}; #=>[2..8], #numeric mandatory, but default value
92 @NS=@{$arguments{"score_NS"}}; #=>[2..8], #numeric mandatory, but default value
93 @NI=@{$arguments{"score_nIND"}}; #=>[2..8], #numeric mandatory, but default value
94 @Q=@{$arguments{"scoreeQTL"}}; #numeric mandatory, but default value
95 @G=@{$arguments{"scoreG"}}; #=>[1..3], #numeric mandatory, but default value
96 @I=@{$arguments{"scoreI"}};
97
98 $Rfile=$arguments{"fileR"};
99 $Tfile=$arguments{"fileC"};
100 $Ofile=$arguments{"ofile"};
101 open(O,">$Ofile");
102 print O "disease_clinvar\tscore_AF\tscore_functional\tscore_NS\tscore_nIND\tscoreeQTL\tscoreG\tCut_off\tPosD\tPosH\tPvalue\tFold_change\n";
103 $commandR="perl $dir/score_complete_alt_M.pl -vcf $dir/$Rfile -ofile $dir/R.csv -ovcfile $dir/R.vcf $add_string";
104 $commandT="perl $dir/score_complete_alt_M.pl -vcf $dir/$Tfile -ofile $dir/T.csv -ovcfile $dir/T.vcf $add_string";
105
106
107 foreach $dc (@DC)
108 {
109
110 foreach $af (@AF)
111 {
112
113 foreach $fun (@FUN)
114 {
115
116 foreach $ns (@NS)
117 {
118
119 foreach $ni (@NI)
120 {
121
122
123 foreach $Q (@Q)
124 {
125 foreach $G (@G)
126 {
127 foreach $I (@I)
128 {
129 $commandR.="-score_AF $af ";
130 $commandT.="-score_AF $af ";
131 $commandR.="-score_functional $fun ";
132 $commandT.="-score_functional $fun ";
133 $commandR.="-score_NS $ns ";
134 $commandT.="-score_NS $ns ";
135 $commandR.="-score_nIND $ni ";
136 $commandT.="-score_nIND $ni ";
137 $commandR.="-scoreeQTL $Q ";
138 $commandT.="-scoreeQTL $Q ";
139 $commandR.="-disease_clinvar $dc ";
140 $commandT.="-disease_clinvar $dc ";
141 $commandR.="-scoreG $G ";
142 $commandT.="-scoreG $G ";
143 $commandR.="-scoreI $I ";
144 $commandT.="-scoreI $I ";
145
146 #print "$commandR\n$commandT\n";
147 system($commandR)==0||die("Non giro Rfile");
148 system($commandT)==0||die("Non giro Tfile");
149 $commandR="perl $dir/score_complete_alt_M.pl -vcf $dir/$Rfile -ofile $dir/R.csv -ovcfile $dir/R.vcf $add_string";
150 $commandT="perl $dir/score_complete_alt_M.pl -vcf $dir/$Tfile -ofile $dir/T.csv -ovcfile $dir/T.vcf $add_string";
151
152 $r=`Rscript --vanilla $dir/survival_optM.R $dir/R.csv $dir/T.csv`;
153
154 print O "$dc\t$af\t$fun\t$ns\t$ni\t$Q\t$G\t$r\n";
155 }
156 #die();
157 }
158 }
159 }
160 }
161 }
162 }
163 }