I'm trying to BLASTX a sequence using Biopython in Google Colab. Here is the code I am using. I'm not able to understand why I am getting an empty list []
for alignments
.
result_handle = NCBIWWW.qblast("blastx", "nr", test_seq.seq, expect=1e-05)
blast_record = NCBIXML.read(result_handle)
alignments = []
for alignment in tqdm(blast_record.alignments):
for hsp in alignment.hsps:
alignments.append({
"title": alignment.title,
"length": alignment.length,
"e_value": hsp.expect,
"score": hsp.score,
"query": hsp.query,
"match": hsp.match,
"subject": hsp.sbjct
})
len(alignments) # its coming 0 because its empty
As a note, here is the test sequence I am using, which is giving proper results in BLASTX on NCBI server in NCBI NR database. Any help would be very helpful.
>test_seq
GCAGCAGCAGCAGCAGCAGCGCGGCGCGCGACTGCCTGGCCATGAATGCTTTCTCCAAGCTGCTGCGCGT
GCTGACCACGCCCTCCATGCTGCACAACCTGTGCAACAGCGACCAAGGCGTGCACGTGCTGATCCGGCTC
ATCAAGCTGAGCTCGCCGCCAGAGACGGCTTTCATTGCTGACCAGGTCCTGCACGACTTGGCTGACATGG
TGGTCAGCAAGGGCGGCGCTCTGGTGGTCTGCACCCTGGTCGACCGCCTGGCCGTCGCGGCCAGCTGCGA
CAACCCGGGGGTGGTGGAGCGGGCCACGGGCGCGGTTGTGCGCATGTGCAGCCACCTGTGCCAGCACCAT
CGCGCGCTGCAGCAGTGTGCGCGGCACCAGTACCTGGGTCCCAAGGTCGTTGAGCTGCTGCAGTGCGGCC
TGCCCGCTGTGGATGCCTTCAAGATGGGGTTTGAGCTGGTCCAGAACGCGCCCGCGCTGGCGGCCACCCG
CCACGGCAGCCGCACGCTGCAGCTGCTCACGGAGATTCGGGCCGCCGATGCGCGGTCGCGAGAGATGCTG
CGAGACGTGGTCTGCCACGCGTCCAAGGCGCTGCAGGGCCACTTTGGCCAGCTGGCGGCCAAGGGGGAGA
CGGGAGGGCCCGCCCTGGTCCGCGCCCTGCTGGACTACCTGCTGGCGGAGCGGGAGGACGACTGGGTGGT
GCAGATCACCTGGGAGCTGCTGGCGGCGGGCAGT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AGTGGCCGCCGCCGCCGCCGCCAGCGGGGTGCTGCGGCGGGAATGCCGGC
GATGCCATGCCGGTGCTTGTGGGGTAGCCGTAGGCAGCTGCGCCGGGCACATAGCCGCCCATCTGGCCTC
CCATCATCATGTACGGGCTGGGGGCCATGCCCCCCATGCCAGCCATTGGGCTCATGCCACCGTACTGCTG
GGCCATGCCGGCATACTGCATGCCAAAGCCGGGGCCGCCCGGCACCATGCCTGCATGCGGGTAGCCGAAC
ATGCCAAAGCCGGCGGCCGCGTAGGGGCTGGGCGGGCTGCCAAACAGCGCGCCGGGTGAGCCCACCACGG
CGCCGGGCGGGCCGCCAAAGGGCGGCAGGCCCATGCCGCCGCGGCCGCCGGCGCCGCTGGTGCTG
EDIT: By the way, to test the code, I tried running Biopython in Jupyter locally. When I tried with BLASTp with same code for a different sequence, I got this error:
URLError: <urlopen error [Errno 11001] getaddrinfo failed>
I'm thinking there is some problem with the scraper implemented in Biopython. When attempting BLASTX, the code keeps on running for an unreasonable amount of time (>10 min. I had to stop the Kernel). Let me know if it makes sense.
Thanks
include
directives so we can reproduce this locally? (not sure why you chose to undo my edit, by the way, that is really hard to read) $\endgroup$test_seq.seq
is a file? What kind of file? Simple text file? Windows line endings? Unix? $\endgroup$test_seq.seq
is definitely aBio.Seq.Seq
object. I checked that 5 times before posting this query.NCBI
servers seem to be having a problem in general, really. $\endgroup$Biopython
all the way. FromFASTA
parsing to getting the first sequence. $\endgroup$