Mercurial > repos > geert-vandeweyer > vcf_to_variantdb
diff 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 |
line wrap: on
line diff
--- a/VCF_to_VariantDB.pl Wed May 08 04:34:30 2013 -0400 +++ b/VCF_to_VariantDB.pl Wed Feb 19 06:45:32 2014 -0500 @@ -22,7 +22,7 @@ # H = (H)ost of the galaxy web server (http://my.galaxy.server/galaxy/) getopts('v:u:n:a:g:o:b:B:V:c:S:R:H:', \%opts); # option are in %opts - +$|++; ################# ## CHECK INPUT ## ################# @@ -55,6 +55,7 @@ $url =~ s/\/\/$/\//; $url .= "cgi-bin/galaxy_communication.cgi"; my $conn = LWP::UserAgent->new(); +$conn->timeout(1800); my $response = $conn->post( $url, {'HelloWorld' => 1} ); my $content = $response->decoded_content(); @@ -113,20 +114,42 @@ $gender = $opts{'g'}; # post form to the variantDB host. if (exists($opts{'b'})) { - $response = $conn->post( $url, {'VCFurl1' => "$vcfurl", 'BAMurl1' => "$bamurl", 'BAIurl1' => "$bamidxurl",'storedata' => 1, 'name1' => "$sample", 'gender1' => "$gender", 'User' => $email} ); + $response = $conn->post( $url, {'VCFurl1' => "$vcfurl", 'BAMurl1' => "$bamurl", 'BAIurl1' => "$bamidxurl",'storedata1' => 1, 'name1' => "$sample", 'gender1' => "$gender", 'User' => $email, 'GalaxyUpload' => 1} ); } else { - $response = $conn->post( $url, {'VCFurl1' => "$vcfurl", 'sample1' => "$sample", 'gender1' => "$gender", 'User' => $email} ); + $response = $conn->post( $url, {'VCFurl1' => "$vcfurl", 'name1' => "$sample", 'gender1' => "$gender", 'User' => $email, 'GalaxyUpload' =>1 } ); } my $content = $response->decoded_content(); chomp($content); -if ($content =~ m/OK$/) { - print OUT "Processing Datafiles : OK.\n"; - print OUT "\n$content\n"; -} -else { +## check if upload went ok. +if (substr($content,0,2) ne 'OK') { die("ERROR: $content"); } +## extract wd from content. +print OUT "Uploading datafiles to VariantDB : OK.\n"; +$content =~ m/OK-(.+)$/; +$rwd = $1; +if ($rwd eq '') { + die("ERROR : No remote working directory provided to check status."); +} +## now wait for the import to finish. +$status = 0; +while ($status == 0) { + my $response = $conn->post( $url, {'CheckStatus' => 1,'rwd' => $rwd}) ; + $content = $response->decoded_content(); + chomp($content); + if (substr($content,0,2) ne 'OK') { + die("ERROR: $content"); + } + $status = substr($content,3,1); + sleep 10; +} + +## Loading OK +# latest respons : OK-1-Content +$content = substr($content,5); +print OUT "Processing Datafiles : OK.\n"; +print OUT "\n$content\n"; close OUT; # clean up