|
| 1 | +package demo; |
| 2 | + |
| 3 | +import org.biojava.nbio.core.sequence.MultipleSequenceAlignment; |
| 4 | +import org.biojava.nbio.core.sequence.ProteinSequence; |
| 5 | +import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; |
| 6 | +import org.biojava.nbio.phylo.TreeConstructionAlgorithm; |
| 7 | +import org.biojava.nbio.phylo.ProgressListenerStub; |
| 8 | +import org.biojava.nbio.phylo.TreeConstructor; |
| 9 | +import org.biojava.nbio.phylo.TreeType; |
| 10 | + |
| 11 | +/** |
| 12 | + * This demo contains the CookBook examples to create a phylogenetic tree from a |
| 13 | + * given multiple sequence alignment (MSA). |
| 14 | + * |
| 15 | + * @author Aleix Lafita |
| 16 | + * |
| 17 | + */ |
| 18 | +public class DemoTreeConstructor { |
| 19 | + |
| 20 | + public static void main(String[] args) throws Exception { |
| 21 | + |
| 22 | + MultipleSequenceAlignment<ProteinSequence, AminoAcidCompound> msa = new |
| 23 | + MultipleSequenceAlignment<ProteinSequence, AminoAcidCompound>(); |
| 24 | + |
| 25 | + ProteinSequence pSeq1 = new ProteinSequence( |
| 26 | + "RER-RDGGGNSRKYDDRRSPRDGE---IDYDERTVSHYQRQFQDERISDGM" |
| 27 | + + "LNTLKQSLKGLDCQPIHLKDSKANRSIMIDEIHTGTADSVTFEQKLPDGEMKL"); |
| 28 | + ProteinSequence pSeq2 = new ProteinSequence( |
| 29 | + "RDRHRD---DRHRYDEDRDHRRDQRNVSDYDSEELRKFEEDYKSDRLGQYV" |
| 30 | + + "FSDLNSAVKGLVVQPIHL-NKEVNRTVIIDSICKESAEKVRFEFGKGEDAREI"); |
| 31 | + ProteinSequence pSeq3 = new ProteinSequence( |
| 32 | + "RPTH---GGLSLNIDVSTTMILEPGPVIEF-----LKANQSVETPRQIDWI" |
| 33 | + + "-----KAAKML--KHMRVKATHRNMEFKIIGLSSKPCNQQLFSMKIKDGEREV"); |
| 34 | + |
| 35 | + msa.addAlignedSequence(pSeq1); |
| 36 | + msa.addAlignedSequence(pSeq2); |
| 37 | + msa.addAlignedSequence(pSeq3); |
| 38 | + |
| 39 | + TreeConstructor<ProteinSequence, AminoAcidCompound> treeConstructor = |
| 40 | + new TreeConstructor<ProteinSequence, AminoAcidCompound>( |
| 41 | + msa, TreeType.NJ, TreeConstructionAlgorithm.PID, |
| 42 | + new ProgressListenerStub()); |
| 43 | + treeConstructor.process(); |
| 44 | + String newick = treeConstructor.getNewickString(true, true); |
| 45 | + |
| 46 | + System.out.println(newick); |
| 47 | + } |
| 48 | +} |
0 commit comments