comparison VCF_to_VariantDB.pl @ 2:d03a63a57e82 draft

New version, better following configuration guidelines
author geert-vandeweyer
date Wed, 19 Feb 2014 06:45:32 -0500
parents 355e491dbd0f
children 6ddc1c6472ef
comparison
equal deleted inserted replaced
1:355e491dbd0f 2:d03a63a57e82
20 # S = (S)erver addrress to send data to. 20 # S = (S)erver addrress to send data to.
21 # R = (r)oot of galaxy web server (/home/galaxyuser/galaxy-dist) 21 # R = (r)oot of galaxy web server (/home/galaxyuser/galaxy-dist)
22 # H = (H)ost of the galaxy web server (http://my.galaxy.server/galaxy/) 22 # H = (H)ost of the galaxy web server (http://my.galaxy.server/galaxy/)
23 getopts('v:u:n:a:g:o:b:B:V:c:S:R:H:', \%opts); # option are in %opts 23 getopts('v:u:n:a:g:o:b:B:V:c:S:R:H:', \%opts); # option are in %opts
24 24
25 25 $|++;
26 ################# 26 #################
27 ## CHECK INPUT ## 27 ## CHECK INPUT ##
28 ################# 28 #################
29 if (!exists($opts{'v'})) { 29 if (!exists($opts{'v'})) {
30 die('No VCF File Specified'); 30 die('No VCF File Specified');
53 use LWP::UserAgent; 53 use LWP::UserAgent;
54 my $url = $opts{'S'}."/"; 54 my $url = $opts{'S'}."/";
55 $url =~ s/\/\/$/\//; 55 $url =~ s/\/\/$/\//;
56 $url .= "cgi-bin/galaxy_communication.cgi"; 56 $url .= "cgi-bin/galaxy_communication.cgi";
57 my $conn = LWP::UserAgent->new(); 57 my $conn = LWP::UserAgent->new();
58 $conn->timeout(1800);
58 my $response = $conn->post( $url, {'HelloWorld' => 1} ); 59 my $response = $conn->post( $url, {'HelloWorld' => 1} );
59 my $content = $response->decoded_content(); 60 my $content = $response->decoded_content();
60 61
61 if ($content eq 'HelloGalaxy') { 62 if ($content eq 'HelloGalaxy') {
62 print OUT "Testing connection to $opts{'S'} : OK.\n"; 63 print OUT "Testing connection to $opts{'S'} : OK.\n";
111 } 112 }
112 $sample = $opts{'n'}; 113 $sample = $opts{'n'};
113 $gender = $opts{'g'}; 114 $gender = $opts{'g'};
114 # post form to the variantDB host. 115 # post form to the variantDB host.
115 if (exists($opts{'b'})) { 116 if (exists($opts{'b'})) {
116 $response = $conn->post( $url, {'VCFurl1' => "$vcfurl", 'BAMurl1' => "$bamurl", 'BAIurl1' => "$bamidxurl",'storedata' => 1, 'name1' => "$sample", 'gender1' => "$gender", 'User' => $email} ); 117 $response = $conn->post( $url, {'VCFurl1' => "$vcfurl", 'BAMurl1' => "$bamurl", 'BAIurl1' => "$bamidxurl",'storedata1' => 1, 'name1' => "$sample", 'gender1' => "$gender", 'User' => $email, 'GalaxyUpload' => 1} );
117 } 118 }
118 else { 119 else {
119 $response = $conn->post( $url, {'VCFurl1' => "$vcfurl", 'sample1' => "$sample", 'gender1' => "$gender", 'User' => $email} ); 120 $response = $conn->post( $url, {'VCFurl1' => "$vcfurl", 'name1' => "$sample", 'gender1' => "$gender", 'User' => $email, 'GalaxyUpload' =>1 } );
120 } 121 }
121 my $content = $response->decoded_content(); 122 my $content = $response->decoded_content();
122 chomp($content); 123 chomp($content);
123 if ($content =~ m/OK$/) { 124 ## check if upload went ok.
124 print OUT "Processing Datafiles : OK.\n"; 125 if (substr($content,0,2) ne 'OK') {
125 print OUT "\n$content\n";
126 }
127 else {
128 die("ERROR: $content"); 126 die("ERROR: $content");
129 } 127 }
128 ## extract wd from content.
129 print OUT "Uploading datafiles to VariantDB : OK.\n";
130 $content =~ m/OK-(.+)$/;
131 $rwd = $1;
132 if ($rwd eq '') {
133 die("ERROR : No remote working directory provided to check status.");
134 }
135 ## now wait for the import to finish.
136 $status = 0;
137 while ($status == 0) {
138 my $response = $conn->post( $url, {'CheckStatus' => 1,'rwd' => $rwd}) ;
139 $content = $response->decoded_content();
140 chomp($content);
141 if (substr($content,0,2) ne 'OK') {
142 die("ERROR: $content");
143 }
144 $status = substr($content,3,1);
145 sleep 10;
146 }
147
148 ## Loading OK
149 # latest respons : OK-1-Content
150 $content = substr($content,5);
151 print OUT "Processing Datafiles : OK.\n";
152 print OUT "\n$content\n";
130 close OUT; 153 close OUT;
131 154
132 # clean up 155 # clean up
133 system("rm -Rf '$wd'"); 156 system("rm -Rf '$wd'");
134 157