diff --git a/install.bash b/install.bash index 626501d..cd558ab 100644 --- a/install.bash +++ b/install.bash @@ -1,4 +1,4 @@ #!/usr/bin/env bash conda install -y -c conda-forge matplotlib progressbar -conda install -y -c anaconda pandas biopython reportlab # reportlab for Bio.Graphics (Biopython) \ No newline at end of file +conda install -y -c anaconda pandas biopython reportlab openpyxl # reportlab for Bio.Graphics (Biopython) \ No newline at end of file diff --git a/kegg_charter.py b/kegg_charter.py index 1c187c5..dc4db0c 100644 --- a/kegg_charter.py +++ b/kegg_charter.py @@ -9,7 +9,7 @@ import argparse, pandas as pd, numpy as np, os, pathlib, PIL, re, sys, subprocess import matplotlib.pyplot as plt -__version__ = "0.0.3" +__version__ = "0.0.4" class KEGGCharter: @@ -34,9 +34,9 @@ def get_arguments(self): parser.add_argument("-mtc", "--metatranscriptomic-columns", type = str, help = "Names of columns with metatranscriptomics quantification") parser.add_argument("-tc", "--taxa-column", type = str, default = 'Taxonomic lineage(GENUS)', - help = "Column with the taxa designations to represent with KEGGChart") + help = "Column with the taxa designations to represent with KEGGChart") # TODO - test this argument without UniProt shenanigans parser.add_argument("-tls", "--taxa-list", type = str, - help = "List of taxa to represent in genomic potential charts (comma separated)") + help = "List of taxa to represent in genomic potential charts (comma separated)") # TODO - must be tested parser.add_argument("-not", "--number-of-taxa", type = str, help = "Number of taxa to represent in genomic potential charts (comma separated)", default = '10') @@ -459,9 +459,6 @@ def main(self): self.timed_message('Creating KEGG Pathway representations for {} metabolic pathways.'.format( str(len(metabolic_maps)))) - not_loaded = list(); differential_no_kos = list() - i = 1 - # Set colours for taxa if MG data is present if hasattr(args, 'metagenomic_columns'): args.metagenomic_columns = args.metagenomic_columns.split(',') @@ -478,36 +475,44 @@ def main(self): if hasattr(args, 'metatranscriptomic_columns'): args.metatranscriptomic_columns = args.metatranscriptomic_columns.split(',') + i = 1 + failed_maps = list(); differential_no_kos = list() + # For each metabolic map, will chart genomic potential and differential expression if MG and MT data are available, respectively for metabolic_map in metabolic_maps: - kegg_pathway_map = KEGGPathwayMap(data, metabolic_map) # if getting 404 here, is likely because map doesn't exist # TODO - put something here to inform users to report that problem - print('[{}/{}] Creating representation for pathway: {}'.format( - str(i), str(len(metabolic_maps)), - kegg_pathway_map.pathway.title)) - if args.metagenomic_columns: - kegg_pathway_map = KEGGPathwayMap(data, metabolic_map) - if args.uniprot_taxonomic_columns: - args.taxa_column = 'Taxonomic lineage ({})'.format(args.taxonomic_level.upper()) - self.genomic_potential_taxa(kegg_pathway_map, data, - args.metagenomic_columns, dic_colors, - taxa_column = args.taxa_column, - output_basename = args.output + '/potential') # TODO - log should be True, fix the other TODO - if args.metatranscriptomic_columns: - kegg_pathway_map = KEGGPathwayMap(data, metabolic_map) - saul_good = self.differential_expression_sample(kegg_pathway_map, data, - args.metatranscriptomic_columns, - output_basename = args.output + '/differential', - log = False) - if saul_good == 1: - differential_no_kos.append(metabolic_map) - plt.close() + try: + kegg_pathway_map = KEGGPathwayMap(data, metabolic_map) # if getting 404 here, is likely because map doesn't exist # TODO - put something here to inform users to report that problem + print('[{}/{}] Creating representation for pathway [{}]: {}'.format( + str(i), str(len(metabolic_maps)), metabolic_map, + kegg_pathway_map.pathway.title)) + if args.metagenomic_columns: + kegg_pathway_map = KEGGPathwayMap(data, metabolic_map) + if args.uniprot_taxonomic_columns: + args.taxa_column = 'Taxonomic lineage ({})'.format(args.taxonomic_level.upper()) + self.genomic_potential_taxa(kegg_pathway_map, data, + args.metagenomic_columns, dic_colors, + taxa_column = args.taxa_column, + output_basename = args.output + '/potential') # TODO - log should be True, fix the other TODO + if args.metatranscriptomic_columns: + kegg_pathway_map = KEGGPathwayMap(data, metabolic_map) + saul_good = self.differential_expression_sample(kegg_pathway_map, data, + args.metatranscriptomic_columns, + output_basename = args.output + '/differential', + log = False) + if saul_good == 1: + differential_no_kos.append(metabolic_map) + plt.close() + except: + print('[{}/{}] Representation of pathway [{}] has failed!'.format( + str(i), str(len(metabolic_maps)), metabolic_map)) + failed_maps.append(metabolic_map) i += 1 - not_loaded_filename = args.output + '/not_loaded.txt' + failed_maps_filename = args.output + '/failed_maps.txt' no_kos_filename = args.output + '/no_kos.txt' print('{} maps could not be loaded. You can see which ones at {}'.format( - len(not_loaded), not_loaded_filename)) - open(not_loaded_filename, 'w').write('\n'.join(not_loaded)) + len(failed_maps), failed_maps_filename)) + open(failed_maps_filename, 'w').write('\n'.join(failed_maps)) print('{} maps had no KOs attributed to them. You can see which ones at {}'.format( len(differential_no_kos), no_kos_filename)) open(no_kos_filename, 'w').write('\n'.join(differential_no_kos)) diff --git a/meta.yaml b/meta.yaml index ec9a42d..d279dc0 100644 --- a/meta.yaml +++ b/meta.yaml @@ -1,6 +1,6 @@ {% set name = "keggcharter" %} -{% set version = "0.0.3" %} -{% set sha256 = "c824ad580a422a55073d569e1567a255472b90ea428af7cf990022522a5587e9" %} +{% set version = "0.0.4" %} +{% set sha256 = "3031f4aed298df068aa6fd3d9f70b10b4b6974eb6221abb3e4fcccec74488f98" %} package: name: {{ name|lower }} @@ -13,7 +13,13 @@ source: build: noarch: generic number: 0 - script: "mkdir -p $PREFIX/bin && cp *.py KEGGCharter_prokaryotic_maps.txt $PREFIX/bin" + script: | + dir="${PREFIX}/share/KEGGCharter" + mkdir -p "${dir}" + cp *.py KEGGCharter_prokaryotic_maps.txt "${dir}/" + mkdir -p "${PREFIX}/bin" + chmod +x "${dir}/kegg_charter.py" + ln -s "${dir}/kegg_charter.py" "${PREFIX}/bin/" requirements: run: