Pairwise Filter Results
1
0
Entering edit mode
12.0 years ago
martinkara7 ▴ 20

from Bio import pairwise2 from Bio import SeqIO import sys for t in SeqIO.parse(sys.argv[1], "fasta"): for q in SeqIO.parse(sys.argv[2], "fasta"): a = pairwise2.align.localms(t.seq, q.seq, 1, -3, -7, -2, one_alignment_only=1, score_only=1) print t.id, "\t", q.id, "\t", a

i was trying this script another persn posted on here. The thing is it outputs all scores for one to the other, for instance

gi|321422410|gb|ADIH01013800.1| gi|321371556|gb|AEAQ01026353.1| 245.0 gi|321422410|gb|ADIH01013800.1| gi|321372252|gb|AEAQ01025657.1|_1 266.0 gi|321422410|gb|ADIH01013800.1| gi|321393004|gb|AEAQ01005223.1| 307.0 gi|321422409|gb|ADIH01013801.1| gi|321371556|gb|AEAQ01026353.1| 266.0 gi|321422409|gb|ADIH01013801.1| gi|321372252|gb|AEAQ01025657.1|_1 299.0 gi|321422409|gb|ADIH01013801.1| gi|321393004|gb|AEAQ01005223.1| 356.0

but i only want it to output the best score for that one to the other, like for insance

gi|321422410|gb|ADIH01013800.1| gi|321393004|gb|AEAQ01005223.1| 307.0 gi|321422409|gb|ADIH01013801.1| gi|321393004|gb|AEAQ01005223.1| 356.0

is there something i could add to get it to do this. i looked up pairwise2 but thing.? thanks

pairwise filter • 2.5k views
ADD COMMENT
0
Entering edit mode

Could you please clarify what your question actually is? You want to parse text or modify an output?

ADD REPLY
0
Entering edit mode

yes i want to modify the output. The script gives every one match to for example, A TO C gives score 56 A TO D gives score 95 B TO C gives score 65 B TP D gives score 82

and i want it to only output the best score, such that A TO D gives score 95 B TP D gives score 82

ADD REPLY
5
Entering edit mode
12.0 years ago

Here you go:

from Bio import pairwise2 
from Bio import SeqIO 
import sys 

for t in SeqIO.parse(sys.argv[1], "fasta"):
    bestHit = ['','',0]
    for q in SeqIO.parse(sys.argv[2], "fasta"): 
        score = pairwise2.align.localms(t.seq, q.seq, 1, -3, -7, -2, one_alignment_only=1, score_only=1)
        if score>bestHit[2]:
            bestHit = [t.id, q.id, score]
    print bestHit[0], "\t", bestHit[1], "\t", bestHit[2]
ADD COMMENT

Login before adding your answer.

Traffic: 2534 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6