################## # Make connection with Ensembl, and retrieve start, end and rank. ################## my $datasource = "DBI:mysql:homo_sapiens_core_23_34e:ensembldb.ensembl.org"; my $dbh=(); my $sth=(); # database and statement handles my @rows; # to get results or queries my $row_count; # to see how much we get back my $username = "anonymous"; my $password = ""; my $marker = 'marker_list.txt'; # connect to database: $dbh = DBI->connect($datasource, $username, $password, {RaiseError => 1}); open (LIST, "<$marker") or die ("Couldn't open file $marker: $!.\n"); while (){ my ($ensemblID, $score) = $_; # select all sequence entries: $row_count = 0; $sth = $dbh->prepare (qq{ SELECT gene_stable_id.stable_id, gene.seq_region_start, gene.seq_region_end, gene.seq_region_strand FROM gene, gene_stable_id WHERE gene_stable_id.gene_id = gene.gene_id AND gene_stable_id.stable_id ="$ensemblID" }); $sth->execute (); # read results: while (@rows = $sth->fetchrow_array () ) { $row_count++; print join ("\t", @rows), "\n"; } unless ( $row_count ) { print "This gene doesn't appear to be placed on the current assembly.\n"; } # tidy up: close(LIST); $sth->finish (); $dbh->disconnect (); }