Take the 2-minute tour ×
Biology Stack Exchange is a question and answer site for biology researchers, academics, and students. It's 100% free, no registration required.

I have pairs of coding DNA sequences which I wish to perform pairwise codon alignments via Python, I have "half completed" the process.

So far..

  • I retrive pairs of orthologous DNA sequences from genbank using Biopython package.
  • I translate the orthologous pairs into peptide sequences and then align them using EMBOSS Needle program.

I wish to..

  • Transfer the gaps from the peptide sequences into the original DNA sequences.

Question

I would appreciate suggestions for programs/code (called from Python) that can transfer gaps from aligned peptide sequence pairs onto codons of the corresponding nucleotide sequence pairs. Or programs/code that can carry out the pairwise codon alignment from scratch.

enter image description here

share|improve this question

closed as off-topic by terdon, Chris, MattDMo, Satwik Pasani, WYSIWYG Jan 1 at 7:06

  • This question does not appear to be about biology within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Why don't you simply align the nucleotide sequences in the first place? Just use any alignment software. –  terdon Dec 30 '13 at 17:59
    
Codon alignments serve a purpose, only this way you can obtain values of non-synonymous (dN) and synonymous (dS) rates of mutation.. which can then be used to obtain the dN/dS ratio used to infer selection –  hello_there_andy Dec 30 '13 at 18:04
    
You can do that easily enough from the DNA sequence, no need to translate. Just align and read the codons from the alignment. You seem to be complicating your life needlessly. That said, this is probably too computer geeky for this site and you would be better off asking on biostars. –  terdon Dec 30 '13 at 18:07
5  
This question appears to be off-topic because it is about programming and not biology. Bioinformatics questions are on topic here if they are about the underlying concepts, you are asking a very technical issue whose answer will be code. –  terdon Dec 30 '13 at 18:10
1  
I am quite familiar with it, thanks :). I did my PhD on comparative genomics and reconstructing evolutionary histories, I've done more alignments than I care to remember. You need to know whether two codons are synonymous or not in order to get the dN/dS but not necessarily to translate them, it's just an easy way to check. Anyway, using my dict suggestion this is pretty trivial. Feel free to @ping me in Biology Chat if you need more help with it. –  terdon Dec 30 '13 at 18:30
show 3 more comments

1 Answer 1

up vote 3 down vote accepted

The basic process would be (in pseudocode, I don't know python well enough, I'm a Perl geek):

$seq1=ATGCCAGGCTGA
$seq2=ATGGGACCATAA;
for ($i=0;$i<length($seq1);$i++){
   codons1[$i]=amino_acid
}
for ($i=0;$i<length($seq2);$i++){
       codons2[$i]=amino_acid
}

At this point you will have two arrays or hashes or tuples or dicts or whatever holding the amino acid that corresponds to each codon position of the input seqs. You go and do your translation and dS/dN thing and you can then use these lists to map back to the original nucleotides:

for ($i=0;$i<length($ProteinSseq1);$i++){
  print codons1[$i]
}

You will need to adapt this to deal with codons correctly (i++ will only increment by one, you need to extract the triplets) and then to read the gaps but these are all programming issues that have nothing to do with the biological side of things.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.