{"action":"created","comment":{"url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls/comments/180676221","pull_request_review_id":111130895,"id":180676221,"diff_hunk":"@@ -0,0 +1,75 @@\n+import os\n+import subprocess\n+\n+\n+def train(vlmcs, sequence_length, out_directory, number_of_parameters=128):\n+  os.system(\"rm -rf {}/*\".format(out_directory))\n+\n+  [write_sequence_as_fasta(vlmc, sequence_length, out_directory) for vlmc in vlmcs]\n+\n+  list_path = os.path.join(out_directory, \"list.txt\")\n+  with open(list_path, 'w') as f:\n+    f.write('\\n'.join([vlmc.name for vlmc in vlmcs]))\n+\n+  parameters = {\n+      'use_constant_cutoff': \"false\",\n+      'cutoff_value': \"3.9075\",\n+      'number_of_parameters': number_of_parameters,\n+      'min_count': 4,\n+      'max_depth': 15,\n+      'count_free_parameters_individually': 'false'\n+  }\n+  train_vlmcs(parameters, list_path, out_directory)\n+\n+\n+def write_sequence_as_fasta(vlmc, sequence_length, out_directory):\n+  vlmc.reset_sequence()\n+  size_of_line = 990\n+  context = vlmc.generate_sequence(50, 500)[-vlmc.order:]\n+\n+  file_name = vlmc.name + \".fa\"\n+  with open(os.path.join(out_directory, file_name), 'w') as f:\n+    f.write(\"> {}\\n\".format(vlmc.name))\n+    # Iteratively generate lines from a sequence of correct length\n+    for _ in range(sequence_length // size_of_line):\n+      sequence = vlmc.generate_sequence_from(size_of_line, context)\n+      f.write(\"{}\\n\".format(sequence))\n+      context = sequence[-vlmc.order]\n+\n+    length_left = sequence_length % size_of_line\n+    sequence = vlmc.generate_sequence_from(length_left, context)\n+    f.write(\"{}\\n\".format(sequence))\n+\n+\n+def train_vlmcs(parameters, list_path, out_directory, input_directory=None, add_underlines_=True):\n+  if input_directory is None:\n+    input_directory = out_directory\n+\n+  standard_args = \"-pseudo -crr -f_f {} -ipf .fa -ipwd {} -opwd {} -osf TEST_ -m 1 -frac 0 -revcomp\".format(\n+      list_path, input_directory, out_directory)\n+  parameter_args = \"-c_c {} -nc {} -npar {} -minc {} -kmax {} -free {}\".format(\n+      parameters['use_constant_cutoff'],\n+      parameters['cutoff_value'],\n+      parameters['number_of_parameters'],\n+      parameters['min_count'],\n+      parameters['max_depth'],\n+      parameters['count_free_parameters_individually']\n+  )\n+\n+  args = (\"../lib/classifier \" + standard_args + \" \" + parameter_args).split()\n+\n+  popen = subprocess.Popen(args, stdout=subprocess.PIPE)\n+  popen.wait()\n+  output = popen.stdout.read()\n+  # print(output.decode(\"utf-8\"))\n+  if add_underlines_:\n+    # Needed for the parsing (since we expect them to be there...)\n+    add_underlines(out_directory)\n+\n+\n+def add_underlines(directory):\n+  for file in [f for f in os.listdir(directory) if f.endswith(\".tree\")]:","path":"src/train.py","position":71,"original_position":71,"commit_id":"7ca83846fd423c5b70843bbef8f7e703b1ed28ed","original_commit_id":"7ca83846fd423c5b70843bbef8f7e703b1ed28ed","user":{"login":"NeonNeon","id":6126906,"avatar_url":"https://avatars0.githubusercontent.com/u/6126906?v=4","gravatar_id":"","url":"https://api.github.com/users/NeonNeon","html_url":"https://github.com/NeonNeon","followers_url":"https://api.github.com/users/NeonNeon/followers","following_url":"https://api.github.com/users/NeonNeon/following{/other_user}","gists_url":"https://api.github.com/users/NeonNeon/gists{/gist_id}","starred_url":"https://api.github.com/users/NeonNeon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NeonNeon/subscriptions","organizations_url":"https://api.github.com/users/NeonNeon/orgs","repos_url":"https://api.github.com/users/NeonNeon/repos","events_url":"https://api.github.com/users/NeonNeon/events{/privacy}","received_events_url":"https://api.github.com/users/NeonNeon/received_events","type":"User","site_admin":false},"body":"should we continue to use file_ here?\r\n","created_at":"2018-04-11T08:40:10Z","updated_at":"2018-04-11T08:42:18Z","html_url":"https://github.com/Kalior/clustering-genomic-signatures/pull/59#discussion_r180676221","pull_request_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls/59","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls/comments/180676221"},"html":{"href":"https://github.com/Kalior/clustering-genomic-signatures/pull/59#discussion_r180676221"},"pull_request":{"href":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls/59"}}},"pull_request":{"url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls/59","id":178408594,"html_url":"https://github.com/Kalior/clustering-genomic-signatures/pull/59","diff_url":"https://github.com/Kalior/clustering-genomic-signatures/pull/59.diff","patch_url":"https://github.com/Kalior/clustering-genomic-signatures/pull/59.patch","issue_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/issues/59","number":59,"state":"open","locked":false,"title":"Print the successive regeneration distance, doesn't quite reach 0 with 1000000 length","user":{"login":"Kalior","id":2412457,"avatar_url":"https://avatars2.githubusercontent.com/u/2412457?v=4","gravatar_id":"","url":"https://api.github.com/users/Kalior","html_url":"https://github.com/Kalior","followers_url":"https://api.github.com/users/Kalior/followers","following_url":"https://api.github.com/users/Kalior/following{/other_user}","gists_url":"https://api.github.com/users/Kalior/gists{/gist_id}","starred_url":"https://api.github.com/users/Kalior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kalior/subscriptions","organizations_url":"https://api.github.com/users/Kalior/orgs","repos_url":"https://api.github.com/users/Kalior/repos","events_url":"https://api.github.com/users/Kalior/events{/privacy}","received_events_url":"https://api.github.com/users/Kalior/received_events","type":"User","site_admin":false},"body":"Fixes #56\r\n\r\nExample output:\r\n![regeneration-distance](https://user-images.githubusercontent.com/2412457/38107055-240d0ac0-3391-11e8-9231-1058f60df81f.png)\r\n\r\nShould probably improve output before merging.","created_at":"2018-03-29T18:39:32Z","updated_at":"2018-04-11T08:42:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8198b1a010cb611c09837d41fdc7bbfdabff66dc","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls/59/commits","review_comments_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls/59/comments","review_comment_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/issues/59/comments","statuses_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/statuses/7ca83846fd423c5b70843bbef8f7e703b1ed28ed","head":{"label":"Kalior:feature/regeneration-distance","ref":"feature/regeneration-distance","sha":"7ca83846fd423c5b70843bbef8f7e703b1ed28ed","user":{"login":"Kalior","id":2412457,"avatar_url":"https://avatars2.githubusercontent.com/u/2412457?v=4","gravatar_id":"","url":"https://api.github.com/users/Kalior","html_url":"https://github.com/Kalior","followers_url":"https://api.github.com/users/Kalior/followers","following_url":"https://api.github.com/users/Kalior/following{/other_user}","gists_url":"https://api.github.com/users/Kalior/gists{/gist_id}","starred_url":"https://api.github.com/users/Kalior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kalior/subscriptions","organizations_url":"https://api.github.com/users/Kalior/orgs","repos_url":"https://api.github.com/users/Kalior/repos","events_url":"https://api.github.com/users/Kalior/events{/privacy}","received_events_url":"https://api.github.com/users/Kalior/received_events","type":"User","site_admin":false},"repo":{"id":117526417,"name":"clustering-genomic-signatures","full_name":"Kalior/clustering-genomic-signatures","owner":{"login":"Kalior","id":2412457,"avatar_url":"https://avatars2.githubusercontent.com/u/2412457?v=4","gravatar_id":"","url":"https://api.github.com/users/Kalior","html_url":"https://github.com/Kalior","followers_url":"https://api.github.com/users/Kalior/followers","following_url":"https://api.github.com/users/Kalior/following{/other_user}","gists_url":"https://api.github.com/users/Kalior/gists{/gist_id}","starred_url":"https://api.github.com/users/Kalior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kalior/subscriptions","organizations_url":"https://api.github.com/users/Kalior/orgs","repos_url":"https://api.github.com/users/Kalior/repos","events_url":"https://api.github.com/users/Kalior/events{/privacy}","received_events_url":"https://api.github.com/users/Kalior/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Kalior/clustering-genomic-signatures","description":"Thesis project at Chalmers University of Technology","fork":false,"url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures","forks_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/forks","keys_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/teams","hooks_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/hooks","issue_events_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/issues/events{/number}","events_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/events","assignees_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/assignees{/user}","branches_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/branches{/branch}","tags_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/tags","blobs_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/statuses/{sha}","languages_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/languages","stargazers_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/stargazers","contributors_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/contributors","subscribers_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/subscribers","subscription_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/subscription","commits_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/contents/{+path}","compare_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/merges","archive_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/downloads","issues_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/issues{/number}","pulls_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls{/number}","milestones_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/milestones{/number}","notifications_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/labels{/name}","releases_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/releases{/id}","deployments_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/deployments","created_at":"2018-01-15T09:43:27Z","updated_at":"2018-04-04T13:19:14Z","pushed_at":"2018-04-11T08:30:45Z","git_url":"git://github.com/Kalior/clustering-genomic-signatures.git","ssh_url":"git@github.com:Kalior/clustering-genomic-signatures.git","clone_url":"https://github.com/Kalior/clustering-genomic-signatures.git","svn_url":"https://github.com/Kalior/clustering-genomic-signatures","homepage":null,"size":249,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":22,"license":null,"forks":0,"open_issues":22,"watchers":0,"default_branch":"master"}},"base":{"label":"Kalior:master","ref":"master","sha":"03215c7079ef280409e37605732b783fb3b3aa47","user":{"login":"Kalior","id":2412457,"avatar_url":"https://avatars2.githubusercontent.com/u/2412457?v=4","gravatar_id":"","url":"https://api.github.com/users/Kalior","html_url":"https://github.com/Kalior","followers_url":"https://api.github.com/users/Kalior/followers","following_url":"https://api.github.com/users/Kalior/following{/other_user}","gists_url":"https://api.github.com/users/Kalior/gists{/gist_id}","starred_url":"https://api.github.com/users/Kalior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kalior/subscriptions","organizations_url":"https://api.github.com/users/Kalior/orgs","repos_url":"https://api.github.com/users/Kalior/repos","events_url":"https://api.github.com/users/Kalior/events{/privacy}","received_events_url":"https://api.github.com/users/Kalior/received_events","type":"User","site_admin":false},"repo":{"id":117526417,"name":"clustering-genomic-signatures","full_name":"Kalior/clustering-genomic-signatures","owner":{"login":"Kalior","id":2412457,"avatar_url":"https://avatars2.githubusercontent.com/u/2412457?v=4","gravatar_id":"","url":"https://api.github.com/users/Kalior","html_url":"https://github.com/Kalior","followers_url":"https://api.github.com/users/Kalior/followers","following_url":"https://api.github.com/users/Kalior/following{/other_user}","gists_url":"https://api.github.com/users/Kalior/gists{/gist_id}","starred_url":"https://api.github.com/users/Kalior/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kalior/subscriptions","organizations_url":"https://api.github.com/users/Kalior/orgs","repos_url":"https://api.github.com/users/Kalior/repos","events_url":"https://api.github.com/users/Kalior/events{/privacy}","received_events_url":"https://api.github.com/users/Kalior/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Kalior/clustering-genomic-signatures","description":"Thesis project at Chalmers University of Technology","fork":false,"url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures","forks_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/forks","keys_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/teams","hooks_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/hooks","issue_events_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/issues/events{/number}","events_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/events","assignees_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/assignees{/user}","branches_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/branches{/branch}","tags_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/tags","blobs_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/statuses/{sha}","languages_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/languages","stargazers_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/stargazers","contributors_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/contributors","subscribers_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/subscribers","subscription_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/subscription","commits_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/contents/{+path}","compare_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/merges","archive_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/downloads","issues_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/issues{/number}","pulls_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls{/number}","milestones_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/milestones{/number}","notifications_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/labels{/name}","releases_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/releases{/id}","deployments_url":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/deployments","created_at":"2018-01-15T09:43:27Z","updated_at":"2018-04-04T13:19:14Z","pushed_at":"2018-04-11T08:30:45Z","git_url":"git://github.com/Kalior/clustering-genomic-signatures.git","ssh_url":"git@github.com:Kalior/clustering-genomic-signatures.git","clone_url":"https://github.com/Kalior/clustering-genomic-signatures.git","svn_url":"https://github.com/Kalior/clustering-genomic-signatures","homepage":null,"size":249,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":22,"license":null,"forks":0,"open_issues":22,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls/59"},"html":{"href":"https://github.com/Kalior/clustering-genomic-signatures/pull/59"},"issue":{"href":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/issues/59"},"comments":{"href":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/issues/59/comments"},"review_comments":{"href":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls/59/comments"},"review_comment":{"href":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/pulls/59/commits"},"statuses":{"href":"https://api.github.com/repos/Kalior/clustering-genomic-signatures/statuses/7ca83846fd423c5b70843bbef8f7e703b1ed28ed"}},"author_association":"OWNER"}}
{"actor":{"display_login":"NeonNeon"}}