Bioops

Bioinformatics=(ACGAAG->AK)+(#!/bin/sh)+(P(A|B)=P(B|A)*P(A)/P(B))

Transfer Protein Alignment to DNA Alignment by Bioperl

| Comments

aaln_to_daln.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# it needs two files as input,
# 1) protein alignment result
# 2)cds sequences of the proteins
use strict;
use Bio::SeqIO;
use Bio::AlignIO;
use Bio::Align::Utilities qw(aa_to_dna_aln);
my $alignio = Bio::AlignIO->new(-format => 'NEXUS',
-file => 'pro.nxs');

my $aa_aln = $alignio->next_aln;

my $seqdata= 'cds.fa';
my $seqio = new Bio::SeqIO(-file => $seqdata,
-format => 'fasta');
my %seqs;
# process each sequence
while ( my $seq = $seqio->next_seq ) {
$seqs{$seq->display_id} = $seq;
}

my $dna_aln = aa_to_dna_aln($aa_aln, %seqs);

my $out = Bio::AlignIO->new(-file => ">cds.phylip" , '-format' => 'NEXUS');
$out ->write_aln($dna_aln);

Comments