[Biopython] Integrating SQL query to biopython
Brad Chapman
chapmanb at 50mail.com
Thu May 24 09:15:02 UTC 2012
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
More information about the Biopython
mailing list