Skip to content

Commit

Permalink
Refactor code in notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Vini2 committed Aug 10, 2022
1 parent ccb1d7a commit 40a9c34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
24 changes: 13 additions & 11 deletions notebooks/MD1_UniProt12.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,19 @@
"metadata": {},
"outputs": [],
"source": [
"from Bio import SeqIO\n",
"import re\n",
"import xlsxwriter\n",
"import collections\n",
"\n",
"from Bio import SeqIO"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"contig_lengths = {}\n",
"\n",
"for index, record in enumerate(SeqIO.parse(project_path+\"all_genes.fna\", \"fasta\")):\n",
Expand All @@ -37,8 +48,6 @@
"metadata": {},
"outputs": [],
"source": [
"import re\n",
"\n",
"species_len = {}\n",
"\n",
"unclassified = []\n",
Expand Down Expand Up @@ -94,10 +103,6 @@
"metadata": {},
"outputs": [],
"source": [
"import re\n",
"\n",
"min_len = 0\n",
"\n",
"sorted_species = {k: v for k, v in sorted(species_len.items(), reverse=True, key=lambda item: item[1])}\n",
"\n",
"species_list = []\n",
Expand All @@ -112,7 +117,7 @@
"for key, value in sorted_species.items():\n",
" key_strings = key.split(\" \")\n",
" \n",
" if value > min_len and len(key_strings) > 3 and \"cellular organisms\" not in key:\n",
" if len(key_strings) > 3 and \"cellular organisms\" not in key:\n",
" \n",
" taxid = key_strings[-1][:-1]\n",
" \n",
Expand Down Expand Up @@ -193,9 +198,6 @@
"metadata": {},
"outputs": [],
"source": [
"import xlsxwriter\n",
"import collections\n",
"\n",
"od = collections.OrderedDict(sorted(gene_species.items()))\n",
"\n",
"# Create a workbook and add a worksheet.\n",
Expand Down
10 changes: 1 addition & 9 deletions notebooks/MD2_UniProt-12.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,10 @@
"outputs": [],
"source": [
"import re\n",
"import csv\n",
"import subprocess\n",
"import os\n",
"import gzip\n",
"import shutil\n",
"import glob\n",
"import xlsxwriter\n",
"import collections\n",
"\n",
"from datetime import datetime, timedelta\n",
"from Bio import SeqIO\n",
"from collections import defaultdict"
"from Bio import SeqIO"
]
},
{
Expand Down

0 comments on commit 40a9c34

Please sign in to comment.