<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    Hi Gary,<br>
    <br>
    Can you give us some more information about the problem, what
    version of API you are using and what is the error message you are
    getting? You can also download the full gene using biomart. <br>
    <br>
    thanks<br>
    Uma<br>
    <br>
    <br>
    On 13/12/11 17:00, Gary Duncan wrote:
    <blockquote
cite="mid:CACOtV4cYpssY7GoxBU3nLTVUQu_dcHOsSbVsDZ8oZvy7N+T_EA@mail.gmail.com"
      type="cite">I have the script below but it isnt quite working what
      did i do wrong?<br>
      Plus can you get the entire length of the gene?<br>
      <br>
      <br>
      use strict;<br>
      use warnings;<br>
      use Bio::EnsEMBL::Registry;<br>
      use Bio::EnsEMBL::DBSQL::DBConnection;<br>
      use Bio::EnsEMBL::Utils::SqlHelper;<br>
      <br>
      #Load all DBs from Ensembl Genomes<br>
      Bio::EnsEMBL::Registry->load_registry_from_db(<br>
        -HOST => '<a moz-do-not-send="true"
        href="http://mysql.ebi.ac.uk">mysql.ebi.ac.uk</a>',<br>
        -PORT => 4157,<br>
        -USER => 'anonymous'<br>
      );<br>
      <br>
      my $dbc = Bio::EnsEMBL::DBSQL::DBConnection->new(<br>
        -HOST => 'localhost', <br>
        -PORT => 3306,<br>
        -USER => 'xxxxxx', <br>
        -PASS => 'xxxxxx',<br>
        -DBNAME => 'xxxxxx'<br>
      );<br>
      #Holds a soft reference to the DBConnection so we cannot combine
      the two news<br>
      my $h = Bio::EnsEMBL::Utils::SqlHelper->new(-DB_CONNECTION
      => $dbc);<br>
      <br>
      #Cleanup schema using do()<br>
      $dbc->do('DROP TABLE IF EXISTS exon');<br>
      $dbc->do(<<'SQL');<br>
      CREATE TABLE exon (<br>
        idgld int(10) NOT NULL auto_increment,<br>
         stbl_id varchar(12), <br>
        seq_start varchar(12), <br>
        seq_stop varchar(12), <br>
        sequence text, <br>
        PRIMARY KEY(idgld)#)<br>
      SQL<br>
      <br>
      #File management<br>
      my $file = '/home/glduncan/data/intron.txt';<br>
      if(-f $file) {<br>
        unlink $file or die "Cannot remove file '${file}': $!";<br>
      }<br>
       open my $out, '>', $file or die "Cannot open ${file} for
      writing: $!";<br>
      <br>
      my $ids_file = '/home/glduncan/data/three4.txt';<br>
      open my $fh, '<', $ids_file or die "Failed. Cannot open
      '${ids_file}' for reading: $!";<br>
      my $i = 1;<br>
      <br>
      #Get the adaptors once<br>
      my $dba = Bio::EnsEMBL::Registry->get_DBAdaptor('Dictyostelium
      discoideum', 'core');<br>
      my $gene_adaptor = $dba->get_GeneAdaptor();<br>
      <br>
      my @data;<br>
      <br>
      while(my $stable_id = <$fh>){<br>
          chomp $stable_id;<br>
          my $gene = $gene_adaptor->fetch_by_stable_id($stable_id);<br>
          foreach my $transcript (@{$gene->get_all_Transcripts()}) {<br>
            # print $out $transcript->stable_id(), "\n";<br>
              foreach my $exons (@{$transcript->get_all_Exons}) {<br>
              print $out $exons->seq_region_start.' -
      '.$exons->seq_region_end.' - '.$exons->seq. "\n";<br>
                #Store into a temporary array<br>
                push(@data, [<br>
                  $transcript->stable_id(),<br>
                  $exons->seq_region_start(),<br>
                  $exons->seq_region_end(),<br>
                  $exons->seq()<br>
                ]);<br>
              }<br>
          }<br>
      }<br>
      close($fh) or die "Cannot close input file handle: $!";<br>
      <br>
      #Use the batch command from the helper to insert the data using
      only one prepared statement<br>
      my $dml = <<'SQL';<br>
      INSERT INTO exon (stbl_id, seq_start, seq_stop, sequence) <br>
      VALUES (?,?,?,?)<br>
      SQL<br>
      my $affected_rows = $h->batch(-DATA => \@data, -SQL =>
      $dml);<br>
      foreach my $row(@data){<br>
          foreach my $value(@$row){<br>
          print $value,'\n';<br>
      }<br>
      }<br>
      <br>
      <br>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Dev mailing list    <a class="moz-txt-link-abbreviated" href="mailto:Dev@ensembl.org">Dev@ensembl.org</a>
List admin (including subscribe/unsubscribe): <a class="moz-txt-link-freetext" href="http://lists.ensembl.org/mailman/listinfo/dev">http://lists.ensembl.org/mailman/listinfo/dev</a>
Ensembl Blog: <a class="moz-txt-link-freetext" href="http://www.ensembl.info/">http://www.ensembl.info/</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>