{"action":"created","comment":{"url":"https://api.github.com/repos/geronimp/graftM/pulls/comments/40521520","id":40521520,"diff_hunk":"@@ -0,0 +1,80 @@\n+\n+# System imports\n+import logging\n+from skbio import TreeNode\n+from graftm.reannotator import Reannotator\n+from graftm.tree_decorator import TreeDecorator\n+\n+class Decorator:\n+    '''re-root a tree and decorate it using old taxonomy, for the graftM \n+    decorate pipeline.\n+    \n+    ALL trees provided to this class must be in newick format. No other formats \n+    are supported. If any taxonomic decoration is already in the tree to be \n+    decorated by this class is WILL be overwritten. Of course, bootstrap values \n+    will remain untouched.'''\n+\n+    def __init__(self, **kwargs):\n+        '''\n+        Parameters\n+        ----------\n+        reference_tree_path: str\n+            Path to the file containing the reference tree, which is used to\n+            retroot the tree tree provided to old_tree\n+        old_tree_path: str\n+            Path to the file containing the tree to be re-rooted. This tree will\n+            be rerooted at the same position as the tree porovided to the \n+            reference_tree\n+        '''\n+        reference_tree_path = kwargs.pop('reference_tree_path', None)\n+        tree_path = kwargs.pop('tree_path', None)\n+        \n+        if tree_path == None:\n+            logging.error(\"No tree for provided for Decorator class to modify\")\n+            exit(1)\n+        else:\n+            logging.debug(\"Importing old tree from file: %s\" \n+                            % tree_path)\n+            self.tree = TreeNode.read(open(tree_path, \"r\"))  \n+        \n+        if reference_tree_path:\n+            logging.debug(\"Importing reference tree from file: %s\" \n+                            % reference_tree_path)\n+            self.reference_tree = TreeNode.read(open(reference_tree_path, \"r\"))   \n+        else:\n+            self.reference_tree = None\n+        if len(kwargs) > 0:\n+            raise Exception(\"Unexpected arguments provided to Decorator class: %s\" % kwargs)\n+        \n+    def _reroot(self):\n+        '''Run the re-rooting algorithm in the Reannotator class.'''\n+        reannotator = Reannotator()\n+        self.tree = reannotator._reroot_tree_by_old_root(self.reference_tree, \n+                                                         self.tree)\n+        \n+    def main(self, taxonomy, output_tree, output_tax, seqinfo = None):\n+        '''Decorate and if necessary, re-root the tree. If an old reference tree\n+        is provided it is assumed that re-rooting is desired\n+        \n+        Parameters\n+        ----------\n+        taxonomy: str\n+            Path to a GreenGenes formatted taxonomy file, containing the \n+            taxonomy of all or some if the sequences used to construct the tree.\n+            This taxonomy will be used by the tree_decorator.TreeDecorator class\n+            to decorate self.tree\n+        output_tree: str\n+            Path to file to which the decorated tree will be written to.\n+        output_tax: str\n+            Path to file to which the decorated taxonomy will be written to.'''        ","path":"graftm/decorator.py","position":69,"original_position":69,"commit_id":"60e57bc9f79fcaac123aa3a1e0837d5e6cc8a1f2","original_commit_id":"60e57bc9f79fcaac123aa3a1e0837d5e6cc8a1f2","user":{"login":"geronimp","id":7812442,"avatar_url":"https://avatars.githubusercontent.com/u/7812442?v=3","gravatar_id":"","url":"https://api.github.com/users/geronimp","html_url":"https://github.com/geronimp","followers_url":"https://api.github.com/users/geronimp/followers","following_url":"https://api.github.com/users/geronimp/following{/other_user}","gists_url":"https://api.github.com/users/geronimp/gists{/gist_id}","starred_url":"https://api.github.com/users/geronimp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geronimp/subscriptions","organizations_url":"https://api.github.com/users/geronimp/orgs","repos_url":"https://api.github.com/users/geronimp/repos","events_url":"https://api.github.com/users/geronimp/events{/privacy}","received_events_url":"https://api.github.com/users/geronimp/received_events","type":"User","site_admin":false},"body":"Okay, thanks","created_at":"2015-09-28T06:41:48Z","updated_at":"2015-09-28T06:41:48Z","html_url":"https://github.com/geronimp/graftM/pull/116#discussion_r40521520","pull_request_url":"https://api.github.com/repos/geronimp/graftM/pulls/116","_links":{"self":{"href":"https://api.github.com/repos/geronimp/graftM/pulls/comments/40521520"},"html":{"href":"https://github.com/geronimp/graftM/pull/116#discussion_r40521520"},"pull_request":{"href":"https://api.github.com/repos/geronimp/graftM/pulls/116"}}},"pull_request":{"url":"https://api.github.com/repos/geronimp/graftM/pulls/116","id":45723228,"html_url":"https://github.com/geronimp/graftM/pull/116","diff_url":"https://github.com/geronimp/graftM/pull/116.diff","patch_url":"https://github.com/geronimp/graftM/pull/116.patch","issue_url":"https://api.github.com/repos/geronimp/graftM/issues/116","number":116,"state":"open","locked":false,"title":"Geronimp ben reannotator and decorate","user":{"login":"geronimp","id":7812442,"avatar_url":"https://avatars.githubusercontent.com/u/7812442?v=3","gravatar_id":"","url":"https://api.github.com/users/geronimp","html_url":"https://github.com/geronimp","followers_url":"https://api.github.com/users/geronimp/followers","following_url":"https://api.github.com/users/geronimp/following{/other_user}","gists_url":"https://api.github.com/users/geronimp/gists{/gist_id}","starred_url":"https://api.github.com/users/geronimp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geronimp/subscriptions","organizations_url":"https://api.github.com/users/geronimp/orgs","repos_url":"https://api.github.com/users/geronimp/repos","events_url":"https://api.github.com/users/geronimp/events{/privacy}","received_events_url":"https://api.github.com/users/geronimp/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-22T22:04:41Z","updated_at":"2015-09-28T06:41:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/geronimp/graftM/pulls/116/commits","review_comments_url":"https://api.github.com/repos/geronimp/graftM/pulls/116/comments","review_comment_url":"https://api.github.com/repos/geronimp/graftM/pulls/comments{/number}","comments_url":"https://api.github.com/repos/geronimp/graftM/issues/116/comments","statuses_url":"https://api.github.com/repos/geronimp/graftM/statuses/60e57bc9f79fcaac123aa3a1e0837d5e6cc8a1f2","head":{"label":"geronimp:geronimp-ben_reannotator_and_decorate","ref":"geronimp-ben_reannotator_and_decorate","sha":"60e57bc9f79fcaac123aa3a1e0837d5e6cc8a1f2","user":{"login":"geronimp","id":7812442,"avatar_url":"https://avatars.githubusercontent.com/u/7812442?v=3","gravatar_id":"","url":"https://api.github.com/users/geronimp","html_url":"https://github.com/geronimp","followers_url":"https://api.github.com/users/geronimp/followers","following_url":"https://api.github.com/users/geronimp/following{/other_user}","gists_url":"https://api.github.com/users/geronimp/gists{/gist_id}","starred_url":"https://api.github.com/users/geronimp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geronimp/subscriptions","organizations_url":"https://api.github.com/users/geronimp/orgs","repos_url":"https://api.github.com/users/geronimp/repos","events_url":"https://api.github.com/users/geronimp/events{/privacy}","received_events_url":"https://api.github.com/users/geronimp/received_events","type":"User","site_admin":false},"repo":{"id":22001913,"name":"graftM","full_name":"geronimp/graftM","owner":{"login":"geronimp","id":7812442,"avatar_url":"https://avatars.githubusercontent.com/u/7812442?v=3","gravatar_id":"","url":"https://api.github.com/users/geronimp","html_url":"https://github.com/geronimp","followers_url":"https://api.github.com/users/geronimp/followers","following_url":"https://api.github.com/users/geronimp/following{/other_user}","gists_url":"https://api.github.com/users/geronimp/gists{/gist_id}","starred_url":"https://api.github.com/users/geronimp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geronimp/subscriptions","organizations_url":"https://api.github.com/users/geronimp/orgs","repos_url":"https://api.github.com/users/geronimp/repos","events_url":"https://api.github.com/users/geronimp/events{/privacy}","received_events_url":"https://api.github.com/users/geronimp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/geronimp/graftM","description":"GraftM - Rapid community profiles from metagenomes","fork":false,"url":"https://api.github.com/repos/geronimp/graftM","forks_url":"https://api.github.com/repos/geronimp/graftM/forks","keys_url":"https://api.github.com/repos/geronimp/graftM/keys{/key_id}","collaborators_url":"https://api.github.com/repos/geronimp/graftM/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/geronimp/graftM/teams","hooks_url":"https://api.github.com/repos/geronimp/graftM/hooks","issue_events_url":"https://api.github.com/repos/geronimp/graftM/issues/events{/number}","events_url":"https://api.github.com/repos/geronimp/graftM/events","assignees_url":"https://api.github.com/repos/geronimp/graftM/assignees{/user}","branches_url":"https://api.github.com/repos/geronimp/graftM/branches{/branch}","tags_url":"https://api.github.com/repos/geronimp/graftM/tags","blobs_url":"https://api.github.com/repos/geronimp/graftM/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/geronimp/graftM/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/geronimp/graftM/git/refs{/sha}","trees_url":"https://api.github.com/repos/geronimp/graftM/git/trees{/sha}","statuses_url":"https://api.github.com/repos/geronimp/graftM/statuses/{sha}","languages_url":"https://api.github.com/repos/geronimp/graftM/languages","stargazers_url":"https://api.github.com/repos/geronimp/graftM/stargazers","contributors_url":"https://api.github.com/repos/geronimp/graftM/contributors","subscribers_url":"https://api.github.com/repos/geronimp/graftM/subscribers","subscription_url":"https://api.github.com/repos/geronimp/graftM/subscription","commits_url":"https://api.github.com/repos/geronimp/graftM/commits{/sha}","git_commits_url":"https://api.github.com/repos/geronimp/graftM/git/commits{/sha}","comments_url":"https://api.github.com/repos/geronimp/graftM/comments{/number}","issue_comment_url":"https://api.github.com/repos/geronimp/graftM/issues/comments{/number}","contents_url":"https://api.github.com/repos/geronimp/graftM/contents/{+path}","compare_url":"https://api.github.com/repos/geronimp/graftM/compare/{base}...{head}","merges_url":"https://api.github.com/repos/geronimp/graftM/merges","archive_url":"https://api.github.com/repos/geronimp/graftM/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/geronimp/graftM/downloads","issues_url":"https://api.github.com/repos/geronimp/graftM/issues{/number}","pulls_url":"https://api.github.com/repos/geronimp/graftM/pulls{/number}","milestones_url":"https://api.github.com/repos/geronimp/graftM/milestones{/number}","notifications_url":"https://api.github.com/repos/geronimp/graftM/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/geronimp/graftM/labels{/name}","releases_url":"https://api.github.com/repos/geronimp/graftM/releases{/id}","created_at":"2014-07-19T04:29:28Z","updated_at":"2015-05-24T13:31:01Z","pushed_at":"2015-09-27T05:50:20Z","git_url":"git://github.com/geronimp/graftM.git","ssh_url":"git@github.com:geronimp/graftM.git","clone_url":"https://github.com/geronimp/graftM.git","svn_url":"https://github.com/geronimp/graftM","homepage":"http://geronimp.github.io/graftM/","size":67185,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":14,"forks":2,"open_issues":14,"watchers":2,"default_branch":"master"}},"base":{"label":"geronimp:master","ref":"master","sha":"51e88429c6307a3b31e0ba260dd4c21e97264d99","user":{"login":"geronimp","id":7812442,"avatar_url":"https://avatars.githubusercontent.com/u/7812442?v=3","gravatar_id":"","url":"https://api.github.com/users/geronimp","html_url":"https://github.com/geronimp","followers_url":"https://api.github.com/users/geronimp/followers","following_url":"https://api.github.com/users/geronimp/following{/other_user}","gists_url":"https://api.github.com/users/geronimp/gists{/gist_id}","starred_url":"https://api.github.com/users/geronimp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geronimp/subscriptions","organizations_url":"https://api.github.com/users/geronimp/orgs","repos_url":"https://api.github.com/users/geronimp/repos","events_url":"https://api.github.com/users/geronimp/events{/privacy}","received_events_url":"https://api.github.com/users/geronimp/received_events","type":"User","site_admin":false},"repo":{"id":22001913,"name":"graftM","full_name":"geronimp/graftM","owner":{"login":"geronimp","id":7812442,"avatar_url":"https://avatars.githubusercontent.com/u/7812442?v=3","gravatar_id":"","url":"https://api.github.com/users/geronimp","html_url":"https://github.com/geronimp","followers_url":"https://api.github.com/users/geronimp/followers","following_url":"https://api.github.com/users/geronimp/following{/other_user}","gists_url":"https://api.github.com/users/geronimp/gists{/gist_id}","starred_url":"https://api.github.com/users/geronimp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geronimp/subscriptions","organizations_url":"https://api.github.com/users/geronimp/orgs","repos_url":"https://api.github.com/users/geronimp/repos","events_url":"https://api.github.com/users/geronimp/events{/privacy}","received_events_url":"https://api.github.com/users/geronimp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/geronimp/graftM","description":"GraftM - Rapid community profiles from metagenomes","fork":false,"url":"https://api.github.com/repos/geronimp/graftM","forks_url":"https://api.github.com/repos/geronimp/graftM/forks","keys_url":"https://api.github.com/repos/geronimp/graftM/keys{/key_id}","collaborators_url":"https://api.github.com/repos/geronimp/graftM/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/geronimp/graftM/teams","hooks_url":"https://api.github.com/repos/geronimp/graftM/hooks","issue_events_url":"https://api.github.com/repos/geronimp/graftM/issues/events{/number}","events_url":"https://api.github.com/repos/geronimp/graftM/events","assignees_url":"https://api.github.com/repos/geronimp/graftM/assignees{/user}","branches_url":"https://api.github.com/repos/geronimp/graftM/branches{/branch}","tags_url":"https://api.github.com/repos/geronimp/graftM/tags","blobs_url":"https://api.github.com/repos/geronimp/graftM/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/geronimp/graftM/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/geronimp/graftM/git/refs{/sha}","trees_url":"https://api.github.com/repos/geronimp/graftM/git/trees{/sha}","statuses_url":"https://api.github.com/repos/geronimp/graftM/statuses/{sha}","languages_url":"https://api.github.com/repos/geronimp/graftM/languages","stargazers_url":"https://api.github.com/repos/geronimp/graftM/stargazers","contributors_url":"https://api.github.com/repos/geronimp/graftM/contributors","subscribers_url":"https://api.github.com/repos/geronimp/graftM/subscribers","subscription_url":"https://api.github.com/repos/geronimp/graftM/subscription","commits_url":"https://api.github.com/repos/geronimp/graftM/commits{/sha}","git_commits_url":"https://api.github.com/repos/geronimp/graftM/git/commits{/sha}","comments_url":"https://api.github.com/repos/geronimp/graftM/comments{/number}","issue_comment_url":"https://api.github.com/repos/geronimp/graftM/issues/comments{/number}","contents_url":"https://api.github.com/repos/geronimp/graftM/contents/{+path}","compare_url":"https://api.github.com/repos/geronimp/graftM/compare/{base}...{head}","merges_url":"https://api.github.com/repos/geronimp/graftM/merges","archive_url":"https://api.github.com/repos/geronimp/graftM/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/geronimp/graftM/downloads","issues_url":"https://api.github.com/repos/geronimp/graftM/issues{/number}","pulls_url":"https://api.github.com/repos/geronimp/graftM/pulls{/number}","milestones_url":"https://api.github.com/repos/geronimp/graftM/milestones{/number}","notifications_url":"https://api.github.com/repos/geronimp/graftM/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/geronimp/graftM/labels{/name}","releases_url":"https://api.github.com/repos/geronimp/graftM/releases{/id}","created_at":"2014-07-19T04:29:28Z","updated_at":"2015-05-24T13:31:01Z","pushed_at":"2015-09-27T05:50:20Z","git_url":"git://github.com/geronimp/graftM.git","ssh_url":"git@github.com:geronimp/graftM.git","clone_url":"https://github.com/geronimp/graftM.git","svn_url":"https://github.com/geronimp/graftM","homepage":"http://geronimp.github.io/graftM/","size":67185,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":14,"forks":2,"open_issues":14,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/geronimp/graftM/pulls/116"},"html":{"href":"https://github.com/geronimp/graftM/pull/116"},"issue":{"href":"https://api.github.com/repos/geronimp/graftM/issues/116"},"comments":{"href":"https://api.github.com/repos/geronimp/graftM/issues/116/comments"},"review_comments":{"href":"https://api.github.com/repos/geronimp/graftM/pulls/116/comments"},"review_comment":{"href":"https://api.github.com/repos/geronimp/graftM/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/geronimp/graftM/pulls/116/commits"},"statuses":{"href":"https://api.github.com/repos/geronimp/graftM/statuses/60e57bc9f79fcaac123aa3a1e0837d5e6cc8a1f2"}}}}