Skip to content

Commit

Permalink
Summary now reports functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
meren committed Jun 14, 2015
1 parent dc5734a commit fbda8a3
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 14 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.8
0.9.0
58 changes: 45 additions & 13 deletions anvio/data/static/template/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,9 @@

<!-- Custom CSS -->
<link href=".html/css/anvio.css" rel="stylesheet">

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<body>

<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
Expand Down Expand Up @@ -148,7 +140,7 @@
<div class="container">
<div class="panel panel-info" id="bins_percent_recruitment_panel">
<div class="panel-heading">
<h1 class="panel-title"><a data-toggle="collapse" data-parent="#bins_percent_recruitment_panel" href="#collapse-bins-percent-recruitment">Bins Percent Recruitment</a></h1>
<h1 class="panel-title"><a data-toggle="collapse" data-parent="#bins_percent_recruitment_panel" href="#collapse-bins-percent-recruitment">Percent Recruitment</a></h1>
</div>

<div id="collapse-bins-percent-recruitment" class="panel-collapse collapse">
Expand Down Expand Up @@ -182,13 +174,12 @@
</section>



<!-- BINS PANEL -->
<section>
<div class="container">
<div class="panel panel-info" id="bins_panel">
<div class="panel-heading">
<h1 class="panel-title"><a data-toggle="collapse" data-parent="#bins_panel" href="#collapse-bins">Bins Summary ({{ meta|lookup:"num_bins"|pretty }})</a></h1>
<h1 class="panel-title"><a data-toggle="collapse" data-parent="#bins_panel" href="#collapse-bins">Summary ({{ meta|lookup:"num_bins"|pretty }})</a></h1>
</div>

<div id="collapse-bins" class="panel-collapse collapse">
Expand Down Expand Up @@ -364,7 +355,7 @@
<div class="container">
<div class="panel panel-info" id="bins_across_samples_panel">
<div class="panel-heading">
<h1 class="panel-title"><a data-toggle="collapse" data-parent="#bins_across_samples_panel" href="#collapse-bins-across-samples">Bins Across Samples ({{ meta|lookup:"profile"|lookup:"samples"|length|pretty }})</a></h1>
<h1 class="panel-title"><a data-toggle="collapse" data-parent="#bins_across_samples_panel" href="#collapse-bins-across-samples">Across Samples ({{ meta|lookup:"profile"|lookup:"samples"|length|pretty }})</a></h1>
</div>

<div id="collapse-bins-across-samples" class="panel-collapse collapse">
Expand Down Expand Up @@ -430,8 +421,49 @@
</section>


<div style="margin-bottom:200px"></div>
{% if meta|lookup:"annotation"|lookup:"genes_annotation_source" %}
<!-- GENES PANEL -->
<section>
<div class="container">
<div class="panel panel-info" id="functions_panel">
<div class="panel-heading">
<h1 class="panel-title"><a data-toggle="collapse" data-parent="#functions_panel" href="#collapse-functions">Functions</a></h1>
</div>

<div id="collapse-functions" class="panel-collapse collapse">
<div class="panel-body">
<table class="table table-striped sortable" id="tblGrid_bin">
<thead id="tblHead_bin">
<tr>
<th data-defaultsort='disabled' class="text-center"></th>
<th>Bin</th>
<th class="text-center">Total Size</th>
<th class="text-center">Num Genes Identified</th>
<th data-defaultsort='disabled' class="text-center">Functions Table</th>
</tr>
</thead>
<tbody>
{% for bin in meta|lookup:"bins" %}
<tr>
<td style="vertical-align: middle; width: 18px;"><div style="width:18px; height: 18px; background-color: {{ collection|lookup:bin|lookup:"color" }}; fload:left; border-radius: 3px;">&nbsp;</div></td>
<td style="vertical-align: middle;">{{ bin }}</td>
<td class="text-center" data-value="{{ collection|lookup:bin|lookup:"total_length" }}"><button type="button" class="btn btn-default" data-toggle="modal" data-target="#modFiles_{{bin}}">{{ collection|lookup:bin|lookup:"total_length"|humanize_n }}</button></td>
<td class="text-center" style="vertical-align: middle;" data-value="{{ collection|lookup:bin|lookup:"genes"|lookup:"num_genes_found"|humanize_n }}">{{ collection|lookup:bin|lookup:"genes"|lookup:"num_genes_found"|humanize_n }}</td>
<td class="text-center" style="vertical-align: middle;"><a href="{{ collection|lookup:bin|lookup:"files"|lookup:"functions" }}">🔗 Link</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>


{% endif %}

<div style="margin-bottom:200px"></div>

<!-- jQuery -->
<script src=".html/js/jquery.js"></script>
Expand Down
34 changes: 34 additions & 0 deletions anvio/summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ def create(self):

self.store_profile_data()

self.store_gene_coverages_matrix()

self.progress.end()

return self.bin_info_dict
Expand Down Expand Up @@ -317,6 +319,38 @@ def store_profile_data(self):
utils.store_dict_as_TAB_delimited_file({table_name: self.bin_profile[table_name]}, None, headers = ['bin'] + self.summary.p_meta['samples'], file_obj = output_file_obj)


def store_gene_coverages_matrix(self):
self.progress.update('Storing gene coverages ...')

info_dict = {}
genes_dict = {}

gene_entry_ids_in_bin = set([])
for split_name in self.split_ids:
gene_entry_ids_in_bin.update(self.summary.split_to_genes_in_splits_ids[split_name])

info_dict['num_genes_found'] = len(gene_entry_ids_in_bin)

headers = ['function', 'contig', 'start', 'stop', 'direction']
for gene_entry_id in gene_entry_ids_in_bin:
prot_id = self.summary.genes_in_splits[gene_entry_id]['prot']
genes_dict[prot_id] = {}

# first fill in sample independent information;
for header in headers:
genes_dict[prot_id][header] = self.summary.genes_in_contigs_dict[prot_id][header]

# then fill in distribution across samples:
for sample_name in self.summary.p_meta['samples']:
genes_dict[prot_id][sample_name] = self.summary.gene_coverages_dict[prot_id][sample_name]


output_file_obj = self.get_output_file_handle('functions.txt')
utils.store_dict_as_TAB_delimited_file(genes_dict, None, headers = ['prot'] + headers + self.summary.p_meta['samples'], file_obj = output_file_obj)

self.bin_info_dict['genes'] = info_dict


def store_contigs_fasta(self):
"""Storing contig sequences.
Expand Down

0 comments on commit fbda8a3

Please sign in to comment.