#!/usr/bin/perl # Description: Reads a genomic sequence from STDIN and submits to RNAMmer to predict rRNA genes # Author: Peter Fischer Hallin # Email: pfh@cbs.dtu.dk # Version: 1.2 ws0 # Date: 2008-11-19 # include standard XML::Compile helper functions (used to initiate WSDL proxys) require "xml-compile.pl"; require "fasta.inc.pl"; my @fasta = read_fasta(); my $rnammer = WSDLclient ( 'http://www.cbs.dtu.dk/ws/RNAmmer/RNAmmer_1_2_ws0.wsdl' ); my ($kingdom , $mol) = @ARGV; $kingdom = "bac" unless defined $kingdom; $mol = "ssu,lsu,tsu" unless defined $mol; print STDERR "# kingdom: $kingdom\n"; print STDERR "# mol: $mol\n"; for ( my $i = 0 ; $i < scalar ( @fasta ) ; $i++ ) { my $ident = $fasta[$i]->{id}; my $comment = $fasta[$i]->{comment}; my $seq = $fasta[$i]->{seq}; run_rnammer ($ident,$comment,$seq,$kingdom,$mol) ; } sub run_rnammer { my ($jobid,$status,$expires); my ($ident,$comment,$seq,$kingdom,$mol) = @_; my $response; $response = $rnammer->{runService}->( parameters => { parameters => { mol => $mol ,kingdom => $kingdom , sequences => { entry => { ident => $ident , seq => $seq}}}}); die "error obtaining jobid\n" unless defined ( $response->{parameters}->{queueentry}); $jobid = $response->{parameters}->{queueentry}->{jobid}; wait_job($rnammer->{pollQueue},$jobid); $response = $rnammer->{fetchResult}->( job => { jobid => $jobid }) ; print STDERR "# parsing 'anndata' object\n"; printf STDERR "# annotations from %s version %s\n" , $response->{parameters}->{anndata}->{annsource}->{method} , $response->{parameters}->{anndata}->{annsource}->{version}; foreach my $ann (@{$response->{parameters}->{output}->{entries}->{entry}}) { my $inp_id = $ann->{sequenceEntry}; my ( $begin , $end ) = ( $ann->{start} , $ann->{stop} ); my $strand = $ann->{direction}; my $mol = $ann->{mol}; my $id; if ( $strand eq "+") { $id = "rRNA_$begin-$end"; } else { $id = "rRNA_$end-$begin"; } my $gene = $ann->{sequence}; my $comment = "/input_id=$inp_id /mol=$mol /score=$ann->{score}"; print ">$id $comment\n"; for (my $x=0 ; $x < length ( $gene ) ; $x += 60) { print substr($gene,$x,60),"\n"; } } }