0
$\begingroup$

I'd like to perform multiple alignments, where a gene from each sample was read in from fasta files. The fasta file represented one sample and had multiple genes. I have read in each sample fasta file and now have a dictionary of genes and their samples and sequences. Here is a small example.

The main key is the gene ID for another dictionary as the value. In the dictionary 'R??' is the sample name and key, followed by the annotation and sequence in a list.

{'PRELSG_MIT_v1:5894-6032': {'R47': ['not annotated',
                                     Seq('ATAAAAATAGTTACCATAGCTGTTGATGGATGCTTCGATCATAAAATATGTTTG...GGA')],
                             'R48': ['not annotated',
                                     Seq('ATAAAAATAGTTACCATAGCTGTTGATGGATGCTTCGATCATAAAATATGTTTG...GGA')],
                             'R49': ['not annotated',
                                     Seq('ATAAAAATAGTTACCATAGCTGTTGATGGATGCTTCGATCATAAAATATGTTTG...GGA')],
                             'R50': ['not annotated',
                                     Seq('ATAAAAATAGTTACCATAGCTGTTGATGGATGCTTCGATCATAAAATATGTTTG...GGA')],
                             'R51': ['not annotated',
                                     Seq('ATAAAAATAGTTACCATAGCTGTTGATGGATGCTTCGATCATAAAATATGTTTG...GGA')],
                             'R52': ['not annotated',
                                     Seq('ATAAAAATAGTTACCATAGCTGTTGATGGATGCTTCGATCATAAAATATGTTTG...GGA')]},
 'exon_PRELSG_MIT00300.1-E1': {'R47': ['cytochrome b',
                                       Seq('TCCAGATAATGCTATTACAGTAGATAGATATGCTACTCCTTTACATATTGTTCC...TTC')],
                               'R48': ['cytochrome b',
                                       Seq('TCCAGATAATGCTATTACAGTAGATAGATATGCTACTCCTTTACATATTGTTCC...TTC')],
                               'R49': ['cytochrome b',
                                       Seq('TCCAGATAATGCTATTACAGTAGATAGATATGCTACTCCTTTACATATTGTTCC...TTC')],
                               'R50': ['cytochrome b',
                                       Seq('TCCAGATAATGCTATTACAGTAGATAGATATGCTACTCCTTTACATATTGTTCC...TTC')],
                               'R51': ['cytochrome b',
                                       Seq('TCCAGATAATGCTATTACAGTAGATAGATATGCTACTCCTTTACATATTGTTCC...TTC')],
                               'R52': ['cytochrome b',
                                       Seq('TCCAGATAATGCTATTACAGTAGATAGATATGCTACTCCTTTACATATTGTTCC...TTC')]}}

I'd like to align each gene and write out those alignments to file without any intermediate files written to disk. How do I do that?

$\endgroup$
2
  • $\begingroup$ do you want to align each of those Seq('ATAAAAATAGTT...... on top of each other ? $\endgroup$
    – moth
    Nov 11 '21 at 13:54
  • $\begingroup$ Yes, what you said moth. I want one alignment for each gene. $\endgroup$
    – Glubbdrubb
    Nov 12 '21 at 14:29
0
$\begingroup$

This BioPython document should get you started.

A specific example is given here.

$\endgroup$
6
  • $\begingroup$ All the examples in documentation you linked require the files to be ready to be aligned, where each file represents only one gene and multiple samples. That is not what I have here, and I don't want to write intermediate gene files. I want to do it all in memory until the final alignments are ready. $\endgroup$
    – Glubbdrubb
    Nov 8 '21 at 12:27
  • $\begingroup$ Strange requirement. No idea how to align in python without calling another application by file. $\endgroup$
    – Dan Bolser
    Nov 9 '21 at 13:31
  • $\begingroup$ I learnt how to create a MultipleSeqAlignment object based on that dict, but I can't see how to pass that object to a muscle subprocess... I guess I'd need a muscle python library. $\endgroup$
    – Glubbdrubb
    Nov 9 '21 at 13:45
  • $\begingroup$ I don't think muscle can work 'file free'... may be wrong. $\endgroup$
    – Dan Bolser
    Nov 11 '21 at 10:13
  • $\begingroup$ Yeah, I've given up on this. Biopython supports this using pairwise alignments, but that's obviously not going to work here. Thanks for your help. $\endgroup$
    – Glubbdrubb
    Nov 11 '21 at 10:21
0
$\begingroup$

I don't believe this is possible. So I'm answering this to close it, since I don't have enough reputation to close it myself.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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