Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pangraph 0.3.0 #2357

Open
wants to merge 281 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
281 commits
Select commit Hold shift + click to select a range
b01ec3a
even better
meren Jan 4, 2024
ecab089
further sanity checks for ext genoems txt
meren Jan 4, 2024
69ad7af
Merge branch 'master' into pangraph
meren Jan 4, 2024
656e706
better paralog solving
ahenoch Jan 5, 2024
8985e58
changed some logic regarding single gene contigs
ahenoch Jan 8, 2024
3062052
added some sanity checks
ahenoch Jan 8, 2024
659a47c
rework of second algorithm and many more changes
ahenoch Jan 10, 2024
f48095d
a slight improvement: get json data in class
meren Jan 14, 2024
0017402
version tracking of pan-graph-json
meren Jan 14, 2024
d322adc
code to ensure code and data is compatible
meren Jan 14, 2024
87a9eb1
add number of genomes explicitly
meren Jan 14, 2024
3e3dbd7
show num genomes, not 'undefined' in consensus inf
meren Jan 14, 2024
9dea0aa
fixy fix
meren Jan 14, 2024
a4db8cc
show correct num genomes info
meren Jan 14, 2024
3e5e0eb
proper inheritance so we can see alignments
meren Jan 14, 2024
b4acf7f
in progess update
ahenoch Jan 15, 2024
5c792f8
remove modal header
meren Jan 15, 2024
76045c3
major update to gene cluster inspection window
meren Jan 15, 2024
66b63cf
css for some new items
meren Jan 15, 2024
ed540a0
this does not seem to be doing anything..
meren Jan 16, 2024
b980ef1
don't hardcode functional annotation soruces
meren Jan 16, 2024
6a104dd
minor sanity check
meren Jan 16, 2024
2a5549e
learn annotation sources from genomesstorage
meren Jan 16, 2024
5ba7a94
fixy :/
meren Jan 16, 2024
545c4fa
update JSON structure, bump version
meren Jan 16, 2024
4a5e272
better variable names
meren Jan 16, 2024
04bc99e
fill in the available sources for functions
meren Jan 16, 2024
b9aa7a3
easier on the eyes
meren Jan 16, 2024
042ac72
temporary revert changes made to panflow algorithm
ahenoch Jan 17, 2024
135f535
Added "Alex test area" in the code to be able to change things withou…
ahenoch Jan 18, 2024
b04bcf4
remove submodule
metehaansever Jan 22, 2024
5f00c8d
Bootstrap remove
metehaansever Jan 22, 2024
dc33665
bootstrap-waitingfor remove
metehaansever Jan 22, 2024
a854b44
bootstrap-markdown remove
metehaansever Jan 22, 2024
7c4fc36
jquery remove
metehaansever Jan 22, 2024
3a26439
jquery-ui remove
metehaansever Jan 22, 2024
192ecaa
marked removed
metehaansever Jan 22, 2024
dfb5407
randomColor remove
metehaansever Jan 22, 2024
ec4527b
toastr remove
metehaansever Jan 22, 2024
ee5de8e
Javascript-MD5 remove
metehaansever Jan 22, 2024
f47dc99
d3.js remove
metehaansever Jan 22, 2024
a5d4dca
in progress
ahenoch Jan 24, 2024
8a7d734
update
ahenoch Jan 24, 2024
ac20a76
testing algorithm performance
ahenoch Jan 25, 2024
ab45203
update
ahenoch Jan 26, 2024
0cc712d
wolbachia 100% included information
ahenoch Jan 26, 2024
e223031
Fix lib > node_modules
metehaansever Jan 29, 2024
3c57ff7
Fix sortable package update
metehaansever Jan 29, 2024
10d131a
remove accordion functionality
metehaansever Feb 1, 2024
2ec0293
Add html5sortable package
metehaansever Feb 1, 2024
25a9459
Update panops.py
ahenoch Feb 1, 2024
c3cd259
Remove func call
metehaansever Feb 1, 2024
8a0e6d9
Merge branch 'ui-pangraph' into pangraph
metehaansever Feb 5, 2024
4d40e81
Merge pull request #2212 from merenlab/pangraph
metehaansever Feb 5, 2024
91802f9
Fix jquery-ui order
metehaansever Feb 5, 2024
90dbb41
Update package.json += svg-pan-zoom
metehaansever Feb 5, 2024
fc1827f
Update symlink lib -> node_modules
metehaansever Feb 6, 2024
33c6ef5
Remove merge string
metehaansever Feb 6, 2024
0a37589
Update pangraph ui
metehaansever Feb 12, 2024
163b4da
Update ui elements
metehaansever Feb 12, 2024
82d5a57
Update Alex's changes
metehaansever Feb 12, 2024
7f6a04f
Add disable class
metehaansever Feb 12, 2024
294393b
Add main css into pangraph css
metehaansever Feb 12, 2024
4ea22b4
Update genomes section
metehaansever Feb 13, 2024
e314235
Update jquery-ui version
metehaansever Feb 13, 2024
6770884
Update main section ui
metehaansever Feb 13, 2024
b082599
Fix Settings btn z-index
metehaansever Feb 14, 2024
18659f2
Update bin page
metehaansever Feb 15, 2024
b0d1abf
Add bin icon size
metehaansever Feb 15, 2024
0c35c6f
Update Data section
metehaansever Feb 15, 2024
945efab
Update table header
metehaansever Feb 16, 2024
f30a82c
Update Search
metehaansever Feb 19, 2024
d5cf52f
Fix settings btn visibility
metehaansever Feb 22, 2024
13d0aaf
Fix info bin modal
metehaansever Feb 22, 2024
79d1b92
Fix bs4 changes
metehaansever Feb 22, 2024
efd1a51
Fix bs4 changes
metehaansever Feb 22, 2024
37a3184
Add Title
metehaansever Feb 26, 2024
d1bb270
Update jquery 1.12 changes
metehaansever Feb 26, 2024
96f3056
Add title panel
metehaansever Feb 26, 2024
08337c8
Fix panel-left z-index
metehaansever Feb 26, 2024
900e677
Update btn functionality
metehaansever Feb 26, 2024
5c73788
Fix anchor tab link
metehaansever Feb 26, 2024
5a45af1
Update browser control
metehaansever Feb 26, 2024
6b131a8
Fix table-sortable package
metehaansever Feb 26, 2024
96f8a34
Fix table-sortable +=
metehaansever Feb 26, 2024
e378f5f
Fix packages
metehaansever Feb 26, 2024
bc8ab58
Fix genome color sorting
metehaansever Feb 27, 2024
fdb1fae
Remove gitmodule
metehaansever Feb 27, 2024
9a3bd9c
Remove unused package
metehaansever Feb 27, 2024
d0d84cb
Remove unused func
metehaansever Feb 27, 2024
63a5aa4
Add sortable func to tables
metehaansever Feb 27, 2024
86bb8b1
Update draw btn
metehaansever Feb 27, 2024
1fdca7a
Remove sortable codes
metehaansever Feb 29, 2024
f8df4a3
Remove unused code
metehaansever Feb 29, 2024
5cbeb10
Update package link
metehaansever Mar 4, 2024
4f44cb7
update
ahenoch Mar 27, 2024
d8295bc
update
ahenoch Mar 28, 2024
6389e7b
yaml test and summary table for graph information layer
ahenoch Apr 3, 2024
015c353
svg creation update 1
ahenoch Apr 4, 2024
d89752d
beautified curved edge paths
ahenoch Apr 4, 2024
c390d3b
summary table layer update
ahenoch Apr 4, 2024
4f879c5
modular layers based on json data
ahenoch Apr 5, 2024
aecf3f9
obsolete settings removal
ahenoch Apr 5, 2024
54803da
edge thickness
ahenoch Apr 5, 2024
49c575a
beautify
ahenoch Apr 5, 2024
71879de
various updates including multiple local info layer
ahenoch Apr 8, 2024
495465d
update
ahenoch Apr 8, 2024
a41fbbd
fixy fix
meren Apr 9, 2024
c17c9f9
f-strings cosmetics
meren Apr 9, 2024
c839af3
this is confusing, but this fixes the problem
meren Apr 9, 2024
e654fbf
entropie calc fixy
ahenoch Apr 9, 2024
c8ecb16
Color genome path and nodes fixy
ahenoch Apr 9, 2024
f1fcb95
setting changes hardcoded path bug fixy
ahenoch Apr 9, 2024
fd26af6
fixys
ahenoch Apr 9, 2024
f9256e1
added pangenome to yaml function
ahenoch Apr 9, 2024
dabf439
info tab alignments are back
ahenoch Apr 10, 2024
2ad94c5
fix js main() reset scope
ahenoch Apr 10, 2024
56c34a2
cleanup
ahenoch Apr 10, 2024
a074469
update
ahenoch Apr 11, 2024
7b02a31
various changes to binning functionality
ahenoch Apr 11, 2024
48723d2
Update Modal page
metehaansever Apr 11, 2024
757b39b
Merge branch 'pangraph-ui-backend' of https://github.com/merenlab/anv…
metehaansever Apr 11, 2024
9700248
merge fixy
metehaansever Apr 11, 2024
153dad5
tippy and close button remove
ahenoch Apr 11, 2024
a9254b1
fixed tippy
ahenoch Apr 11, 2024
6f8ab44
removed fixme
ahenoch Apr 11, 2024
907ebe5
preparation for search rework
ahenoch Apr 11, 2024
2327e75
layer checkboxes
ahenoch Apr 11, 2024
8f468d5
Fix gene seq font monospace +=
metehaansever Apr 12, 2024
3a72bb9
Fix misalignment
metehaansever Apr 12, 2024
6e2ae8b
Fix Data tab alignment
metehaansever Apr 12, 2024
c88d9aa
gc info to csv download function
ahenoch Apr 12, 2024
7258e01
Merge branch 'pangraph-ui-backend' of https://github.com/merenlab/anv…
ahenoch Apr 12, 2024
9d83c68
fixy
metehaansever Apr 12, 2024
1a3503d
Merge branch 'pangraph-ui-backend' of https://github.com/merenlab/anv…
metehaansever Apr 12, 2024
8e881d9
alignment download function and some beautifications
ahenoch Apr 12, 2024
24ef57d
disbled a future UI functions
ahenoch Apr 12, 2024
d6ffd8b
label and size settings for layers
ahenoch Apr 12, 2024
7652475
fixy
ahenoch Apr 12, 2024
28a3fd1
Fix font-family monospace +=
metehaansever Apr 15, 2024
e7bfda8
Add table scroll func
metehaansever Apr 15, 2024
a4a21d4
Add keyboard func
metehaansever Apr 15, 2024
daeb364
in progress genome layers
ahenoch Apr 15, 2024
202bec2
Merge branch 'pangraph-ui-backend' of https://github.com/merenlab/anv…
ahenoch Apr 15, 2024
39c2283
complete rework of the svg drawing section for easier layer addition
ahenoch Apr 15, 2024
82da972
Fix table colors
metehaansever Apr 16, 2024
e052b18
updates to new line layers
ahenoch Apr 16, 2024
085f893
Merge branch 'pangraph-ui-backend' of https://github.com/merenlab/anv…
ahenoch Apr 16, 2024
32a4e59
minor fixy
ahenoch Apr 16, 2024
affcedf
Filter and search for function workign
ahenoch Apr 17, 2024
1014047
fixys and polishing
ahenoch Apr 17, 2024
02dd71a
add contig to alignment view tab
ahenoch Apr 18, 2024
b06b2f6
fixy
ahenoch Apr 18, 2024
26b1ec2
Fix S key issue
metehaansever Apr 22, 2024
70cae9a
Fix gc table
metehaansever Apr 22, 2024
41a6f98
update
ahenoch Apr 22, 2024
6a0f250
Merge branch 'pangraph-ui-backend' of https://github.com/merenlab/anv…
ahenoch Apr 22, 2024
a11eb59
Fix header and sequence scroll behaviour
metehaansever Apr 22, 2024
3493cb4
Fixy fix
metehaansever Apr 22, 2024
fb10415
fixy
ahenoch Apr 22, 2024
4b1eca1
Merge branch 'pangraph-ui-backend' of https://github.com/merenlab/anv…
ahenoch Apr 22, 2024
3785b91
fixy function search and disable expression search for now
ahenoch Apr 22, 2024
3f6ef67
fixyyyyyys
ahenoch Apr 24, 2024
fd5522f
homogeneity index available now
ahenoch Apr 26, 2024
fae871c
fixy
ahenoch Apr 26, 2024
0b71cc6
entropie -> entropy
ahenoch Apr 26, 2024
a725399
Merge branch 'master' into pangraph-ui-backend also added removable g…
ahenoch Apr 29, 2024
268f1d8
removable genomes
ahenoch Apr 29, 2024
5321443
outcommented some debugging
ahenoch Apr 29, 2024
23f0b4b
some more
ahenoch Apr 29, 2024
6834c2d
update genome graph inclusion
ahenoch Apr 30, 2024
79a4372
Update seq-align table
metehaansever May 6, 2024
dffc4d9
updated paralog solving (beta)
ahenoch May 7, 2024
87fd51f
cleanup
ahenoch May 7, 2024
9a34a83
Add thead sticky
metehaansever May 7, 2024
67c0001
fixys on paralog solving (beta)
ahenoch May 8, 2024
635211c
Add github repo > npm package
metehaansever May 8, 2024
9673a31
HVR Score first iteration
ahenoch May 14, 2024
6ef2263
update
ahenoch May 14, 2024
45e0793
updated layers
ahenoch May 22, 2024
eaa8c9f
better layer data json position
ahenoch May 22, 2024
8c0d0f6
in progress
ahenoch May 22, 2024
2ba19e2
GC Group compression in progress
ahenoch May 22, 2024
6c2a58e
update
ahenoch May 23, 2024
0e0e3c9
UI and backend GC group compression function finished
ahenoch May 23, 2024
049c190
added paralog clustering graphics output and summary parameters
ahenoch May 23, 2024
5867401
first iteration of external layer data script
ahenoch May 23, 2024
eed512a
update
ahenoch May 27, 2024
c49b4ce
I have to split local layers by the group compression factor and reca…
ahenoch May 28, 2024
8be5dfe
change requirements to use networkx V3.1 only
ahenoch May 28, 2024
b51021a
bin add/remove button in gc info view
ahenoch May 28, 2024
aa92d24
fixy
ahenoch May 28, 2024
bd9ffc0
various updates
ahenoch Jun 6, 2024
1828e52
update
ahenoch Jun 11, 2024
10edc4d
added more parameter
ahenoch Jun 11, 2024
6887a5e
refracturing, comments, rework of code secions
ahenoch Jun 11, 2024
288aa9c
finished new read_graph_from_json and multiple change features for fa…
ahenoch Jun 12, 2024
c846435
update
ahenoch Jun 18, 2024
af8e8d8
finished a smaller and more efficient reiteration bottleroute
ahenoch Jun 19, 2024
0634a1c
important fix
ahenoch Jun 27, 2024
f211bd0
patch
ahenoch Jun 28, 2024
81c996d
fix
ahenoch Jul 4, 2024
1b005c5
fix for wilson
ahenoch Jul 4, 2024
ccb7e83
solved Tomas and Wilsons long range bug
ahenoch Jul 8, 2024
5a834e9
Merge remote-tracking branch 'origin/master' into pangraph-0.3.0
ahenoch Jul 9, 2024
681a7ca
trim trailing whitespace, add some defensiveness, added all error mes…
ahenoch Jul 9, 2024
a91ef97
compress pangraph json to 1/10 or original size
ahenoch Jul 9, 2024
318e522
Added function to skip over set of genomes from pangenome for in dept…
ahenoch Jul 9, 2024
6fee2b6
changes on JS and bottle to streamline pangraph json
ahenoch Jul 10, 2024
8fb906f
added warning
ahenoch Jul 18, 2024
4a832c0
added genome-names function
ahenoch Jul 22, 2024
c4936bd
pass filter
ahenoch Jul 22, 2024
2c7f556
JS rework, linear layout 50% done
ahenoch Jul 24, 2024
13c9b5f
JS rework, added standard UI settings calc, linear graph layout 75%
ahenoch Jul 24, 2024
6ac4e42
JS rework, linearize circularize finished
ahenoch Jul 25, 2024
01a8466
line thickness cosmetics
ahenoch Jul 25, 2024
4d3ac14
fixy
ahenoch Jul 25, 2024
37c92a5
do not require pan-db in test mode
meren Jul 26, 2024
beed4e5
updates
ahenoch Jul 26, 2024
2df9af2
fixy not saving compression value bug
ahenoch Jul 30, 2024
f8c8175
fixy in anvi interactive to load pan db
ahenoch Jul 30, 2024
8b1b34a
remove debug print statement
ahenoch Jul 30, 2024
fccb508
additional features e.g. mor efficient search implementation
ahenoch Jul 30, 2024
8354640
update
ahenoch Aug 5, 2024
36468f8
update syntenous distance values
ahenoch Aug 6, 2024
0670259
added syntenous distance newick tree
ahenoch Aug 8, 2024
da387c7
fixy
ahenoch Aug 8, 2024
97cab07
multiple new UI buttons and functions including saturation by signifi…
ahenoch Aug 12, 2024
362324e
added responses for on/off the tree
ahenoch Aug 12, 2024
c2b7108
tree fix
ahenoch Aug 12, 2024
3440967
feature for ungrouping just a user defined area while keeping the res…
ahenoch Aug 14, 2024
ab0b43b
Merge branch 'master' of https://github.com/merenlab/anvio into pangr…
ahenoch Aug 19, 2024
45edca4
added small feature of higher weighted core genes (for testing)
ahenoch Oct 7, 2024
255a170
Merge branch 'master' into pangraph-0.3.0
ahenoch Oct 7, 2024
b40ed78
REMOVE bootstrap4-toggle package to align UI with anvio master
ahenoch Oct 7, 2024
8bc62df
ADDED anvio reorient contigs tool
ahenoch Oct 8, 2024
c93ed87
UPDATE set standard to include all genomes if no genomes names are given
ahenoch Oct 8, 2024
e8d894c
Update: fixy
ahenoch Oct 8, 2024
7710dca
can we please not have trailing whitespaces anymore :(
meren Oct 8, 2024
444f0a0
cosmetics. now just like the rest of the repo
meren Oct 8, 2024
1a8265f
better variable names
meren Oct 8, 2024
27d63f5
Update: changed the rating values for paralog splitting
ahenoch Oct 8, 2024
ae3c717
option to not raise if file is not FASTA
meren Oct 8, 2024
b9c6675
use the community parameter with specific help
meren Oct 8, 2024
409a7c7
much better way to find fasta files using `glob`
meren Oct 8, 2024
e4566a2
number of contigs is a better varaible name here
meren Oct 8, 2024
837a160
more streamlined design
meren Oct 8, 2024
5987cc3
Merge branch 'pangraph-0.3.0' of github.com:merenlab/anvio into pangr…
meren Oct 8, 2024
13a3b52
better reporting (and a little fix)
meren Oct 8, 2024
327ee0f
Added: pangeome graph motif algorithm
ahenoch Nov 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions anvio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ def TABULATE(table, header, numalign="right", max_width=0):
"You can provide these names as a comma-separated list of names, or you can put them in a file, "
"where you have a single genome name in each line, and provide the file path."}
),
'genomes-reverse': (
['-R', '--genome-reverse'],
{'metavar': "GENOME_NAMES",
'required': False,
'help': "Genome names to 'reverse'. You can use this parameter to choose the genomes whose synteny you want to reverse. "
"You can provide these names as a comma-separated list of names, or you can put them in a file, "
"where you have a single genome name in each line, and provide the file path."}
),
'blank-profile': (
['--blank-profile'],
{'default': False,
Expand Down Expand Up @@ -2115,6 +2123,74 @@ def TABULATE(table, header, numalign="right", max_width=0):
'type': str,
'help': "Directory path for output files"}
),
# start of anvi-pan-graph related input and output variables:
'testing-yaml': (
['--testing-yaml'],
{'metavar': 'YAML',
'type': str,
'help': "A yaml file containing raw gene cluster order for testing the anvi'o pan graph."}
),
'gene-additional-data': (
['--gene-additional-data'],
{'metavar': 'CSV',
'type': str,
'help': "A CSV file containing at least one column with values per genome, contig and genecall column."}
),
'gc-additional-data': (
['--gc-additional-data'],
{'metavar': 'CSV',
'type': str,
'help': "A CSV file containing at least one column with values per genome, contig and gc column."}
),
'output-pan-graph-json': (
['-o', '--output-pan-graph-json'],
{'metavar': 'FILE_PATH',
'type': str,
'help': "File path to store the temporary pan-graph-json file."}
),
'output-graphml': (
['--output-graphml'],
{'metavar': 'FILE_PATH',
'type': str,
'help': "File path to store the final graph file."}
),
'output-raw-gc-additional-data': (
['--output-raw-gc-additional-data'],
{'metavar': 'FILE_PATH',
'type': str,
'help': "File path to create and store a raw gc additional data table for testing or join purposes."}
),
'output-raw-gene-additional-data': (
['--output-raw-gene-additional-data'],
{'metavar': 'FILE_PATH',
'type': str,
'help': "File path to create and store a raw gc additional data table for testing or join purposes."}
),
'output-testing-yaml': (
['--output-testing-yaml'],
{'metavar': 'FILE_PATH',
'type': str,
'help': "File path to create and store a testing yaml for a existing pangenome."}
),
'output-dir-summary': (
['--output-dir-summary'],
{'metavar': 'DIR_PATH',
'type': str,
'help': "File path to store a CSV file containing values describing the pan-graph for downstream analysis."}
),
'output-dir-graphics': (
['--output-dir-graphics'],
{'metavar': 'DIR_PATH',
'type': str,
'help': "File path to store the hierarchical clusterings for the paralog splitting."}
),
'pan-graph-json': (
['-i', '--pan-graph-json'],
{'metavar': 'JSON',
'type': str,
'help': "A JSON formatted anvi'o pan graph, which is typically generated by `anvi-pan-graph`."}
),
# end of pan-graph related variables
'output-file': (
['-o', '--output-file'],
{'metavar': 'FILE_PATH',
Expand Down Expand Up @@ -3701,6 +3777,7 @@ def set_version():
anvio_codename, \
t.contigs_db_version, \
t.pan_db_version, \
t.pangraph_json_version, \
t.profile_db_version, \
t.genes_db_version, \
t.auxiliary_data_version, \
Expand All @@ -3717,6 +3794,7 @@ def get_version_tuples():
("Genes DB version", __genes__version__),
("Auxiliary data storage version", __auxiliary_data_version__),
("Pan DB version", __pan__version__),
("Pangraph JSON version", __pangraph__version__),
("Genome data storage version", __genomes_storage_version__),
("Structure DB version", __structure__version__),
("KEGG Modules DB version", __kegg_modules_version__),
Expand All @@ -3729,6 +3807,7 @@ def print_version():
run.info("Profile database", __profile__version__)
run.info("Contigs database", __contigs__version__)
run.info("Pan database", __pan__version__)
run.info("Pangraph JSON", __pangraph__version__)
run.info("Genome data storage", __genomes_storage_version__)
run.info("Auxiliary data storage", __auxiliary_data_version__)
run.info("Structure database", __structure__version__)
Expand All @@ -3740,6 +3819,7 @@ def print_version():
__codename__, \
__contigs__version__, \
__pan__version__, \
__pangraph__version__, \
__profile__version__, \
__genes__version__, \
__auxiliary_data_version__, \
Expand Down
146 changes: 142 additions & 4 deletions anvio/bottleroutes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import argparse
import datetime
import importlib
import networkx as nx

from hashlib import md5
from ete3 import Tree
Expand All @@ -38,6 +39,7 @@

import anvio
import anvio.dbops as dbops
import anvio.panops as panops
import anvio.utils as utils
import anvio.drivers as drivers
import anvio.terminal as terminal
Expand Down Expand Up @@ -197,7 +199,12 @@ def register_routes(self):
self.route('/data/get_gene_info/<gene_callers_id>', callback=self.get_gene_info)
self.route('/data/get_metabolism', callback=self.get_metabolism)
self.route('/data/get_scale_bar', callback=self.get_scale_bar, method='POST')

self.route('/pangraph/settings', callback=self.get_pangraph_settings, method="POST")
self.route('/pangraph/get_json', callback=self.get_pangraph_json_data, method="POST")
self.route('/pangraph/alignment', callback=self.get_pangraph_gc_alignment, method="POST")
self.route('/pangraph/analyse', callback=self.get_pangraph_bin_summary, method="POST")
self.route('/pangraph/function', callback=self.get_pangraph_gc_function, method="POST")
self.route('/pangraph/filter', callback=self.get_pangraph_passed_gene_clusters, method="POST")

def run_application(self, ip, port):
# check for the wsgi module bottle will use.
Expand Down Expand Up @@ -266,6 +273,8 @@ def redirect_to_app(self):
homepage = 'structure.html'
elif self.interactive.mode == 'metabolism':
homepage = 'metabolism.html'
elif self.interactive.mode == 'pangraph':
homepage = 'pangraph.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)))

Expand Down Expand Up @@ -1069,7 +1078,7 @@ def gen_summary(self, collection_name):

path = "summary/%s/index.html" % (collection_name)
return json.dumps({'path': path})


def send_summary_static(self, collection_name, filename):
if self.interactive.mode == 'pan':
Expand Down Expand Up @@ -1534,7 +1543,7 @@ def get_functions_for_gene_clusters(self):
message = (f"At least one of the gene clusters in your list (e.g., {gene_cluster_name}) is missing in "
f"the functions summary dict :/")
return json.dumps({'status': 1, 'message': message})

d[gene_cluster_name] = self.interactive.gene_clusters_functions_summary_dict[gene_cluster_name]

return json.dumps({'functions': d, 'sources': list(self.interactive.gene_clusters_function_sources)})
Expand All @@ -1551,4 +1560,133 @@ def get_scale_bar(self):
message = str(e.clear_text()) if hasattr(e, 'clear_text') else str(e)
return json.dumps({'status': 1, 'message': message})

return json.dumps({'scale_bar_value': total_branch_length})
return json.dumps({'scale_bar_value': total_branch_length})

def get_pangraph_json_data(self):

return self.interactive.get_pangraph_json()


def get_pangraph_bin_summary(self):

payload = request.json
selection = payload['selection']
result = {}

self.interactive.init_gene_clusters()
self.interactive.init_gene_clusters_functions_summary_dict()

bin_functions = {}
all_functions = []

for bin in list(payload.keys())[1:]:

bin_functions[bin] = []
gene_cluster_list = payload[bin]
for gene_cluster_name in gene_cluster_list:
function = self.interactive.gene_clusters_functions_summary_dict[gene_cluster_name][selection]['function']

bin_functions[bin].append(function)
all_functions.append(function)

for function in all_functions:
result[function] = {}
for bin in bin_functions.keys():
if function in bin_functions[bin]:
result[function][bin] = 1
else:
result[function][bin] = 0

return json.dumps(result)

def get_pangraph_settings(self):

payload = request.json
max_edge_length_filter = payload['maxlength']
gene_cluster_grouping_threshold = payload['condtr']
groupcompress = payload['groupcompress']
ungrouping_area = payload['ungroup']
print(ungrouping_area)

args = argparse.Namespace(
pan_graph_json=self.interactive.pan_graph_json_path,
output_pan_graph_json=self.interactive.pan_graph_json_path,
max_edge_length_filter=max_edge_length_filter,
gene_cluster_grouping_threshold=gene_cluster_grouping_threshold,
gene_cluster_grouping_compression=groupcompress,
ungrouping_area = ungrouping_area
)

Pangraph = panops.Pangraph(args)

Pangraph.load_graph_from_json_file()
Pangraph.run_synteny_layout_algorithm()
Pangraph.update_json_dict()
Pangraph.store_network()

return({'status': 0})

def get_pangraph_gc_alignment(self):

payload = request.json
result = {}

for genome in payload.keys():
genecall, contig, direction, name = payload[genome]
gene_cluster_alignment_dict = self.interactive.get_sequences_for_gene_clusters(gene_cluster_names=set([name]), skip_alignments=False, report_DNA_sequences=False)[name]
sequence = gene_cluster_alignment_dict[genome][int(genecall)]

result[genome] = [genecall, contig, direction, sequence]

return(result)

def get_pangraph_gc_function(self):

payload = request.json
result = {}

self.interactive.init_gene_clusters()
self.interactive.init_gene_clusters_functions_summary_dict()

gene_cluster_name = payload['genecluster']

for selection in self.interactive.gene_clusters_functions_summary_dict[gene_cluster_name].keys():
result[selection] = self.interactive.gene_clusters_functions_summary_dict[gene_cluster_name][selection]
return json.dumps(result)

def get_pangraph_passed_gene_clusters(self):

payload = request.json
result = {'gene_clusters': []}

self.interactive.init_gene_clusters()
self.interactive.init_gene_clusters_functions_summary_dict()

functions_dict = self.interactive.gene_clusters_functions_summary_dict

for gene_cluster in functions_dict.keys():
for selection in payload.keys():
if selection in functions_dict[gene_cluster].keys():
for search in payload[selection]:
value = functions_dict[gene_cluster][selection]

accession = value['accession']
func = value['function']

if not accession or not func:
accession = ''
func = ''

if search == '':

print(search, accession, func)
if search == accession or search == func:
if gene_cluster not in result['gene_clusters']:
result['gene_clusters'] += [gene_cluster]

else:
if search.lower() in accession.lower() or search.lower() in func.lower():
if gene_cluster not in result['gene_clusters']:
result['gene_clusters'] += [gene_cluster]

return json.dumps(result)
17 changes: 17 additions & 0 deletions anvio/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ def get_newick_tree_data_for_dict(d, transpose=False, linkage=constants.linkage_
return newick


def get_newick(node, parent_dist, leaf_names, newick=''):
"""
Modified from the solution at https://stackoverflow.com/questions/28222179/save-dendrogram-to-newick-format
"""
if node.is_leaf():
return "%s:%.2f%s" % (leaf_names[node.id], parent_dist - node.dist, newick)
else:
if len(newick) > 0:
newick = "):%.2f%s" % (parent_dist - node.dist, newick)
else:
newick = ");"
newick = get_newick(node.get_left(), node.dist, leaf_names, newick=newick)
newick = get_newick(node.get_right(), node.dist, leaf_names, newick=",%s" % (newick))
newick = "(%s" % (newick)
return newick


def get_vectors_for_vectors_with_missing_data(vectors):
"""Get a distance matrix for vectors with missing data.

Expand Down
Loading