{"action":"created","comment":{"url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/comments/46248690","id":46248690,"diff_hunk":"@@ -0,0 +1,105 @@\n+# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-\n+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 fileencoding=utf-8\n+#\n+# MDAnalysis --- http://www.MDAnalysis.org\n+# Copyright (c) 2006-2015 Naveen Michaud-Agrawal, Elizabeth J. Denning, Oliver Beckstein\n+# and contributors (see AUTHORS for the full list)\n+#\n+# Released under the GNU Public Licence, v2 or any higher version\n+#\n+# Please cite your use of MDAnalysis in published work:\n+#\n+# N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein.\n+# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations.\n+# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787\n+#\n+\n+\"\"\"\n+Analysis building blocks --- :mod:`MDAnalysis.analysis.base`\n+============================================================\n+\n+A collection of useful building blocks for creating Analysis\n+classes.\n+\n+\n+\"\"\"\n+import numpy as np\n+import logging\n+\n+\n+logger = logging.getLogger(__name__)\n+\n+\n+class AnalysisBase(object):\n+    \"\"\"Base class for defining multi frame analysis\n+\n+    The analysis base class is designed as a template for creating\n+    multiframe analysis.  \n+\n+    The class implements the following methods:\n+\n+    _setup_frames(trajectory, start=None, stop=None, step=None)\n+      Pass a Reader object and define the desired iteration pattern\n+      through the trajectory\n+      \n+    run\n+      The user facing run method.  Calls the analysis methods\n+      defined below\n+\n+    Your analysis can implement the following methods, which are\n+    called from run:\n+\n+    _prepare\n+      Called before iteration on the trajectory has begun.\n+      Data structures can be set up at this time, however most\n+      error checking should be done in the __init__\n+\n+    _single_frame\n+      Called after the trajectory is moved onto each new frame.\n+\n+    _conclude\n+      Called once iteration on the trajectory is finished.\n+      Apply normalisation and averaging to results here.\n+\n+    \"\"\"\n+    def _setup_frames(self, trajectory, start=None,\n+                      stop=None, step=None):\n+        self._trajectory = trajectory\n+        start, stop, step = trajectory._check_slice_indices(\n+            start, stop, step)\n+        self.start = start\n+        self.stop = stop\n+        self.step = step\n+        self.nframes = len(xrange(start, stop, step))\n+\n+    def _single_frame(self):\n+        \"\"\"Calculate data from a single frame of trajectory\n+ \n+        Don't worry about normalising, just deal with a single frame.\n+        \"\"\"\n+        pass\n+\n+    def _prepare(self):\n+        \"\"\"Set things up before the analysis loop begins\"\"\"\n+        pass\n+\n+    def _conclude(self):\n+        \"\"\"Finalise the results you've gathered.\n+\n+        Called at the end of the run() method to finish everything up.\n+        \"\"\"\n+        pass\n+\n+    def run(self):\n+        \"\"\"Perform the calculation\"\"\"\n+        logger.info(\"Starting preparation\")\n+        self._prepare()\n+        for i, ts in enumerate(\n+                self._trajectory[self.start:self.stop:self.step]):\n+            self._ts = ts\n+            logger.info(\"--> Doing frame {} of {}\".format(i+1, self.nframes))","path":"package/MDAnalysis/analysis/base.py","position":100,"original_position":100,"commit_id":"daac9993f0a441422235d6200099baebbf8730fa","original_commit_id":"daac9993f0a441422235d6200099baebbf8730fa","user":{"login":"orbeckst","id":237980,"avatar_url":"https://avatars.githubusercontent.com/u/237980?v=3","gravatar_id":"","url":"https://api.github.com/users/orbeckst","html_url":"https://github.com/orbeckst","followers_url":"https://api.github.com/users/orbeckst/followers","following_url":"https://api.github.com/users/orbeckst/following{/other_user}","gists_url":"https://api.github.com/users/orbeckst/gists{/gist_id}","starred_url":"https://api.github.com/users/orbeckst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orbeckst/subscriptions","organizations_url":"https://api.github.com/users/orbeckst/orgs","repos_url":"https://api.github.com/users/orbeckst/repos","events_url":"https://api.github.com/users/orbeckst/events{/privacy}","received_events_url":"https://api.github.com/users/orbeckst/received_events","type":"User","site_admin":false},"body":"Don't log every frame because this makes log files really big! Use `ProgressMeter`.\r\n\r\nIf you really, really, really want to log then log at DEBUg.\r\n\r\nBut still better: don't.","created_at":"2015-12-01T07:56:29Z","updated_at":"2015-12-01T07:56:29Z","html_url":"https://github.com/MDAnalysis/mdanalysis/pull/460#discussion_r46248690","pull_request_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/460","_links":{"self":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/comments/46248690"},"html":{"href":"https://github.com/MDAnalysis/mdanalysis/pull/460#discussion_r46248690"},"pull_request":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/460"}}},"pull_request":{"url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/460","id":46458297,"html_url":"https://github.com/MDAnalysis/mdanalysis/pull/460","diff_url":"https://github.com/MDAnalysis/mdanalysis/pull/460.diff","patch_url":"https://github.com/MDAnalysis/mdanalysis/pull/460.patch","issue_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/460","number":460,"state":"open","locked":false,"title":"Feature polymers & analysis base","user":{"login":"richardjgowers","id":9249543,"avatar_url":"https://avatars.githubusercontent.com/u/9249543?v=3","gravatar_id":"","url":"https://api.github.com/users/richardjgowers","html_url":"https://github.com/richardjgowers","followers_url":"https://api.github.com/users/richardjgowers/followers","following_url":"https://api.github.com/users/richardjgowers/following{/other_user}","gists_url":"https://api.github.com/users/richardjgowers/gists{/gist_id}","starred_url":"https://api.github.com/users/richardjgowers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardjgowers/subscriptions","organizations_url":"https://api.github.com/users/richardjgowers/orgs","repos_url":"https://api.github.com/users/richardjgowers/repos","events_url":"https://api.github.com/users/richardjgowers/events{/privacy}","received_events_url":"https://api.github.com/users/richardjgowers/received_events","type":"User","site_admin":false},"body":"So I'm trying to polish up a few of the tools I've made lately, starting with persistence length.\r\n\r\nI made an `_AnalysisBase` class to run things.  Hopefully this can be used by lots of tools so that initialising and using analysis tools uses a similar set of keywords.  For the init, I've got the following kwargs to control where in the trajectory is used:\r\n - start, first frame to use\r\n - stop, last frame to use\r\n - skip, spacing between frames\r\n\r\nThen this is started using `run`.  Does this look remotely useful to other people writing stuff?  If so, it could move into `analysis.base`.\r\n\r\nI wasn't sure what the best way to make results available is.  Maybe a dictionary called `results` that has all possible things that people might be interested in?\r\n\r\nThoughts/opinions/random heckling?","created_at":"2015-09-30T21:21:07Z","updated_at":"2015-12-01T07:56:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f3f41cfe4dbf226237e5a603033e9c4600a4f7de","assignee":{"login":"kain88-de","id":4302678,"avatar_url":"https://avatars.githubusercontent.com/u/4302678?v=3","gravatar_id":"","url":"https://api.github.com/users/kain88-de","html_url":"https://github.com/kain88-de","followers_url":"https://api.github.com/users/kain88-de/followers","following_url":"https://api.github.com/users/kain88-de/following{/other_user}","gists_url":"https://api.github.com/users/kain88-de/gists{/gist_id}","starred_url":"https://api.github.com/users/kain88-de/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kain88-de/subscriptions","organizations_url":"https://api.github.com/users/kain88-de/orgs","repos_url":"https://api.github.com/users/kain88-de/repos","events_url":"https://api.github.com/users/kain88-de/events{/privacy}","received_events_url":"https://api.github.com/users/kain88-de/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/460/commits","review_comments_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/460/comments","review_comment_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/460/comments","statuses_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/statuses/daac9993f0a441422235d6200099baebbf8730fa","head":{"label":"MDAnalysis:feature-polymers","ref":"feature-polymers","sha":"daac9993f0a441422235d6200099baebbf8730fa","user":{"login":"MDAnalysis","id":11445951,"avatar_url":"https://avatars.githubusercontent.com/u/11445951?v=3","gravatar_id":"","url":"https://api.github.com/users/MDAnalysis","html_url":"https://github.com/MDAnalysis","followers_url":"https://api.github.com/users/MDAnalysis/followers","following_url":"https://api.github.com/users/MDAnalysis/following{/other_user}","gists_url":"https://api.github.com/users/MDAnalysis/gists{/gist_id}","starred_url":"https://api.github.com/users/MDAnalysis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MDAnalysis/subscriptions","organizations_url":"https://api.github.com/users/MDAnalysis/orgs","repos_url":"https://api.github.com/users/MDAnalysis/repos","events_url":"https://api.github.com/users/MDAnalysis/events{/privacy}","received_events_url":"https://api.github.com/users/MDAnalysis/received_events","type":"Organization","site_admin":false},"repo":{"id":33389183,"name":"mdanalysis","full_name":"MDAnalysis/mdanalysis","owner":{"login":"MDAnalysis","id":11445951,"avatar_url":"https://avatars.githubusercontent.com/u/11445951?v=3","gravatar_id":"","url":"https://api.github.com/users/MDAnalysis","html_url":"https://github.com/MDAnalysis","followers_url":"https://api.github.com/users/MDAnalysis/followers","following_url":"https://api.github.com/users/MDAnalysis/following{/other_user}","gists_url":"https://api.github.com/users/MDAnalysis/gists{/gist_id}","starred_url":"https://api.github.com/users/MDAnalysis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MDAnalysis/subscriptions","organizations_url":"https://api.github.com/users/MDAnalysis/orgs","repos_url":"https://api.github.com/users/MDAnalysis/repos","events_url":"https://api.github.com/users/MDAnalysis/events{/privacy}","received_events_url":"https://api.github.com/users/MDAnalysis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MDAnalysis/mdanalysis","description":"MDAnalysis is a Python library to analyze molecular dynamics trajectories.","fork":false,"url":"https://api.github.com/repos/MDAnalysis/mdanalysis","forks_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/forks","keys_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/teams","hooks_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/hooks","issue_events_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/events{/number}","events_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/events","assignees_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/assignees{/user}","branches_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/branches{/branch}","tags_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/tags","blobs_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/refs{/sha}","trees_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/statuses/{sha}","languages_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/languages","stargazers_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/stargazers","contributors_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/contributors","subscribers_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/subscribers","subscription_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/subscription","commits_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/commits{/sha}","git_commits_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/commits{/sha}","comments_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/comments{/number}","issue_comment_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/comments{/number}","contents_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/contents/{+path}","compare_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/merges","archive_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/downloads","issues_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues{/number}","pulls_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls{/number}","milestones_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/milestones{/number}","notifications_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/labels{/name}","releases_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/releases{/id}","created_at":"2015-04-04T00:39:41Z","updated_at":"2015-11-18T14:54:20Z","pushed_at":"2015-11-30T21:07:01Z","git_url":"git://github.com/MDAnalysis/mdanalysis.git","ssh_url":"git@github.com:MDAnalysis/mdanalysis.git","clone_url":"https://github.com/MDAnalysis/mdanalysis.git","svn_url":"https://github.com/MDAnalysis/mdanalysis","homepage":"http://www.mdanalysis.org","size":203002,"stargazers_count":44,"watchers_count":44,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":23,"mirror_url":null,"open_issues_count":68,"forks":23,"open_issues":68,"watchers":44,"default_branch":"develop"}},"base":{"label":"MDAnalysis:develop","ref":"develop","sha":"0c3aa90cf0a748642a9aab5e50562ca1b9fedc18","user":{"login":"MDAnalysis","id":11445951,"avatar_url":"https://avatars.githubusercontent.com/u/11445951?v=3","gravatar_id":"","url":"https://api.github.com/users/MDAnalysis","html_url":"https://github.com/MDAnalysis","followers_url":"https://api.github.com/users/MDAnalysis/followers","following_url":"https://api.github.com/users/MDAnalysis/following{/other_user}","gists_url":"https://api.github.com/users/MDAnalysis/gists{/gist_id}","starred_url":"https://api.github.com/users/MDAnalysis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MDAnalysis/subscriptions","organizations_url":"https://api.github.com/users/MDAnalysis/orgs","repos_url":"https://api.github.com/users/MDAnalysis/repos","events_url":"https://api.github.com/users/MDAnalysis/events{/privacy}","received_events_url":"https://api.github.com/users/MDAnalysis/received_events","type":"Organization","site_admin":false},"repo":{"id":33389183,"name":"mdanalysis","full_name":"MDAnalysis/mdanalysis","owner":{"login":"MDAnalysis","id":11445951,"avatar_url":"https://avatars.githubusercontent.com/u/11445951?v=3","gravatar_id":"","url":"https://api.github.com/users/MDAnalysis","html_url":"https://github.com/MDAnalysis","followers_url":"https://api.github.com/users/MDAnalysis/followers","following_url":"https://api.github.com/users/MDAnalysis/following{/other_user}","gists_url":"https://api.github.com/users/MDAnalysis/gists{/gist_id}","starred_url":"https://api.github.com/users/MDAnalysis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MDAnalysis/subscriptions","organizations_url":"https://api.github.com/users/MDAnalysis/orgs","repos_url":"https://api.github.com/users/MDAnalysis/repos","events_url":"https://api.github.com/users/MDAnalysis/events{/privacy}","received_events_url":"https://api.github.com/users/MDAnalysis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MDAnalysis/mdanalysis","description":"MDAnalysis is a Python library to analyze molecular dynamics trajectories.","fork":false,"url":"https://api.github.com/repos/MDAnalysis/mdanalysis","forks_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/forks","keys_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/teams","hooks_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/hooks","issue_events_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/events{/number}","events_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/events","assignees_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/assignees{/user}","branches_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/branches{/branch}","tags_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/tags","blobs_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/refs{/sha}","trees_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/statuses/{sha}","languages_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/languages","stargazers_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/stargazers","contributors_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/contributors","subscribers_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/subscribers","subscription_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/subscription","commits_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/commits{/sha}","git_commits_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/git/commits{/sha}","comments_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/comments{/number}","issue_comment_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/comments{/number}","contents_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/contents/{+path}","compare_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/merges","archive_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/downloads","issues_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues{/number}","pulls_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls{/number}","milestones_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/milestones{/number}","notifications_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/labels{/name}","releases_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/releases{/id}","created_at":"2015-04-04T00:39:41Z","updated_at":"2015-11-18T14:54:20Z","pushed_at":"2015-11-30T21:07:01Z","git_url":"git://github.com/MDAnalysis/mdanalysis.git","ssh_url":"git@github.com:MDAnalysis/mdanalysis.git","clone_url":"https://github.com/MDAnalysis/mdanalysis.git","svn_url":"https://github.com/MDAnalysis/mdanalysis","homepage":"http://www.mdanalysis.org","size":203002,"stargazers_count":44,"watchers_count":44,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":23,"mirror_url":null,"open_issues_count":68,"forks":23,"open_issues":68,"watchers":44,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/460"},"html":{"href":"https://github.com/MDAnalysis/mdanalysis/pull/460"},"issue":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/460"},"comments":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/460/comments"},"review_comments":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/460/comments"},"review_comment":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/pulls/460/commits"},"statuses":{"href":"https://api.github.com/repos/MDAnalysis/mdanalysis/statuses/daac9993f0a441422235d6200099baebbf8730fa"}}}}