{"action":"created","issue":{"url":"https://api.github.com/repos/GuangchuangYu/ggtree/issues/55","repository_url":"https://api.github.com/repos/GuangchuangYu/ggtree","labels_url":"https://api.github.com/repos/GuangchuangYu/ggtree/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/GuangchuangYu/ggtree/issues/55/comments","events_url":"https://api.github.com/repos/GuangchuangYu/ggtree/issues/55/events","html_url":"https://github.com/GuangchuangYu/ggtree/pull/55","id":149960720,"number":55,"title":"modify read.nhx to take a connection so that it can be fed tree strings","user":{"login":"caseywdunn","id":385706,"avatar_url":"https://avatars.githubusercontent.com/u/385706?v=3","gravatar_id":"","url":"https://api.github.com/users/caseywdunn","html_url":"https://github.com/caseywdunn","followers_url":"https://api.github.com/users/caseywdunn/followers","following_url":"https://api.github.com/users/caseywdunn/following{/other_user}","gists_url":"https://api.github.com/users/caseywdunn/gists{/gist_id}","starred_url":"https://api.github.com/users/caseywdunn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseywdunn/subscriptions","organizations_url":"https://api.github.com/users/caseywdunn/orgs","repos_url":"https://api.github.com/users/caseywdunn/repos","events_url":"https://api.github.com/users/caseywdunn/events{/privacy}","received_events_url":"https://api.github.com/users/caseywdunn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-21T04:11:25Z","updated_at":"2016-04-21T04:27:39Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/GuangchuangYu/ggtree/pulls/55","html_url":"https://github.com/GuangchuangYu/ggtree/pull/55","diff_url":"https://github.com/GuangchuangYu/ggtree/pull/55.diff","patch_url":"https://github.com/GuangchuangYu/ggtree/pull/55.patch"},"body":"`read.nhx` could only take a file path, specified with `file`. This is then used three times:\r\n\r\n- In `readLines(file)` to parse the tree text\r\n- In `phylo <- read.tree(file)` to parse the file as a tree\r\n- In `file = file` to put the path into a character slot in the new object\r\n\r\nThis means that `file` must be a character string that specifies a path. Often, though, the user would like to read the tree from a string instead. This could be accomplished if `file` could be a connection. The user could then create a text connection and pass that, eg `nhx = read.nhx( textConnection( nhx_text ) )`.\r\n\r\n`readLines()` can take a path or connection as `file`. So it is OK as-is. `file` should only be used here. I therefore made the following two modifications:\r\n\r\n- Use the parsed tree string used to generate `phylo` with `phylo <- read.tree( text = treetext)`\r\n- Instead of putting the path in the `nhx` slot, put in the treetext with `file = treetext`"},"comment":{"url":"https://api.github.com/repos/GuangchuangYu/ggtree/issues/comments/212735971","html_url":"https://github.com/GuangchuangYu/ggtree/pull/55#issuecomment-212735971","issue_url":"https://api.github.com/repos/GuangchuangYu/ggtree/issues/55","id":212735971,"user":{"login":"GuangchuangYu","id":626539,"avatar_url":"https://avatars.githubusercontent.com/u/626539?v=3","gravatar_id":"","url":"https://api.github.com/users/GuangchuangYu","html_url":"https://github.com/GuangchuangYu","followers_url":"https://api.github.com/users/GuangchuangYu/followers","following_url":"https://api.github.com/users/GuangchuangYu/following{/other_user}","gists_url":"https://api.github.com/users/GuangchuangYu/gists{/gist_id}","starred_url":"https://api.github.com/users/GuangchuangYu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GuangchuangYu/subscriptions","organizations_url":"https://api.github.com/users/GuangchuangYu/orgs","repos_url":"https://api.github.com/users/GuangchuangYu/repos","events_url":"https://api.github.com/users/GuangchuangYu/events{/privacy}","received_events_url":"https://api.github.com/users/GuangchuangYu/received_events","type":"User","site_admin":false},"created_at":"2016-04-21T04:27:39Z","updated_at":"2016-04-21T04:27:39Z","body":"the file path will be shown if you print the object. If the `file` slot is the treetext, it maybe messy when printing the object if the treetext is very long and treetext is not human friendly either.\r\n"}}