#!/usr/bin/perl -w use SOAP::Lite; my $service = SOAP::Lite -> service('http://prodom.prabi.fr/prodom/current/wsdl/fetchProDom.wsdl') -> on_fault( sub { my($self, $res) = @_; die "faultcode:", ref $res ? $res->faultcode : $self->transport->status, "\n" , "faultstring:", ref $res ? $res->faultstring : $self->transport->status, "\n"; }); my @allowedMethods = ("runFetchFasta", "runFetchDom", "runFetchAlign", "runFetchKW","runFetchProt"); my $method; if (! @ARGV) { &printUsage; } else{ $method = shift @ARGV; foreach my $i (@allowedMethods) { if ($method eq $i) { &makeSOAPCall; } } } sub makeSOAPCall { my $result; my @resultat; if ($method eq "runFetchFasta") { #$result = $ARGV[0]; if ($ARGV[0] =~ /^PD/) { $result = $service->runFetchFasta($ARGV[0]); print $result; } elsif ($ARGV[0] =~ /txt/){ my $file; open(FILE,"$ARGV[0]"); while (){ $file .= $_; } close(FILE); $file =~ s/\n/ /g; #$result=$file; $result= $service->runFetchFasta($file); print $result; } } elsif ($method eq "runFetchDom") { if ($ARGV[0] =~ /^PD/) { $result = $service->runFetchDom($ARGV[0]); print $result; } elsif ($ARGV[0] =~ /txt/){ my $file; open(FILE,"$ARGV[0]"); while (){ $file .= $_; } close(FILE); $file =~ s/\n/ /g; #$result=$file; $result= $service->runFetchDom($file); print $result; } } elsif ($method eq "runFetchProt") { $result = $service->runFetchProt($ARGV[0]); print $result; } elsif ($method eq "runFetchAlign") { if ($ARGV[0] =~ /^PD/) { @resultat = $service->runFetchAlign($ARGV[0]); print @resultat; } else { $result = "Not a valid ProDom AC PD+6digits(eg. PD000039)"; print $result; } } elsif ($method eq "runFetchKW") { my $j; my $numArgs= $#ARGV + 1; my $argkw ; #$argkw = $ARGV[0] . " "; for ($j=0;$j<$numArgs;$j++){ $argkw .= $ARGV[$j]; $argkw .= " "; } #$result = $argkw; $result = $service->runFetchKWscript($argkw); print $result; } else { &printUsage; } exit(0); } #my $result = $service->runFetchFasta($f); #print 'test tibou', # $service->hi($f); # print $result; sub printUsage { print "USAGE: \n"; print "------ \n"; print "runFetchFasta \n Enter a ProDom AC (PD+6digits) of a file name.txt with a list of ProDom AC .\n\n"; print " runFetchDom \n Enter a ProDom AC (PD+6digits) of a file name.txt with a list of ProDom AC . \n\n"; print " runFetchProt \n\n"; print " runFetchAlign (PD+6digits)\n\n"; print "runFetchKW please enter or as connector if you have only one keyword\n"; print "eg : perl fetchprodom.perl runFetchFasta file.txt or perl fetchprodom.perl runFetchFasta PD000039 \n\n"; exit(0); }