[Biopython] Integrating SQL query to biopython

Peter Cock p.j.a.cock at googlemail.com
Thu May 24 09:28:14 UTC 2012


On Thu, May 24, 2012 at 10:15 AM, Brad Chapman <chapmanb at 50mail.com> wrote:
>
> Animesh;
>
>> I am running small SQL queries to select sequences from a local BIOSQL
>> database. One instance such query is as follows:
>>
>> SELECT  biosequence.*
>> FROM    biosequence JOIN bioentry USING (bioentry_id)
>> WHERE   biosequence.seq NOT LIKE "%X%"
>> AND   biosequence.alphabet = 'protein'
>>
>> I am wondering, how do I integrate this SQL query with Biopython code to get
>> the output in form of SeqRecord or Seq objects.
>
> If you have the interval bioentry IDs you can use the BioSQL code
> directly to get SeqRecord compatible objects:
>
> from BioSQL import BioSeqDatabase
> from BioSQL.BioSeq import DBSeqRecord
>
> server = BioSeqDatabase.open_database(driver="MySQLdb", user="root",
>                     passwd = "", host = "localhost", db="bioseqdb")
> rec = DBSeqRecord(server.adaptor, your_bioentry_id)
>
> Hope this helps,
> Brad

Good to see we gave the same answer :)

Peter




More information about the Biopython mailing list