PageRenderTime 25ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Bio/Pipeline/Runnable/Promoterwise.pm

https://github.com/bioperl/bioperl-pipeline
Perl | 183 lines | 94 code | 22 blank | 67 comment | 8 complexity | 1049d901674375da174b0c3c3d37780d MD5 | raw file
Possible License(s): LGPL-2.0
  1. # Please direct questions and support issues to <bioperl-l@bioperl.org>
  2. #
  3. # Cared for by Chuah Aaron <aaron@tll.org.sg>
  4. #
  5. # Copyright Chuah Aaron
  6. #
  7. # You may distribute this module under the same terms as perl itself
  8. #
  9. # POD documentation - main docs before the code
  10. =pod
  11. =head1 NAME
  12. Bio::Pipeline::Runnable::Promoterwise
  13. =head1 SYNOPSIS
  14. =head1 DESCRIPTION
  15. This package is based on Promoterwise. Promoterwise takes in two
  16. fasta files. The resulting output is parsed to produce a set of
  17. Bio::SeqFeatures.
  18. =head1 FEEDBACK
  19. =head2 Mailing Lists
  20. User feedback is an integral part of the evolution of this and other
  21. Bioperl modules. Send your comments and suggestions preferably to one
  22. of the Bioperl mailing lists. Your participation is much appreciated.
  23. bioperl-l@bio.perl.org
  24. =head2 Support
  25. Please direct usage questions or support issues to the mailing list:
  26. L<bioperl-l@bioperl.org>
  27. rather than to the module maintainer directly. Many experienced and
  28. reponsive experts will be able look at the problem and quickly
  29. address it. Please include a thorough description of the problem
  30. with code and data examples if at all possible.
  31. =head2 Reporting Bugs
  32. Report bugs to the Bioperl bug tracking system to help us keep track
  33. the bugs and their resolution. Bug reports can be submitted via email
  34. or the web:
  35. bioperl-bugs@bio.perl.org
  36. http://bio.perl.org/bioperl-bugs/
  37. =head1 AUTHOR -Chuah Aaron
  38. Email aaron@tll.org.sg
  39. Describe contact details here
  40. =head1 APPENDIX
  41. The rest of the documentation details each of the object methods.
  42. Internal methods are usually preceded with a _
  43. =cut
  44. package Bio::Pipeline::Runnable::Promoterwise;
  45. use vars qw(@ISA);
  46. use strict;
  47. use Bio::Root::RootI;
  48. use Bio::Pipeline::DataType;
  49. use Bio::Tools::Run::Promoterwise;
  50. use Bio::Pipeline::RunnableI;
  51. @ISA = qw(Bio::Pipeline::RunnableI);
  52. sub new {
  53. my ($class,@args) = @_;
  54. my $self = $class->SUPER::new(@args);
  55. return $self;
  56. }
  57. sub datatypes {
  58. my ($self) = @_;
  59. my $dt1 = Bio::Pipeline::DataType->new(-object_type=>'Bio::SeqI');
  60. my $dt2 = Bio::Pipeline::DataType->new(-object_type=>'Bio::SeqI');
  61. my %dt;
  62. $dt{subject_dna} = $dt1;
  63. $dt{query_dna} = $dt2;
  64. return %dt;
  65. }
  66. sub subject_dna {
  67. my ($self, $seq) = @_;
  68. if ($seq)
  69. {
  70. unless ($seq->isa("Bio::PrimarySeqI") || $seq->isa("Bio::SeqI")) {
  71. print "subject $seq is not a sequence object!! Trying to read it as a filename\n";
  72. my $subject_file=Bio::Root::IO->catfile($seq);
  73. my $subject_seqs=Bio::SeqIO->new(-file=>$subject_file, -format=>'fasta');
  74. $seq=$subject_seqs->next_seq() || $self->throw("Subject dna isn't a Bio::Seq or Bio::PrimarySeq or fasta file");
  75. }
  76. $self->{'_subject_dna'} = $seq ;
  77. }
  78. return $self->{'_subject_dna'};
  79. }
  80. sub target_dna {
  81. my ($self, $seq) = @_;
  82. if ($seq)
  83. {
  84. unless ($seq->isa("Bio::PrimarySeqI") || $seq->isa("Bio::SeqI")) {
  85. print "target $seq is not a sequence object!! Trying to read it as a filename\n";
  86. my $target_file=Bio::Root::IO->catfile($seq);
  87. my $target_seqs=Bio::SeqIO->new(-file=>$target_file, -format=>'fasta');
  88. $seq=$target_seqs->next_seq() || $self->throw("Target dna isn't a Bio::Seq or Bio::PrimarySeq or fasta file");
  89. }
  90. $self->{'_target_dna'} = $seq ;
  91. }
  92. return $self->{'_target_dna'};
  93. }
  94. =head2 run
  95. Title : run
  96. Usage : $obj->run()
  97. Function: Runs promoterwise and creates array of seqfeature::featurepairs
  98. Returns :
  99. Args : none
  100. =cut
  101. sub run {
  102. my ($self) = @_;
  103. #check seq
  104. my $analysis = $self->analysis;
  105. $self->throw("Analysis not set")
  106. unless $analysis->isa("Bio::Pipeline::Analysis");
  107. my $seq1 = $self->subject_dna() ||
  108. $self->throw("Subject dna sequence required for Promoterwise\n");
  109. my $seq2 = $self->target_dna() ||
  110. $self->throw("Target dna sequence required for Promoterwise\n");
  111. #run promoterwise
  112. my @params = $self->parse_params($self->analysis->analysis_parameters);
  113. my $factory = Bio::Tools::Run::Promoterwise->new(@params);
  114. $factory->executable($analysis->program_file) if $analysis->program_file;
  115. my @promoters;
  116. eval {
  117. @promoters = $factory->run($seq1, $seq2);
  118. };
  119. $self->output(\@promoters);
  120. return \@promoters;
  121. }
  122. =head2 output
  123. Title : output
  124. Usage : $self->output($seq)
  125. Function: Get/set method for output
  126. Returns : An array of Bio::SeqFeature objects
  127. Args : An array ref to an array of Bio::SeqFeature objects
  128. =cut
  129. sub output{
  130. my ($self,$promoter) = @_;
  131. if(defined $promoter){
  132. (ref($promoter) eq "ARRAY") ||
  133. $self->throw("Output must be an array reference.");
  134. $self->{'_promoter'} = $promoter;
  135. }
  136. return @{$self->{'_promoter'}};
  137. }
  138. 1;