PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Bio/Pipeline/Runnable/Est2Genome.pm

https://github.com/bioperl/bioperl-pipeline
Perl | 230 lines | 156 code | 52 blank | 22 comment | 15 complexity | 6b083610726253de77a9b451af85dc08 MD5 | raw file
Possible License(s): LGPL-2.0
  1. # Pipeline module for Est2Genome Bio::Pipeline::Runnable::Est2Genome
  2. #
  3. # Based on the EnsEMBL module Bio::EnsEMBL::Pipeline::Runnable::Est2Genome
  4. # originally written by Michele Clamp <michele@sanger.ac.uk>
  5. # Written in BioPipe by Shawn Hoon <shawnh@fugu-sg.org>
  6. # Please direct questions and support issues to <bioperl-l@bioperl.org>
  7. #
  8. # Cared for by the Fugu Informatics team (fuguteam@fugu-sg.org)
  9. #
  10. # You may distribute this module under the same terms as perl itself
  11. #
  12. # POD documentation - main docs before the code
  13. #
  14. # =pod
  15. #
  16. # =head1 NAME
  17. #
  18. # Bio::Pipeline::Runnable::Est2Genome
  19. #
  20. =head1 SYNOPSIS
  21. my $runnable = Bio::Pipeline::Runnable::RunnableSkeleton->new();
  22. $runnable->analysis($analysis);
  23. $runnable->run;
  24. my $output = $runnable->output;
  25. =head1 DESCRIPTION
  26. Bare Bones Runnable for writing you own runnable quickly. You
  27. probably need to do the following:
  28. =over 3
  29. =item 1
  30. Naturally, replace all cases of RunnableSkeleton with the name of your
  31. runnable
  32. =item 2
  33. Create get/set methods for your specified datatypes
  34. =item 3
  35. Write the functionality inside the run routine calling the appropriate
  36. binary wrapper
  37. =back
  38. =head1 AUTHOR
  39. Based on the EnsEMBL module Bio::EnsEMBL::Pipeline::Runnable::Est2Genome
  40. originally written by Michele Clamp, michele@sanger.ac.uk.
  41. Written in BioPipe by Shawn Hoon, shawnh@fugu-sg.org.
  42. # Please direct questions and support issues to <bioperl-l@bioperl.org>
  43. #
  44. Cared for by the Fugu Informatics team, fuguteam@fugu-sg.org.
  45. =head1 APPENDIX
  46. =cut
  47. package Bio::Pipeline::Runnable::Est2Genome;
  48. use vars qw(@ISA);
  49. use strict;
  50. use Bio::Root::Root;
  51. use Bio::Root::IO;
  52. use Bio::Pipeline::DataType;
  53. use Bio::Pipeline::RunnableI;
  54. use Bio::Factory::EMBOSS;
  55. use Bio::Tools::Est2Genome;
  56. @ISA = qw(Bio::Pipeline::RunnableI);
  57. =head2 new
  58. Title : new
  59. Usage : $self->new()
  60. Function:
  61. Returns :
  62. Args :
  63. =cut
  64. sub new {
  65. my ($class, @args) = @_;
  66. my $self = $class->SUPER::new(@args);
  67. my ($return_gene) = $self->_rearrange([qw(RETURN_GENE)],@args);
  68. $self->return_gene($return_gene) if $return_gene;
  69. return $self;
  70. }
  71. =head2 datatypes
  72. Title : datatypes
  73. Usage : $self->datatypes()
  74. Function: returns a hash of the datatypes required by the runnable
  75. Returns :
  76. Args :
  77. =cut
  78. sub datatypes {
  79. my ($self) = @_;
  80. my $dt = Bio::Pipeline::DataType->new('-object_type'=>'Bio::PrimarySeqI',
  81. '-name'=>'sequence',
  82. '-reftype'=>'SCALAR');
  83. my %dts;
  84. #Replace seq1 with whatever you want to call your get/set methods
  85. $dts{seq} = $dt;
  86. return %dts;
  87. }
  88. =head2 strand
  89. Title : strand
  90. Usage : $self->strand ()
  91. Function: get/set for genomic sequence
  92. Returns :
  93. Args :
  94. =cut
  95. sub strand{
  96. my ($self,$strand) = @_;
  97. if($strand){
  98. $self->{'_strand'} = $strand;
  99. }
  100. return $self->{'_strand'};
  101. }
  102. =head2 genome
  103. Title : genome
  104. Usage : $self->genome ()
  105. Function: get/set for genomic sequence
  106. Returns :
  107. Args :
  108. =cut
  109. sub genome{
  110. my ($self,$genome) = @_;
  111. if($genome){
  112. $self->{'_genome'} = $genome;
  113. }
  114. return $self->{'_genome'};
  115. }
  116. =head2 return_gene
  117. Title : return_gene
  118. Usage : $self->return_gene ()
  119. Function: get/set for return gene
  120. Returns :
  121. Args :
  122. =cut
  123. sub return_gene{
  124. my ($self,$return_gene) = @_;
  125. if($return_gene){
  126. $self->{'_return_gene'} = $return_gene;
  127. }
  128. return $self->{'_return_gene'};
  129. }
  130. =head2 cdna
  131. Title : cdna
  132. Usage : $self->cdna ()
  133. Function: get/set for cdna sequence
  134. Returns :
  135. Args :
  136. =cut
  137. sub cdna{
  138. my ($self,$cdna) = @_;
  139. if($cdna){
  140. $self->{'_cdna'} = $cdna;
  141. }
  142. return $self->{'_cdna'};
  143. }
  144. =head2 run
  145. Title : run
  146. Usage : $self->run()
  147. Function: execute
  148. Returns :
  149. Args :
  150. =cut
  151. sub run {
  152. my ($self) = @_;
  153. my $cdna = $self->cdna || $self->throw("Need a cdna sequence to run Est2Genome");
  154. my $genome = $self->genome || $self->throw("Need a genomic sequence to run Est2Genome");
  155. my $analysis = $self->analysis;
  156. $self->throw("Analysis not set") unless $self->analysis->isa("Bio::Pipeline::Analysis");
  157. my $factory = new Bio::Factory::EMBOSS;
  158. my $est2genome = $factory->program('est2genome');
  159. my $io = Bio::Root::IO->new();
  160. my $tmpdir = $io->tempdir(CLEANUP=>1);
  161. my ($tfh,$outfile) = $io->tempfile(-dir=>$tmpdir);
  162. my @params = ('-est'=>$cdna,'-genome'=>$genome,'-outfile'=>$outfile);
  163. push @params , $self->parse_params($analysis->analysis_parameters,1);
  164. eval {
  165. $est2genome->run({@params});
  166. };
  167. if($@){
  168. $self->throw("Est2Genome Runnable had problems running. $@");
  169. }
  170. my $parser = Bio::Tools::Est2Genome->new(-file=>$outfile);
  171. my @feat;
  172. while(my $f = $parser->parse_next_gene($self->return_gene)){
  173. push @feat,$f;
  174. }
  175. $self->output(\@feat);
  176. return @feat;
  177. }
  178. 1;