Domanda

I am trying to get results from different sequences in a list so heres my code:

from Bio.Blast import NCBIXML

from Bio.Blast import NCBIWWW

lst=['TGCCCCGAAAATGAACTCAGTAAAGAATGACAGTTTCGCAAGACCCGTTGCTTTTTCAGTGCTAGCTAGCTGACTGATCGTAGCTGACGTAGTCTAGCTAGC','ATCGATCGTACTACGTAGCTGATCGTAGCTAGCTAGCTGATCGTAGCTATCGTACGTAGCTGATCGATCGTAGCTGACTGACGTACGTAGCTGATCGTAGCTAGCTAGCTAGCTGATCGATC']

eq="Homo sapiens[Organism]"


for i in range(0,2):

    rslt  = NCBIWWW.qblast("blastn", "nr", lst[i],entrez_query=eq)
    rcrds = NCBIXML.parse(rslt)
    br = rcrds.next()
    for alignment in br.alignments:
        for hsp in alignment.hsps:
            if hsp.expect < 2:

                print "***** RECORD ****"+str(i)
                print "sequence:", alignment.title
                print "E-value:", hsp.expect

The output only provides blast records for lsts second item and str(i)=0

***** RECORD ****0
sequence: gi|27436767|gb|AF274855.3| Homo sapiens chromosome X clone RP11-366F6 map q28, complete sequence

E-value: 0.197898

Any help will be appreciated.

È stato utile?

Soluzione

well....your code is correct!...but you are searching for data which is not there... the problem is, that there can be no output if br.alignments is empty...(and thats the case with the secont lst entry)

>>> br.alignments
[]

take a look at this snipped:

from Bio.Blast import NCBIXML
from Bio.Blast import NCBIWWW

lst=['TGCCCCGAAAATGAACTCAGTAAAGAATGACAGTTTCGCAAGACCCGTTGCTTTTTCAGTGCTAGCTAGCTGACTGATCGTAGCTGACGTAGTCTAGCTAGC','ATCGATCGTACTACGTAGCTGATCGTAGCTAGCTAGCTGATCGTAGCTATCGTACGTAGCTGATCGATCGTAGCTGACTGACGTACGTAGCTGATCGTAGCTAGCTAGCTAGCTGATCGATC']
eq="Homo sapiens[Organism]"
# download with lst[1]
print "download start"
rslt  = NCBIWWW.qblast("blastn", "nr", lst[1],entrez_query=eq)
print "download end"
print "parsing start"
rcrds = NCBIXML.parse(rslt)
print "parsing end"
br = rcrds.next()
print "br.alignments"
print br.alignments

you can try the same snipped for lst[0], the result would be the following output:

>>> br.alignments
[<Bio.Blast.Record.Alignment object at 0x02ACCF90>, <Bio.Blast.Record.Alignment object at 0x02ACCE50>, <Bio.Blast.Record.Alignment object at 0x02ACCCF0>, <Bio.Blast.Record.Alignment object at 0x02ACCE10>, <Bio.Blast.Record.Alignment object at 0x02ACCCD0>, <Bio.Blast.Record.Alignment object at 0x02ACCBF0>, <Bio.Blast.Record.Alignment object at 0x02ACCD70>, <Bio.Blast.Record.Alignment object at 0x02ACC930>, <Bio.Blast.Record.Alignment object at 0x02ACC9B0>, <Bio.Blast.Record.Alignment object at 0x02ACCA90>, <Bio.Blast.Record.Alignment object at 0x02ACCAD0>, <Bio.Blast.Record.Alignment object at 0x02ACCB90>, <Bio.Blast.Record.Alignment object at 0x02ACC850>, <Bio.Blast.Record.Alignment object at 0x02ACC970>]

So the short version is: The output only provides blast records for str(i)=0 because for i=1 there is no DATA! If you want to see all entries of i=0 you have to delete the line "hsp.expect < 2";

i hope that helps

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top