{"action":"created","comment":{"url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls/comments/135886458","pull_request_review_id":59351617,"id":135886458,"diff_hunk":"@@ -1,37 +1,128 @@\n from Bio import SeqIO\n+from Bio import AlignIO\n+from Bio.Align import MultipleSeqAlignment\n+from Bio.Alphabet import IUPAC, Gapped\n+import os\n from pathlib import Path\n+from tempfile import TemporaryFile\n import itertools\n \n-def multi_fasta_manipulator(full_file, id_file, manipulation='remove', added_name='_G2'):\n+\n+def multi_fasta_manipulator(target_file, reference, output, manipulation='remove'):\n     # Inspired by the BioPython Tutorial and Cookbook (\"20.1.1 Filtering a sequence file\")\n     \"\"\"\n     This method manipulated selected sequences in a multi-FASTA files.  The original\n     purpose was to filter files created by the GUIDANCE2 alignment program, but\n     the function has been made in order to accommodate other situations as well.\n \n-    :param full_file:  Target multi-FASTA file.\n-    :param id_file:  Selected sequences for removal in a multi-FASTA file.\n+    :param target_file:  Target multi-FASTA file.\n+    :param reference:  Selected sequences for removal in a multi-FASTA file.\n     :param manipulation:  Type of manipulation.  (remove, add, tbd..)\n     :param added_name:  The output file uses this parameter to name itself.\n     :return:  A multi-FASTA file with filter sequences.\n     \"\"\"\n     # Create path variables\n-    file_name = Path(full_file).stem + added_name + Path(full_file).suffix\n-    new_file = Path(full_file).parent / Path(file_name)\n-    # Turn the id_file into set of ids\n-    ids = set(record.id for record in SeqIO.parse(id_file, 'fasta'))\n-    # Create a new multi-fasta record object using the full_file and the newly generated set of ids\n+    file_name = output\n+    new_file = Path(target_file).parent / Path(file_name)\n+    # Create a new multi-fasta record object using the target_file, reference, and output\n+    # Remove specific sequences from a fasta file\n     if manipulation is 'remove':\n-        new_records = (record for record in SeqIO.parse(full_file, 'fasta') if record.id not in ids)\n-        print('Sequences have been filtered.')\n-        SeqIO.write(new_records, str(new_file), 'fasta')\n+        multi_fasta_remove(target_file, reference, new_file)\n     # Combine all the FASTA sequence in one record object\n-    elif manipulation == 'add':\n-        # Concatenate the multifasta files together by chaining the SeqIO.parse generators\n-        # adding generators - https://stackoverflow.com/questions/3211041/how-to-join-two-generators-in-python\n-        new_records = itertools.chain(SeqIO.parse(full_file, 'fasta',), SeqIO.parse(id_file, 'fasta'))\n-        SeqIO.write(new_records, str(new_file), 'fasta')\n-        print('Sequences have been added.')\n+    elif manipulation is 'add':\n+        muli_fasta_add(target_file, reference, new_file)\n+    # Sort one fasta file based on the order of another\n+    # Works for alignments\n+    elif manipulation is 'sort':\n+        multi_fasta_sort(target_file, reference, new_file)\n+\n     print('A new fasta file has been created.')\n     return new_file\n \n+\n+def dir_config(path, tier_frame_dict):\n+    \"\"\"\n+    Configure the genbank directories.\n+    :param path: Path to create directory structure.\n+    :param tier_frame_dict:  Dictionary from the blast super class.\n+    :return:  Creates a directory structure as follows\n+        --Tier_1\n+            --Gene_1\n+            --Gene_M\n+        --Tier_N\n+            --Gene_M+1\n+            --Gene_N\n+    \"\"\"\n+    for G_KEY, G_value in tier_frame_dict.items():","path":"Datasnakes/Orthologs/Genbank/utils.py","position":73,"original_position":73,"commit_id":"4cd653d8f255b72edf54a528dbc1b3d4f9f22c82","original_commit_id":"4cd653d8f255b72edf54a528dbc1b3d4f9f22c82","user":{"login":"grabear","id":20953530,"avatar_url":"https://avatars0.githubusercontent.com/u/20953530?v=4","gravatar_id":"","url":"https://api.github.com/users/grabear","html_url":"https://github.com/grabear","followers_url":"https://api.github.com/users/grabear/followers","following_url":"https://api.github.com/users/grabear/following{/other_user}","gists_url":"https://api.github.com/users/grabear/gists{/gist_id}","starred_url":"https://api.github.com/users/grabear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grabear/subscriptions","organizations_url":"https://api.github.com/users/grabear/orgs","repos_url":"https://api.github.com/users/grabear/repos","events_url":"https://api.github.com/users/grabear/events{/privacy}","received_events_url":"https://api.github.com/users/grabear/received_events","type":"User","site_admin":false},"body":"# Fixed.  Used tier_frame_dict.keys() instead of tier_frame_dict.items()","created_at":"2017-08-29T19:16:12Z","updated_at":"2017-08-29T19:16:12Z","html_url":"https://github.com/datasnakes/Datasnakes-Scripts/pull/44#discussion_r135886458","pull_request_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls/44","_links":{"self":{"href":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls/comments/135886458"},"html":{"href":"https://github.com/datasnakes/Datasnakes-Scripts/pull/44#discussion_r135886458"},"pull_request":{"href":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls/44"}},"in_reply_to_id":135878526},"pull_request":{"url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls/44","id":138252459,"html_url":"https://github.com/datasnakes/Datasnakes-Scripts/pull/44","diff_url":"https://github.com/datasnakes/Datasnakes-Scripts/pull/44.diff","patch_url":"https://github.com/datasnakes/Datasnakes-Scripts/pull/44.patch","issue_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/issues/44","number":44,"state":"closed","locked":false,"title":"DataMana-patch","user":{"login":"grabear","id":20953530,"avatar_url":"https://avatars0.githubusercontent.com/u/20953530?v=4","gravatar_id":"","url":"https://api.github.com/users/grabear","html_url":"https://github.com/grabear","followers_url":"https://api.github.com/users/grabear/followers","following_url":"https://api.github.com/users/grabear/following{/other_user}","gists_url":"https://api.github.com/users/grabear/gists{/gist_id}","starred_url":"https://api.github.com/users/grabear/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grabear/subscriptions","organizations_url":"https://api.github.com/users/grabear/orgs","repos_url":"https://api.github.com/users/grabear/repos","events_url":"https://api.github.com/users/grabear/events{/privacy}","received_events_url":"https://api.github.com/users/grabear/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-08-29T18:29:46Z","updated_at":"2017-08-29T19:16:12Z","closed_at":"2017-08-29T18:50:30Z","merged_at":"2017-08-29T18:50:30Z","merge_commit_sha":"440b9921de145e8ce8da1718465fbaab46eacf78","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls/44/commits","review_comments_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls/44/comments","review_comment_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls/comments{/number}","comments_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/issues/44/comments","statuses_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/statuses/4cd653d8f255b72edf54a528dbc1b3d4f9f22c82","head":{"label":"datasnakes:DataMana-patch","ref":"DataMana-patch","sha":"4cd653d8f255b72edf54a528dbc1b3d4f9f22c82","user":{"login":"datasnakes","id":27606353,"avatar_url":"https://avatars2.githubusercontent.com/u/27606353?v=4","gravatar_id":"","url":"https://api.github.com/users/datasnakes","html_url":"https://github.com/datasnakes","followers_url":"https://api.github.com/users/datasnakes/followers","following_url":"https://api.github.com/users/datasnakes/following{/other_user}","gists_url":"https://api.github.com/users/datasnakes/gists{/gist_id}","starred_url":"https://api.github.com/users/datasnakes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datasnakes/subscriptions","organizations_url":"https://api.github.com/users/datasnakes/orgs","repos_url":"https://api.github.com/users/datasnakes/repos","events_url":"https://api.github.com/users/datasnakes/events{/privacy}","received_events_url":"https://api.github.com/users/datasnakes/received_events","type":"Organization","site_admin":false},"repo":{"id":88282824,"name":"Datasnakes-Scripts","full_name":"datasnakes/Datasnakes-Scripts","owner":{"login":"datasnakes","id":27606353,"avatar_url":"https://avatars2.githubusercontent.com/u/27606353?v=4","gravatar_id":"","url":"https://api.github.com/users/datasnakes","html_url":"https://github.com/datasnakes","followers_url":"https://api.github.com/users/datasnakes/followers","following_url":"https://api.github.com/users/datasnakes/following{/other_user}","gists_url":"https://api.github.com/users/datasnakes/gists{/gist_id}","starred_url":"https://api.github.com/users/datasnakes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datasnakes/subscriptions","organizations_url":"https://api.github.com/users/datasnakes/orgs","repos_url":"https://api.github.com/users/datasnakes/repos","events_url":"https://api.github.com/users/datasnakes/events{/privacy}","received_events_url":"https://api.github.com/users/datasnakes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/datasnakes/Datasnakes-Scripts","description":"This package is a collection of the modules which aids in the analysis and visualization of orthologs-related bioinformatics projects.","fork":false,"url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts","forks_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/forks","keys_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/teams","hooks_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/hooks","issue_events_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/issues/events{/number}","events_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/events","assignees_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/assignees{/user}","branches_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/branches{/branch}","tags_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/tags","blobs_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/languages","stargazers_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/stargazers","contributors_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/contributors","subscribers_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/subscribers","subscription_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/subscription","commits_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/contents/{+path}","compare_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/merges","archive_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/downloads","issues_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/issues{/number}","pulls_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/labels{/name}","releases_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/releases{/id}","deployments_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/deployments","created_at":"2017-04-14T16:11:14Z","updated_at":"2017-08-27T14:53:43Z","pushed_at":"2017-08-29T18:50:30Z","git_url":"git://github.com/datasnakes/Datasnakes-Scripts.git","ssh_url":"git@github.com:datasnakes/Datasnakes-Scripts.git","clone_url":"https://github.com/datasnakes/Datasnakes-Scripts.git","svn_url":"https://github.com/datasnakes/Datasnakes-Scripts","homepage":"","size":38206,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":18,"forks":1,"open_issues":18,"watchers":6,"default_branch":"master"}},"base":{"label":"datasnakes:master","ref":"master","sha":"f02a3e0050f572a166f1527f881a4b705f52b37e","user":{"login":"datasnakes","id":27606353,"avatar_url":"https://avatars2.githubusercontent.com/u/27606353?v=4","gravatar_id":"","url":"https://api.github.com/users/datasnakes","html_url":"https://github.com/datasnakes","followers_url":"https://api.github.com/users/datasnakes/followers","following_url":"https://api.github.com/users/datasnakes/following{/other_user}","gists_url":"https://api.github.com/users/datasnakes/gists{/gist_id}","starred_url":"https://api.github.com/users/datasnakes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datasnakes/subscriptions","organizations_url":"https://api.github.com/users/datasnakes/orgs","repos_url":"https://api.github.com/users/datasnakes/repos","events_url":"https://api.github.com/users/datasnakes/events{/privacy}","received_events_url":"https://api.github.com/users/datasnakes/received_events","type":"Organization","site_admin":false},"repo":{"id":88282824,"name":"Datasnakes-Scripts","full_name":"datasnakes/Datasnakes-Scripts","owner":{"login":"datasnakes","id":27606353,"avatar_url":"https://avatars2.githubusercontent.com/u/27606353?v=4","gravatar_id":"","url":"https://api.github.com/users/datasnakes","html_url":"https://github.com/datasnakes","followers_url":"https://api.github.com/users/datasnakes/followers","following_url":"https://api.github.com/users/datasnakes/following{/other_user}","gists_url":"https://api.github.com/users/datasnakes/gists{/gist_id}","starred_url":"https://api.github.com/users/datasnakes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/datasnakes/subscriptions","organizations_url":"https://api.github.com/users/datasnakes/orgs","repos_url":"https://api.github.com/users/datasnakes/repos","events_url":"https://api.github.com/users/datasnakes/events{/privacy}","received_events_url":"https://api.github.com/users/datasnakes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/datasnakes/Datasnakes-Scripts","description":"This package is a collection of the modules which aids in the analysis and visualization of orthologs-related bioinformatics projects.","fork":false,"url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts","forks_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/forks","keys_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/teams","hooks_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/hooks","issue_events_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/issues/events{/number}","events_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/events","assignees_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/assignees{/user}","branches_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/branches{/branch}","tags_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/tags","blobs_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/languages","stargazers_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/stargazers","contributors_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/contributors","subscribers_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/subscribers","subscription_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/subscription","commits_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/contents/{+path}","compare_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/merges","archive_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/downloads","issues_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/issues{/number}","pulls_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/labels{/name}","releases_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/releases{/id}","deployments_url":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/deployments","created_at":"2017-04-14T16:11:14Z","updated_at":"2017-08-27T14:53:43Z","pushed_at":"2017-08-29T18:50:30Z","git_url":"git://github.com/datasnakes/Datasnakes-Scripts.git","ssh_url":"git@github.com:datasnakes/Datasnakes-Scripts.git","clone_url":"https://github.com/datasnakes/Datasnakes-Scripts.git","svn_url":"https://github.com/datasnakes/Datasnakes-Scripts","homepage":"","size":38206,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":18,"forks":1,"open_issues":18,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls/44"},"html":{"href":"https://github.com/datasnakes/Datasnakes-Scripts/pull/44"},"issue":{"href":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/issues/44"},"comments":{"href":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls/44/comments"},"review_comment":{"href":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/pulls/44/commits"},"statuses":{"href":"https://api.github.com/repos/datasnakes/Datasnakes-Scripts/statuses/4cd653d8f255b72edf54a528dbc1b3d4f9f22c82"}}}}
{"actor":{"display_login":"grabear"}}