{"id":25977604,"url":"https://github.com/nylander/parse_mrbayes_ancestral_states","last_synced_at":"2026-04-19T11:32:19.209Z","repository":{"id":146538647,"uuid":"104477536","full_name":"nylander/Parse_MrBayes_Ancestral_States","owner":"nylander","description":"Create FASTA file for ancestral sequence reported in MrBayes v.3","archived":false,"fork":false,"pushed_at":"2022-10-06T15:16:16.000Z","size":305,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-10-20T22:08:50.085Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nylander.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-09-22T13:28:35.000Z","updated_at":"2023-10-20T22:08:59.661Z","dependencies_parsed_at":null,"dependency_job_id":"7799a4a3-ee28-4906-b997-92f9aff3ae50","html_url":"https://github.com/nylander/Parse_MrBayes_Ancestral_States","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nylander%2FParse_MrBayes_Ancestral_States","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nylander%2FParse_MrBayes_Ancestral_States/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nylander%2FParse_MrBayes_Ancestral_States/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nylander%2FParse_MrBayes_Ancestral_States/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nylander","download_url":"https://codeload.github.com/nylander/Parse_MrBayes_Ancestral_States/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241966988,"owners_count":20050324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-05T04:38:41.543Z","updated_at":"2026-04-19T11:32:14.180Z","avatar_url":"https://github.com/nylander.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Parse MrBayes Ancestral States\n\n- Last modified: tor okt 06, 2022  05:10\n- Johan.Nylander\\@{nrm|nbis}.se\n\nThe software MrBayes have the capacity of inferring ancestral character states.\nThe results are summarized in the `.pstat` file. This script parses the MrBayes\noutput and saves the actual states or sequence, with the highest posterior\nprobability, as a fasta-formatted file.\n\n## Example 1: Ancestral state estimation for morphological characters\n\n### Step 1. Set up MrBayes to do the ancestral reconstructions\n\nHere is an example [dataset](data/mix.nex) with combined DNA and morphological\ndata.  When reading the data, the morphological data are automatically assigned\nto a separate partition (number 2). We will define one specific node where\nancestral states should be estimated, then tell MrBayes to report the ancestral\nstates for all characters in partition 2. The `Lset coding=variable` command is\nfor accounting for coding bias in the morphological data (see the MrBayes\nmanual for explanation). Also note that with your data, you might want to\nchange default settings on substitution models, MCMC, etc.\n\nExectute the following commands in MrBayes:\n\n    #NEXUS\n    Begin MrBayes;\n        Set autoclose=yes nowarn=yes;\n        Execute mix.nex;\n        Taxset MyTaxset = Andricus_curvator Andricus_kollari;\n        Constraint MyConstraint = MyTaxset;\n        Prset topologypr = constraints(MyConstraint);\n        Lset applyto=(2) coding=variable;\n        Report applyto=(2) ancstates=yes;\n        Mcmc nruns=1 nchains=1 ngen=50000 checkpoint=no;\n        Sump;\n        Quit;\n    End;\n\n### Step 2. Parse the output from MrBayes\n\nRun the `parsemb.pl` script with the `.pstat` file as input. The resulting\nsequence is written to standard out, while the details about state\nprobabilities is printed on standard error:\n\n    $ ./parsemb.pl data/mix.nex.pstat\n    # MyConstraint\n    485\t0=6.361512e-01\t2=2.980698e-01\t1=6.577902e-02\t\n    486\t1=9.579908e-01\t0=4.200920e-02\t\n    487\t2=9.909044e-01\t0=8.459564e-03\t1=6.360484e-04\t\n    488\t1=9.693519e-01\t0=2.806066e-02\t2=2.587463e-03\t\n    489\t2=9.919600e-01\t0=7.198033e-03\t1=8.419819e-04\t\n    490\t0=5.094045e-01\t2=4.638707e-01\t1=2.672478e-02\t\n    \u003eMyConstraint Ancestral states at node MyConstraint\n    012120\n\nAlternatively, if you wish to have the table (tab separated) and fasta in\nseparate files:\n\n    $ ./parsemb.pl data/mix.nex.pstat \u003e ancestral.fas 2\u003e ancestral.txt\n\n## Example 2: Ancestral sequence estimation\n\nHere we will report the ancestral sequence for a specific node in the tree.\nWe will use an example [file](data/dna.nex) with DNA data.\n\n### MrBayes commands:\n\n    #NEXUS\n    Begin MrBayes;\n        Set autoclose=yes nowarn=yes;\n        Execute dna.nex;\n        Taxset MyTaxset = Andricus_curvator Andricus_kollari;\n        Constraint MyConstraint = MyTaxset;\n        Prset topologypr = constraints(MyConstraint);\n        Report ancstates=yes;\n        Mcmc nruns=1 nchains=1 ngen=50000 checkpoint=no;\n        Sump;\n        Quit;\n    End;\n\n### Run the script:\n\nHere we redirect the table to `/dev/null`, and fold the long sequence using the\nunix command `fold`:\n\n    $ ./parsemb.pl data/dna.nex.pstat 2\u003e /dev/null | fold\n    \u003eMyConstraint Ancestral states at node MyConstraint\n    TCTTGGTCCATTCTTGTGTGAGATATACGCTTTACTTGGTTCTCTATTTGGATGTGGCTCCATTTGGACAATGTGTATGA\n    TTGCTTTTGATAGGTACAATGTAATAGTGAAAGGTTTGGCTGGGAAGCCCTTAACAATCACCGGTGCAATTATACGCATA\n    ATTGGCCTTTGGGTCTGGGCCATTATTTGGACTATTGCGCCAATGTTTGGATGGAATCGGTTTTATGTACCTGAAGGTAA\n    CATGACAGCTTGCGGAACTGATTATTTAAGTAAAGACTGGTTCTCGAGGTCTTACATCCTTGTATACAGTATCTTCGTAT\n    ACTATATGCCGCTTTTCCTTATCATATACAGTTACTATTTTATCATCTCAGCTGTATCTGCTCACGAAAAAGCAATGCGC\n    GAACAGGCCAAAAAGATGAACGTAGCTTCTCTACGTTCATCTGACAATGCAAACACAAGTGCTGAGCATAAACTCGCAAA\n    GGTA\n\n**Alternatively**, we may filter the ancestral sequence and say, for example, that\nwe should only report the states where the posterior probability is above 0.99.\nThe other states are given as an \"unknown\" character (default is \"`?`\", here we\nwill use `N`):\n\n    $ ./parsemb.pl --cutoff 0.99 --unknown N data/dna.nex.pstat 2\u003e /dev/null | fold\n    \u003eMyConstraint Ancestral states at node MyConstraint\n    NNNNGGTCCATTCTTGTGTGAGATATACGCTTTACTTGGTTCTCTATTTGGATGTGGCTCCATTTGGACAATGTGTATGA\n    TTGCTTTTGATAGGTACAATGTAATAGTGAAAGGTTTGGCTGGGAAGCCCTTAACAATCACCGGTGCAATTATACGCATA\n    ATTGGCCTTTGGGTCTGGGCCATTATTTGGACTATTGCGCCAATGTTTGGATGGAATCGGNNNTATGTACCTGAAGGTAA\n    CATGACAGCTTGCGGAACTGATTATTTAAGTAAAGACTGGTTCTCGAGGTCTTACATCCTTGTATACAGTATCTTCGTAT\n    ACTATATGCCGCTTTTCCTTATCATATACAGTTACTATTTTATCATCTCAGCTGTATCTGCTCACGAAAAAGCAATGCGC\n    GAACAGGCCAAAAAGATGAACGTAGCTTCTCTACGTTCATCTGACAATGCAAACACAAGTGCTGAGCATAAACTCGCAAA\n    GGTA\n\n\n## Thanks to\n\nThanks to Dr. Robin Beck, Univ. Salford, for feature suggestions.\n\n## Licence and copyright\n\nCopyright (c) 2018-2022 Johan Nylander\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnylander%2Fparse_mrbayes_ancestral_states","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnylander%2Fparse_mrbayes_ancestral_states","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnylander%2Fparse_mrbayes_ancestral_states/lists"}