Adding Sequence Names to Pairwise2 output?
0
0
Entering edit mode
5.9 years ago
reui879 ▴ 10

I have a the following script utilizing pairwise2 from Biopython. It takes 2 Fasta files as input. I would like to add the sequence names to the output from these files if possible.

from Bio.Blast import NCBIXML

from Bio import pairwise2

from Bio.SubsMat import MatrixInfo as mat list

from math import log, exp

from Bio import SeqIO

from itertools import product

from Bio.pairwise2

import format_alignment

seq1=SeqIO.to_dict(SeqIO.parse(open('less.fasta'), 'fasta'))

seq2=SeqIO.to_dict(SeqIO.parse(open('out.fasta'), 'fasta'))

with open("align.txt", "w") as out:

    for s1, s2 in product(seq1, seq2):        

            for a in pairwise2.align.localds(str(seq1[s1].seq), str(seq2[s2].seq), matlist.blosum62, -11, -1):            

                    out.write(format_alignment(*a))

Current output:

KMLEENTNILK

||

TMVGFGDFV--

Score=6

KMLEENTNILK

   |||

-FTHDLINLL-

Score=12

KMLEENTNILK

  |||

LQVWSVTEV--

Score=8

KMLEENTNILK-----

    ||

-------VIMVGSAGV

Score=6

alignment • 1.1k views
ADD COMMENT
0
Entering edit mode

Please fix the formatting in your code, and ideally mock up an example of what you would like as output.

ADD REPLY

Login before adding your answer.

Traffic: 2811 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