sequence alignment BIOPYTHON
0
0
Entering edit mode
6.9 years ago
sssss • 0

I am dealing with two fasta files and wanted to align them with clustal using biopython. I want these two files as two sequences in this code, i.e., ref_seq= fasta file 1 and target_seq=fasta file 2. Can anyone help?

>>from Bio.Seq import Seq
>>from Bio.SeqRecord import SeqRecord
>>from Bio.Alphabet import IUPAC
>>import Bio.SeqIO as SeqIO
>>from Bio.Align.Applications import ClustalOmegaCommandline
>>    
>>ref_seq = "ERVVIGSKPFNEQYILANMIAILLEENGYKA"
>>target_seq = "ERVVIGSKPFNEQYILANMINGYKA"
>>in_file = "unaligned.fasta"
>>out_file = "aligned.fasta"

>># Write my sequences to a fasta file
>>handle = open(in_file, 'w')
>>records = (SeqRecord(Seq(seq, IUPAC.protein), id=str(index), name="Test", description="Test") for index,seq in enumerate([ref_seq, target_seq]) )

>>with open(in_file, 'w') as handle:
    SeqIO.write(records, handle, "fasta")
>>handle.close()

>>clustalomega_cline = ClustalOmegaCommandline(infile=in_file, outfile=out_file, verbose=True, auto=True, force=True)
>>clustalomega_cline()
alignment sequencing gene SNP • 2.3k views
ADD COMMENT
0
Entering edit mode

I added code markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

ADD REPLY

Login before adding your answer.

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