{"action":"created","comment":{"url":"https://api.github.com/repos/biocore/qiita/pulls/comments/43846859","id":43846859,"diff_hunk":"@@ -0,0 +1,522 @@\n+# -----------------------------------------------------------------------------\n+# Copyright (c) 2014--, The Qiita Development Team.\n+#\n+# Distributed under the terms of the BSD 3-clause License.\n+#\n+# The full license is in the file LICENSE, distributed with this software.\n+# -----------------------------------------------------------------------------\n+\n+from .base import QiitaObject\n+from .sql_connection import TRN\n+from .exceptions import (QiitaDBDuplicateError, QiitaDBError,\n+                         QiitaDBUnknownIDError)\n+from .util import get_table_cols, get_table_cols_w_type\n+\n+\n+class Command(QiitaObject):\n+    r\"\"\"An executable command available in the system\n+\n+    Attributes\n+    ----------\n+    name\n+    description\n+    cli\n+    parameters_table\n+\n+    Methods\n+    -------\n+    create\n+\n+    See Also\n+    --------\n+    qiita_db.software.Software\n+    \"\"\"\n+    _table = \"software_command\"\n+\n+    def _check_id(self, id_):\n+        \"\"\"Check that the provided ID actually exists in the database\n+\n+        Parameters\n+        ----------\n+        id_ : int\n+            The ID to test\n+\n+        Notes\n+        -----\n+        This function overwrites the base function, as the sql layout doesn't\n+        follow the same conventions done in the other classes.\n+        \"\"\"\n+        with TRN:\n+            sql = \"\"\"SELECT EXISTS(\n+                        SELECT *\n+                        FROM qiita.software_command\n+                        WHERE command_id = %s)\"\"\"\n+            TRN.add(sql, [id_])\n+            return TRN.execute_fetchlast()\n+\n+    @classmethod\n+    def create(cls, software, name, description, cli_cmd, parameters_table):\n+        r\"\"\"Creates a new command in the system\n+\n+        Parameters\n+        ----------\n+        software : qiita_db.software.Software\n+            The software to which this command belongs to.\n+        name : str\n+            The name of the command\n+        description : str\n+            The description of the command\n+        cli_cmd : str\n+            The CLI used to call this command\n+        parameters_table : str\n+            The name of the table in which the parameters of the commands are\n+            stored\n+\n+        Returns\n+        -------\n+        qiita_db.software.Command\n+            The newly created command\n+        \"\"\"\n+        with TRN:\n+            sql = \"\"\"INSERT INTO qiita.software_command\n+                            (name, software_id, description, cli_cmd,\n+                             parameters_table)\n+                     VALUES (%s, %s, %s, %s, %s)\n+                     RETURNING command_id\"\"\"\n+            sql_params = [name, software.id, description, cli_cmd,\n+                          parameters_table]\n+            TRN.add(sql, sql_params)\n+            c_id = TRN.execute_fetchlast()\n+\n+        return cls(c_id)\n+\n+    @property\n+    def name(self):\n+        \"\"\"The name of the command\n+\n+        Returns\n+        -------\n+        str\n+            The name of the command\n+        \"\"\"\n+        with TRN:\n+            sql = \"\"\"SELECT name\n+                     FROM qiita.software_command\n+                     WHERE command_id = %s\"\"\"\n+            TRN.add(sql, [self.id])\n+            return TRN.execute_fetchlast()\n+\n+    @property\n+    def description(self):\n+        \"\"\"The description of the command\n+\n+        Returns\n+        -------\n+        str\n+            The description of the command\n+        \"\"\"\n+        with TRN:\n+            sql = \"\"\"SELECT description\n+                     FROM qiita.software_command\n+                     WHERE command_id = %s\"\"\"\n+            TRN.add(sql, [self.id])\n+            return TRN.execute_fetchlast()\n+\n+    @property\n+    def cli(self):\n+        \"\"\"The CLI used to call the command\n+\n+        Returns\n+        -------\n+        str\n+            The CLI used to call the command\n+        \"\"\"\n+        with TRN:\n+            sql = \"\"\"SELECT cli_cmd\n+                     FROM qiita.software_command\n+                     WHERE command_id = %s\"\"\"\n+            TRN.add(sql, [self.id])\n+            return TRN.execute_fetchlast()\n+\n+    @property\n+    def parameters_table(self):\n+        \"\"\"The table in which the parameters of th e command are stored\n+\n+        Returns\n+        -------\n+        str\n+            The name of the table\n+        \"\"\"\n+        with TRN:\n+            sql = \"\"\"SELECT parameters_table\n+                     FROM qiita.software_command\n+                     WHERE command_id = %s\"\"\"\n+            TRN.add(sql, [self.id])\n+            return TRN.execute_fetchlast()\n+\n+\n+class Software(QiitaObject):\n+    r\"\"\"A software available in the system","path":"qiita_db/software.py","position":159,"original_position":159,"commit_id":"2e4308eff80aa92cc00043c4dd3fd0d050a2a1d4","original_commit_id":"2e4308eff80aa92cc00043c4dd3fd0d050a2a1d4","user":{"login":"ElDeveloper","id":375307,"avatar_url":"https://avatars.githubusercontent.com/u/375307?v=3","gravatar_id":"","url":"https://api.github.com/users/ElDeveloper","html_url":"https://github.com/ElDeveloper","followers_url":"https://api.github.com/users/ElDeveloper/followers","following_url":"https://api.github.com/users/ElDeveloper/following{/other_user}","gists_url":"https://api.github.com/users/ElDeveloper/gists{/gist_id}","starred_url":"https://api.github.com/users/ElDeveloper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElDeveloper/subscriptions","organizations_url":"https://api.github.com/users/ElDeveloper/orgs","repos_url":"https://api.github.com/users/ElDeveloper/repos","events_url":"https://api.github.com/users/ElDeveloper/events{/privacy}","received_events_url":"https://api.github.com/users/ElDeveloper/received_events","type":"User","site_admin":false},"body":"'A software' sounds rather strange, would it be more appropriate to say \"A software package\" ... ","created_at":"2015-11-04T06:30:52Z","updated_at":"2015-11-04T06:30:52Z","html_url":"https://github.com/biocore/qiita/pull/1525#discussion_r43846859","pull_request_url":"https://api.github.com/repos/biocore/qiita/pulls/1525","_links":{"self":{"href":"https://api.github.com/repos/biocore/qiita/pulls/comments/43846859"},"html":{"href":"https://github.com/biocore/qiita/pull/1525#discussion_r43846859"},"pull_request":{"href":"https://api.github.com/repos/biocore/qiita/pulls/1525"}}},"pull_request":{"url":"https://api.github.com/repos/biocore/qiita/pulls/1525","id":49500222,"html_url":"https://github.com/biocore/qiita/pull/1525","diff_url":"https://github.com/biocore/qiita/pull/1525.diff","patch_url":"https://github.com/biocore/qiita/pull/1525.patch","issue_url":"https://api.github.com/repos/biocore/qiita/issues/1525","number":1525,"state":"open","locked":false,"title":"Software, Command and Parameters objects","user":{"login":"josenavas","id":2501478,"avatar_url":"https://avatars.githubusercontent.com/u/2501478?v=3","gravatar_id":"","url":"https://api.github.com/users/josenavas","html_url":"https://github.com/josenavas","followers_url":"https://api.github.com/users/josenavas/followers","following_url":"https://api.github.com/users/josenavas/following{/other_user}","gists_url":"https://api.github.com/users/josenavas/gists{/gist_id}","starred_url":"https://api.github.com/users/josenavas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josenavas/subscriptions","organizations_url":"https://api.github.com/users/josenavas/orgs","repos_url":"https://api.github.com/users/josenavas/repos","events_url":"https://api.github.com/users/josenavas/events{/privacy}","received_events_url":"https://api.github.com/users/josenavas/received_events","type":"User","site_admin":false},"body":"This adds the Software, Commands and Parameters objects, which is another item in https://github.com/biocore/qiita/pull/1523.\r\n\r\nDisclaimer: these objects will probably change once we have the plugins in place. However, I need them in order to move forward with the artifact object. I did a smaller PR so it is easier to review, rather than adding all the objects at once.","created_at":"2015-11-02T23:17:24Z","updated_at":"2015-11-04T06:30:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6070fa441f5ae731b1de2df4df7898a45afc1951","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/biocore/qiita/pulls/1525/commits","review_comments_url":"https://api.github.com/repos/biocore/qiita/pulls/1525/comments","review_comment_url":"https://api.github.com/repos/biocore/qiita/pulls/comments{/number}","comments_url":"https://api.github.com/repos/biocore/qiita/issues/1525/comments","statuses_url":"https://api.github.com/repos/biocore/qiita/statuses/2e4308eff80aa92cc00043c4dd3fd0d050a2a1d4","head":{"label":"josenavas:artifact-software-obj","ref":"artifact-software-obj","sha":"2e4308eff80aa92cc00043c4dd3fd0d050a2a1d4","user":{"login":"josenavas","id":2501478,"avatar_url":"https://avatars.githubusercontent.com/u/2501478?v=3","gravatar_id":"","url":"https://api.github.com/users/josenavas","html_url":"https://github.com/josenavas","followers_url":"https://api.github.com/users/josenavas/followers","following_url":"https://api.github.com/users/josenavas/following{/other_user}","gists_url":"https://api.github.com/users/josenavas/gists{/gist_id}","starred_url":"https://api.github.com/users/josenavas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josenavas/subscriptions","organizations_url":"https://api.github.com/users/josenavas/orgs","repos_url":"https://api.github.com/users/josenavas/repos","events_url":"https://api.github.com/users/josenavas/events{/privacy}","received_events_url":"https://api.github.com/users/josenavas/received_events","type":"User","site_admin":false},"repo":{"id":13527677,"name":"QiiTa","full_name":"josenavas/QiiTa","owner":{"login":"josenavas","id":2501478,"avatar_url":"https://avatars.githubusercontent.com/u/2501478?v=3","gravatar_id":"","url":"https://api.github.com/users/josenavas","html_url":"https://github.com/josenavas","followers_url":"https://api.github.com/users/josenavas/followers","following_url":"https://api.github.com/users/josenavas/following{/other_user}","gists_url":"https://api.github.com/users/josenavas/gists{/gist_id}","starred_url":"https://api.github.com/users/josenavas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josenavas/subscriptions","organizations_url":"https://api.github.com/users/josenavas/orgs","repos_url":"https://api.github.com/users/josenavas/repos","events_url":"https://api.github.com/users/josenavas/events{/privacy}","received_events_url":"https://api.github.com/users/josenavas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/josenavas/QiiTa","description":"QiiTa databasing effort","fork":true,"url":"https://api.github.com/repos/josenavas/QiiTa","forks_url":"https://api.github.com/repos/josenavas/QiiTa/forks","keys_url":"https://api.github.com/repos/josenavas/QiiTa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/josenavas/QiiTa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/josenavas/QiiTa/teams","hooks_url":"https://api.github.com/repos/josenavas/QiiTa/hooks","issue_events_url":"https://api.github.com/repos/josenavas/QiiTa/issues/events{/number}","events_url":"https://api.github.com/repos/josenavas/QiiTa/events","assignees_url":"https://api.github.com/repos/josenavas/QiiTa/assignees{/user}","branches_url":"https://api.github.com/repos/josenavas/QiiTa/branches{/branch}","tags_url":"https://api.github.com/repos/josenavas/QiiTa/tags","blobs_url":"https://api.github.com/repos/josenavas/QiiTa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/josenavas/QiiTa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/josenavas/QiiTa/git/refs{/sha}","trees_url":"https://api.github.com/repos/josenavas/QiiTa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/josenavas/QiiTa/statuses/{sha}","languages_url":"https://api.github.com/repos/josenavas/QiiTa/languages","stargazers_url":"https://api.github.com/repos/josenavas/QiiTa/stargazers","contributors_url":"https://api.github.com/repos/josenavas/QiiTa/contributors","subscribers_url":"https://api.github.com/repos/josenavas/QiiTa/subscribers","subscription_url":"https://api.github.com/repos/josenavas/QiiTa/subscription","commits_url":"https://api.github.com/repos/josenavas/QiiTa/commits{/sha}","git_commits_url":"https://api.github.com/repos/josenavas/QiiTa/git/commits{/sha}","comments_url":"https://api.github.com/repos/josenavas/QiiTa/comments{/number}","issue_comment_url":"https://api.github.com/repos/josenavas/QiiTa/issues/comments{/number}","contents_url":"https://api.github.com/repos/josenavas/QiiTa/contents/{+path}","compare_url":"https://api.github.com/repos/josenavas/QiiTa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/josenavas/QiiTa/merges","archive_url":"https://api.github.com/repos/josenavas/QiiTa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/josenavas/QiiTa/downloads","issues_url":"https://api.github.com/repos/josenavas/QiiTa/issues{/number}","pulls_url":"https://api.github.com/repos/josenavas/QiiTa/pulls{/number}","milestones_url":"https://api.github.com/repos/josenavas/QiiTa/milestones{/number}","notifications_url":"https://api.github.com/repos/josenavas/QiiTa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/josenavas/QiiTa/labels{/name}","releases_url":"https://api.github.com/repos/josenavas/QiiTa/releases{/id}","created_at":"2013-10-12T19:29:32Z","updated_at":"2015-05-05T22:50:05Z","pushed_at":"2015-11-03T18:10:30Z","git_url":"git://github.com/josenavas/QiiTa.git","ssh_url":"git@github.com:josenavas/QiiTa.git","clone_url":"https://github.com/josenavas/QiiTa.git","svn_url":"https://github.com/josenavas/QiiTa","homepage":null,"size":129488,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"biocore:artifact","ref":"artifact","sha":"753f7eafd425d35a61af416260aab90bee3f6fb1","user":{"login":"biocore","id":6241857,"avatar_url":"https://avatars.githubusercontent.com/u/6241857?v=3","gravatar_id":"","url":"https://api.github.com/users/biocore","html_url":"https://github.com/biocore","followers_url":"https://api.github.com/users/biocore/followers","following_url":"https://api.github.com/users/biocore/following{/other_user}","gists_url":"https://api.github.com/users/biocore/gists{/gist_id}","starred_url":"https://api.github.com/users/biocore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biocore/subscriptions","organizations_url":"https://api.github.com/users/biocore/orgs","repos_url":"https://api.github.com/users/biocore/repos","events_url":"https://api.github.com/users/biocore/events{/privacy}","received_events_url":"https://api.github.com/users/biocore/received_events","type":"Organization","site_admin":false},"repo":{"id":13131245,"name":"qiita","full_name":"biocore/qiita","owner":{"login":"biocore","id":6241857,"avatar_url":"https://avatars.githubusercontent.com/u/6241857?v=3","gravatar_id":"","url":"https://api.github.com/users/biocore","html_url":"https://github.com/biocore","followers_url":"https://api.github.com/users/biocore/followers","following_url":"https://api.github.com/users/biocore/following{/other_user}","gists_url":"https://api.github.com/users/biocore/gists{/gist_id}","starred_url":"https://api.github.com/users/biocore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biocore/subscriptions","organizations_url":"https://api.github.com/users/biocore/orgs","repos_url":"https://api.github.com/users/biocore/repos","events_url":"https://api.github.com/users/biocore/events{/privacy}","received_events_url":"https://api.github.com/users/biocore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/biocore/qiita","description":"Qiita - A QIIME databasing effort","fork":false,"url":"https://api.github.com/repos/biocore/qiita","forks_url":"https://api.github.com/repos/biocore/qiita/forks","keys_url":"https://api.github.com/repos/biocore/qiita/keys{/key_id}","collaborators_url":"https://api.github.com/repos/biocore/qiita/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/biocore/qiita/teams","hooks_url":"https://api.github.com/repos/biocore/qiita/hooks","issue_events_url":"https://api.github.com/repos/biocore/qiita/issues/events{/number}","events_url":"https://api.github.com/repos/biocore/qiita/events","assignees_url":"https://api.github.com/repos/biocore/qiita/assignees{/user}","branches_url":"https://api.github.com/repos/biocore/qiita/branches{/branch}","tags_url":"https://api.github.com/repos/biocore/qiita/tags","blobs_url":"https://api.github.com/repos/biocore/qiita/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/biocore/qiita/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/biocore/qiita/git/refs{/sha}","trees_url":"https://api.github.com/repos/biocore/qiita/git/trees{/sha}","statuses_url":"https://api.github.com/repos/biocore/qiita/statuses/{sha}","languages_url":"https://api.github.com/repos/biocore/qiita/languages","stargazers_url":"https://api.github.com/repos/biocore/qiita/stargazers","contributors_url":"https://api.github.com/repos/biocore/qiita/contributors","subscribers_url":"https://api.github.com/repos/biocore/qiita/subscribers","subscription_url":"https://api.github.com/repos/biocore/qiita/subscription","commits_url":"https://api.github.com/repos/biocore/qiita/commits{/sha}","git_commits_url":"https://api.github.com/repos/biocore/qiita/git/commits{/sha}","comments_url":"https://api.github.com/repos/biocore/qiita/comments{/number}","issue_comment_url":"https://api.github.com/repos/biocore/qiita/issues/comments{/number}","contents_url":"https://api.github.com/repos/biocore/qiita/contents/{+path}","compare_url":"https://api.github.com/repos/biocore/qiita/compare/{base}...{head}","merges_url":"https://api.github.com/repos/biocore/qiita/merges","archive_url":"https://api.github.com/repos/biocore/qiita/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/biocore/qiita/downloads","issues_url":"https://api.github.com/repos/biocore/qiita/issues{/number}","pulls_url":"https://api.github.com/repos/biocore/qiita/pulls{/number}","milestones_url":"https://api.github.com/repos/biocore/qiita/milestones{/number}","notifications_url":"https://api.github.com/repos/biocore/qiita/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/biocore/qiita/labels{/name}","releases_url":"https://api.github.com/repos/biocore/qiita/releases{/id}","created_at":"2013-09-26T18:50:43Z","updated_at":"2015-09-20T19:09:27Z","pushed_at":"2015-11-03T18:10:30Z","git_url":"git://github.com/biocore/qiita.git","ssh_url":"git@github.com:biocore/qiita.git","clone_url":"https://github.com/biocore/qiita.git","svn_url":"https://github.com/biocore/qiita","homepage":"http://qiita.microbio.me","size":132649,"stargazers_count":24,"watchers_count":24,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"open_issues_count":302,"forks":25,"open_issues":302,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/biocore/qiita/pulls/1525"},"html":{"href":"https://github.com/biocore/qiita/pull/1525"},"issue":{"href":"https://api.github.com/repos/biocore/qiita/issues/1525"},"comments":{"href":"https://api.github.com/repos/biocore/qiita/issues/1525/comments"},"review_comments":{"href":"https://api.github.com/repos/biocore/qiita/pulls/1525/comments"},"review_comment":{"href":"https://api.github.com/repos/biocore/qiita/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/biocore/qiita/pulls/1525/commits"},"statuses":{"href":"https://api.github.com/repos/biocore/qiita/statuses/2e4308eff80aa92cc00043c4dd3fd0d050a2a1d4"}}}}