Pairwise Filter Results
1
0
Entering edit mode
8.9 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

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

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

pairwise filter • 1.9k views
0
Entering edit mode

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

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

5
Entering edit mode
8.9 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]