Merge pull request #42 from solgenomics/topic/duplicate_image_warning
[cxgn-corelibs.git] / lib / CXGN / Primers.pm
blob7b2883c005fdd471a422c513d8575e7529f828d1
1 #!/usr/bin/perl
3 package CXGN::Primers;
5 use CXGN::DB::Connection;
6 use strict;
8 sub get_sequence {
9 my $sequence_name = shift;
11 my $dbh = CXGN::DB::Connection->new() or die "cannot connect: $!\n";
13 my $sequence = &get_sequence_1($sequence_name,$dbh);
14 if ($sequence eq "") {
15 $sequence = &get_sequence_2($sequence_name,$dbh);
18 $dbh->disconnect(42) or die "cannot disconnect: $!\n";
20 return $sequence;
23 sub get_sequence_2 {
24 my ($sequence_name,$dbh) = @_;
26 my $select = "select seq from unigene join unigene_member using "
27 . "(unigene_id) join est using (est_id) where sequence_name = '$sequence_name';";
28 my $sth = $dbh->prepare("$select");
29 $sth->execute;
30 my $sequence = $sth->fetchrow();
31 $sth->finish;
33 return $sequence;
36 sub get_sequence_1 {
37 my ($sequence_name,$dbh) = @_;
39 my $select = "select seq from unigene_consensi join unigene "
40 . "using (consensi_id) where sequence_name = '$sequence_name';";
41 my $sth = $dbh->prepare("$select");
42 $sth->execute;
43 my $sequence = $sth->fetchrow();
44 $sth->finish;
46 return $sequence;