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

Redo collection table to be built in the same way as search results #699

Open
wants to merge 1 commit into
base: testing
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 50 additions & 0 deletions wqflask/base/trait.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,56 @@ def get_sample_data():
else:
return None

def for_collection_table(trait_obs):
trait_list = []
for i, trait in enumerate(trait_obs):
trait_dict = {}
trait_dict['index'] = i + 1

trait_dict['dataset_fullname'] = trait.dataset.fullname
trait_dict['dataset'] = trait.dataset.name
trait_dict['name'] = trait.name
trait_dict['hmac'] = hmac.data_hmac('{}:{}'.format(trait.display_name, trait.dataset.name))
trait_dict['display_name'] = trait.display_name
trait_dict['symbol'] = "N/A"
trait_dict['description'] = "N/A"
trait_dict['location'] = "N/A"
trait_dict['mean'] = "N/A"
if trait.symbol:
trait_dict['symbol'] = trait.symbol
elif trait.abbreviation:
trait_dict['symbol'] = trait.abbreviation

if trait.dataset.type == "Geno":
trait_dict['description'] = f"Marker: {trait.name}"
elif trait.description_display:
trait_dict['description'] = trait.description_display

if trait.dataset.type != "Publish":
trait_dict['location'] = trait.location_repr

if trait.dataset.type != "Geno":
trait_dict['mean'] = f"{trait.mean:.3f}"

trait_dict['lod_score'] = trait.LRS_score_repr
try:
if float(trait.LRS_score_repr) > 0:
trait_dict['lod_score'] = f"{trait.LRS_score_repr:.3f}"
except:
pass

trait_dict['lod_location'] = trait.LRS_location_repr

trait_dict['additive'] = "N/A"
try:
if float(trait.additive) > 0:
trait_dict['additive'] = f"{trait.additive:.3f}"
except:
pass

trait_list.append(trait_dict)

return trait_list

def jsonable(trait, dataset=None):
"""Return a dict suitable for using as json
Expand Down
6 changes: 4 additions & 2 deletions wqflask/wqflask/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from base.trait import create_trait
from base.trait import retrieve_trait_info
from base.trait import jsonable
from base.trait import jsonable, for_collection_table
from base.data_set import create_dataset

from utility.logger import getLogger
Expand Down Expand Up @@ -258,8 +258,10 @@ def view_collection():

json_version.append(jsonable(trait_ob))

trait_list = for_collection_table(trait_obs)

collection_info = dict(
trait_obs=trait_obs,
trait_list=trait_list,
uc=uc,
heatmap_data_url=f"{GN_SERVER_URL}api/heatmaps/clustered")

Expand Down
Loading