Mercurial > repos > elixir-it > vinyl_optimizer
comparison old_version/optimizer_M.pl @ 2:6e4eb4856874 draft
Uploaded
| author | elixir-it |
|---|---|
| date | Wed, 22 Jul 2020 19:20:30 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:35c308dd6420 | 2:6e4eb4856874 |
|---|---|
| 1 #!/usr/bin/perl -w | |
| 2 use Cwd; | |
| 3 use strict; | |
| 4 | |
| 5 my %arguments= | |
| 6 ( | |
| 7 "fileR"=>"", #file: vcf file of affected individuals | |
| 8 "fileC"=>"", #file: vcf file of unaffected individuals | |
| 9 "ofile"=>"", #name: name of the output files | |
| 10 "AD"=>"T", | |
| 11 "XL"=>"F", # | |
| 12 "disease_clinvar"=>[4,6], #numeric mandadory, multiple values | |
| 13 "score_AF"=>[2,4], #numeric mandatory, multiple values | |
| 14 "score_functional"=>[4,6], #numeric mandatory, multiple values | |
| 15 "score_NS"=>[2,4], #numeric mandatory, multiple values | |
| 16 "score_nIND"=>[2,4], #numeric mandatory, multiple values | |
| 17 "scoreeQTL"=>[2,4], #numeric mandatory, multiple values | |
| 18 "scoreG"=>[3,5], #numeric mandatory, multiple values | |
| 19 "scoreI"=>[0.1..0.3], | |
| 20 "disease"=>"", #name optional | |
| 21 "similarD"=>"", #file optional | |
| 22 "lgenes"=>"", #file optional | |
| 23 "leQTL"=>"qfile", #file mandatory, but default value | |
| 24 "keywords"=>"kfile", #file mandatory, but default value | |
| 25 "effects"=>"efile", #file mandatory, but default value | |
| 26 "ifile"=>"inter_Hs.file", | |
| 27 "nind"=>5, | |
| 28 "AF"=>0.0001 | |
| 29 ); | |
| 30 | |
| 31 my @arguments=@ARGV; | |
| 32 for (my $i=0;$i<=$#ARGV;$i+=2) | |
| 33 { | |
| 34 my $act=$ARGV[$i]; | |
| 35 $act=~s/-//g; | |
| 36 my $val=$ARGV[$i+1]; | |
| 37 if (exists $arguments{$act}) | |
| 38 { | |
| 39 unless ($val=~/\:/) | |
| 40 { | |
| 41 $arguments{$act}=$val; | |
| 42 }else{ | |
| 43 my ($s,$e)=(split(/\:/,$val)); | |
| 44 my $increment= $s=~/\./ ? 0.1 : 1; | |
| 45 my @vls=(); | |
| 46 for (my $I=$s;$I<=$e;$I+=$increment) | |
| 47 { | |
| 48 push(@vls,$I); | |
| 49 } | |
| 50 $arguments{$act}=\@vls; | |
| 51 } | |
| 52 }else{ | |
| 53 warn("$act: unknown argument\n"); | |
| 54 my @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 my %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 my $dir=getcwd(); | |
| 78 my $add_string=" "; | |
| 79 | |
| 80 foreach my $a (keys %compose_ARG) | |
| 81 { | |
| 82 $add_string.="-$a $arguments{$a} " if $arguments{$a} ne ""; | |
| 83 } | |
| 84 | |
| 85 | |
| 86 my @DC=@{$arguments{"disease_clinvar"}}; #=>[2..8], #numeric mandadory, but default value | |
| 87 my @AF=@{$arguments{"score_AF"}}; #numeric mandatory, but default value | |
| 88 my @FUN=@{$arguments{"score_functional"}}; #=>[2..8], #numeric mandatory, but default value | |
| 89 my @NS=@{$arguments{"score_NS"}}; #=>[2..8], #numeric mandatory, but default value | |
| 90 my @NI=@{$arguments{"score_nIND"}}; #=>[2..8], #numeric mandatory, but default value | |
| 91 my @Q=@{$arguments{"scoreeQTL"}}; #numeric mandatory, but default value | |
| 92 my @G=@{$arguments{"scoreG"}}; #=>[1..3], #numeric mandatory, but default value | |
| 93 my @I=@{$arguments{"scoreI"}}; | |
| 94 | |
| 95 my $Rfile=$arguments{"fileR"}; | |
| 96 my $Tfile=$arguments{"fileC"}; | |
| 97 my $Ofile=$arguments{"ofile"}; | |
| 98 | |
| 99 #print "@DC\n @AF\n @FUN\n @NS\n @NI\n @Q\n @G\n @I\n"; | |
| 100 | |
| 101 open(O,">$Ofile"); | |
| 102 print O "score_DB\tscore_RV\tscore_FE\tscore_NS\tscore_OR\tscore_eQ\tscore_AD\tScore_DG\tCut_Off\tPos_Affected\tPos_Healthy\tPvalue\tFold_change\n"; | |
| 103 | |
| 104 | |
| 105 my $commandR="perl $dir/score_complete_alt_M.pl -vcf $dir/$Rfile -ofile $dir/R.csv -ovcfile $dir/R.vcf $add_string"; | |
| 106 my $commandT="perl $dir/score_complete_alt_M.pl -vcf $dir/$Tfile -ofile $dir/T.csv -ovcfile $dir/T.vcf $add_string"; | |
| 107 my %ODATA=(); | |
| 108 | |
| 109 foreach my $dc (@DC) | |
| 110 { | |
| 111 | |
| 112 foreach my $af (@AF) | |
| 113 { | |
| 114 | |
| 115 foreach my $fun (@FUN) | |
| 116 { | |
| 117 | |
| 118 foreach my $ns (@NS) | |
| 119 { | |
| 120 | |
| 121 foreach my $ni (@NI) | |
| 122 { | |
| 123 | |
| 124 | |
| 125 foreach my $Q (@Q) | |
| 126 { | |
| 127 foreach my $G (@G) | |
| 128 { | |
| 129 foreach my $I (@I) | |
| 130 { | |
| 131 $commandR.="-score_AF $af "; | |
| 132 $commandT.="-score_AF $af "; | |
| 133 $commandR.="-score_functional $fun "; | |
| 134 $commandT.="-score_functional $fun "; | |
| 135 $commandR.="-score_NS $ns "; | |
| 136 $commandT.="-score_NS $ns "; | |
| 137 $commandR.="-score_nIND $ni "; | |
| 138 $commandT.="-score_nIND $ni "; | |
| 139 $commandR.="-scoreeQTL $Q "; | |
| 140 $commandT.="-scoreeQTL $Q "; | |
| 141 $commandR.="-disease_clinvar $dc "; | |
| 142 $commandT.="-disease_clinvar $dc "; | |
| 143 $commandR.="-scoreG $G "; | |
| 144 $commandT.="-scoreG $G "; | |
| 145 $commandR.="-scoreI $I "; | |
| 146 $commandT.="-scoreI $I "; | |
| 147 | |
| 148 system($commandR)==0||die("Non giro Rfile"); | |
| 149 system($commandT)==0||die("Non giro Tfile"); | |
| 150 $commandR="perl $dir/score_complete_alt_M.pl -vcf $dir/$Rfile -ofile $dir/R.csv -ovcfile $dir/R.vcf $add_string"; | |
| 151 $commandT="perl $dir/score_complete_alt_M.pl -vcf $dir/$Tfile -ofile $dir/T.csv -ovcfile $dir/T.vcf $add_string"; | |
| 152 my $r=`Rscript --vanilla $dir/wilcox.R $dir/R.csv $dir/T.csv`; | |
| 153 my $PV=(split(/\t/,$r))[3]; | |
| 154 push(@{$ODATA{$PV}},"$dc\t$af\t$fun\t$ns\t$ni\t$Q\t$G\t$I\t$r\n"); | |
| 155 } | |
| 156 } | |
| 157 } | |
| 158 } | |
| 159 } | |
| 160 } | |
| 161 } | |
| 162 } | |
| 163 | |
| 164 foreach my $O (sort {$a<=>$b} keys %ODATA) | |
| 165 { | |
| 166 my @values=@{$ODATA{$O}}; | |
| 167 foreach my $v (@values) | |
| 168 { | |
| 169 print O "$v"; | |
| 170 } | |
| 171 } |
