comparison optimizer_genetic.pl @ 0:4c6529d120c3 draft

Uploaded
author elixir-it
date Tue, 09 Jun 2020 16:07:19 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c6529d120c3
1 #!/usr/bin/perl -w
2 use Cwd;
3 use strict;
4 #scoreN=c("-disease_clinvar","-score_AF","-score_functional",
5 # "-score_NS","-score_nIND","-scoreeQTL",
6 # "-scoreG","-scoreT","-scoreM",
7 # "-scoreR","-scoreSP","-scoreGW")
8
9
10 my %arguments=
11 (
12 "fileR"=>"", #file: vcf file of affected individuals
13 "fileC"=>"", #file: vcf file of unaffected individuals
14 "ofile"=>"", #name: name of the output files
15 "AD"=>"T",
16 "XL"=>"F", #
17 "disease_clinvar"=>[1,10], #numeric mandadory, multiple values
18 "score_AF"=>[1,10], #numeric mandatory, multiple values
19 "score_functional"=>[1,10], #numeric mandatory, multiple values
20 "score_NS"=>[1,10], #numeric mandatory, multiple values
21 "score_nIND"=>[1,10], #numeric mandatory, multiple values
22 "scoreeQTL"=>[1,10], #numeric mandatory, multiple values
23 "scoreG"=>[1,10], #numeric mandatory, multiple values
24 "scoreT"=>[1,10],
25 "scoreM"=>[1,10],
26 "scoreR"=>[1,10],
27 "scoreSP"=>[1,10],
28 "scoreGW"=>[1,10],
29 "disease"=>"", #name optional
30 "similarD"=>"", #file optional
31 "lgenes"=>"", #file optional
32 "leQTL"=>"qfile", #file mandatory, but default value
33 "keywords"=>"kfile", #file mandatory, but default value
34 "effects"=>"efile", #file mandatory, but default value
35 "nind"=>5,
36 "AF"=>0.0001
37 );
38
39 my @arguments=@ARGV;
40 for (my $i=0;$i<=$#ARGV;$i+=2)
41 {
42 my $act=$ARGV[$i];
43 $act=~s/-//g;
44 my $val=$ARGV[$i+1];
45 if (exists $arguments{$act})
46 {
47 unless ($val=~/\:/)
48 {
49 $arguments{$act}=$val;
50 }else{
51 my ($s,$e)=(split(/\:/,$val));
52 $arguments{$act}=[$s,$e];
53 }
54 }else{
55 warn("$act: unknown argument\n");
56 my @valid=keys %arguments;
57 warn("Valid arguments are @valid\n");
58 die("All those moments will be lost in time, like tears in rain.\n Time to die!\n");
59 }
60 #print "$act $val\n";
61 }
62
63 my %compose_ARG=
64 (
65 "disease"=>1, #name optional
66 "similarD"=>1, #file optional
67 "lgenes"=>1, #file optional
68 "leQTL"=>1, #file mandatory, but default value
69 "keywords"=>1, #file mandatory, but default value
70 "effects"=>1, #file
71 "AF"=>1,
72 "nind"=>1,
73 "AD"=>1,
74 "XL"=>1,
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 @T=@{$arguments{"scoreT"}};
94 my @M=@{$arguments{"scoreM"}};
95 my @R=@{$arguments{"scoreR"}};
96 my @SP=@{$arguments{"scoreSP"}};
97 my @GW=@{$arguments{"scoreGW"}};
98
99 my $Rfile=$arguments{"fileR"};
100 my $Cfile=$arguments{"fileC"};
101 my $Ofile=$arguments{"ofile"};
102
103 my $minVals="$DC[0] $AF[0] $FUN[0] $NS[0] $NI[0] $Q[0] $G[0] $T[0] $M[0] $R[0] $SP[0] $GW[0]";
104 my $maxVals="$DC[1] $AF[1] $FUN[1] $NS[1] $NI[1] $Q[1] $G[1] $T[1] $M[1] $R[1] $SP[1] $GW[1]";
105
106 system("Rscript --vanilla $dir/GENEO_VINYL.R $Rfile $Cfile \"$add_string\" \"$minVals\" \"$maxVals\" $Ofile.tmp")==0||die("no optimization");
107
108 system("(head -n 1 $Ofile.tmp && tail -n +1 $Ofile.tmp | sort -nk 19 -r) > $Ofile")==0||die("no sort");
109