How to get msa output in fasta format
2
0
Entering edit mode
cav3gh • 0
@cav3gh-15680
Last seen 2.8 years ago

My current code is :

myFirstAlignment <- msaClustalOmega(mySequences)

msaPrettyPrint(myFirstAlignment, output=c("pdf", "tex", "dvi", "asis"))

msaPrettyPrint says that its first writes to a fasta file but does not include that as an output option, is there anyway to get that fasta file?  I am trying to use phangorn to create phylogenetic trees in downstream analysis.

msa msaprettyprint() • 1.8k views
2
Entering edit mode
Mike Smith ★ 5.4k
@mike-smith
Last seen 8 hours ago
EMBL Heidelberg / de.NBI

You can use the argument alFile = /path/to/a/file.fasta to specify the location of the generated alignment file e.g.

msaPrettyPrint(myFirstAlignment, output=c("pdf", "tex", "dvi", "asis"), alFile = "/tmp/alignment.fasta")


Note that it has to have the file extension .fasta otherwise it throws an error.

0
Entering edit mode
UBodenhofer ▴ 290
@ubodenhofer-5425
Last seen 12 weeks ago
University of Applied Sciences Upper Au…

If you do not want to make the extra way via the msaPrettyPrint() function, you can also directly write to a FASTA file in the following way (which is actually what msaPrettyPrint() does internally; suppose 'aln' is an object containing a multiple alignment):

writeXStringSet(as(unmasked(aln), "XStringSet"), file="aln.fasta")