From 5a4ca8ab2a51f76ee361e6e7055bab1d5bf40c74 Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Sun, 18 Oct 2020 12:03:27 +1300 Subject: [PATCH 1/6] Format README.md with markdown syntax for code block (bash) --- README.md | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 92cdcbf..12a953d 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,34 @@ -rootstrap.py: A script to calculate the rootstrap support values for all the branches +`rootstrap.py`: A script to calculate the rootstrap support values for all the branches Syntax: -rootstrap.py \ \ \ \ +```bash +rootstrap.py -\                     The tree file where you want to calculate the rootstrap support values in Newick format (e.g. tree.treefile).
-                                        The tree can be rooted or unrooted. + The tree file where you want to calculate the rootstrap support values in Newick format (e.g. tree.treefile). + The tree can be rooted or unrooted. -\ All the bootstrap trees in Newick format.
-                                      For example: .ufboot file from IQ-TREE (tree.ufboot) + All the bootstrap trees in Newick format. + For example: .ufboot file from IQ-TREE (tree.ufboot) -\                  Are the ML tree and the boostrap trees rooted or not.
-                                       True - The trees assumed to be rooted and no outgroup taxa infromation is required
-                                      False - The trees assumed to be unrooted and outgroup taxa infromation is required
-                                      (default: True) + Are the ML tree and the boostrap trees rooted or not. + True - The trees assumed to be rooted and no outgroup taxa infromation is required + False - The trees assumed to be unrooted and outgroup taxa infromation is required + (default: True) -\ ;              outgroup taxa in Nexus format.
-                                      The outgroup block can be part of the alignment (e.g. OG_File1.nex) file or in a separate file (e.g. OG_File2.nex) + outgroup taxa in Nexus format. + The outgroup block can be part of the alignment (e.g. OG_File1.nex) file or in a separate file (e.g. OG_File2.nex) +``` ------------------------------------------------------------------------------------- -rBED_rSED.py: A script to calculate the root Branchlength Error Distance (rBED) and the root Split Error Distance (rSED) +`rBED_rSED.py`: A script to calculate the root Branchlength Error Distance (rBED) and the root Split Error Distance (rSED) Syntax: -rBED_rSED.py \ +```bash +rBED_rSED.py -\                     The tree file (rooted tree only in Newick format) where you want to calculate rBED and rSED values. + The tree file (rooted tree only in Newick format) where you want to calculate rBED and rSED values. +``` Note: In order to calculate rBED and rSED values, the true root should be known (or assumed to be known) in advance. From e7deb4ea6f6e1c432b1d7ced535c105d80d77960 Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Sun, 18 Oct 2020 12:09:35 +1300 Subject: [PATCH 2/6] Fix typos --- rootstrap.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rootstrap.py b/rootstrap.py index 1b4efad..8199556 100644 --- a/rootstrap.py +++ b/rootstrap.py @@ -49,7 +49,7 @@ def all_possible_roots(treefile): raise SystemExit('Error: you have unrooted trees. please deactivate the is_rooted flag and provide outgroup taxa file in Nexus format') return roots, sameTree -def caluclate_rootstrap(treeFile, bootFile, is_rooted, out_group): +def calculate_rootstrap(treeFile, bootFile, is_rooted, out_group): ''' input: treeFile: rooted tree in newick format (.treefile in IQ-TREE) @@ -111,7 +111,7 @@ def caluclate_rootstrap(treeFile, bootFile, is_rooted, out_group): boottrees.append(t.write(format=9)) N_boottrees = len(boottrees) - booted = [(g[0], len(list(g[1]))) for g in ite.groupby(boottrees)] #a list of all unique bootstrap trees with thier number of occurrence + booted = [(g[0], len(list(g[1]))) for g in ite.groupby(boottrees)] #a list of all unique bootstrap trees with their number of occurrence boottrees = [] for b in booted: t2 = Tree(b[0]) @@ -192,7 +192,7 @@ def rootstrap(): out_group = sys.argv[4] elif len(sys.argv) > 5: raise SystemExit('Error: too many arguments') - print('Note: ingroup taxa are not monophyletic in {} bootstrap trees\n'.format(caluclate_rootstrap(sys.argv[1], sys.argv[2], is_rooted, out_group))) + print('Note: ingroup taxa are not monophyletic in {} bootstrap trees\n'.format(calculate_rootstrap(sys.argv[1], sys.argv[2], is_rooted, out_group))) if __name__ == '__main__': rootstrap() From a9fad7d195da2d9095dfe57f47157875e8ead625 Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Sun, 18 Oct 2020 12:20:24 +1300 Subject: [PATCH 3/6] Remove unused ML_tree variable in else code block --- rootstrap.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rootstrap.py b/rootstrap.py index 8199556..d75f441 100644 --- a/rootstrap.py +++ b/rootstrap.py @@ -104,7 +104,6 @@ def calculate_rootstrap(treeFile, bootFile, is_rooted, out_group): ML_tree.write(outfile=rootedMLtree) #write the rooted tree with ingroup taxa only to a file else: - ML_tree = Tree(treeFile) with open(bootFile, 'r') as f: for tree in f: t = Tree(tree) From db2482da52e34fc28d5f048d00e23cc6f3fafd96 Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Sun, 18 Oct 2020 12:35:06 +1300 Subject: [PATCH 4/6] Add requirements.txt file --- requirements.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..12f2720 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +ete3==3.1.* +dendropy==4.4.* +biopython==1.78 +six==1.15.* From 114dc90ee93604f3f195c95838dce809e72fda8d Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Sun, 18 Oct 2020 12:35:17 +1300 Subject: [PATCH 5/6] Use is for comparing with None --- rootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootstrap.py b/rootstrap.py index d75f441..796ac2b 100644 --- a/rootstrap.py +++ b/rootstrap.py @@ -64,7 +64,7 @@ def calculate_rootstrap(treeFile, bootFile, is_rooted, out_group): trees = [] polyphyly = 0 if not is_rooted: - if out_group == None: + if out_group is None: raise SystemExit('Error: Please provide outgroup taxa in Nexus format') ML_tree = Tree(treeFile) nex = Nexus.Nexus() From 7def995b9d972c38830592d2ef04c9fbf3e28962 Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Sun, 18 Oct 2020 12:46:04 +1300 Subject: [PATCH 6/6] Add installation instructions with pip or conda --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 12a953d..5a158e2 100644 --- a/README.md +++ b/README.md @@ -32,3 +32,33 @@ rBED_rSED.py ``` Note: In order to calculate rBED and rSED values, the true root should be known (or assumed to be known) in advance. + +## Installation + +For running the scripts in this repository you will need Python 3, and the dependencies +listed in `requirements.txt`. + +It is recommended to use a virtual environment to avoid complications with system +dependencies and Python. + +For users that prefer `pip`, the following should work assuming you have Python 3 +`python` and `pip` in your command line `$PATH` (if using an older OS, you may still +have `python3` and `pip3`, so just use those commands instead). + +```bash +$ python -m venv venv # create a virtual environment called venv with pip +$ source venv/bin/activate # load the virtual environment, note the change in some shells displaying the venv name +(venv) $ pip install -r requirements.txt +# ... it should take a few minutes to download dependencies from PYPI.org and install in your venv (not in your OS Python modules) +(venv) $ python rootstrap.py +Error: Please provide the ML tree file and the bootstrap trees file +(venv) $ python rBED_rSED.py +Error: Please provide the rooted ML tree file +``` + +If you had a similar output to the commands above, your installation worked successfully. +Have a read at the command syntax instructions to use the scripts. + +For Conda users, follow their instructions for [managing environments](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html) +and just run `pip`. Alternativelly, you can consult [Conda Forge](https://conda-forge.org/) +searching for equivalent packages and installing them via `conda install $package-name`.