#!/usr/bin/perl # Description: run tRNAscan SE on input fasta # Author: Peter Fischer Hallin # Email: pfh@cbs.dtu.dk # Version: Genome Atlas 3.0 ws2 # Date: 2009-09-02 # Reads a genomic sequence from STDIN and submits to tRNAscan . R-value cutoff, and model are # defined as argv 0 and argv 1 # output is orfs # include standard XML::Compile helper functions (used to initiate WSDL proxys) require "xml-compile.pl"; require "fasta.inc.pl"; die "usage: trnascan.pl bac/arc/euk < genome.fsa\n" unless defined $ARGV[0]; use Data::Dumper; my $trnascan = WSDLclient ( 'http://www.cbs.dtu.dk/ws/GenomeAtlas/GenomeAtlas_3_0_ws2.wsdl' ); my @fasta = read_fasta(); for ( my $i = 0 ; $i < scalar ( @fasta ) ; $i++ ) { my $id = $fasta[$i]->{id}; my $comment = $fasta[$i]->{comment}; my $seq = $fasta[$i]->{seq}; run_trnascan ($id,$comment,$seq) ; } sub run_trnascan { my ($jobid,$status,$expires); my ($id,$comment,$seq) = @_; my $response; $response = $trnascan->{trnascanRun}->( parameters => { parameters => { kingdom => $ARGV[0] , sequence => { id => $id , comment => $comment , seq => $seq}}}); die "error obtaining jobid\n" unless defined $response->{queueentry}->{queueentry}; $jobid = $response->{queueentry}->{queueentry}->{jobid}; wait_job($trnascan->{pollQueue},$jobid); my $response = $trnascan->{trnascanFetchResult}->( job => { jobid => $jobid }) ; print STDERR "# parsing 'anndata' object\n"; foreach my $ann (@{$response->{parameters}->{anndata}->{ann}}) { printf STDERR "# annotations from %s version %s\n" , $response->{parameters}->{anndata}->{annsource}->{method} , $response->{parameters}->{anndata}->{annsource}->{version}; foreach my $record (@{$ann->{annrecords}->{annrecord}}) { my ( $begin , $end ) = ( $record->{range}->{begin}->numify , $record->{range}->{end}->numify ); my $score = sprintf("%0.4f",$record->{score}[0]->{value}->numify); my $new_id = ""; my $feature = $record->{feature}; if ( $begin < $end) { my $len = ( $end - $begin) + 1; $gene = substr($seq,$begin-1,$len); } else { my $len = ( $begin - $end) + 1; $gene = substr($seq,$end-1, $len); $gene = rev($gene); } print ">$id\_tRNA_$begin-$end /score=$score $comment\n"; for (my $x=0 ; $x < length ( $gene ) ; $x += 60) { print substr($gene,$x,60),"\n"; } } } } sub rev { my $output = reverse $_[0]; $output =~ tr/ACTGactg/TGACtgac/; return $output; }