From 5b44d93dabef45b97e6a80876acce1ea9964de6b Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 11 Apr 2021 16:41:00 -0500 Subject: [PATCH 0001/1020] pass self.progress --- anvio/genomedescriptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anvio/genomedescriptions.py b/anvio/genomedescriptions.py index 58f4fd6ea9..c0a9637ca1 100644 --- a/anvio/genomedescriptions.py +++ b/anvio/genomedescriptions.py @@ -332,7 +332,7 @@ def get_functions_and_sequences_dicts_from_contigs_db(self, genome_name, request if genome_name in self.internal_genome_names: args.split_names_of_interest = self.get_split_names_of_interest_for_internal_genome(g) - contigs_super = dbops.ContigsSuperclass(args, r=anvio.terminal.Run(verbose=False)) + contigs_super = dbops.ContigsSuperclass(args, r=anvio.terminal.Run(verbose=False), p=self.progress) if self.functions_are_available: contigs_super.init_functions(requested_sources=requested_source_list) From 76ba386897502c3e6968d9524229ca8876cb85e0 Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 11 Apr 2021 16:41:46 -0500 Subject: [PATCH 0002/1020] cosmetics --- anvio/bottleroutes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/anvio/bottleroutes.py b/anvio/bottleroutes.py index 6518e7a65e..ccd983b2e9 100644 --- a/anvio/bottleroutes.py +++ b/anvio/bottleroutes.py @@ -174,8 +174,8 @@ def register_routes(self): self.route('/data/get_variability', callback=self.get_variability, method='POST') self.route('/data/store_variability', callback=self.store_variability, method='POST') self.route('/data/store_structure_as_pdb', callback=self.store_structure_as_pdb, method='POST') - self.route('/data/get_gene_function_info/', callback=self.get_gene_function_info) - self.route('/data/get_model_info/', callback=self.get_model_info) + self.route('/data/get_gene_function_info/', callback=self.get_gene_function_info) + self.route('/data/get_model_info/', callback=self.get_model_info) self.route('/data/filter_gene_clusters', callback=self.filter_gene_clusters, method='POST') self.route('/data/reroot_tree', callback=self.reroot_tree, method='POST') self.route('/data/save_tree', callback=self.save_tree, method='POST') From 96b743b05d383871a533f09d723c94d889307f86 Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 11 Apr 2021 17:18:35 -0500 Subject: [PATCH 0003/1020] fixy fix for a bug that almost deserves to stay .. given how long it managed to survive in the codebase :/ --- anvio/dbops.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/anvio/dbops.py b/anvio/dbops.py index d0023f20dc..f847335fa2 100644 --- a/anvio/dbops.py +++ b/anvio/dbops.py @@ -3719,8 +3719,8 @@ def init(self): except: pass - self.internal_genomes = [s.strip() for s in self.meta['internal_genome_names'].split(',')] - self.external_genomes = [s.strip() for s in self.meta['external_genome_names'].split(',')] + self.internal_genomes = [s.strip() for s in self.meta['internal_genome_names'].split(',') if len(s.strip())] + self.external_genomes = [s.strip() for s in self.meta['external_genome_names'].split(',') if len(s.strip())] self.genomes = self.internal_genomes + self.external_genomes # open the database From a4ddc62f501a22efc5e6920bedf6f75d2f97271f Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 11 Apr 2021 18:06:54 -0500 Subject: [PATCH 0004/1020] placeholders for genome view interactive files --- anvio/data/interactive/genomeview.html | 15 +++++++++++ anvio/data/interactive/js/genomeview.js | 36 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 anvio/data/interactive/genomeview.html create mode 100644 anvio/data/interactive/js/genomeview.js diff --git a/anvio/data/interactive/genomeview.html b/anvio/data/interactive/genomeview.html new file mode 100644 index 0000000000..f852ec9d12 --- /dev/null +++ b/anvio/data/interactive/genomeview.html @@ -0,0 +1,15 @@ + + + + Genome View + + + + + + + + +
Check your JavaScript console! :)
+ + diff --git a/anvio/data/interactive/js/genomeview.js b/anvio/data/interactive/js/genomeview.js new file mode 100644 index 0000000000..4f8361aabb --- /dev/null +++ b/anvio/data/interactive/js/genomeview.js @@ -0,0 +1,36 @@ +/** + * Javascript library for anvi'o genome view + * + * Authors: Isaac Fink + * Matthew Klein + * Copyright 2021, The anvi'o project + * + * This file is part of anvi'o (). + * + * Anvi'o is a free software. You can redistribute this program + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * You should have received a copy of the GNU General Public License + * along with anvi'o. If not, see . + * + * @license GPL-3.0+ + */ + + +$(document).ready(function() { + initData(); +}); + +function initData() { +// initialize the bulk of the data. + $.ajax({ + type: 'POST', + cache: false, + url: '/data/get_genome_view_data', + success: function(data) { + console.log(data); + } + }); +} From b902aaa6c965af7feee41f41202b2fe9a08d73a3 Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 11 Apr 2021 18:52:08 -0500 Subject: [PATCH 0005/1020] cosmetics --- anvio/genomedescriptions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/anvio/genomedescriptions.py b/anvio/genomedescriptions.py index c0a9637ca1..397d323ca9 100644 --- a/anvio/genomedescriptions.py +++ b/anvio/genomedescriptions.py @@ -425,8 +425,10 @@ def init_functions(self): (', '.join(self.function_annotation_sources), ', '.join(function_annotation_sources_some_genomes_miss))) else: # every function ever observed is common to all genomes. - self.run.warning("Good news! Anvi'o found all these functions that are common to all of your genomes and will use them for " - "downstream analyses and is very proud of you: '%s'." % (', '.join(self.function_annotation_sources)), lc='green') + self.run.warning(f"Good news! Anvi'o found functions that are common to all of your genomes and will use them for " + f"downstream analyses and is very proud of you. Here is the " + f"{P('annotation source', len(self.function_annotation_sources), alt='list of annotation sources')}: " + f"anvi'o recognizes: {', '.join(self.function_annotation_sources)}'.", header="YAY FOR FUNCTIONS 🥂", lc='green') def get_genome_hash_for_external_genome(self, entry): From 83922fe85ced3c9f9730b91b82ff2f884d27918e Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 11 Apr 2021 18:52:56 -0500 Subject: [PATCH 0006/1020] a new interactive 'mode', `genomeview` --- anvio/dbops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anvio/dbops.py b/anvio/dbops.py index f847335fa2..14dcb3699e 100644 --- a/anvio/dbops.py +++ b/anvio/dbops.py @@ -139,7 +139,7 @@ def __init__(self, args, r=run, p=progress): # associated with the call. so having done our part, we will quietly return from here hoping # that we are not driving a developer crazy somewhere by doing so. D = lambda x: self.__dict__[x] if x in self.__dict__ else None - if D('mode') == 'pan' or D('mode') == 'functional' or D('mode') == 'manual': + if D('mode') == 'pan' or D('mode') == 'functional' or D('mode') == 'manual' or D('mode') == 'genomeview': return A = lambda x: self.args.__dict__[x] if x in self.args.__dict__ else None From b2e2e6e48598a1694df151e5eefd7a2ca40ca4cf Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 11 Apr 2021 18:53:25 -0500 Subject: [PATCH 0007/1020] unused variable --- anvio/kegg.py | 1 - 1 file changed, 1 deletion(-) diff --git a/anvio/kegg.py b/anvio/kegg.py index f03c26718c..a7332ddf0b 100644 --- a/anvio/kegg.py +++ b/anvio/kegg.py @@ -5016,7 +5016,6 @@ def get_enrichment_input(self, output_file_path): "it using the --sample-header parameter. Just so you know, the columns in modules-txt that you can choose from " f"are: {col_list}") - required_groups_txt_headers = ['sample', 'group'] samples_to_groups_dict, groups_to_samples_dict = utils.get_groups_txt_file_as_dict(self.groups_txt) # make sure the samples all have a group From 67ccc4b76ce70e433b25bb3d84ec689ab9820311 Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 11 Apr 2021 18:54:11 -0500 Subject: [PATCH 0008/1020] a new artifact, `genome-view` --- anvio/docs/__init__.py | 6 ++++++ anvio/docs/artifacts/genome-view.md | 1 + 2 files changed, 7 insertions(+) create mode 100644 anvio/docs/artifacts/genome-view.md diff --git a/anvio/docs/__init__.py b/anvio/docs/__init__.py index 3081aeb7ec..9c4107cd12 100644 --- a/anvio/docs/__init__.py +++ b/anvio/docs/__init__.py @@ -370,6 +370,12 @@ "provided_by_anvio": True, "provided_by_user": False }, + "genome-view": { + "name": "GENOME VIEW", + "type": "DISPLAY", + "provided_by_anvio": True, + "provided_by_user": False + }, "view-data": { "name": "VIEW DATA", "type": "TXT", diff --git a/anvio/docs/artifacts/genome-view.md b/anvio/docs/artifacts/genome-view.md new file mode 100644 index 0000000000..e56889c4b8 --- /dev/null +++ b/anvio/docs/artifacts/genome-view.md @@ -0,0 +1 @@ +An interactive anvi'o interface to study gene synteny across genomes. From 51048c287fbe62c74b78115f5c46b791f2013a1f Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 11 Apr 2021 18:55:08 -0500 Subject: [PATCH 0009/1020] GenomeView class the purpose of this class is to collect everything necessary for the interactive interface to read through bottleroutes. It is likely that we will need a way to re-implement this class to be lazy (so it doesn't read everything into memory and pass it around). but this draft will serve well to figure out how to structure the interactive interface with real data. --- anvio/genomedescriptions.py | 132 ++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) diff --git a/anvio/genomedescriptions.py b/anvio/genomedescriptions.py index 397d323ca9..a203d38c24 100644 --- a/anvio/genomedescriptions.py +++ b/anvio/genomedescriptions.py @@ -1012,6 +1012,138 @@ def sanity_check(self): [utils.is_this_name_OK_for_database('metagenome name "%s"' % metagenome_name, metagenome_name) for metagenome_name in self.metagenomes] +class AggregateGenomes(object): + """Aggregate information related to a group of genomes from anywhere. + + The purpose of this class is to collect all relevant information about + a group of genomes comprehensively for downstream analyses. The primary + client of this class is genome view. + + Please note that despite similar names, the use of this class and the class + AggregateFunctions is quite different. + """ + + def __init__(self, args, run=run, progress=progress, skip_init=False): + self.run = run + self.progress = progress + + self.args = args + self.initialized = False + + A = lambda x: args.__dict__[x] if x in args.__dict__ else None + self.external_genomes_file = A('external_genomes') + self.internal_genomes_file = A('internal_genomes') + self.pan_db_path = A('pan_db') + + self.genome_descriptions = GenomeDescriptions(args, progress=terminal.Progress(verbose=False)) + self.genome_descriptions.load_genomes_descriptions() + + # critical items for genome view bottleroutes: + self.genomes = {} + self.gene_associations = {} + + # let's have this ready for convenience: + self.genome_names = list(self.genome_descriptions.genomes.keys()) + + if not skip_init: + self.init() + + + def init(self): + """Learn everything about genomes of interest. + + Calling this funciton will populate multiple critical dictionaries this class + designed to give access to, including `self.genomes` and `self.gene_associations`. + """ + + # before going through all the gneomes, we will recover gene associations. the reason + # we want to do it early on to make sure if there are incompatibilities between genome + # names of interest and reosurces provided to learn gene-gene associations (such as the + # pan database), they are discovered earlier than later: + self.gene_associations = self.get_gene_associations() + + # now we will go through genomes of interest, and build our gigantic dictionary + for genome_name in self.genome_names: + self.genomes[genome_name] = {} + + # learn all about genes: + self.genomes[genome_name]['genes'] = self.get_genes_dict(genome_name) + + # learn all about contigs: + self.genomes[genome_name]['contigs'] = self.get_contigs_dict(genome_name) + + self.initialized = True + + + def get_gene_associations(self): + """Recovers gene assoctiations through gene clusters found in a pan database. + + FIXME/TODO: also recover gene associations through user-provided input files. + """ + + d = {} + + # if we have a pan database, we will start with that, first, and learn gene clusters in it: + if self.pan_db_path: + pan_db = dbops.PanDatabase(self.pan_db_path) + + genome_names_missing_in_pan_db = [g for g in self.genome_names if g not in pan_db.genomes] + if len(genome_names_missing_in_pan_db): + raise ConfigError(f"You have provided a pan database to recover assocaitions between genes across " + f"your genomes, but not all genome names in your list of genomes occur in this " + f"pan database :/ Here is the list of genome names that you are missing: " + f"{', '.join(genome_names_missing_in_pan_db)}") + else: + self.run.warning("Anvi'o found each of the genome name you are interested in the pan database you " + "have provided. Which means the gene cluster information will be recovered for " + "downstream magic.", header="PAN DATABASE LOOKS GOOD 🚀", lc="green") + + pan_db.disconnect() + + + pan_db = dbops.PanSuperclass(self.args) + pan_db.init_gene_clusters() + + d['anvio-pangenome'] = pan_db.gene_clusters + + return d + + + def get_genes_dict(self, genome_name): + """Learn everything about genes in a genome""" + + contigs_db_path = self.genome_descriptions.genomes[genome_name]['contigs_db_path'] + + d = {} + + # learn gene calls, start-stop positions, and so on + d['gene_calls'] = db.DB(contigs_db_path, None, ignore_version=True).smart_get(t.genes_in_contigs_table_name, 'gene_callers_id', self.genome_descriptions.genomes[genome_name]['gene_caller_ids']) + + # learn gene functions as well as gene amino acid and DNA sequences + d['functions'], d['aa'], d['dna'] = self.genome_descriptions.get_functions_and_sequences_dicts_from_contigs_db(genome_name) + + return d + + + def get_contigs_dict(self, genome_name): + """Learn everything about contigs associated with a genome""" + + contigs_db_path = self.genome_descriptions.genomes[genome_name]['contigs_db_path'] + + d = {} + + # get contig sequences + if genome_name in self.genome_descriptions.internal_genome_names: + raise ConfigError("This is not yet implemented :( Someone needs to find a rapid way to get contig " + "associated with a set of gene caller ids without having to create an instance " + "of ContigsSuperclass :/") + else: + d['info'] = db.DB(contigs_db_path, None, ignore_version=True).get_table_as_dict(t.contigs_info_table_name) + d['dna'] = db.DB(contigs_db_path, None, ignore_version=True).get_table_as_dict(t.contig_sequences_table_name) + + return d + + class AggregateFunctions: """Aggregate functions from anywhere. From 7e514706a391b80fd1fe7af989991376c3a2cd6d Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 11 Apr 2021 18:57:14 -0500 Subject: [PATCH 0010/1020] GenomeView class for the interactive module. All this class does at the moment is to aggregate all necessary information for the interactive interface through the AggregateGenomes class. It will likely grow with new functions quickly to take care of interactive interface related tasks (many of the parameters it claims to accept have currently no effect). --- anvio/interactive.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/anvio/interactive.py b/anvio/interactive.py index 01b643fa45..af27f96131 100644 --- a/anvio/interactive.py +++ b/anvio/interactive.py @@ -31,7 +31,7 @@ from anvio.variabilityops import VariabilitySuper from anvio.variabilityops import variability_engines from anvio.dbops import get_default_item_order_name -from anvio.genomedescriptions import AggregateFunctions +from anvio.genomedescriptions import AggregateFunctions, AggregateGenomes from anvio.errors import ConfigError, RefineError, GenesDBError from anvio.clusteringconfuguration import ClusteringConfiguration from anvio.dbops import ProfileSuperclass, ContigsSuperclass, PanSuperclass, TablesForStates, ProfileDatabase @@ -1775,6 +1775,31 @@ def get_anvio_news(self): pass +class GenomeView(AggregateGenomes): + def __init__(self, args, run=run, progress=progress, skip_init=False): + self.run = run + self.progress = progress + + self.args = args + self.mode = 'genomeview' + + A = lambda x: args.__dict__[x] if x in args.__dict__ else None + self.mode = A('mode') + self.tree = A('tree') + self.title = A('title') + self.skip_auto_ordering = A('skip_auto_ordering') + self.skip_news = A('skip_news') + self.skip_news = A('dry-run') + + # critical items for genome view bottleroutes, which will be filled + # by `AggregateGenomes` upon initialization: + self.genomes = {} + self.initialized = False + + if not skip_init: + AggregateGenomes.__init__(self, self.args, run=self.run, progress=self.progress) + + class StructureInteractive(VariabilitySuper, ContigsSuperclass): def __init__(self, args, run=run, progress=progress): self.run = run From 067d899815db2243785ec7f5021d49ea7f8178fb Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 11 Apr 2021 18:59:59 -0500 Subject: [PATCH 0011/1020] a draft route for genomeview. --- anvio/bottleroutes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/anvio/bottleroutes.py b/anvio/bottleroutes.py index ccd983b2e9..1bc889ce58 100644 --- a/anvio/bottleroutes.py +++ b/anvio/bottleroutes.py @@ -180,6 +180,7 @@ def register_routes(self): self.route('/data/reroot_tree', callback=self.reroot_tree, method='POST') self.route('/data/save_tree', callback=self.save_tree, method='POST') self.route('/data/check_homogeneity_info', callback=self.check_homogeneity_info, method='POST') + self.route('/data/get_genome_view_data', callback=self.get_genome_view_data, method='POST') self.route('/data/search_items', callback=self.search_items_by_name, method='POST') self.route('/data/get_taxonomy', callback=self.get_taxonomy, method='POST') self.route('/data/get_functions_for_gene_clusters', callback=self.get_functions_for_gene_clusters, method='POST') @@ -256,6 +257,8 @@ def redirect_to_app(self): homepage = 'metabolism.html' elif self.interactive.mode == 'inspect': redirect('/app/charts.html?id=%s&show_snvs=true&rand=%s' % (self.interactive.inspect_split_name, self.random_hash(8))) + elif self.interactive.mode == 'genomeview': + homepage = 'genomeview.html' redirect('/app/%s?rand=%s' % (homepage, self.random_hash(8))) @@ -1342,6 +1345,14 @@ def get_initial_data(self): return json.dumps(self.interactive.get_initial_data()) + def get_genome_view_data(self): + try: + return json.dumps({'genomes': self.interactive.genomes, + 'gene_associations': self.interactive.gene_associations}) + except Exception as e: + return json.dumps({'error': f"Something went wrong at the backend :( Here is the error message: '{e}'"}) + + def get_column_info(self): gene_callers_id = int(request.forms.get('gene_callers_id')) engine = request.forms.get('engine') From d93d60ee5d7c7b6c69e7bff85e2d3433481b1658 Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 11 Apr 2021 19:00:25 -0500 Subject: [PATCH 0012/1020] a new program, anvi-display-genomes. --- bin/anvi-display-genomes | 88 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 bin/anvi-display-genomes diff --git a/bin/anvi-display-genomes b/bin/anvi-display-genomes new file mode 100755 index 0000000000..fe5b78fe9e --- /dev/null +++ b/bin/anvi-display-genomes @@ -0,0 +1,88 @@ +#!/usr/bin/env python +# -*- coding: utf-8 +"""Entry point to the interactive interface for genome view. + +The massage of the data is being taken care of in the interactive module, +and this file implements the bottle callbacks. +""" + +import sys +from anvio.argparse import ArgumentParser + +import anvio +import anvio.utils as utils +import anvio.terminal as terminal +import anvio.interactive as interactive +from anvio.bottleroutes import BottleApplication + +from anvio.errors import ConfigError, FilesNPathsError + + +__author__ = "Developers of anvi'o (see AUTHORS.txt)" +__copyright__ = "Copyleft 2021, the Meren Lab (http://merenlab.org/)" +__credits__ = [] +__license__ = "GPL 3.0" +__version__ = anvio.__version__ +__maintainer__ = "A. Murat Eren" +__email__ = "a.murat.eren@gmail.com" +__requires__ = ['external-genomes', 'internal-genomes', 'pan-db'] +__provides__ = ['genome-view'] +__description__ = "Start an anvi'o interactive interface for 'genome view'" + +run = terminal.Run() +progress = terminal.Progress() + +if __name__ == '__main__': + parser = ArgumentParser(description=__description__) + + groupA = parser.add_argument_group('GENOMES', "Tell anvi'o where your genomes are.") + groupA.add_argument(*anvio.A('external-genomes'), **anvio.K('external-genomes')) + groupA.add_argument(*anvio.A('internal-genomes'), **anvio.K('internal-genomes')) + + groupB = parser.add_argument_group('GENE ASSOCIATIONS', "Tell anvi'o how genes in your genomes related to one another.") + groupB.add_argument(*anvio.A('pan-db'), **anvio.K('pan-db', {'required': False})) + + groupC = parser.add_argument_group("PRO STUFF", "Tell anvi'o which gene caller to use.") + groupC.add_argument(*anvio.A('gene-caller'), **anvio.K('gene-caller')) + + groupB = parser.add_argument_group('OPTIONAL INPUTS', "Where the yay factor becomes a reality.") + groupB.add_argument(*anvio.A('tree'), **anvio.K('tree')) + + groupD = parser.add_argument_group('VISUALS RELATED', "Parameters that give access to various adjustements regarding\ + the interface.") + groupD.add_argument(*anvio.A('title'), **anvio.K('title')) + + groupE = parser.add_argument_group('SWEET PARAMS OF CONVENIENCE', "Parameters and flags that are not quite essential (but nice to have).") + groupE.add_argument(*anvio.A('dry-run'), **anvio.K('dry-run')) + groupE.add_argument(*anvio.A('skip-auto-ordering'), **anvio.K('skip-auto-ordering')) + groupE.add_argument(*anvio.A('skip-news'), **anvio.K('skip-news')) + + groupF = parser.add_argument_group('SERVER CONFIGURATION', "For power users.") + groupF.add_argument(*anvio.A('ip-address'), **anvio.K('ip-address')) + groupF.add_argument(*anvio.A('port-number'), **anvio.K('port-number')) + groupF.add_argument(*anvio.A('browser-path'), **anvio.K('browser-path')) + groupF.add_argument(*anvio.A('read-only'), **anvio.K('read-only')) + groupF.add_argument(*anvio.A('server-only'), **anvio.K('server-only')) + groupF.add_argument(*anvio.A('password-protected'), **anvio.K('password-protected')) + groupF.add_argument(*anvio.A('user-server-shutdown'), **anvio.K('user-server-shutdown')) + + args = parser.get_args(parser) + + try: + args.mode = 'genomeview' + d = interactive.GenomeView(args) + + args.port_number = utils.get_port_num(args.port_number, args.ip_address, run=run) + except ConfigError as e: + print(e) + sys.exit(-1) + except FilesNPathsError as e: + print(e) + sys.exit(-2) + + if args.dry_run: + run.info_single('Dry run? Kthxbai.', nl_after=1, nl_before=1) + sys.exit() + + app = BottleApplication(d) + app.run_application(args.ip_address, args.port_number) From d7ef3ddc4619dc6e9c25fc0c838920329ad5b911 Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Sun, 11 Apr 2021 19:46:37 -0500 Subject: [PATCH 0013/1020] make sure the pan db is a pan db --- anvio/genomedescriptions.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/anvio/genomedescriptions.py b/anvio/genomedescriptions.py index a203d38c24..95081a0374 100644 --- a/anvio/genomedescriptions.py +++ b/anvio/genomedescriptions.py @@ -1035,6 +1035,10 @@ def __init__(self, args, run=run, progress=progress, skip_init=False): self.internal_genomes_file = A('internal_genomes') self.pan_db_path = A('pan_db') + if self.pan_db_path: + utils.is_pan_db(self.pan_db_path) + + self.genome_descriptions = GenomeDescriptions(args, progress=terminal.Progress(verbose=False)) self.genome_descriptions.load_genomes_descriptions() @@ -1051,7 +1055,7 @@ def __init__(self, args, run=run, progress=progress, skip_init=False): def init(self): """Learn everything about genomes of interest. - + Calling this funciton will populate multiple critical dictionaries this class designed to give access to, including `self.genomes` and `self.gene_associations`. """ @@ -1068,7 +1072,7 @@ def init(self): # learn all about genes: self.genomes[genome_name]['genes'] = self.get_genes_dict(genome_name) - + # learn all about contigs: self.genomes[genome_name]['contigs'] = self.get_contigs_dict(genome_name) From d93b1be92bce90aad7e685e87cc64759a7f1a310 Mon Sep 17 00:00:00 2001 From: "A. Murat Eren" Date: Mon, 12 Apr 2021 15:29:03 -0500 Subject: [PATCH 0014/1020] fix license & author info, remove trailing spaces --- anvio/data/interactive/js/animations.js | 24 ++++- anvio/data/interactive/js/area-zoom.js | 39 +++++--- anvio/data/interactive/js/bin.js | 93 ++++++++++---------- anvio/data/interactive/js/charts.js | 11 ++- anvio/data/interactive/js/color-coding.js | 23 +++-- anvio/data/interactive/js/constants.js | 20 +++++ anvio/data/interactive/js/context-menu.js | 9 +- anvio/data/interactive/js/contigs-plot.js | 22 ++++- anvio/data/interactive/js/drawer.js | 9 +- anvio/data/interactive/js/geneclusters.js | 16 ++-- anvio/data/interactive/js/genomeview.js | 5 +- anvio/data/interactive/js/help-messages.js | 19 ++++ anvio/data/interactive/js/inspectionutils.js | 8 +- anvio/data/interactive/js/main.js | 8 +- anvio/data/interactive/js/migrations.js | 23 ++++- anvio/data/interactive/js/mouse-events.js | 7 +- anvio/data/interactive/js/multiple.js | 21 ++++- anvio/data/interactive/js/news.js | 20 +++++ anvio/data/interactive/js/sample.js | 64 +++++++++----- anvio/data/interactive/js/search.js | 37 +++++--- anvio/data/interactive/js/structure.js | 69 +++++++++------ anvio/data/interactive/js/svg-helpers.js | 12 +-- anvio/data/interactive/js/tree.js | 26 +++--- anvio/data/interactive/js/utils.js | 32 +++---- 24 files changed, 411 insertions(+), 206 deletions(-) diff --git a/anvio/data/interactive/js/animations.js b/anvio/data/interactive/js/animations.js index 16b99afbf3..e771bc2a12 100644 --- a/anvio/data/interactive/js/animations.js +++ b/anvio/data/interactive/js/animations.js @@ -1,3 +1,21 @@ +/** + * Functions for panel animations. + * + * Authors: Özcan Esen + * + * Copyright 2015-2021, The anvi'o project (http://anvio.org) + * + * Anvi'o is a free software. You can redistribute this program + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * You should have received a copy of the GNU General Public License + * along with anvi'o. If not, see . + * + * @license GPL-3.0+ + */ + var ANIMATIONS_ENABLED = true; var SLIDE_INTERVAL = 4; var SLIDE_STEP_SIZE = 15; @@ -11,7 +29,7 @@ function toggleLeftPanel() { is_left_panel_sliding = true; if ($('#panel-left').is(':visible')) { - var animation_frame = function(){ + var animation_frame = function(){ if (ANIMATIONS_ENABLED && $('#panel-left')[0].getBoundingClientRect().right > 0) { $('#panel-left').css('left', parseInt($('#panel-left').css('left')) - SLIDE_STEP_SIZE); $('#toggle-panel-left').css('left', $('#sidebar')[0].getBoundingClientRect().right + 'px'); @@ -28,7 +46,7 @@ function toggleLeftPanel() { animation_frame(); } else { $('#panel-left').show(); - var animation_frame = function(){ + var animation_frame = function(){ if (ANIMATIONS_ENABLED && $('#panel-left')[0].getBoundingClientRect().left < 0) { $('#panel-left').css('left', parseInt($('#panel-left').css('left')) + SLIDE_STEP_SIZE); $('#toggle-panel-left').css('left', $('#sidebar')[0].getBoundingClientRect().right + 'px'); @@ -50,7 +68,7 @@ function toggleRightPanel(name) { ['#mouse_hover_panel', '#description-panel', '#news-panel'].forEach(function(right_panel) { if (right_panel == name) return; - + $(right_panel).hide(); }); diff --git a/anvio/data/interactive/js/area-zoom.js b/anvio/data/interactive/js/area-zoom.js index 24b97881a1..40d1805e97 100644 --- a/anvio/data/interactive/js/area-zoom.js +++ b/anvio/data/interactive/js/area-zoom.js @@ -1,3 +1,22 @@ +/** + * Zooming in an out. + * + * Authors: Özcan Esen + * + * Copyright 2015-2021, The anvi'o project (http://anvio.org) + * + * Anvi'o is a free software. You can redistribute this program + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * You should have received a copy of the GNU General Public License + * along with anvi'o. If not, see . + * + * @license GPL-3.0+ + */ + + var mouse_event_origin_x = 0; var mouse_event_origin_y = 0; @@ -9,8 +28,8 @@ function initialize_area_zoom() { var viewport = document.getElementById('svg'); viewport.addEventListener('mousedown', - function(event) { - dragging = false; + function(event) { + dragging = false; document.activeElement.blur(); mouse_event_origin_x = event.clientX; @@ -28,11 +47,11 @@ function initialize_area_zoom() { } }); - viewport.addEventListener('mousemove', + viewport.addEventListener('mousemove', function(event) { if (Math.abs(mouse_event_origin_x - event.clientX) + Math.abs(mouse_event_origin_y - event.clientY) > 2) { - dragging = true; + dragging = true; } if (event.shiftKey && drawing_zoom) @@ -56,25 +75,25 @@ function initialize_area_zoom() { } }); - viewport.addEventListener('mouseup', + viewport.addEventListener('mouseup', function() { if (drawing_zoom) { var zoom_rect = document.getElementById('divzoom').getBoundingClientRect(); - + if (zoom_rect.width > 2 && zoom_rect.height > 2) { var _dx = (parseInt("0" + $('#svg').position().left) + (VIEWER_WIDTH / 2)) - (zoom_rect.left + zoom_rect.width / 2); var _dy = (parseInt("0" + $('#svg').position().top) + (VIEWER_HEIGHT / 2)) - (zoom_rect.top + zoom_rect.height / 2); - pan(_dx,_dy); + pan(_dx,_dy); zoom(Math.min(VIEWER_WIDTH / zoom_rect.width, VIEWER_HEIGHT / zoom_rect.height)); } } clearTextSelection(); - drawing_zoom=false; - zoomBox = {}; - $('#divzoom').hide(); + drawing_zoom=false; + zoomBox = {}; + $('#divzoom').hide(); }); } diff --git a/anvio/data/interactive/js/bin.js b/anvio/data/interactive/js/bin.js index 8f0f3650f6..8572c1169c 100644 --- a/anvio/data/interactive/js/bin.js +++ b/anvio/data/interactive/js/bin.js @@ -1,17 +1,16 @@ /** * Draw bins, bin labels stuff. * - * Author: Özcan Esen - * Credits: A. Murat Eren - * Copyright 2017, The anvio Project + * Authors: Özcan Esen + * A. Murat Eren + * + * Copyright 2015-2021, The anvi'o project (http://anvio.org) * - * This file is part of anvi'o (). - * * Anvi'o is a free software. You can redistribute this program - * and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, either + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either * version 3 of the License, or (at your option) any later version. - * + * * You should have received a copy of the GNU General Public License * along with anvi'o. If not, see . * @@ -125,7 +124,7 @@ Bins.prototype.NewBin = function(id, binState) { if (current_color != previous_color) { emit('bin-settings-changed'); - bins.PushHistory([{'type': 'ChangeColor', + bins.PushHistory([{'type': 'ChangeColor', 'bin_id': id, 'color-before': previous_color, 'color': current_color}]); @@ -184,13 +183,13 @@ Bins.prototype.DeleteBin = function(bin_id, show_confirm=true) { node.ResetColor(); if (this.keepHistory) { - transaction.push({'type': 'RemoveNode', + transaction.push({'type': 'RemoveNode', 'bin_id': bin_id, 'node': node}); } } - transaction.push({'type': 'DeleteBin', + transaction.push({'type': 'DeleteBin', 'bin_id': bin_id, 'name': document.getElementById('bin_name_' + bin_id).value, 'color': document.getElementById('bin_color_' + bin_id).getAttribute('color')}); @@ -211,7 +210,7 @@ Bins.prototype.DeleteBin = function(bin_id, show_confirm=true) { if (!this.container.querySelector('input[name=active_bin]:checked')) { this.SelectLastRadio(); } - + this.RedrawBins(); }; @@ -253,13 +252,13 @@ Bins.prototype.Redo = function() { } } -Bins.prototype.ProcessTransaction = function(transaction, reversed=false) { +Bins.prototype.ProcessTransaction = function(transaction, reversed=false) { this.keepHistory = false; this.allowRedraw = false; let updated_bins = new Set(); let removed_bins = new Set(); - + for (var i = 0; i < transaction.length; i++) { let operation = transaction[i]; @@ -278,7 +277,7 @@ Bins.prototype.ProcessTransaction = function(transaction, reversed=false) { $('#bin_color_' + operation.bin_id).css('background-color', operation['color-before']); break; case 'DeleteBin': - this.NewBin(operation.bin_id, {'name': operation.name, + this.NewBin(operation.bin_id, {'name': operation.name, 'color': operation.color}); removed_bins.delete(operation.bin_id); break; @@ -305,7 +304,7 @@ Bins.prototype.ProcessTransaction = function(transaction, reversed=false) { removed_bins.add(operation.bin_id); break; case 'NewBin': - this.NewBin(operation.bin_id, {'name': operation.name, + this.NewBin(operation.bin_id, {'name': operation.name, 'color': operation.color}); removed_bins.delete(operation.bin_id); break; @@ -368,7 +367,7 @@ Bins.prototype.AppendNode = function(targets, bin_id) { bins_to_update.add(other_bin_id); if (this.keepHistory && node.IsLeaf()) { - transaction.push({'type': 'RemoveNode', + transaction.push({'type': 'RemoveNode', 'bin_id': other_bin_id, 'node': node}); } @@ -380,16 +379,16 @@ Bins.prototype.AppendNode = function(targets, bin_id) { bins_to_update.add(bin_id); if (this.keepHistory && node.IsLeaf()) { - transaction.push({'type': 'AppendNode', + transaction.push({'type': 'AppendNode', 'bin_id': bin_id, 'node': node}); } } node.SetColor(bin_color); - } + } } - + bins_to_update = Array.from(bins_to_update); this.PushHistory(transaction); this.RedrawBins(); @@ -419,7 +418,7 @@ Bins.prototype.RemoveNode = function(targets, bin_id) { bins_to_update.add(bin_id); if (this.keepHistory && node.IsLeaf()) { - transaction.push({'type': 'RemoveNode', + transaction.push({'type': 'RemoveNode', 'bin_id': bin_id, 'node': node}); } @@ -449,7 +448,7 @@ Bins.prototype.IsNodeMemberOfBin = function(node) { Bins.prototype.BinsSorted = function() { // move every taxonomy row after their original parent. - this.container.querySelectorAll('[data-parent]').forEach((elem) => { + this.container.querySelectorAll('[data-parent]').forEach((elem) => { let taxonomy_row = elem.parentNode.removeChild(elem); let parent_bin_id = elem.getAttribute('data-parent'); @@ -471,7 +470,7 @@ Bins.prototype.UpdateBinsWindow = function(bin_list) { if (mode == 'pan') { let num_gene_clusters = 0; let num_gene_calls = 0; - + for (let node of this.selections[bin_id].values()) { if (node.IsLeaf()) { num_gene_clusters++; @@ -676,8 +675,8 @@ Bins.prototype.ImportCollection = function(collection, threshold = 1000) { if (mode != 'full') { nodes.push(collection['data'][bin_name][i]); - } - else if (typeof item_lengths[collection['data'][bin_name][i]] !== 'undefined') + } + else if (typeof item_lengths[collection['data'][bin_name][i]] !== 'undefined') { nodes.push(collection['data'][bin_name][i]); sum_length += item_lengths[collection['data'][bin_name][i]]; @@ -805,11 +804,11 @@ Bins.prototype.RedrawLineColors = function() { }; Bins.prototype.DrawInvertedNodes = function(leaf_list, rect_width){ - + var inverse_fill_opacity = $('#inverse_fill_opacity').val(); var inverse_color = document.getElementById('inverse_color').getAttribute('color'); - let nodes_for_inversion = [] - + let nodes_for_inversion = [] + for(let i = 0; i < leaf_list.length; i++){ //selecting all the nodes that aren't assigned to bins if(leaf_list[i] === -1){ nodes_for_inversion.push(drawer.tree.leaves.filter(leaf => leaf.order === i)) @@ -818,17 +817,17 @@ Bins.prototype.DrawInvertedNodes = function(leaf_list, rect_width){ nodes_for_inversion.map((node, idx) => { - let p1; - let p2; + let p1; + let p2; let p = node[0]; if(idx == [nodes_for_inversion.length - 1]){ - return // last node does not have 2 adjacent border nodes, throws error on GetBorderNodes() call + return // last node does not have 2 adjacent border nodes, throws error on GetBorderNodes() call } else { [p1, p2] = p.GetBorderNodes(); } - + if (tree_type == 'circlephylogram'){ let pie = drawPie( 'bin', @@ -850,9 +849,9 @@ Bins.prototype.DrawInvertedNodes = function(leaf_list, rect_width){ } else { let rect = drawPhylogramRectangle('bin', 'bin_background_' + idx, - p.xy.x, + p.xy.x, p.xy.y, - p.size, + p.size, rect_width, inverse_color, inverse_fill_opacity, @@ -914,8 +913,8 @@ Bins.prototype.RedrawBins = function() { // draw new bins var show_grid = $('#show_grid_for_bins')[0].checked; - var show_shade = $('#show_shade_for_bins')[0].checked; - var invert_shade = $('#invert_shade_for_bins')[0].checked; + var show_shade = $('#show_shade_for_bins')[0].checked; + var invert_shade = $('#invert_shade_for_bins')[0].checked; var shade_fill_opacity = $('#shade_fill_opacity').val(); var grid_color = document.getElementById('grid_color').getAttribute('color'); var grid_width = $('#grid_width').val(); @@ -924,7 +923,7 @@ Bins.prototype.RedrawBins = function() { var autorotate_bin_labels = $('#autorotate_bin_labels')[0].checked; var bin_labels_angle = $('#bin_labels_angle').val(); var background_starts_from_branch = $('#begins_from_branch').is(':checked'); - + var outer_ring_size = parseFloat($('#outer-ring-height').val()); var outer_ring_margin = parseFloat($('#outer-ring-margin').val()); @@ -939,7 +938,7 @@ Bins.prototype.RedrawBins = function() { var startAncestors = new Set(start.GetAncestors()); var endAncestors = new Set(end.GetAncestors()); var intersection = new Set([...startAncestors].filter(x => endAncestors.has(x))).values().next().value; - + if (typeof intersection === 'undefined') { throw `It seems Node:${start.id} and Node:${end.id} does not have common ancestor.`; } @@ -982,8 +981,8 @@ Bins.prototype.RedrawBins = function() { drawRotatedText( 'bin', { - 'x': bin_label_px, - 'y': bin_label_py, + 'x': bin_label_px, + 'y': bin_label_py, }, $('#bin_name_' + bins_to_draw[i][2]).val().replace("_", " "), (autorotate_bin_labels) ? new_angle : bin_labels_angle, @@ -1005,7 +1004,7 @@ Bins.prototype.RedrawBins = function() { (show_grid) ? total_radius + outer_ring_margin + outer_ring_size : total_radius, (Math.abs(end.angle - start.angle) + start.size / 2 + end.size / 2 > Math.PI) ? 1 : 0, color, - (show_grid) ? 0 : shade_fill_opacity, + (show_grid) ? 0 : shade_fill_opacity, false); if (show_grid && !show_shade) { @@ -1046,8 +1045,8 @@ Bins.prototype.RedrawBins = function() { drawRotatedText( 'bin', { - 'y': (start.xy.y - start.size / 2 + end.xy.y + end.size / 2) / 2 + (bin_labels_font_size / 3), - 'x': (total_radius + outer_ring_margin * 1.5 + outer_ring_size * (this.higlighted_items.length > 0 ? 2 : 1)), + 'y': (start.xy.y - start.size / 2 + end.xy.y + end.size / 2) / 2 + (bin_labels_font_size / 3), + 'x': (total_radius + outer_ring_margin * 1.5 + outer_ring_size * (this.higlighted_items.length > 0 ? 2 : 1)), }, $('#bin_name_' + bins_to_draw[i][2]).val().replace("_", " "), (autorotate_bin_labels) ? 0 : bin_labels_angle, @@ -1065,7 +1064,7 @@ Bins.prototype.RedrawBins = function() { width_with_grids = total_radius + outer_ring_margin + outer_ring_size - backgroundStart width_no_grids = total_radius - backgroundStart - // ^ these get passed to invert_shade method so we don't have to re-declare a bunch of other stuff. + // ^ these get passed to invert_shade method so we don't have to re-declare a bunch of other stuff. var rect = drawPhylogramRectangle('bin', 'bin_background_' + i, @@ -1113,7 +1112,7 @@ Bins.prototype.RedrawBins = function() { (node.size / 2 > Math.PI) ? 1 : 0, color, 1, - true); + true); } else { @@ -1128,7 +1127,7 @@ Bins.prototype.RedrawBins = function() { true); } } - invert_shade ? this.DrawInvertedNodes(leaf_list, show_grid ? width_with_grids : width_no_grids) : null + invert_shade ? this.DrawInvertedNodes(leaf_list, show_grid ? width_with_grids : width_no_grids) : null } @@ -1165,7 +1164,7 @@ Bins.prototype.RebuildIntersections = function() { this.selections[bin_id].delete(node); node.ResetColor(); } - } + } } while (inserted) { diff --git a/anvio/data/interactive/js/charts.js b/anvio/data/interactive/js/charts.js index c735fa57c1..2251ed9a79 100644 --- a/anvio/data/interactive/js/charts.js +++ b/anvio/data/interactive/js/charts.js @@ -1,11 +1,14 @@ /** * Javascript library to visualize anvi'o charts * - * Author: A. Murat Eren - * Credits: Özcan Esen, Gökmen Göksel, Tobias Paczian. - * Copyright 2015, The anvio Project + * Authors: A. Murat Eren + * Ozcan Esen + * Isaac Fink + * Matthew Klein + * Gökmen Göksel + * Tobias Paczian * - * This file is part of anvi'o (). + * Copyright 2015-2021, The anvi'o project (http://anvio.org) * * Anvi'o is a free software. You can redistribute this program * and/or modify it under the terms of the GNU General Public diff --git a/anvio/data/interactive/js/color-coding.js b/anvio/data/interactive/js/color-coding.js index c6e830f205..e353ec06de 100644 --- a/anvio/data/interactive/js/color-coding.js +++ b/anvio/data/interactive/js/color-coding.js @@ -1,10 +1,9 @@ /** * Javascript library to visualize anvi'o gene clusterss * - * Author: Mahmoud Yousef - * Copyright 2018, The anvio Project + * Authors: Mahmoud Yousef * - * This file is part of anvi'o (). + * Copyright 2018-2021, The anvi'o project (http://anvio.org) * * Anvi'o is a free software. You can redistribute this program * and/or modify it under the terms of the GNU General Public @@ -56,7 +55,7 @@ function colorAlgorithm(positions){ var _positions = [] for (aa in positions){ if (checked(positions[aa]) && aboveThreshold(positions, positions[aa])) { - _positions[aa] = color(positions, positions[aa]); + _positions[aa] = color(positions, positions[aa]); } else{ var dict = {} dict[positions[aa]] = "BLACK"; @@ -80,7 +79,7 @@ function checked(letter){ //does the actual comparisons //This checks for amino acid conservation by common characteristics -function aboveThreshold(positions, aa) { +function aboveThreshold(positions, aa) { var number = 0; for (acid in positions) { if (acid === '') { @@ -91,7 +90,7 @@ function aboveThreshold(positions, aa) { var count = 0.0; var count2 = 0.0; var count3 = 0.0; - + var letter = aa switch (letter) { case "A": @@ -238,7 +237,7 @@ function aboveThreshold(positions, aa) { break; default: break; } - return false; + return false; } @@ -275,7 +274,7 @@ function color(positions, aa){ case "Y": x = "DARKTURQUOISE"; break; - case "P": + case "P": x = "YELLOW"; break; case "C": @@ -315,15 +314,15 @@ function initializeCheckBoxes(){ box.onclick = ( function() { return createDisplay(); } ) - + var label = document.createElement('label') label.htmlFor = word; label.style = "margin-left:1px;"; label.appendChild(document.createTextNode(word)); - + container.appendChild(box); - container.appendChild(label); - box.checked = true + container.appendChild(label); + box.checked = true } container.appendChild(document.createElement('br')); diff --git a/anvio/data/interactive/js/constants.js b/anvio/data/interactive/js/constants.js index 7d24b675bb..6ac5562012 100644 --- a/anvio/data/interactive/js/constants.js +++ b/anvio/data/interactive/js/constants.js @@ -1,3 +1,23 @@ +/** + * Constants used from various interface functions + * + * Authors: A. Murat Eren + * Isaac Fink + * Ozcan Esen + * + * Copyright 2015-2021, The anvi'o project (http://anvio.org) + * + * Anvi'o is a free software. You can redistribute this program + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * You should have received a copy of the GNU General Public License + * along with anvi'o. If not, see . + * + * @license GPL-3.0+ + */ + var COG_categories = { 'A': '[A] RNA processing and modification', 'B': '[B] Chromatin Structure and dynamics', diff --git a/anvio/data/interactive/js/context-menu.js b/anvio/data/interactive/js/context-menu.js index 13ae77c32b..c0e13f750e 100644 --- a/anvio/data/interactive/js/context-menu.js +++ b/anvio/data/interactive/js/context-menu.js @@ -1,9 +1,9 @@ /** - * Handles right click menu + * Handles right click menu functions * - * Author: Özcan Esen - * Credits: A. Murat Eren - * Copyright 2018, The anvio Project + * Authors: Özcan Esen + * A. Murat Eren + * Matthew Klein * * This file is part of anvi'o (). * @@ -17,6 +17,7 @@ * * @license GPL-3.0+ */ + let outerLimit1; let outerLimit2; diff --git a/anvio/data/interactive/js/contigs-plot.js b/anvio/data/interactive/js/contigs-plot.js index e6f4f8f8e9..a616d73031 100644 --- a/anvio/data/interactive/js/contigs-plot.js +++ b/anvio/data/interactive/js/contigs-plot.js @@ -1,3 +1,21 @@ +/** + * Contigs db stats visualization + * + * Authors: Ozcan Esen + * + * Copyright 2015-2021, The anvi'o project (http://anvio.org) + * + * Anvi'o is a free software. You can redistribute this program + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * You should have received a copy of the GNU General Public License + * along with anvi'o. If not, see . + * + * @license GPL-3.0+ + */ + function draw_n_values_plot(container, stats) { var svg = d3.select(container) .append('svg') @@ -45,7 +63,7 @@ function draw_n_values_plot(container, stats) { .attr('height', tooltip_pos.height) .attr('fill-opacity', '0.7') .attr('width', tooltip_pos.width); - + var tooltip_text = tooltip.append('text') .attr('x', '10') .attr('y', '15') @@ -162,7 +180,7 @@ function draw_gene_counts_chart(container, gene_counts) { .attr('height', tooltip_pos.height) .attr('fill-opacity', '0.7') .attr('width', tooltip_pos.width); - + var tooltip_text = tooltip.append('text') .attr('x', '10') .attr('y', '15') diff --git a/anvio/data/interactive/js/drawer.js b/anvio/data/interactive/js/drawer.js index 756ea9a5d7..e3385939a3 100644 --- a/anvio/data/interactive/js/drawer.js +++ b/anvio/data/interactive/js/drawer.js @@ -1,11 +1,10 @@ /** - * Javascript library to display phylogenetic trees + * Javascript library to display phylogenetic trees and more * - * Author: Özcan Esen - * Credits: A. Murat Eren - * Copyright 2015, The anvio Project + * Authors: Özcan Esen + * A. Murat Eren * - * This file is part of anvi'o (). + * Copyright 2015-2021, The anvi'o project (http://anvio.org) * * Anvi'o is a free software. You can redistribute this program * and/or modify it under the terms of the GNU General Public diff --git a/anvio/data/interactive/js/geneclusters.js b/anvio/data/interactive/js/geneclusters.js index 30583cef8e..c4ef5ed483 100644 --- a/anvio/data/interactive/js/geneclusters.js +++ b/anvio/data/interactive/js/geneclusters.js @@ -1,11 +1,11 @@ /** * Javascript library to visualize anvi'o gene clusterss * - * Author: A. Murat Eren - * Credits: Özcan Esen - * Copyright 2016, The anvio Project + * Authors: A. Murat Eren + * Özcan Esen + * Mahmoud Yousef * - * This file is part of anvi'o (). + * Copyright 2016-2021, The anvi'o project (http://anvio.org) * * Anvi'o is a free software. You can redistribute this program * and/or modify it under the terms of the GNU General Public @@ -162,7 +162,7 @@ function createDisplay(){ if (gene_cluster_data.genomes.indexOf(layer) === -1) continue; - + var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); rect.setAttribute('x', 0); rect.setAttribute('y', y_cord); @@ -187,7 +187,7 @@ function createDisplay(){ sub_y_cord = y_cord + 5; gene_cluster_data.gene_caller_ids_in_genomes[layer].forEach(function (caller_id) { - sequence = gene_cluster_data.aa_sequences_in_gene_cluster[layer][caller_id]; + sequence = gene_cluster_data.aa_sequences_in_gene_cluster[layer][caller_id]; var text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); text.setAttribute('x', 0); text.setAttribute('y', sub_y_cord); @@ -232,7 +232,7 @@ function createDisplay(){ tspan.appendChild(document.createTextNode(acid)); tspan.setAttribute('style', 'alignment-baseline:text-before-edge'); text.appendChild(tspan); - } + } fragment.appendChild(text); @@ -267,7 +267,7 @@ function createDisplay(){ $('[data-toggle="popover"]').on('shown.bs.popover', function (e) { var popover = $(e.target).data("bs.popover").$tip; - + if ($(popover).css('top').charAt(0) === '-') { $(popover).css('top', '0px'); } diff --git a/anvio/data/interactive/js/genomeview.js b/anvio/data/interactive/js/genomeview.js index 4f8361aabb..095e2e9103 100644 --- a/anvio/data/interactive/js/genomeview.js +++ b/anvio/data/interactive/js/genomeview.js @@ -3,9 +3,9 @@ * * Authors: Isaac Fink * Matthew Klein - * Copyright 2021, The anvi'o project + * A. Murat Eren * - * This file is part of anvi'o (). + * Copyright 2021, The anvi'o project (http://anvio.org) * * Anvi'o is a free software. You can redistribute this program * and/or modify it under the terms of the GNU General Public @@ -18,7 +18,6 @@ * @license GPL-3.0+ */ - $(document).ready(function() { initData(); }); diff --git a/anvio/data/interactive/js/help-messages.js b/anvio/data/interactive/js/help-messages.js index 47222c471c..e1b8b7d493 100644 --- a/anvio/data/interactive/js/help-messages.js +++ b/anvio/data/interactive/js/help-messages.js @@ -1,3 +1,22 @@ +/** + * Constants for tooltips + * + * Authors: A. Murat Eren + * Ozcan Esen + * + * Copyright 2015-2021, The anvi'o project (http://anvio.org) + * + * Anvi'o is a free software. You can redistribute this program + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * You should have received a copy of the GNU General Public License + * along with anvi'o. If not, see . + * + * @license GPL-3.0+ + */ + var help_contents = { 'load-state-button': 'Load a previously stored visual state from the profile database', 'save-state-button': 'Save a snapshot of all user settings for layers into the profile database', diff --git a/anvio/data/interactive/js/inspectionutils.js b/anvio/data/interactive/js/inspectionutils.js index 46fc742600..c8d4094433 100644 --- a/anvio/data/interactive/js/inspectionutils.js +++ b/anvio/data/interactive/js/inspectionutils.js @@ -1,11 +1,11 @@ /** * Helper funcitons for amvi'o inspection pages * - * Author: A. Murat Eren - * Credits: Özcan Esen, Gökmen Göksel, Tobias Paczian. - * Copyright 2015, The anvio Project + * Authors: A. Murat Eren + * Ozcan Esen + * Isaac Fink * - * This file is part of anvi'o (). + * Copyright 2015-2021, The anvi'o project (http://anvio.org) * * Anvi'o is a free software. You can redistribute this program * and/or modify it under the terms of the GNU General Public diff --git a/anvio/data/interactive/js/main.js b/anvio/data/interactive/js/main.js index 7662d53e0f..acf5d6ceba 100644 --- a/anvio/data/interactive/js/main.js +++ b/anvio/data/interactive/js/main.js @@ -1,11 +1,11 @@ /** * Javascript library for anvi'o interactive interface * - * Author: Özcan Esen - * Credits: A. Murat Eren, Doğan Can Kilment - * Copyright 2015, The anvio Project + * Authors: A. Murat Eren + * Ozcan Esen + * Isaac Fink * - * This file is part of anvi'o (). + * Copyright 2015-2021, The anvi'o project (http://anvio.org) * * Anvi'o is a free software. You can redistribute this program * and/or modify it under the terms of the GNU General Public diff --git a/anvio/data/interactive/js/migrations.js b/anvio/data/interactive/js/migrations.js index 5cf3e48580..cb8404b428 100644 --- a/anvio/data/interactive/js/migrations.js +++ b/anvio/data/interactive/js/migrations.js @@ -1,3 +1,20 @@ +/** + * Javascript library for state migrations + * + * Authors: Ozcan Esen + * + * Copyright 2019-2021, The anvi'o project (http://anvio.org) + * + * Anvi'o is a free software. You can redistribute this program + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * You should have received a copy of the GNU General Public License + * along with anvi'o. If not, see . + * + * @license GPL-3.0+ + */ function migrate_state(state) { let current_version = state['version']; @@ -37,7 +54,7 @@ function migrate_state(state) { for (let layer_name in state['stack_bar_colors']) { let bar_names = layer_name.split('!')[1].split(';'); new_stack_bar_colors[layer_name] = {}; - + for (let j=0; j < bar_names.length; j++) { new_stack_bar_colors[layer_name][bar_names[j]] = state['stack_bar_colors'][layer_name][j]; } @@ -52,7 +69,7 @@ function migrate_state(state) { for (let layer_name in state['samples-stack-bar-colors'][group]) { let bar_names = layer_name.split('!')[1].split(';'); new_samples_stack_bar_colors[group][layer_name] = {}; - + for (let j=0; j < bar_names.length; j++) { new_samples_stack_bar_colors[group][layer_name][bar_names[j]] = state['samples-stack-bar-colors'][group][layer_name][j]; } @@ -70,6 +87,6 @@ function migrate_state(state) { toastr.error(`Anvi'o failed to upgrade the state. State will be ignored.`); return {} } - + return state; } diff --git a/anvio/data/interactive/js/mouse-events.js b/anvio/data/interactive/js/mouse-events.js index 7caafca84d..c27d25c1e7 100644 --- a/anvio/data/interactive/js/mouse-events.js +++ b/anvio/data/interactive/js/mouse-events.js @@ -1,10 +1,11 @@ /** * Javascript user input handler functions for anvi'o interactive interface * - * Author: Özcan Esen - * Copyright 2015, The anvio Project + * Authors: Ozcan Esen + * Matthew Klein + * A. Murat Eren * - * This file is part of anvi'o (). + * Copyright 2015-2021, The anvi'o project (http://anvio.org) * * Anvi'o is a free software. You can redistribute this program * and/or modify it under the terms of the GNU General Public diff --git a/anvio/data/interactive/js/multiple.js b/anvio/data/interactive/js/multiple.js index 4b74ef4ba6..6945722031 100644 --- a/anvio/data/interactive/js/multiple.js +++ b/anvio/data/interactive/js/multiple.js @@ -1,4 +1,21 @@ -// Edit Attributes For Multiple Layers +/** + * Edit Attributes For Multiple Layers + * + * Authors: Ozcan Esen + * Dogan Can Kilment + * + * Copyright 2015-2021, The anvi'o project (http://anvio.org) + * + * Anvi'o is a free software. You can redistribute this program + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * You should have received a copy of the GNU General Public License + * along with anvi'o. If not, see . + * + * @license GPL-3.0+ + */ $(document).ready(function() { $('.select_layer').on('change', function() { @@ -85,7 +102,7 @@ $(document).ready(function() { var row = $(this).parent().parent(); var combo = $(row).find(target_selector); - if (combo.find('option[value="' + new_val + '"]').length > 0) + if (combo.find('option[value="' + new_val + '"]').length > 0) { combo.val(new_val).trigger('change'); return; diff --git a/anvio/data/interactive/js/news.js b/anvio/data/interactive/js/news.js index 537d93c8c2..a8e15f9bdf 100644 --- a/anvio/data/interactive/js/news.js +++ b/anvio/data/interactive/js/news.js @@ -1,3 +1,23 @@ +/** + * Javascript library to display anvi'o news. + * + * Authors: Ozcan Esen + * Isaac Fink + * A. Murat Eren + * + * Copyright 2015-2021, The anvi'o project (http://anvio.org) + * + * Anvi'o is a free software. You can redistribute this program + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * You should have received a copy of the GNU General Public License + * along with anvi'o. If not, see . + * + * @license GPL-3.0+ + */ + $(document).ready(function() { checkNews(); }); diff --git a/anvio/data/interactive/js/sample.js b/anvio/data/interactive/js/sample.js index 1a4354b439..632c920469 100644 --- a/anvio/data/interactive/js/sample.js +++ b/anvio/data/interactive/js/sample.js @@ -1,3 +1,23 @@ +/** + * Javascript library to visualize additional layer info + * (previously known as samples db) + * + * Authors: Ozcan Esen + * A. Murat Eren + * + * Copyright 2015-2021, The anvi'o project (http://anvio.org) + * + * Anvi'o is a free software. You can redistribute this program + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * You should have received a copy of the GNU General Public License + * along with anvi'o. If not, see . + * + * @license GPL-3.0+ + */ + var samples_categorical_colors = {}; var samples_categorical_stats = {}; var samples_stack_bar_colors = {}; @@ -91,7 +111,7 @@ $(document).ready(function() { $('#group_select_all').click(function() { let target_group = $('#group_list_for_select_all').val(); - + $('#tbody_samples tr').each((index, tr) => { let group = $(tr).attr('samples-group-name'); @@ -103,7 +123,7 @@ $(document).ready(function() { $('#group_unselect_all').click(function() { let target_group = $('#group_list_for_select_all').val(); - + $('#tbody_samples tr').each((index, tr) => { let group = $(tr).attr('samples-group-name'); @@ -224,7 +244,7 @@ function update_samples_layer_min_max(select) { if (max === null || Math.sqrt(parseFloat(samples_information_dict[group][lname][sample_name])) > max) { max = Math.sqrt(parseFloat(samples_information_dict[group][lname][sample_name])); } - } + } else if (norm == 'log') { if (max === null || log10(parseFloat(samples_information_dict[group][lname][sample_name]) + 1) > max) { max = log10(parseFloat(samples_information_dict[group][lname][sample_name]) + 1); @@ -244,7 +264,7 @@ function buildSamplesTable(samples_layer_order, samples_layers) { let first_sample = Object.keys(samples_information_dict[group])[0]; for (let layer_name in samples_information_dict[group][first_sample]) { let found = false; - + for (const [index, entry] of all_information_layers.entries()) { if (entry['group'] == group && entry['layer_name'] == layer_name) { found = true; @@ -284,12 +304,12 @@ function buildSamplesTable(samples_layer_order, samples_layers) { var pretty_name = getNamedLayerDefaults(layer_name, 'pretty_name', layer_name); pretty_name = (pretty_name.indexOf('!') > -1) ? pretty_name.split('!')[0] : pretty_name; - + var short_name = (pretty_name.length > 10) ? pretty_name.slice(0,10) + "..." : pretty_name; var hasSettings = false; - if (typeof(samples_layers) !== 'undefined' && - typeof(samples_layers[group]) !== 'undefined' && + if (typeof(samples_layers) !== 'undefined' && + typeof(samples_layers[group]) !== 'undefined' && typeof(samples_layers[group][layer_name]) !== 'undefined') { hasSettings = true; layer_settings = samples_layers[group][layer_name]; @@ -298,8 +318,8 @@ function buildSamplesTable(samples_layer_order, samples_layers) { if (isNumber(samples_information_dict[group][first_sample][layer_name])) { var data_type = "numeric"; - - if (hasSettings) + + if (hasSettings) { var norm = layer_settings['normalization']; var min = layer_settings['min']['value']; @@ -362,10 +382,10 @@ function buildSamplesTable(samples_layer_order, samples_layers) { .replace(new RegExp('{max}', 'g'), max) .replace(new RegExp('{margin}', 'g'), margin); } - else if (layer_name.indexOf(';') > -1) + else if (layer_name.indexOf(';') > -1) { var data_type = "stack-bar"; - + if (hasSettings) { var norm = layer_settings['normalization']; @@ -411,7 +431,7 @@ function buildSamplesTable(samples_layer_order, samples_layers) { else { var data_type = "categorical"; - + if (hasSettings) { var height = layer_settings['height']; @@ -464,7 +484,7 @@ function buildSamplesTable(samples_layer_order, samples_layers) { } }).keyup(function() { $(this).colpickSetColor(this.value); - }); + }); } function drawSamples() { @@ -499,7 +519,7 @@ function drawSamplesLayers(settings) { var start = (samples_layer_settings['height'] == 0) ? 0 : samples_layer_settings['margin']; var end = start + samples_layer_settings['height']; - + if (i > 0) { start += samples_layer_boundaries[i-1][1]; @@ -562,7 +582,7 @@ function drawSamplesLayers(settings) { } samples_end = Math.max(layer_index); - if (samples_layer_settings['data-type'] == 'numeric') + if (samples_layer_settings['data-type'] == 'numeric') { var value = _samples_information_dict[group][sample_name][samples_layer_name]; var min = parseFloat(samples_layer_settings['min']['value']); @@ -609,7 +629,7 @@ function drawSamplesLayers(settings) { rect.setAttribute('sample-group', group); rect.setAttribute('layer-name', samples_layer_name); } - else if (samples_layer_settings['data-type'] == 'stack-bar') + else if (samples_layer_settings['data-type'] == 'stack-bar') { var norm = samples_layer_settings['normalization']; var stack_bar_items = _samples_information_dict[group][sample_name][samples_layer_name].split(';'); @@ -743,9 +763,9 @@ function drawSamplesLayers(settings) { drawText('samples', { 'x': layer_boundaries[samples_end][1] + 20, 'y': 0 - (samples_layer_boundaries[i][0] + samples_layer_boundaries[i][1]) / 2 + font_size / 6 - }, - getNamedLayerDefaults(samples_layer_name, 'pretty_name', samples_layer_name), - font_size + 'px', + }, + getNamedLayerDefaults(samples_layer_name, 'pretty_name', samples_layer_name), + font_size + 'px', 'left', samples_layer_settings['color'], 'baseline'); @@ -767,8 +787,8 @@ function drawSamplesLayers(settings) { drawText('samples', { 'x': layer_boundaries[samples_end][1] + 20, 'y': 0 - (samples_layer_boundaries[i][0] + samples_layer_boundaries[i][1]) / 2 + font_size / 6 - }, - getNamedLayerDefaults(samples_pretty_name, 'pretty_name', samples_pretty_name), + }, + getNamedLayerDefaults(samples_pretty_name, 'pretty_name', samples_pretty_name), font_size + 'px', 'left', '#919191', @@ -785,7 +805,7 @@ function drawSamplesLayers(settings) { font_size + 'px', 'left', samples_layer_settings['color'], - 'baseline'); + 'baseline'); } } } diff --git a/anvio/data/interactive/js/search.js b/anvio/data/interactive/js/search.js index 99b4af801a..d97fab239b 100644 --- a/anvio/data/interactive/js/search.js +++ b/anvio/data/interactive/js/search.js @@ -1,5 +1,22 @@ - -function searchContigs() +/** + * Search functions for the interactive interface. + * + * Authors: Ozcan Esen + * + * Copyright 2015-2021, The anvi'o project (http://anvio.org) + * + * Anvi'o is a free software. You can redistribute this program + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * You should have received a copy of the GNU General Public License + * along with anvi'o. If not, see . + * + * @license GPL-3.0+ + */ + +function searchContigs() { var svalue = $('#searchValue').val(); @@ -11,7 +28,7 @@ function searchContigs() var column = $('#searchLayerList').val(); search_column = (column == 0) ? 'Item Name' : layerdata[0][column]; var operator = $('#searchOperator').val(); - + if (operator < 6) { var operator_text = $('#searchOperator option:selected').text(); @@ -81,7 +98,7 @@ function searchFunctions() { var _accession = data['results'][i][3]; var _annotation = data['results'][i][4]; var _search_term = data['results'][i][5]; - var _split_name = data['results'][i][6]; + var _split_name = data['results'][i][6]; } else { @@ -94,10 +111,10 @@ function searchFunctions() { } var _beginning = _annotation.toLowerCase().indexOf(_search_term.toLowerCase()); - _annotation = [_annotation.slice(0, _beginning), - '', - _annotation.slice(_beginning, _beginning + _search_term.length), - '', + _annotation = [_annotation.slice(0, _beginning), + '', + _annotation.slice(_beginning, _beginning + _search_term.length), + '', _annotation.slice(_beginning + _search_term.length, _annotation.length) ].join(""); @@ -196,11 +213,11 @@ function highlightResult() { highlighted_splits.push(search_results[i]['split']); } - bins.HighlightItems(highlighted_splits); + bins.HighlightItems(highlighted_splits); } function highlightSplit(name) { - bins.HighlightItems(name); + bins.HighlightItems(name); } function appendResult() { diff --git a/anvio/data/interactive/js/structure.js b/anvio/data/interactive/js/structure.js index c4dffc62ed..b3bb2317db 100644 --- a/anvio/data/interactive/js/structure.js +++ b/anvio/data/interactive/js/structure.js @@ -1,3 +1,22 @@ +/** + * Javascript library to visualize gene structures + * + * Authors: Evan Kiefl + * Ozcan Esen + * + * Copyright 2015-2021, The anvi'o project (http://anvio.org) + * + * Anvi'o is a free software. You can redistribute this program + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * You should have received a copy of the GNU General Public License + * along with anvi'o. If not, see . + * + * @license GPL-3.0+ + */ + const mode = 'structure'; const MAX_NGL_WIDGETS = 16; @@ -82,8 +101,8 @@ $(document).ready(function() { url: '/data/get_initial_data?timestamp=' + new Date().getTime(), success: function(data) { let available_gene_callers_ids = data['available_gene_callers_ids']; - let available_engines = data['available_engines']; - sample_groups = data['sample_groups']; + let available_engines = data['available_engines']; + sample_groups = data['sample_groups']; available_gene_callers_ids.forEach(function(gene_callers_id) { $('#gene_callers_id_list').append(``); @@ -134,7 +153,7 @@ function load_sample_group_widget(category, trigger_create_ngl_views=true) { - `; @@ -175,7 +194,7 @@ function load_sample_group_widget(category, trigger_create_ngl_views=true) { function apply_orientation_matrix_to_all_stages(orientationMatrix) { for (let group in stages) { - stages[group].viewerControls.orient(orientationMatrix); + stages[group].viewerControls.orient(orientationMatrix); } cached_orientation_matrices[$('#gene_callers_id_list').val()] = orientationMatrix; } @@ -217,8 +236,8 @@ async function create_single_ngl_view(group, num_rows, num_columns) { var defer = $.Deferred(); $('#ngl-container').append(` -
${group} @@ -347,7 +366,7 @@ async function create_single_ngl_view(group, num_rows, num_columns) { if (pickingProxy && pickingProxy.atom) { if (pickingProxy.atom.resno != previous_hovered_residue && !(['always', 'variant residue'].includes($('#show_ballstick_when').val()))) { - // remove ball+stick if hovered residue changed or + // remove ball+stick if hovered residue changed or if (pickingProxy.atom.resno != previous_hovered_residue) { stage.compList[0].reprList.slice(0).forEach((rep) => { if (rep.name == 'ball+stick') { @@ -373,7 +392,7 @@ async function create_single_ngl_view(group, num_rows, num_columns) { for (i in contacts) { if (contacts[i] == String(residue)) { variant_contacts.push(contacts[i]); - } + } else if (variability[group].hasOwnProperty(parseInt(contacts[i]))) { variant_contacts.push(contacts[i]); } @@ -929,7 +948,7 @@ function draw_variability() { } else { - spacefill_options['color'] = color_legend[engine][column][column_value]; + spacefill_options['color'] = color_legend[engine][column][column_value]; } } else { spacefill_options['color'] = $('#color_static').attr('color'); @@ -1100,13 +1119,13 @@ function create_ui() { $(container).append(`
${item['title']}

- - +
@@ -1221,7 +1240,7 @@ function onTargetColumnChange(element) { $(`#${prefix}_min`).val(selected_column_info['min']); $(`#${prefix}_max`).val(selected_column_info['max']); - } + } else { $(`#${prefix}_numerical_panel`).hide(); @@ -1237,7 +1256,7 @@ function onTargetColumnChange(element) { if (prefix == 'color') { $(`#color_legend_panel`).append(`
-
' + state_name + ''); } @@ -1798,7 +1817,7 @@ function showSaveStateWindow() }); } -function saveState() +function saveState() { var name = $('#saveState_name').val(); diff --git a/anvio/data/interactive/js/svg-helpers.js b/anvio/data/interactive/js/svg-helpers.js index eb81b14767..6b46d8b168 100644 --- a/anvio/data/interactive/js/svg-helpers.js +++ b/anvio/data/interactive/js/svg-helpers.js @@ -1,12 +1,12 @@ /** - * SVG drawing functions. + * Helper functions to draw SVG objects. * - * Author: Özcan Esen - * Credits: A. Murat Eren - * Copyright 2017, The anvio Project - * - * This file is part of anvi'o (). + * Authors: Ozcan Esen + * Matthew Klein + * A. Murat Eren * + * Copyright 2015-2021, The anvi'o project (http://anvio.org) + * Anvi'o is a free software. You can redistribute this program * and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation, either diff --git a/anvio/data/interactive/js/tree.js b/anvio/data/interactive/js/tree.js index 03f4c8d570..62013158fb 100644 --- a/anvio/data/interactive/js/tree.js +++ b/anvio/data/interactive/js/tree.js @@ -1,17 +1,17 @@ /** * Javascript library to parse newick trees * - * Author: Özcan Esen - * Credits: A. Murat Eren - * Copyright 2015, The anvio Project + * Authors: Özcan Esen + * Matthew Klein + * A. Murat Eren + * + * Copyright 2015-2021, The anvi'o project (http://anvio.org) * - * This file is part of anvi'o (). - * * Anvi'o is a free software. You can redistribute this program - * and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, either + * and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, either * version 3 of the License, or (at your option) any later version. - * + * * You should have received a copy of the GNU General Public License * along with anvi'o. If not, see . * @@ -330,7 +330,7 @@ Tree.prototype.Parse = function(str, edge_length_norm) { i++; if (isNumber(token[i])) { curnode.original_edge_length = parseFloat(token[i]); - + // normalization of edge lengths if (edge_length_norm) { curnode.edge_length = Math.sqrt(parseFloat(token[i]) * 1000000) / 1000000; @@ -461,7 +461,7 @@ function NodeIterator(root) } -NodeIterator.prototype.Begin = function() +NodeIterator.prototype.Begin = function() { /* if (this.root.constructor === Array) { @@ -478,7 +478,7 @@ NodeIterator.prototype.Begin = function() }; -NodeIterator.prototype.Next = function() +NodeIterator.prototype.Next = function() { /* if (this.root.constructor === Array) { @@ -522,14 +522,14 @@ function PreorderIterator() }; -PreorderIterator.prototype.Begin = function() +PreorderIterator.prototype.Begin = function() { this.cur = this.root; return this.cur; }; -PreorderIterator.prototype.Next = function() +PreorderIterator.prototype.Next = function() { if (this.cur.child) { diff --git a/anvio/data/interactive/js/utils.js b/anvio/data/interactive/js/utils.js index 6b815c426c..ffe4ba7622 100644 --- a/anvio/data/interactive/js/utils.js +++ b/anvio/data/interactive/js/utils.js @@ -1,10 +1,10 @@ /** * Utility functions for anvi'o interactive interface * - * Author: Özcan Esen - * Copyright 2015, The anvio Project + * Authors: Özcan Esen + * A. Murat Eren * - * This file is part of anvi'o (). + * Copyright 2015-2021, The anvi'o project (http://anvio.org) * * Anvi'o is a free software. You can redistribute this program * and/or modify it under the terms of the GNU General Public @@ -93,13 +93,13 @@ function fire_up_ncbi_blast(sequence, program, database, target) if (typeof program !== 'undefined') post_variables['PROGRAM'] = program; - + if (typeof database !== 'undefined') post_variables['DATABASE'] = database; var blast_window = window.open('about:blank', '_blank'); var form = document.createElement('form'); - + form.action = 'https://blast.ncbi.nlm.nih.gov/Blast.cgi'; form.method = 'POST'; @@ -134,7 +134,7 @@ function generate_inspect_link(options) { } else if (type == 'inspect_gene') { new_url = 'charts.html?id=' + item_name + '&highlight_gene=true&gene_mode=true'; - } + } else if (type == 'inspect_geneclusters') { new_url = 'geneclusters.html?id=' + item_name; } @@ -478,37 +478,37 @@ function strip(html) } //-------------------------------------------------------------------------------------------------- -function clearMinMax(selectbox) +function clearMinMax(selectbox) { var tr = $(selectbox).parent().parent(); $(tr).find('.input-min').val('0').prop('disabled', true); - $(tr).find('.input-max').val('0').prop('disabled', true); + $(tr).find('.input-max').val('0').prop('disabled', true); } function togglePickerStart(selectbox, togglePicker) { var tr = $(selectbox).parent().parent(); - if(selectbox.value=='intensity' || selectbox.value=='line' || selectbox.value=='text') { + if(selectbox.value=='intensity' || selectbox.value=='line' || selectbox.value=='text') { $(tr).find('.picker_start').css('visibility', 'visible'); if (togglePicker) { $(tr).find('.picker_end').css('visibility', 'visible'); $(tr).find('.input-height').css('visibility', 'hidden'); $('.max-font-size-input').show(); } - } else { + } else { $(tr).find('.picker_start').css('visibility', 'hidden'); if (togglePicker) { $(tr).find('.picker_end').css('visibility', 'hidden'); $(tr).find('.input-height').css('visibility', 'visible'); $(tr).find('.input-height').val('30'); } - } + } } /* Poor man's timer. - * + * * function ...(...) { * var my_timer = new BasicTimer('my_func'); * (...) @@ -519,7 +519,7 @@ function togglePickerStart(selectbox, togglePicker) * my_timer.getDeltaSeconds('End'); * } * - */ + */ function BasicTimer(name) { this.name = name; this.start = new Date().getTime(); @@ -531,7 +531,7 @@ function BasicTimer(name) { deltaSecondsPrev = (this.now - this.previousDelta) / 1000; this.previousDelta = this.now; - + consoleOutput = typeof consoleOutput !== 'undefined' ? consoleOutput: true; prettyText = this.name + ' [' + event + ']: ' + readableNumber(deltaSecondsPrev) + ' seconds (' + readableNumber(deltaSecondsStart) + ' seconds since beginning)'; @@ -646,9 +646,9 @@ function removeSingleParents() { // layerdata and parameter count is global - for (var i = 1; i < parameter_count; i++) + for (var i = 1; i < parameter_count; i++) { - if (layerdata[0][i] == '__parent__') + if (layerdata[0][i] == '__parent__') { var parent_count_dict = {}; for (var j=1; j < layerdata.length; j++) From 86ecc6c8705186e6f75ca08098b0f53a3f6f8075 Mon Sep 17 00:00:00 2001 From: Isaac Fink Date: Tue, 13 Apr 2021 11:18:20 -0500 Subject: [PATCH 0015/1020] add functionality from testing branch --- anvio/data/interactive/css/genomeview.css | 130 +++++++ anvio/data/interactive/genomeview.html | 198 +++++++++- anvio/data/interactive/js/genomeview.js | 357 ++++++++++++++++++ anvio/data/interactive/lib/fabric.js | 1 + .../lib/genomeViewIGDDAta/genedata_1001.json | 1 + .../lib/genomeViewIGDDAta/genedata_437.json | 1 + .../lib/genomeViewIGDDAta/genedata_798.json | 1 + 7 files changed, 680 insertions(+), 9 deletions(-) create mode 100644 anvio/data/interactive/css/genomeview.css create mode 100644 anvio/data/interactive/lib/fabric.js create mode 100644 anvio/data/interactive/lib/genomeViewIGDDAta/genedata_1001.json create mode 100644 anvio/data/interactive/lib/genomeViewIGDDAta/genedata_437.json create mode 100644 anvio/data/interactive/lib/genomeViewIGDDAta/genedata_798.json diff --git a/anvio/data/interactive/css/genomeview.css b/anvio/data/interactive/css/genomeview.css new file mode 100644 index 0000000000..32d8d3d44b --- /dev/null +++ b/anvio/data/interactive/css/genomeview.css @@ -0,0 +1,130 @@ +.container { + width: 95%; //this is being overwritten though. + align-content: center; + margin: 0 auto 20px auto; + background: rgba(255,255,255,0.5); + box-shadow: 1px 1px 4px rgba(0,0,0,0.2); + padding: 20px 30px; + touch-action: none; +} + +#myCanvas { +} + + +#tooltip-body{ + height: 300px; + width: 300px; + background-color: lavenderblush; + opacity: 85%; + border-style: solid; + border-width: 3px; + border-radius: 15px; +} + + +#toggle-panel-settings { + position: fixed; + height: 100px; + width: 15px; + background-color: #EEEEEE; + border: solid 1px #DDDDDD; + top: calc(40%); + border-radius: 10px 0px 0px 10px; + cursor: pointer; + font-size: 10px; + padding-top: 14px; + right: 0px; + z-index: 999; +} + +#settings-panel { + display: none; + top: 0px; + right: 0px; + position: fixed; + height: 100%; + background: url('../images/fractal.jpg') center center scroll; + border-left: 1px solid #D3D3D3; + opacity: 0.9; + width: 420px; + padding: 20px; + font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; + overflow-y: scroll; + z-index: 999; + color: black; +} + +.settings-header { + font-variant: small-caps; + font-size: 1.2em; + border-bottom: 1px #969696 solid; + display: block; + margin-bottom: 5px; + margin-top: 12px; +} + +.settings-section-info { + background: #e7f3381a; + padding: 3px 6px 5px 10px; + border: 1px dashed #a9a9a9; + border-radius: 9px; + font-size: 12px; +} + +#settings-section-info-SNV-warning { + display: none; + color: red; +} + +#settings-panel code { + padding: 1.4px 2px; + font-size: 90%; + color: #c7254e; + background-color: #f3f3f3; + border-radius: 2px; +} + +.settings-info-line { + text-align: center; + border: 1px dashed #c5c5c5; + background: #f3f3f3; + width: 40%; + margin: auto; + border-radius: 7px; + font-style: italic; +} + +.toggle-panel-settings-pos { + right: 420px !important; +} + +#settings-panel .btn { + margin-bottom: 5px !important; +} + +.sidebar-footer { + position: fixed; + background-color: white; + width: 420px; + bottom: -0px; + border-top: 1px solid #D3D3D3; + border-right: 1px solid #D3D3D3; +} + +.sidebar-footer > .btn { + width: 50%; +} + +body{ + font-family: 'Lato', Arial, serif; + font-weight: 300; + font-size: 14px; + color: #888; + -webkit-font-smoothing: antialiased; +} + +a{ + color: #722; + text-decoration: none; +} diff --git a/anvio/data/interactive/genomeview.html b/anvio/data/interactive/genomeview.html index f852ec9d12..ed16297d22 100644 --- a/anvio/data/interactive/genomeview.html +++ b/anvio/data/interactive/genomeview.html @@ -1,15 +1,195 @@ - + + + + Genome View + + + + + + + + - - Genome View - + + + + + + +
+ +
- - +
+ SETTINGS +
- - +
+ + + +
+ + + + + + +
+ diff --git a/anvio/data/interactive/js/genomeview.js b/anvio/data/interactive/js/genomeview.js index 095e2e9103..388ab380b4 100644 --- a/anvio/data/interactive/js/genomeview.js +++ b/anvio/data/interactive/js/genomeview.js @@ -18,8 +18,318 @@ * @license GPL-3.0+ */ + var VIEWER_WIDTH = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth; + + var canvas; + var genomeMax = 0; + var genomes; + + // Settings vars + + var spacing = 30; // genome spacing + var showLabels = true; // show genome labels? + var showScale = true; // show nt scale? + var scale = 100; // nt scale intervals + + var alignToGC = null; + + var color_db; + var cog_annotated = true, kegg_annotated = false; + // doesn't make sense to iterate through every gene with dozens of genomes... + // will need to find an efficient way to find these automatically + +var genomeData; + $(document).ready(function() { initData(); + + function loadAll() { + canvas = new fabric.Canvas('myCanvas'); + $('#tooltip-body').hide() // set initual tooltip hide value + $('#toggle_label_box').attr("checked", showLabels); + + // can either set it on the canvas to check for all arrows, or when arrow is created. + canvas.on('mouse:down', function(options) { + if(options.target && options.target.id == 'arrow') { + options.target.set('fill', options.target.fill=="red" ? "blue" : 'red'); + var testid = options.target.gene.gene_callers_id; + console.log(options.target.gene); + } + }); + + canvas.on('mouse:over', (event) => { + if(event.target && event.target.id === 'arrow'){ + showToolTip(event) + } + }) + + canvas.on('mouse:out', (event) => { + $('#tooltip-body').html('').hide() + }) + + function showToolTip(event){ + $('#tooltip-body').show().append(` +

+ + + + + + + + + +
DataValue
Split${event.target.gene.split}
Start in Contig${event.target.gene.start_in_contig}
Length${event.target.gene.length}
Gene Callers ID${event.target.gene.gene_callers_id}
Gene Cluster${idToGC[event.target.gene.gene_callers_id]}
+ + + `).css({'position' : 'absolute', 'left' : event.e.clientX, 'top' : event.e.clientY }) + } + + genomes = [contig437, contig1001, contig798]; + + $('#gene_color_order').append($('
From bc31fbf05ad683c899a8490ce084f9e68ab40685 Mon Sep 17 00:00:00 2001 From: Matthew Klein Date: Tue, 22 Mar 2022 13:42:23 +0000 Subject: [PATCH 0631/1020] don't clear out bookmarks select --- anvio/data/interactive/js/genomeview/ui.js | 1 - 1 file changed, 1 deletion(-) diff --git a/anvio/data/interactive/js/genomeview/ui.js b/anvio/data/interactive/js/genomeview/ui.js index b294bc118c..ed1b33c724 100644 --- a/anvio/data/interactive/js/genomeview/ui.js +++ b/anvio/data/interactive/js/genomeview/ui.js @@ -742,7 +742,6 @@ function createBookmark(){ toastr.success('bookmark successfully created :)') $('#create_bookmark_input').val('') $('#create_bookmark_description').val('') - $('#bookmarks-select').empty() settings['display']['bookmarks'].map(bookmark => { $('#bookmarks-select').append((new Option(bookmark['name'], [bookmark["start"], bookmark['stop']]))) From b5aee7384b366bf50266df1c300bc1f1f72ea4a4 Mon Sep 17 00:00:00 2001 From: Matthew Klein Date: Tue, 22 Mar 2022 13:56:16 +0000 Subject: [PATCH 0632/1020] actually DO empty select, but add back default option --- anvio/data/interactive/js/genomeview/ui.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/anvio/data/interactive/js/genomeview/ui.js b/anvio/data/interactive/js/genomeview/ui.js index ed1b33c724..c9cfae43b9 100644 --- a/anvio/data/interactive/js/genomeview/ui.js +++ b/anvio/data/interactive/js/genomeview/ui.js @@ -742,6 +742,8 @@ function createBookmark(){ toastr.success('bookmark successfully created :)') $('#create_bookmark_input').val('') $('#create_bookmark_description').val('') + $('#bookmarks-select').empty() + $('#bookmarks-select').prepend('') settings['display']['bookmarks'].map(bookmark => { $('#bookmarks-select').append((new Option(bookmark['name'], [bookmark["start"], bookmark['stop']]))) @@ -757,6 +759,7 @@ function createBookmark(){ function respondToBookmarkSelect(){ $('#bookmarks-select').change(function(e){ let [start, stop] = [$(this).val().split(',')[0], $(this).val().split(',')[1] ] + if(!stop)return // edge case for empty 'Bookmarks' placeholder select value $('#brush_start').val(start); $('#brush_end').val(stop); try { From 44321d0084aa6ce49c5a78eabfd82df9b1f4bc2a Mon Sep 17 00:00:00 2001 From: Isaac Fink Date: Thu, 24 Mar 2022 14:36:45 -0500 Subject: [PATCH 0633/1020] fix --- anvio/data/interactive/js/genomeview/drawer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anvio/data/interactive/js/genomeview/drawer.js b/anvio/data/interactive/js/genomeview/drawer.js index d064c21815..b6cfa34705 100644 --- a/anvio/data/interactive/js/genomeview/drawer.js +++ b/anvio/data/interactive/js/genomeview/drawer.js @@ -502,7 +502,7 @@ GenomeDrawer.prototype.geneArrow = function (gene, geneID, y, genomeID, style) { id: 'arrow', groupID: genomeID, lockMovementY: true, - selectable: false, + selectable: true, hasControls: false, hasBorders: false, lockScaling: true, From f3cd5bd186480db970241c09279d4f0d958c7be1 Mon Sep 17 00:00:00 2001 From: Matthew Klein Date: Sat, 26 Mar 2022 22:26:00 +0000 Subject: [PATCH 0634/1020] on query, don't zoom in small sequences --- .../data/interactive/js/genomeview/drawer.js | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/anvio/data/interactive/js/genomeview/drawer.js b/anvio/data/interactive/js/genomeview/drawer.js index b6cfa34705..abe84110a6 100644 --- a/anvio/data/interactive/js/genomeview/drawer.js +++ b/anvio/data/interactive/js/genomeview/drawer.js @@ -768,14 +768,18 @@ GenomeDrawer.prototype.queryFunctions = function () { return } let lowestStart, highestEnd = null - glowPayload.map(gene => { - let genomeOfInterest = this.settings['genomeData']['genomes'].filter(genome => genome[0] == gene['genomeID']) - let start = genomeOfInterest[0][1]['genes']['gene_calls'][gene['geneID']]['start'] - let end = genomeOfInterest[0][1]['genes']['gene_calls'][gene['geneID']]['stop'] - - if (start < lowestStart || lowestStart == null) lowestStart = start - if (end > highestEnd || highestEnd == null) highestEnd = end - }) + if(genomeMax < 35000){ + glowPayload.map(gene => { + let genomeOfInterest = this.settings['genomeData']['genomes'].filter(genome => genome[0] == gene['genomeID']) + let start = genomeOfInterest[0][1]['genes']['gene_calls'][gene['geneID']]['start'] + let end = genomeOfInterest[0][1]['genes']['gene_calls'][gene['geneID']]['stop'] + if (start < lowestStart || lowestStart == null) lowestStart = start + if (end > highestEnd || highestEnd == null) highestEnd = end + }) + } else { + lowestStart = 0 + highestEnd = genomeMax + } $('#function-query-results-statement').text(`Retreived ${glowPayload.length} hit(s) from ${Object.keys(foundInGenomes).length} genomes`) zoomOut('partial', lowestStart, highestEnd) @@ -800,14 +804,19 @@ GenomeDrawer.prototype.queryMetadata = function(metadataLabel){ return } let lowestStart, highestEnd = null - glowPayload.map(gene => { - let genomeOfInterest = this.settings['genomeData']['genomes'].filter(genome => genome[0] == gene['genomeID']) - let start = genomeOfInterest[0][1]['genes']['gene_calls'][gene['geneID']]['start'] - let end = genomeOfInterest[0][1]['genes']['gene_calls'][gene['geneID']]['stop'] - - if (start < lowestStart || lowestStart == null) lowestStart = start - if (end > highestEnd || highestEnd == null) highestEnd = end - }) + if genomeMax > 35000 { + glowPayload.map(gene => { + let genomeOfInterest = this.settings['genomeData']['genomes'].filter(genome => genome[0] == gene['genomeID']) + let start = genomeOfInterest[0][1]['genes']['gene_calls'][gene['geneID']]['start'] + let end = genomeOfInterest[0][1]['genes']['gene_calls'][gene['geneID']]['stop'] + + if (start < lowestStart || lowestStart == null) lowestStart = start + if (end > highestEnd || highestEnd == null) highestEnd = end + }) + } else { + lowestStart = 0 + highestEnd = genomeMax + } zoomOut('partial', lowestStart, highestEnd) this.glowGenes(glowPayload) } From 0f2e5e18663f873b35d452e24870a415b750c121 Mon Sep 17 00:00:00 2001 From: Matthew Klein Date: Sat, 26 Mar 2022 22:40:19 +0000 Subject: [PATCH 0635/1020] fix --- anvio/data/interactive/js/genomeview/drawer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anvio/data/interactive/js/genomeview/drawer.js b/anvio/data/interactive/js/genomeview/drawer.js index abe84110a6..0ffcfd30cb 100644 --- a/anvio/data/interactive/js/genomeview/drawer.js +++ b/anvio/data/interactive/js/genomeview/drawer.js @@ -804,7 +804,7 @@ GenomeDrawer.prototype.queryMetadata = function(metadataLabel){ return } let lowestStart, highestEnd = null - if genomeMax > 35000 { + if (genomeMax > 35000) { glowPayload.map(gene => { let genomeOfInterest = this.settings['genomeData']['genomes'].filter(genome => genome[0] == gene['genomeID']) let start = genomeOfInterest[0][1]['genes']['gene_calls'][gene['geneID']]['start'] From 6b8f9e052fa1308436216eea1b7bf3be8c31245b Mon Sep 17 00:00:00 2001 From: Matthew Klein Date: Sat, 26 Mar 2022 22:40:43 +0000 Subject: [PATCH 0636/1020] dblclick outside tooltip to close --- anvio/data/interactive/js/genomeview/ui.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/anvio/data/interactive/js/genomeview/ui.js b/anvio/data/interactive/js/genomeview/ui.js index c9cfae43b9..63b78666b4 100644 --- a/anvio/data/interactive/js/genomeview/ui.js +++ b/anvio/data/interactive/js/genomeview/ui.js @@ -287,6 +287,14 @@ function setEventListeners(){ }) } function showDeepDiveToolTip(event){ + + $('.canvas-container').dblclick(function(){ + if($("#deepdive-tooltip-body").is(":visible")){ + $("#deepdive-tooltip-body").hide() + } + console.log('beep'); + }) + $('#tooltip-body').html('').hide() // empty out & hide any previous tooltip instances $('#deepdive-tooltip-body').html('').hide() let totalMetadataString = String() From 3547ac82b46eac43de3de7b7a04ff3b83fae09eb Mon Sep 17 00:00:00 2001 From: Matthew Klein Date: Sat, 26 Mar 2022 22:45:58 +0000 Subject: [PATCH 0637/1020] genomeview-db is required, right? --- anvio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anvio/__init__.py b/anvio/__init__.py index 6cdac8fb3c..a470009998 100644 --- a/anvio/__init__.py +++ b/anvio/__init__.py @@ -139,7 +139,7 @@ def TABULATE(table, header, numalign="right", max_width=0): 'genome-view-db': ( ['-E', '--genome-view-db'], {'metavar': "GENOME_VIEW_DB", - 'required': False, + 'required': True, 'help': "Anvi'o genome view database."} ), 'only-if-structure': ( From 33a1f55a62a7ba47b4799dd67054684f8938560f Mon Sep 17 00:00:00 2001 From: Matthew Klein Date: Sat, 26 Mar 2022 23:09:22 +0000 Subject: [PATCH 0638/1020] populate results table for query hits --- anvio/data/interactive/genomeview.html | 12 ++++++++++++ anvio/data/interactive/js/genomeview/drawer.js | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/anvio/data/interactive/genomeview.html b/anvio/data/interactive/genomeview.html index 05ab7ab0d0..f6f1fbde26 100644 --- a/anvio/data/interactive/genomeview.html +++ b/anvio/data/interactive/genomeview.html @@ -124,10 +124,22 @@ +

+ + + + + + + + + + +
Gene IDGenomeStartStopAction
Genomes diff --git a/anvio/data/interactive/js/genomeview/drawer.js b/anvio/data/interactive/js/genomeview/drawer.js index 0ffcfd30cb..f4906eeeeb 100644 --- a/anvio/data/interactive/js/genomeview/drawer.js +++ b/anvio/data/interactive/js/genomeview/drawer.js @@ -768,13 +768,24 @@ GenomeDrawer.prototype.queryFunctions = function () { return } let lowestStart, highestEnd = null - if(genomeMax < 35000){ + if(genomeMax > 35000){ glowPayload.map(gene => { let genomeOfInterest = this.settings['genomeData']['genomes'].filter(genome => genome[0] == gene['genomeID']) let start = genomeOfInterest[0][1]['genes']['gene_calls'][gene['geneID']]['start'] let end = genomeOfInterest[0][1]['genes']['gene_calls'][gene['geneID']]['stop'] + gene['start'] = start + gene['stop'] = end if (start < lowestStart || lowestStart == null) lowestStart = start if (end > highestEnd || highestEnd == null) highestEnd = end + $('#query-results-table').append(` + + ${gene['geneID']} + ${gene['genomeID']} + ${gene['start']} + ${gene['stop']} +
-

metadata

+

color

+
+

set gene arrow color

+
+

metadata

@@ -361,10 +365,10 @@ function showDeepDiveToolTip(event){
- - - ${totalMetadataString} - + + + ${totalMetadataString} +
metadataaction
metadataaction
@@ -451,6 +455,30 @@ function showDeepDiveToolTip(event){ drawer.queryMetadata(metadataLabel) }) }) + $('#picker_tooltip').colpick({ + layout: 'hex', + submit: 0, + colorScheme: 'light', + onChange: function(hsb, hex, rgb, el, bySetColor) { + $(el).css('background-color', '#' + hex); + $(el).attr('color', '#' + hex); + if (!bySetColor) $(el).val(hex); + let gene = canvas.getObjects().find(obj => obj.id == 'arrow' && + event.target.genomeID == obj.genomeID && + event.target.geneID == obj.geneID); + gene.fill = `#${hex}` + gene.dirty = true + if(!settings['display']['colors']['genes']?.[event.target.genomeID]?.[event.target.geneID]){ + settings['display']['colors']['genes'][event.target.genomeID] = [] + settings['display']['colors']['genes'][event.target.genomeID][event.target.geneID] = `#${hex}` + } else { + settings['display']['colors']['genes'][event.target.genomeID][event.target.geneID] = `#${hex}` + } + canvas.renderAll() + } + }).keyup(function() { + $(this).colpickSetColor(this.value); + }); } function showToolTip(event){ From 12eb853399acbbbb4a3582eed1a0c4398706143c Mon Sep 17 00:00:00 2001 From: Matthew Klein Date: Mon, 28 Mar 2022 22:14:33 +0000 Subject: [PATCH 0642/1020] clear query results table before each run --- anvio/data/interactive/js/genomeview/drawer.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/anvio/data/interactive/js/genomeview/drawer.js b/anvio/data/interactive/js/genomeview/drawer.js index db484c3635..74376cb8e2 100644 --- a/anvio/data/interactive/js/genomeview/drawer.js +++ b/anvio/data/interactive/js/genomeview/drawer.js @@ -736,6 +736,7 @@ GenomeDrawer.prototype.adjustScaleInterval = function () { } GenomeDrawer.prototype.queryFunctions = function () { + $('#query-results-table').empty() let query = $('#function_search_query').val() let category = $('#function_search_category').val() let glowPayload = [] @@ -797,6 +798,7 @@ GenomeDrawer.prototype.queryFunctions = function () { } GenomeDrawer.prototype.queryMetadata = function(metadataLabel){ + $('#query-results-table').empty() let glowPayload = Array() let foundInGenomes = Object() let matches = settings['display']['metadata'].filter( m => m.label.includes(metadataLabel)) From ae8f2e529723794b443f5b82c73cbc929d744d69 Mon Sep 17 00:00:00 2001 From: Matthew Klein Date: Mon, 28 Mar 2022 22:39:18 +0000 Subject: [PATCH 0643/1020] query against annotation AND accession --- anvio/data/interactive/js/genomeview/drawer.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/anvio/data/interactive/js/genomeview/drawer.js b/anvio/data/interactive/js/genomeview/drawer.js index 74376cb8e2..dbceca0f5e 100644 --- a/anvio/data/interactive/js/genomeview/drawer.js +++ b/anvio/data/interactive/js/genomeview/drawer.js @@ -752,7 +752,8 @@ GenomeDrawer.prototype.queryFunctions = function () { } this.settings['genomeData']['genomes'].map(genome => { for (const [key, value] of Object.entries(genome[1]['genes']['functions'])) { - if (value[category]?.[1].includes(query)) { + console.log(key, value); + if (value[category]?.[0].includes(query) || value[category]?.[1].includes(query)) { let glowObject = { genomeID: genome[0], geneID: key From 10743f613dc356392f972473ae9b90e69d9200ab Mon Sep 17 00:00:00 2001 From: Matthew Klein Date: Tue, 29 Mar 2022 14:59:13 +0000 Subject: [PATCH 0644/1020] reasonable max-width for tooltips --- anvio/data/interactive/js/genomeview/ui.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/anvio/data/interactive/js/genomeview/ui.js b/anvio/data/interactive/js/genomeview/ui.js index 7f049a9cec..174f63c6da 100644 --- a/anvio/data/interactive/js/genomeview/ui.js +++ b/anvio/data/interactive/js/genomeview/ui.js @@ -381,7 +381,7 @@ function showDeepDiveToolTip(event){ ${totalAnnotationsString} ; - - - - -

-
-
-
-
+ + + + + + + + -
- SETTINGS -
+ + + +
+
+
+
Loading... +
+
+
+
+ +
+
+
+ +
+ + + + + +

+
+
+
+
-
-