PageRenderTime 55ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/Bio/Pipeline/SQL/DataMongerAdaptor.pm

https://github.com/bioperl/bioperl-pipeline
Perl | 163 lines | 90 code | 54 blank | 19 comment | 1 complexity | 36f7fd8532956abf0cfc61b7245601c5 MD5 | raw file
Possible License(s): LGPL-2.0
  1. # $Id: .pm,v 1.51 Fri Jun 07 05:43:37 SGT 2002
  2. # BioPerl module for
  3. #
  4. # Please direct questions and support issues to <bioperl-l@bioperl.org>
  5. #
  6. # Cared for by Shawn Hoon <shawnh@fugu-sg.org>
  7. #
  8. # Copyright Shawn Hoon
  9. #
  10. # You may distribute this module under the same terms as perl itself
  11. # POD documentation - main docs before the code
  12. =head1 NAME
  13. Bio::Pipeline::SQL::DataMonger
  14. =head1 SYNOPSIS
  15. $seqio = Bio::SeqIO->new( '-format' => 'embl' , -file => 'myfile.dat');
  16. $seqobj = $seqio->next_seq();
  17. =head1 DESCRIPTION
  18. Description here.
  19. =head1 EXAMPLES
  20. A simple and fundamental block of code
  21. use Bio::SeqIO;
  22. =head1 FEEDBACK
  23. =head2 Mailing Lists
  24. User feedback is an integral part of the evolution of this and other
  25. Bioperl modules. Send your comments and suggestions preferably to one
  26. of the Bioperl mailing lists. Your participation is much appreciated.
  27. bioperl-l@bioperl.org - General discussion
  28. http://bioperl.org/wiki/Mailing_lists - About the mailing lists
  29. =head2 Support
  30. Please direct usage questions or support issues to the mailing list:
  31. L<bioperl-l@bioperl.org>
  32. rather than to the module maintainer directly. Many experienced and
  33. reponsive experts will be able look at the problem and quickly
  34. address it. Please include a thorough description of the problem
  35. with code and data examples if at all possible.
  36. =head2 Reporting Bugs
  37. Report bugs to the Bioperl bug tracking system to help us keep track
  38. the bugs and their resolution. Bug reports can be submitted via email
  39. or the web:
  40. bioperl-bugs@bioperl.org
  41. http://bio.perl.org/bioperl-bugs/
  42. =head1 AUTHOR - Shawn Hoon
  43. Email shawnh@fugu-sg.org
  44. =head1 APPENDIX
  45. The rest of the documentation details each of the object
  46. methods. Internal methods are usually preceded with a "_".
  47. =cut
  48. package Bio::Pipeline::SQL::DataMongerAdaptor;
  49. use Bio::Pipeline::Node;
  50. use Bio::Pipeline::Runnable::DataMonger;
  51. use Bio::Root::Root;
  52. use Bio::Pipeline::InputCreate;
  53. use Bio::Pipeline::SQL::AnalysisAdaptor;
  54. use vars qw(@ISA);
  55. use strict;
  56. @ISA = qw( Bio::Pipeline::SQL::BaseAdaptor);
  57. # Let the code begin...
  58. sub fetch_by_analysis{
  59. my ($self,$anal) = @_;
  60. #my $id = $anal->data_monger_id;
  61. my $id = $anal->dbID;
  62. my $dm = Bio::Pipeline::Runnable::DataMonger->new();
  63. #fetch create inputs
  64. my $sth = $self->prepare("SELECT input_create_id,module,rank FROM input_create where data_monger_id=?");
  65. my $sth2 = $self->prepare("SELECT tag,value FROM input_create_argument WHERE input_create_id=?");
  66. $sth->execute($id);
  67. while(my ($inc_id,$module,$rank) = $sth->fetchrow_array()){
  68. $sth2->execute($inc_id);
  69. my @args;
  70. push @args,('-module'=>$module,'-rank'=>$rank,'-dbadaptor'=>$self->db);
  71. while(my($tag,$value) = $sth2->fetchrow_array()){
  72. push @args, ($tag => $value);
  73. }
  74. my $inc = Bio::Pipeline::InputCreate->new(@args);
  75. $dm->add_input_create($inc);
  76. }
  77. return $dm;
  78. }
  79. sub store {
  80. my ($self, $dm, $anal_id) = @_;
  81. # my $dm_analysis = Bio::Pipeline::Analysis->new(-dbID => $anal_id,
  82. # -runnable => 'Bio::Pipeline::Runnable::DataMonger',
  83. # -logic_name => 'DataMonger',
  84. # -program => 'DataMonger');
  85. # $self->db->get_AnalysisAdaptor->store($dm_analysis);
  86. foreach my $input_create($dm->input_creates) {
  87. $self->_store_input_create($input_create, $anal_id);
  88. }
  89. }
  90. sub _store_input_create {
  91. my ($self, $input_create, $data_monger_id) = @_;
  92. my $sth = $self->prepare("INSERT INTO input_create
  93. SET data_monger_id = ?,
  94. module = ?,
  95. rank = ?");
  96. $sth->execute($data_monger_id, $input_create->module,$input_create->rank);
  97. my $dbid = $sth->{mysql_insertid};
  98. $input_create->dbID($dbid);
  99. foreach my $argument (@{$input_create->arguments}) {
  100. my $sth = $self->prepare("INSERT INTO input_create_argument
  101. SET input_create_id = ?,
  102. tag = ?,
  103. value = ?");
  104. $sth->execute($input_create->dbID,$argument->tag, $argument->value);
  105. my $dbid = $sth->{mysql_insertid};
  106. $argument->dbID($dbid);
  107. }
  108. }
  109. 1;