Skip to content

Commit

Permalink
Fix Endpoint of GC additional data
Browse files Browse the repository at this point in the history
  • Loading branch information
metehaansever committed Nov 14, 2024
1 parent c954bf8 commit 0557e25
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions anvio/bottleroutes.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
from anvio.serverAPI import AnviServerAPI
from anvio.errors import RefineError, ConfigError
from anvio.tables.miscdata import TableForLayerOrders
from anvio.tables.miscdata import TableForItemAdditionalData
from anvio.tables.collections import TablesForCollections


Expand Down Expand Up @@ -1426,31 +1425,14 @@ def check_homogeneity_info(self):
return json.dumps({'status': 1})


def fetch_additional_data(self):
"""Fetch GC Accessory Data from TableForItemAdditionalData"""
if self.additional_gc_data is None:
try:
progress = terminal.Progress()
self.additional_gc_data = TableForItemAdditionalData(self.interactive.args, p=progress).get()
except Exception as e:
self.additional_gc_data = None
raise RuntimeError(f'Error fetching additional data: {str(e)}')

def get_additional_gc_data(self, gc_id, gc_key):
try:
self.fetch_additional_data()
gene_cluster_data = None
if self.additional_gc_data and len(self.additional_gc_data) > 1:
gene_cluster_data = self.additional_gc_data[1].get(gc_id, {}).get(gc_key, None)
if gene_cluster_data is None:
raise ValueError("Gene cluster data is None.")
except (KeyError, TypeError, ValueError, RuntimeError) as e:
return json.dumps({'status': 1, 'message': f'Error retrieving data: {str(e)}'})

try:
return json.dumps({'gene_cluster_data': gene_cluster_data, 'status': 0})
except Exception as e:
return json.dumps({'status': 1, 'message': f'Error serializing response: {str(e)}'})
return json.dumps({
'status': 0,
'gene_cluster_data': self.interactive.items_additional_data_dict[gc_id][gc_key]
})
except:
return json.dumps({'status': 1})

def reroot_tree(self):
# Get the Newick tree string from the form data
Expand Down

0 comments on commit 0557e25

Please sign in to comment.