Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ def list_types():
description="Raw spectral-counts of label-free proteomics experiments"),
DataType(id="microarray_norm",
name="Microarray (normalized)",
description="Normalized and log2 transformed microarray-based gene expression values.")

description="Normalized and log2 transformed microarray-based gene expression values."),
DataType(id="metabolomics",
name="Metabolomics",
description="Metabolomics data")
]

return data_types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def get_examples(): # noqa: E501
ExternalData(id="EXAMPLE_SC_B_CELLS", title="B cell scRNAseq example", type="rnaseq_counts",
description="Single-cell RNA-seq data of B cells extracted from the Jerby-Arnon at al. study (Cell 2018).",
group="SC_EXAMPLES"),
ExternalData(id="EXAMPLE_METABOLOMICS", title="Liver cirrhosis metabolomics example", type="metabolomics",
description="Transcriptomic and metabolomic analysis of liver cirrhosis. Metabolights study identifier: MTBLS5665",
group="METABOLOMICS_EXAMPLE")
]


Expand Down Expand Up @@ -221,7 +224,8 @@ def load_data(resourceId, parameters): # noqa: E501
"Socket timeout connecting to storage or queuing system: " + str(e))
abort(503, "Failed to connect to downstream system. Please try again in a few minutes.")

def download_dataset(datasetId, format = None):

def download_dataset(datasetId, format=None):
"""Download a previously loaded dataset

:param datasetId: The dataset's id to download
Expand All @@ -247,34 +251,35 @@ def download_dataset(datasetId, format = None):

# first column is the samples
header_string = "Sample Id\t"
header_string += "\t".join( [field["name"] for field in summary["sample_metadata"]] )
header_string += "\t".join([field["name"] for field in summary["sample_metadata"]])
tsv_string.append(header_string)

# add the field data
for index, sample in enumerate(summary["sample_ids"]):
sample_string = sample + "\t"

# add the fields
sample_string += "\t".join( [str(field["values"][index]) for field in summary["sample_metadata"]] )
sample_string += "\t".join([str(field["values"][index]) for field in summary["sample_metadata"]])

tsv_string.append(sample_string)

return Response(response="\n".join(tsv_string), status=200, headers={"content-type": "text/plain",
"content-disposition": f"attachment; filename=\"{datasetId}_meta.tsv\""})
return Response(response="\n".join(tsv_string), status=200, headers={"content-type": "text/plain",
"content-disposition": f"attachment; filename=\"{datasetId}_meta.tsv\""})
elif format == "expr":
expression_data = storage.get_request_data(token=datasetId)

# fix special character encoding issue
expression_data = expression_data.replace("\\n", "\n")
expression_data = expression_data.replace("\\t", "\t")

return Response(response=expression_data, status=200, headers={"content-type": "text/plain",
"content-disposition": f"attachment; filename=\"{datasetId}_expr.tsv\""})
return Response(response=expression_data, status=200, headers={"content-type": "text/plain",
"content-disposition": f"attachment; filename=\"{datasetId}_expr.tsv\""})
else:
abort(404, "Unsupported format passed.")
except ReactomeStorageException:
abort(404, "Failed to retrieve dataset. Make sure the dataset was successfully loaded beforehand.")


def get_search_species(): # noqa: E501
"""Returns the available species presented in the available datasets.
# noqa: E501
Expand Down Expand Up @@ -321,15 +326,15 @@ def search_data(keywords, species=None): # noqa: E501
loading_parameters.append(parameter.Parameter(name=param_name, value=original_parameters[param_name]))

# create the search result object
search_response_result = data_search_result.DataSearchResult(id=search_result["id"],
title=search_result["title"],
description=search_result["description"],
species=search_result["species"],
search_response_result = data_search_result.DataSearchResult(id=search_result["id"],
title=search_result["title"],
description=search_result["description"],
species=search_result["species"],
resource_name=search_result["data_source"],
resource_loading_id=search_result["resource_id"],
resource_loading_id=search_result["resource_id"],
loading_parameters=loading_parameters,
web_link=search_result["web_link"])

search_response_list.append(search_response_result)

return search_response_list
Loading