Question: Adding Sequence Names to Pairwise2 output?
0
gravatar for reui879
2.0 years ago by
reui87910
reui87910 wrote:

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 • 514 views
ADD COMMENTlink modified 2.0 years ago • written 2.0 years ago by reui87910

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

ADD REPLYlink modified 24 months ago • written 24 months ago by Joe16k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1860 users visited in the last hour